Skip to content

Commit 27ed2f0

Browse files
PatrisiousHaddadrleon
authored andcommitted
RDMA/core: Move ib_uverbs_file struct to uverbs_types.h
In light of the previous commit, make the ib_uverbs_file accessible to drivers by moving its definition to uverbs_types.h, to allow drivers to freely access the struct argument and create a personalized cleanup flow. For the same reason expose uverbs_try_lock_object function to allow driver to safely access the uverbs objects. Signed-off-by: Patrisious Haddad <[email protected]> Link: https://patch.msgid.link/29b718e0dca35daa5f496320a39284fc1f5a1722.1730373303.git.leon@kernel.org Signed-off-by: Leon Romanovsky <[email protected]>
1 parent dc6be44 commit 27ed2f0

File tree

3 files changed

+36
-33
lines changed

3 files changed

+36
-33
lines changed

drivers/infiniband/core/rdma_core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ void uverbs_uobject_put(struct ib_uobject *uobject)
5858
}
5959
EXPORT_SYMBOL(uverbs_uobject_put);
6060

61-
static int uverbs_try_lock_object(struct ib_uobject *uobj,
62-
enum rdma_lookup_mode mode)
61+
int uverbs_try_lock_object(struct ib_uobject *uobj,
62+
enum rdma_lookup_mode mode)
6363
{
6464
/*
6565
* When a shared access is required, we use a positive counter. Each
@@ -84,6 +84,7 @@ static int uverbs_try_lock_object(struct ib_uobject *uobj,
8484
}
8585
return 0;
8686
}
87+
EXPORT_SYMBOL(uverbs_try_lock_object);
8788

8889
static void assert_uverbs_usecnt(struct ib_uobject *uobj,
8990
enum rdma_lookup_mode mode)

drivers/infiniband/core/uverbs.h

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -133,37 +133,6 @@ struct ib_uverbs_completion_event_file {
133133
struct ib_uverbs_event_queue ev_queue;
134134
};
135135

136-
struct ib_uverbs_file {
137-
struct kref ref;
138-
struct ib_uverbs_device *device;
139-
struct mutex ucontext_lock;
140-
/*
141-
* ucontext must be accessed via ib_uverbs_get_ucontext() or with
142-
* ucontext_lock held
143-
*/
144-
struct ib_ucontext *ucontext;
145-
struct ib_uverbs_async_event_file *default_async_file;
146-
struct list_head list;
147-
148-
/*
149-
* To access the uobjects list hw_destroy_rwsem must be held for write
150-
* OR hw_destroy_rwsem held for read AND uobjects_lock held.
151-
* hw_destroy_rwsem should be called across any destruction of the HW
152-
* object of an associated uobject.
153-
*/
154-
struct rw_semaphore hw_destroy_rwsem;
155-
spinlock_t uobjects_lock;
156-
struct list_head uobjects;
157-
158-
struct mutex umap_lock;
159-
struct list_head umaps;
160-
struct page *disassociate_page;
161-
162-
struct xarray idr;
163-
164-
struct mutex disassociation_lock;
165-
};
166-
167136
struct ib_uverbs_event {
168137
union {
169138
struct ib_uverbs_async_event_desc async;

include/rdma/uverbs_types.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ static inline void uverbs_uobject_get(struct ib_uobject *uobject)
134134
}
135135
void uverbs_uobject_put(struct ib_uobject *uobject);
136136

137+
int uverbs_try_lock_object(struct ib_uobject *uobj, enum rdma_lookup_mode mode);
138+
137139
struct uverbs_obj_fd_type {
138140
/*
139141
* In fd based objects, uverbs_obj_type_ops points to generic
@@ -150,6 +152,37 @@ struct uverbs_obj_fd_type {
150152
int flags;
151153
};
152154

155+
struct ib_uverbs_file {
156+
struct kref ref;
157+
struct ib_uverbs_device *device;
158+
struct mutex ucontext_lock;
159+
/*
160+
* ucontext must be accessed via ib_uverbs_get_ucontext() or with
161+
* ucontext_lock held
162+
*/
163+
struct ib_ucontext *ucontext;
164+
struct ib_uverbs_async_event_file *default_async_file;
165+
struct list_head list;
166+
167+
/*
168+
* To access the uobjects list hw_destroy_rwsem must be held for write
169+
* OR hw_destroy_rwsem held for read AND uobjects_lock held.
170+
* hw_destroy_rwsem should be called across any destruction of the HW
171+
* object of an associated uobject.
172+
*/
173+
struct rw_semaphore hw_destroy_rwsem;
174+
spinlock_t uobjects_lock;
175+
struct list_head uobjects;
176+
177+
struct mutex umap_lock;
178+
struct list_head umaps;
179+
struct page *disassociate_page;
180+
181+
struct xarray idr;
182+
183+
struct mutex disassociation_lock;
184+
};
185+
153186
extern const struct uverbs_obj_type_class uverbs_idr_class;
154187
extern const struct uverbs_obj_type_class uverbs_fd_class;
155188
int uverbs_uobject_fd_release(struct inode *inode, struct file *filp);

0 commit comments

Comments
 (0)