diff options
author | Jason Gunthorpe <jgg@mellanox.com> | 2018-07-25 21:40:17 -0600 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-08-01 14:55:48 -0600 |
commit | bbd51e881ff05aa6dccda025e335438f3b3a1dba (patch) | |
tree | 719d347f1f7e3145abed708ca69a3db82366ee16 /include/rdma | |
parent | cc2e14e68004e6dec70842f990085f67c1f6fec7 (diff) | |
download | linux-stable-bbd51e881ff05aa6dccda025e335438f3b3a1dba.tar.gz linux-stable-bbd51e881ff05aa6dccda025e335438f3b3a1dba.tar.bz2 linux-stable-bbd51e881ff05aa6dccda025e335438f3b3a1dba.zip |
IB/uverbs: Do not pass struct ib_device to the write based methods
This is a step to get rid of the global check for disassociation. In this
model, the ib_dev is not proven to be valid by the core code and cannot be
provided to the method. Instead, every method decides if it is able to
run after disassociation and obtains the ib_dev using one of three
different approaches:
- Call srcu_dereference on the udevice's ib_dev. As before, this means
the method cannot be called after disassociation begins.
(eg alloc ucontext)
- Retrieve the ib_dev from the ucontext, via ib_uverbs_get_ucontext()
- Retrieve the ib_dev from the uobject->object after checking
under SRCU if disassociation has started (eg uobj_get)
Largely, the code is all ready for this, the main work is to provide a
ib_dev after calling uobj_alloc(). The few other places simply use
ib_uverbs_get_ucontext() to get the ib_dev.
This flexibility will let the next patches allow destroy to operate
after disassociation.
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'include/rdma')
-rw-r--r-- | include/rdma/uverbs_std_types.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/include/rdma/uverbs_std_types.h b/include/rdma/uverbs_std_types.h index 8c54e1439ba1..64ee2545dd3d 100644 --- a/include/rdma/uverbs_std_types.h +++ b/include/rdma/uverbs_std_types.h @@ -125,12 +125,18 @@ static inline void uobj_alloc_abort(struct ib_uobject *uobj) } static inline struct ib_uobject *__uobj_alloc(const struct uverbs_obj_type *type, - struct ib_uverbs_file *ufile) + struct ib_uverbs_file *ufile, + struct ib_device **ib_dev) { - return rdma_alloc_begin_uobject(type, ufile); + struct ib_uobject *uobj = rdma_alloc_begin_uobject(type, ufile); + + if (!IS_ERR(uobj)) + *ib_dev = uobj->context->device; + return uobj; } -#define uobj_alloc(_type, _ufile) __uobj_alloc(uobj_get_type(_type), _ufile) +#define uobj_alloc(_type, _ufile, _ib_dev) \ + __uobj_alloc(uobj_get_type(_type), _ufile, _ib_dev) #endif |