Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <phaddad@nvidia.com>
Link: https://patch.msgid.link/29b718e0dca35daa5f496320a39284fc1f5a1722.1730373303.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>

authored by

Patrisious Haddad and committed by
Leon Romanovsky
27ed2f00 dc6be441

+36 -33
+3 -2
drivers/infiniband/core/rdma_core.c
··· 58 58 } 59 59 EXPORT_SYMBOL(uverbs_uobject_put); 60 60 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) 63 63 { 64 64 /* 65 65 * When a shared access is required, we use a positive counter. Each ··· 84 84 } 85 85 return 0; 86 86 } 87 + EXPORT_SYMBOL(uverbs_try_lock_object); 87 88 88 89 static void assert_uverbs_usecnt(struct ib_uobject *uobj, 89 90 enum rdma_lookup_mode mode)
-31
drivers/infiniband/core/uverbs.h
··· 133 133 struct ib_uverbs_event_queue ev_queue; 134 134 }; 135 135 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 - 167 136 struct ib_uverbs_event { 168 137 union { 169 138 struct ib_uverbs_async_event_desc async;
+33
include/rdma/uverbs_types.h
··· 134 134 } 135 135 void uverbs_uobject_put(struct ib_uobject *uobject); 136 136 137 + int uverbs_try_lock_object(struct ib_uobject *uobj, enum rdma_lookup_mode mode); 138 + 137 139 struct uverbs_obj_fd_type { 138 140 /* 139 141 * In fd based objects, uverbs_obj_type_ops points to generic ··· 150 148 const struct file_operations *fops; 151 149 const char *name; 152 150 int flags; 151 + }; 152 + 153 + struct ib_uverbs_file { 154 + struct kref ref; 155 + struct ib_uverbs_device *device; 156 + struct mutex ucontext_lock; 157 + /* 158 + * ucontext must be accessed via ib_uverbs_get_ucontext() or with 159 + * ucontext_lock held 160 + */ 161 + struct ib_ucontext *ucontext; 162 + struct ib_uverbs_async_event_file *default_async_file; 163 + struct list_head list; 164 + 165 + /* 166 + * To access the uobjects list hw_destroy_rwsem must be held for write 167 + * OR hw_destroy_rwsem held for read AND uobjects_lock held. 168 + * hw_destroy_rwsem should be called across any destruction of the HW 169 + * object of an associated uobject. 170 + */ 171 + struct rw_semaphore hw_destroy_rwsem; 172 + spinlock_t uobjects_lock; 173 + struct list_head uobjects; 174 + 175 + struct mutex umap_lock; 176 + struct list_head umaps; 177 + struct page *disassociate_page; 178 + 179 + struct xarray idr; 180 + 181 + struct mutex disassociation_lock; 153 182 }; 154 183 155 184 extern const struct uverbs_obj_type_class uverbs_idr_class;