mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-28 16:52:18 +00:00
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>
This commit is contained in:
parent
dc6be4418a
commit
27ed2f0080
@ -58,8 +58,8 @@ void uverbs_uobject_put(struct ib_uobject *uobject)
|
||||
}
|
||||
EXPORT_SYMBOL(uverbs_uobject_put);
|
||||
|
||||
static int uverbs_try_lock_object(struct ib_uobject *uobj,
|
||||
enum rdma_lookup_mode mode)
|
||||
int uverbs_try_lock_object(struct ib_uobject *uobj,
|
||||
enum rdma_lookup_mode mode)
|
||||
{
|
||||
/*
|
||||
* 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,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(uverbs_try_lock_object);
|
||||
|
||||
static void assert_uverbs_usecnt(struct ib_uobject *uobj,
|
||||
enum rdma_lookup_mode mode)
|
||||
|
@ -133,37 +133,6 @@ struct ib_uverbs_completion_event_file {
|
||||
struct ib_uverbs_event_queue ev_queue;
|
||||
};
|
||||
|
||||
struct ib_uverbs_file {
|
||||
struct kref ref;
|
||||
struct ib_uverbs_device *device;
|
||||
struct mutex ucontext_lock;
|
||||
/*
|
||||
* ucontext must be accessed via ib_uverbs_get_ucontext() or with
|
||||
* ucontext_lock held
|
||||
*/
|
||||
struct ib_ucontext *ucontext;
|
||||
struct ib_uverbs_async_event_file *default_async_file;
|
||||
struct list_head list;
|
||||
|
||||
/*
|
||||
* To access the uobjects list hw_destroy_rwsem must be held for write
|
||||
* OR hw_destroy_rwsem held for read AND uobjects_lock held.
|
||||
* hw_destroy_rwsem should be called across any destruction of the HW
|
||||
* object of an associated uobject.
|
||||
*/
|
||||
struct rw_semaphore hw_destroy_rwsem;
|
||||
spinlock_t uobjects_lock;
|
||||
struct list_head uobjects;
|
||||
|
||||
struct mutex umap_lock;
|
||||
struct list_head umaps;
|
||||
struct page *disassociate_page;
|
||||
|
||||
struct xarray idr;
|
||||
|
||||
struct mutex disassociation_lock;
|
||||
};
|
||||
|
||||
struct ib_uverbs_event {
|
||||
union {
|
||||
struct ib_uverbs_async_event_desc async;
|
||||
|
@ -134,6 +134,8 @@ static inline void uverbs_uobject_get(struct ib_uobject *uobject)
|
||||
}
|
||||
void uverbs_uobject_put(struct ib_uobject *uobject);
|
||||
|
||||
int uverbs_try_lock_object(struct ib_uobject *uobj, enum rdma_lookup_mode mode);
|
||||
|
||||
struct uverbs_obj_fd_type {
|
||||
/*
|
||||
* In fd based objects, uverbs_obj_type_ops points to generic
|
||||
@ -150,6 +152,37 @@ struct uverbs_obj_fd_type {
|
||||
int flags;
|
||||
};
|
||||
|
||||
struct ib_uverbs_file {
|
||||
struct kref ref;
|
||||
struct ib_uverbs_device *device;
|
||||
struct mutex ucontext_lock;
|
||||
/*
|
||||
* ucontext must be accessed via ib_uverbs_get_ucontext() or with
|
||||
* ucontext_lock held
|
||||
*/
|
||||
struct ib_ucontext *ucontext;
|
||||
struct ib_uverbs_async_event_file *default_async_file;
|
||||
struct list_head list;
|
||||
|
||||
/*
|
||||
* To access the uobjects list hw_destroy_rwsem must be held for write
|
||||
* OR hw_destroy_rwsem held for read AND uobjects_lock held.
|
||||
* hw_destroy_rwsem should be called across any destruction of the HW
|
||||
* object of an associated uobject.
|
||||
*/
|
||||
struct rw_semaphore hw_destroy_rwsem;
|
||||
spinlock_t uobjects_lock;
|
||||
struct list_head uobjects;
|
||||
|
||||
struct mutex umap_lock;
|
||||
struct list_head umaps;
|
||||
struct page *disassociate_page;
|
||||
|
||||
struct xarray idr;
|
||||
|
||||
struct mutex disassociation_lock;
|
||||
};
|
||||
|
||||
extern const struct uverbs_obj_type_class uverbs_idr_class;
|
||||
extern const struct uverbs_obj_type_class uverbs_fd_class;
|
||||
int uverbs_uobject_fd_release(struct inode *inode, struct file *filp);
|
||||
|
Loading…
Reference in New Issue
Block a user