Skip to content

Commit 036b106

Browse files
yishaihdledford
authored andcommitted
IB/uverbs: Enable device removal when there are active user space applications
Enables the uverbs_remove_one to succeed despite the fact that there are running IB applications working with the given ib device. This functionality enables a HW device to be unbind/reset despite the fact that there are running user space applications using it. It exposes a new IB kernel API named 'disassociate_ucontext' which lets a driver detaching its HW resources from a given user context without crashing/terminating the application. In case a driver implemented the above API and registered with ib_uverb there will be no dependency between its device to its uverbs_device. Upon calling remove_one of ib_uverbs the call should return after disassociating the open HW resources without waiting to clients disconnecting. In case driver didn't implement this API there will be no change to current behaviour and uverbs_remove_one will return only when last client has disconnected and reference count on uverbs device became 0. In case the lower driver device was removed any application will continue working over some zombie HCA, further calls will ended with an immediate error. Signed-off-by: Yishai Hadas <yishaih@mellanox.com> Signed-off-by: Shachar Raindel <raindel@mellanox.com> Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 057aec0 commit 036b106

File tree

3 files changed

+302
-68
lines changed

3 files changed

+302
-68
lines changed

drivers/infiniband/core/uverbs.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,16 @@ struct ib_uverbs_device {
8989
int num_comp_vectors;
9090
struct completion comp;
9191
struct device *dev;
92-
struct ib_device *ib_dev;
92+
struct ib_device __rcu *ib_dev;
9393
int devnum;
9494
struct cdev cdev;
9595
struct rb_root xrcd_tree;
9696
struct mutex xrcd_tree_mutex;
9797
struct kobject kobj;
98+
struct srcu_struct disassociate_srcu;
99+
struct mutex lists_mutex; /* protect lists */
100+
struct list_head uverbs_file_list;
101+
struct list_head uverbs_events_file_list;
98102
};
99103

100104
struct ib_uverbs_event_file {
@@ -106,6 +110,7 @@ struct ib_uverbs_event_file {
106110
wait_queue_head_t poll_wait;
107111
struct fasync_struct *async_queue;
108112
struct list_head event_list;
113+
struct list_head list;
109114
};
110115

111116
struct ib_uverbs_file {
@@ -115,6 +120,8 @@ struct ib_uverbs_file {
115120
struct ib_ucontext *ucontext;
116121
struct ib_event_handler event_handler;
117122
struct ib_uverbs_event_file *async_file;
123+
struct list_head list;
124+
int is_closed;
118125
};
119126

120127
struct ib_uverbs_event {

0 commit comments

Comments
 (0)