Lines Matching refs:pbundle

77 	struct bundle_priv *pbundle;  in uapi_compute_bundle_size()  local
80 sizeof(*pbundle->bundle.attrs) * method_elm->key_bitmap_len + in uapi_compute_bundle_size()
81 sizeof(*pbundle->uattrs) * num_attrs; in uapi_compute_bundle_size()
83 method_elm->use_stack = bundle_size <= sizeof(*pbundle); in uapi_compute_bundle_size()
85 ALIGN(bundle_size + 256, sizeof(*pbundle->internal_buffer)); in uapi_compute_bundle_size()
107 struct bundle_priv *pbundle = in _uverbs_alloc() local
112 if (check_add_overflow(size, pbundle->internal_used, &new_used)) in _uverbs_alloc()
115 if (new_used > pbundle->internal_avail) { in _uverbs_alloc()
121 buf->next = pbundle->allocated_mem; in _uverbs_alloc()
122 pbundle->allocated_mem = buf; in _uverbs_alloc()
126 res = (void *)pbundle->internal_buffer + pbundle->internal_used; in _uverbs_alloc()
127 pbundle->internal_used = in _uverbs_alloc()
128 ALIGN(new_used, sizeof(*pbundle->internal_buffer)); in _uverbs_alloc()
146 static int uverbs_process_attr(struct bundle_priv *pbundle, in uverbs_process_attr() argument
151 struct uverbs_attr *e = &pbundle->bundle.attrs[attr_bkey]; in uverbs_process_attr()
193 e->ptr_attr.uattr_idx = uattr - pbundle->uattrs; in uverbs_process_attr()
199 p = uverbs_alloc(&pbundle->bundle, uattr->len); in uverbs_process_attr()
232 pbundle->bundle.ufile, in uverbs_process_attr()
237 __set_bit(attr_bkey, pbundle->uobj_finalize); in uverbs_process_attr()
240 unsigned int uattr_idx = uattr - pbundle->uattrs; in uverbs_process_attr()
244 if (put_user(id, &pbundle->user_attrs[uattr_idx].data)) in uverbs_process_attr()
266 static void __rcu **uapi_get_attr_for_method(struct bundle_priv *pbundle, in uapi_get_attr_for_method() argument
271 if (likely(attr_key < pbundle->radix_slots_len)) { in uapi_get_attr_for_method()
274 slot = pbundle->radix_slots + attr_key; in uapi_get_attr_for_method()
280 return radix_tree_lookup_slot(pbundle->radix, in uapi_get_attr_for_method()
281 pbundle->method_key | attr_key); in uapi_get_attr_for_method()
284 static int uverbs_set_attr(struct bundle_priv *pbundle, in uverbs_set_attr() argument
293 slot = uapi_get_attr_for_method(pbundle, attr_key); in uverbs_set_attr()
304 *slot, &pbundle->bundle.ufile->device->disassociate_srcu); in uverbs_set_attr()
307 if (test_bit(attr_bkey, pbundle->bundle.attr_present)) in uverbs_set_attr()
310 ret = uverbs_process_attr(pbundle, attr, uattr, attr_bkey); in uverbs_set_attr()
314 __set_bit(attr_bkey, pbundle->bundle.attr_present); in uverbs_set_attr()
319 static int ib_uverbs_run_method(struct bundle_priv *pbundle, in ib_uverbs_run_method() argument
324 size_t uattrs_size = array_size(sizeof(*pbundle->uattrs), num_attrs); in ib_uverbs_run_method()
325 unsigned int destroy_bkey = pbundle->method_elm->destroy_bkey; in ib_uverbs_run_method()
331 pbundle->method_elm->handler, in ib_uverbs_run_method()
332 &pbundle->bundle.ufile->device->disassociate_srcu); in ib_uverbs_run_method()
336 pbundle->uattrs = uverbs_alloc(&pbundle->bundle, uattrs_size); in ib_uverbs_run_method()
337 if (IS_ERR(pbundle->uattrs)) in ib_uverbs_run_method()
338 return PTR_ERR(pbundle->uattrs); in ib_uverbs_run_method()
339 if (copy_from_user(pbundle->uattrs, pbundle->user_attrs, uattrs_size)) in ib_uverbs_run_method()
343 ret = uverbs_set_attr(pbundle, &pbundle->uattrs[i]); in ib_uverbs_run_method()
349 if (unlikely(!bitmap_subset(pbundle->method_elm->attr_mandatory, in ib_uverbs_run_method()
350 pbundle->bundle.attr_present, in ib_uverbs_run_method()
351 pbundle->method_elm->key_bitmap_len))) in ib_uverbs_run_method()
356 &pbundle->bundle.attrs[destroy_bkey].obj_attr; in ib_uverbs_run_method()
361 __clear_bit(destroy_bkey, pbundle->uobj_finalize); in ib_uverbs_run_method()
363 ret = handler(pbundle->bundle.ufile, &pbundle->bundle); in ib_uverbs_run_method()
366 ret = handler(pbundle->bundle.ufile, &pbundle->bundle); in ib_uverbs_run_method()
380 static int bundle_destroy(struct bundle_priv *pbundle, bool commit) in bundle_destroy() argument
382 unsigned int key_bitmap_len = pbundle->method_elm->key_bitmap_len; in bundle_destroy()
388 while ((i = find_next_bit(pbundle->uobj_finalize, key_bitmap_len, in bundle_destroy()
390 struct uverbs_attr *attr = &pbundle->bundle.attrs[i]; in bundle_destroy()
400 for (memblock = pbundle->allocated_mem; memblock;) { in bundle_destroy()
417 struct bundle_priv *pbundle; in ib_uverbs_cmd_verbs() local
435 pbundle = kmalloc(method_elm->bundle_size, GFP_KERNEL); in ib_uverbs_cmd_verbs()
436 if (!pbundle) in ib_uverbs_cmd_verbs()
438 pbundle->internal_avail = in ib_uverbs_cmd_verbs()
441 pbundle->alloc_head.next = NULL; in ib_uverbs_cmd_verbs()
442 pbundle->allocated_mem = &pbundle->alloc_head; in ib_uverbs_cmd_verbs()
444 pbundle = &onstack; in ib_uverbs_cmd_verbs()
445 pbundle->internal_avail = sizeof(pbundle->internal_buffer); in ib_uverbs_cmd_verbs()
446 pbundle->allocated_mem = NULL; in ib_uverbs_cmd_verbs()
450 pbundle->method_elm = method_elm; in ib_uverbs_cmd_verbs()
451 pbundle->method_key = attrs_iter.index; in ib_uverbs_cmd_verbs()
452 pbundle->bundle.ufile = ufile; in ib_uverbs_cmd_verbs()
453 pbundle->radix = &uapi->radix; in ib_uverbs_cmd_verbs()
454 pbundle->radix_slots = slot; in ib_uverbs_cmd_verbs()
455 pbundle->radix_slots_len = radix_tree_chunk_size(&attrs_iter); in ib_uverbs_cmd_verbs()
456 pbundle->user_attrs = user_attrs; in ib_uverbs_cmd_verbs()
458 pbundle->internal_used = ALIGN(pbundle->method_elm->key_bitmap_len * in ib_uverbs_cmd_verbs()
459 sizeof(*pbundle->bundle.attrs), in ib_uverbs_cmd_verbs()
460 sizeof(*pbundle->internal_buffer)); in ib_uverbs_cmd_verbs()
461 memset(pbundle->bundle.attr_present, 0, in ib_uverbs_cmd_verbs()
462 sizeof(pbundle->bundle.attr_present)); in ib_uverbs_cmd_verbs()
463 memset(pbundle->uobj_finalize, 0, sizeof(pbundle->uobj_finalize)); in ib_uverbs_cmd_verbs()
465 ret = ib_uverbs_run_method(pbundle, hdr->num_attrs); in ib_uverbs_cmd_verbs()
466 destroy_ret = bundle_destroy(pbundle, ret == 0); in ib_uverbs_cmd_verbs()
560 struct bundle_priv *pbundle = in create_udata() local
571 &pbundle->user_attrs[uhw_in->ptr_attr.uattr_idx] in create_udata()
592 struct bundle_priv *pbundle = in uverbs_copy_to() local
605 flags = pbundle->uattrs[attr->ptr_attr.uattr_idx].flags | in uverbs_copy_to()
608 &pbundle->user_attrs[attr->ptr_attr.uattr_idx].flags)) in uverbs_copy_to()