@@ -139,7 +139,7 @@ int __uobj_perform_destroy(const struct uverbs_obj_type *type, int id,
139139 struct ib_uobject * uobj ;
140140 int ret ;
141141
142- uobj = rdma_lookup_get_uobject (type , ufile -> ucontext , id , true);
142+ uobj = rdma_lookup_get_uobject (type , ufile , id , true);
143143 if (IS_ERR (uobj ))
144144 return PTR_ERR (uobj );
145145
@@ -150,7 +150,7 @@ int __uobj_perform_destroy(const struct uverbs_obj_type *type, int id,
150150 return success_res ;
151151}
152152
153- static struct ib_uobject * alloc_uobj (struct ib_ucontext * context ,
153+ static struct ib_uobject * alloc_uobj (struct ib_uverbs_file * ufile ,
154154 const struct uverbs_obj_type * type )
155155{
156156 struct ib_uobject * uobj = kzalloc (type -> obj_size , GFP_KERNEL );
@@ -161,8 +161,8 @@ static struct ib_uobject *alloc_uobj(struct ib_ucontext *context,
161161 * user_handle should be filled by the handler,
162162 * The object is added to the list in the commit stage.
163163 */
164- uobj -> ufile = context -> ufile ;
165- uobj -> context = context ;
164+ uobj -> ufile = ufile ;
165+ uobj -> context = ufile -> ucontext ;
166166 uobj -> type = type ;
167167 /*
168168 * Allocated objects start out as write locked to deny any other
@@ -210,15 +210,15 @@ static void uverbs_idr_remove_uobj(struct ib_uobject *uobj)
210210}
211211
212212/* Returns the ib_uobject or an error. The caller should check for IS_ERR. */
213- static struct ib_uobject * lookup_get_idr_uobject ( const struct uverbs_obj_type * type ,
214- struct ib_ucontext * ucontext ,
215- int id , bool exclusive )
213+ static struct ib_uobject *
214+ lookup_get_idr_uobject ( const struct uverbs_obj_type * type ,
215+ struct ib_uverbs_file * ufile , int id , bool exclusive )
216216{
217217 struct ib_uobject * uobj ;
218218
219219 rcu_read_lock ();
220220 /* object won't be released as we're protected in rcu */
221- uobj = idr_find (& ucontext -> ufile -> idr , id );
221+ uobj = idr_find (& ufile -> idr , id );
222222 if (!uobj ) {
223223 uobj = ERR_PTR (- ENOENT );
224224 goto free ;
@@ -239,7 +239,7 @@ static struct ib_uobject *lookup_get_idr_uobject(const struct uverbs_obj_type *t
239239}
240240
241241static struct ib_uobject * lookup_get_fd_uobject (const struct uverbs_obj_type * type ,
242- struct ib_ucontext * ucontext ,
242+ struct ib_uverbs_file * ufile ,
243243 int id , bool exclusive )
244244{
245245 struct file * f ;
@@ -270,13 +270,13 @@ static struct ib_uobject *lookup_get_fd_uobject(const struct uverbs_obj_type *ty
270270}
271271
272272struct ib_uobject * rdma_lookup_get_uobject (const struct uverbs_obj_type * type ,
273- struct ib_ucontext * ucontext ,
274- int id , bool exclusive )
273+ struct ib_uverbs_file * ufile , int id ,
274+ bool exclusive )
275275{
276276 struct ib_uobject * uobj ;
277277 int ret ;
278278
279- uobj = type -> type_class -> lookup_get (type , ucontext , id , exclusive );
279+ uobj = type -> type_class -> lookup_get (type , ufile , id , exclusive );
280280 if (IS_ERR (uobj ))
281281 return uobj ;
282282
@@ -300,20 +300,20 @@ struct ib_uobject *rdma_lookup_get_uobject(const struct uverbs_obj_type *type,
300300}
301301
302302static struct ib_uobject * alloc_begin_idr_uobject (const struct uverbs_obj_type * type ,
303- struct ib_ucontext * ucontext )
303+ struct ib_uverbs_file * ufile )
304304{
305305 int ret ;
306306 struct ib_uobject * uobj ;
307307
308- uobj = alloc_uobj (ucontext , type );
308+ uobj = alloc_uobj (ufile , type );
309309 if (IS_ERR (uobj ))
310310 return uobj ;
311311
312312 ret = idr_add_uobj (uobj );
313313 if (ret )
314314 goto uobj_put ;
315315
316- ret = ib_rdmacg_try_charge (& uobj -> cg_obj , ucontext -> device ,
316+ ret = ib_rdmacg_try_charge (& uobj -> cg_obj , ufile -> ucontext -> device ,
317317 RDMACG_RESOURCE_HCA_OBJECT );
318318 if (ret )
319319 goto idr_remove ;
@@ -328,7 +328,7 @@ static struct ib_uobject *alloc_begin_idr_uobject(const struct uverbs_obj_type *
328328}
329329
330330static struct ib_uobject * alloc_begin_fd_uobject (const struct uverbs_obj_type * type ,
331- struct ib_ucontext * ucontext )
331+ struct ib_uverbs_file * ufile )
332332{
333333 const struct uverbs_obj_fd_type * fd_type =
334334 container_of (type , struct uverbs_obj_fd_type , type );
@@ -341,7 +341,7 @@ static struct ib_uobject *alloc_begin_fd_uobject(const struct uverbs_obj_type *t
341341 if (new_fd < 0 )
342342 return ERR_PTR (new_fd );
343343
344- uobj = alloc_uobj (ucontext , type );
344+ uobj = alloc_uobj (ufile , type );
345345 if (IS_ERR (uobj )) {
346346 put_unused_fd (new_fd );
347347 return uobj ;
@@ -360,17 +360,17 @@ static struct ib_uobject *alloc_begin_fd_uobject(const struct uverbs_obj_type *t
360360
361361 uobj_file -> uobj .id = new_fd ;
362362 uobj_file -> uobj .object = filp ;
363- uobj_file -> ufile = ucontext -> ufile ;
363+ uobj_file -> ufile = ufile ;
364364 INIT_LIST_HEAD (& uobj -> list );
365365 kref_get (& uobj_file -> ufile -> ref );
366366
367367 return uobj ;
368368}
369369
370370struct ib_uobject * rdma_alloc_begin_uobject (const struct uverbs_obj_type * type ,
371- struct ib_ucontext * ucontext )
371+ struct ib_uverbs_file * ufile )
372372{
373- return type -> type_class -> alloc_begin (type , ucontext );
373+ return type -> type_class -> alloc_begin (type , ufile );
374374}
375375
376376static int __must_check remove_commit_idr_uobject (struct ib_uobject * uobj ,
@@ -669,10 +669,9 @@ void uverbs_close_fd(struct file *f)
669669 kref_put (uverbs_file_ref , ib_uverbs_release_file );
670670}
671671
672- static int __uverbs_cleanup_ucontext (struct ib_ucontext * ucontext ,
673- enum rdma_remove_reason reason )
672+ static int __uverbs_cleanup_ufile (struct ib_uverbs_file * ufile ,
673+ enum rdma_remove_reason reason )
674674{
675- struct ib_uverbs_file * ufile = ucontext -> ufile ;
676675 struct ib_uobject * obj , * next_obj ;
677676 int ret = - EINVAL ;
678677 int err = 0 ;
@@ -716,12 +715,11 @@ static int __uverbs_cleanup_ucontext(struct ib_ucontext *ucontext,
716715 return ret ;
717716}
718717
719- void uverbs_cleanup_ucontext (struct ib_ucontext * ucontext , bool device_removed )
718+ void uverbs_cleanup_ufile (struct ib_uverbs_file * ufile , bool device_removed )
720719{
721720 enum rdma_remove_reason reason = device_removed ?
722721 RDMA_REMOVE_DRIVER_REMOVE :
723722 RDMA_REMOVE_CLOSE ;
724- struct ib_uverbs_file * ufile = ucontext -> ufile ;
725723
726724 /*
727725 * Waits for all remove_commit and alloc_commit to finish. Logically, We
@@ -731,7 +729,7 @@ void uverbs_cleanup_ucontext(struct ib_ucontext *ucontext, bool device_removed)
731729 down_write (& ufile -> cleanup_rwsem );
732730 ufile -> ucontext -> cleanup_retryable = true;
733731 while (!list_empty (& ufile -> uobjects ))
734- if (__uverbs_cleanup_ucontext ( ucontext , reason )) {
732+ if (__uverbs_cleanup_ufile ( ufile , reason )) {
735733 /*
736734 * No entry was cleaned-up successfully during this
737735 * iteration
@@ -741,7 +739,7 @@ void uverbs_cleanup_ucontext(struct ib_ucontext *ucontext, bool device_removed)
741739
742740 ufile -> ucontext -> cleanup_retryable = false;
743741 if (!list_empty (& ufile -> uobjects ))
744- __uverbs_cleanup_ucontext ( ucontext , reason );
742+ __uverbs_cleanup_ufile ( ufile , reason );
745743
746744 up_write (& ufile -> cleanup_rwsem );
747745}
@@ -757,19 +755,19 @@ const struct uverbs_obj_type_class uverbs_fd_class = {
757755};
758756EXPORT_SYMBOL (uverbs_fd_class );
759757
760- struct ib_uobject * uverbs_get_uobject_from_context ( const struct uverbs_obj_type * type_attrs ,
761- struct ib_ucontext * ucontext ,
762- enum uverbs_obj_access access ,
763- int id )
758+ struct ib_uobject *
759+ uverbs_get_uobject_from_file ( const struct uverbs_obj_type * type_attrs ,
760+ struct ib_uverbs_file * ufile ,
761+ enum uverbs_obj_access access , int id )
764762{
765763 switch (access ) {
766764 case UVERBS_ACCESS_READ :
767- return rdma_lookup_get_uobject (type_attrs , ucontext , id , false);
765+ return rdma_lookup_get_uobject (type_attrs , ufile , id , false);
768766 case UVERBS_ACCESS_DESTROY :
769767 case UVERBS_ACCESS_WRITE :
770- return rdma_lookup_get_uobject (type_attrs , ucontext , id , true);
768+ return rdma_lookup_get_uobject (type_attrs , ufile , id , true);
771769 case UVERBS_ACCESS_NEW :
772- return rdma_alloc_begin_uobject (type_attrs , ucontext );
770+ return rdma_alloc_begin_uobject (type_attrs , ufile );
773771 default :
774772 WARN_ON (true);
775773 return ERR_PTR (- EOPNOTSUPP );
0 commit comments