linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rdma/core: add __module_get()/module_put() to cma_[de]ref_dev()
@ 2019-09-30  9:04 Stefan Metzmacher
  2019-09-30 12:41 ` Jason Gunthorpe
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Metzmacher @ 2019-09-30  9:04 UTC (permalink / raw)
  To: linux-rdma; +Cc: Stefan Metzmacher

Currently there seems to be a problem when an RDMA listener or connection
is active on an ib_device.

'rmmod rdma_rxe' (the same for 'siw' and most likely all
others) just hangs like this until shutdown the listeners and
connections:

  [<0>] remove_client_context+0x97/0xe0 [ib_core]
  [<0>] disable_device+0x90/0x120 [ib_core]
  [<0>] __ib_unregister_device+0x41/0xa0 [ib_core]
  [<0>] ib_unregister_driver+0xbb/0x100 [ib_core]
  [<0>] rxe_module_exit+0x1a/0x8aa [rdma_rxe]
  [<0>] __x64_sys_delete_module+0x147/0x290
  [<0>] do_syscall_64+0x5a/0x130
  [<0>] entry_SYSCALL_64_after_hwframe+0x44/0xa9

The following would be expected:

  rmmod: ERROR: Module rdma_rxe is in use

And this change provides that.

Once all add listeners and connections are gone
the module can be removed again.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Cc: stable@vger.kernel.org
---
 drivers/infiniband/core/cma.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index a68d0ccf67a4..d10f3d01fa02 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -276,6 +276,7 @@ enum {
 void cma_ref_dev(struct cma_device *cma_dev)
 {
 	atomic_inc(&cma_dev->refcount);
+	__module_get(cma_dev->device->ops.owner);
 }
 
 struct cma_device *cma_enum_devices_by_ibdev(cma_device_filter	filter,
@@ -512,6 +513,7 @@ static void cma_attach_to_dev(struct rdma_id_private *id_priv,
 
 void cma_deref_dev(struct cma_device *cma_dev)
 {
+	module_put(cma_dev->device->ops.owner);
 	if (atomic_dec_and_test(&cma_dev->refcount))
 		complete(&cma_dev->comp);
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-10-02  0:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-30  9:04 [PATCH] rdma/core: add __module_get()/module_put() to cma_[de]ref_dev() Stefan Metzmacher
2019-09-30 12:41 ` Jason Gunthorpe
2019-09-30 13:52   ` Stefan Metzmacher
2019-10-01 14:45     ` Jason Gunthorpe
2019-10-01 22:03       ` Stefan Metzmacher
2019-10-02  0:57         ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).