Skip to content

Commit fd3c790

Browse files
matanb10dledford
authored andcommitted
IB/core: Change idr objects to use the new schema
This changes only the handlers which deals with idr based objects to use the new idr allocation, fetching and destruction schema. This patch consists of the following changes: (1) Allocation, fetching and destruction is done via idr ops. (2) Context initializing and release is done through uverbs_initialize_ucontext and uverbs_cleanup_ucontext. (3) Ditching the live flag. Mostly, this is pretty straight forward. The only place that is a bit trickier is in ib_uverbs_open_qp. Commit [1] added code to check whether the uobject is already live and initialized. This mostly happens because of a race between open_qp and events. We delayed assigning the uobject's pointer in order to eliminate this race without using the live variable. [1] commit a040f95 ("IB/core: Fix XRC race condition in ib_uverbs_open_qp") Signed-off-by: Matan Barak <[email protected]> Reviewed-by: Yishai Hadas <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 6be60ae commit fd3c790

File tree

6 files changed

+402
-1144
lines changed

6 files changed

+402
-1144
lines changed

drivers/infiniband/core/rdma_core.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,19 @@
5252
void uverbs_cleanup_ucontext(struct ib_ucontext *ucontext, bool device_removed);
5353
void uverbs_initialize_ucontext(struct ib_ucontext *ucontext);
5454

55+
/*
56+
* uverbs_uobject_get is called in order to increase the reference count on
57+
* an uobject. This is useful when a handler wants to keep the uobject's memory
58+
* alive, regardless if this uobject is still alive in the context's objects
59+
* repository. Objects are put via uverbs_uobject_put.
60+
*/
61+
void uverbs_uobject_get(struct ib_uobject *uobject);
62+
63+
/*
64+
* In order to indicate we no longer needs this uobject, uverbs_uobject_put
65+
* is called. When the reference count is decreased, the uobject is freed.
66+
* For example, this is used when attaching a completion channel to a CQ.
67+
*/
68+
void uverbs_uobject_put(struct ib_uobject *uobject);
69+
5570
#endif /* RDMA_CORE_H */

drivers/infiniband/core/uverbs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ struct ib_ucq_object {
180180
u32 async_events_reported;
181181
};
182182

183-
void idr_remove_uobj(struct ib_uobject *uobj);
184-
185183
struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
186184
struct ib_device *ib_dev,
187185
int is_async);

0 commit comments

Comments
 (0)