Lines Matching refs:pbundle

79 	struct bundle_priv *pbundle;  in uapi_compute_bundle_size()  local
82 sizeof(*pbundle->bundle.attrs) * method_elm->key_bitmap_len + in uapi_compute_bundle_size()
83 sizeof(*pbundle->uattrs) * num_attrs; in uapi_compute_bundle_size()
85 method_elm->use_stack = bundle_size <= sizeof(*pbundle); in uapi_compute_bundle_size()
87 ALIGN(bundle_size + 256, sizeof(*pbundle->internal_buffer)); in uapi_compute_bundle_size()
109 struct bundle_priv *pbundle = in _uverbs_alloc() local
114 if (check_add_overflow(size, pbundle->internal_used, &new_used)) in _uverbs_alloc()
117 if (new_used > pbundle->internal_avail) { in _uverbs_alloc()
123 buf->next = pbundle->allocated_mem; in _uverbs_alloc()
124 pbundle->allocated_mem = buf; in _uverbs_alloc()
128 res = (void *)pbundle->internal_buffer + pbundle->internal_used; in _uverbs_alloc()
129 pbundle->internal_used = in _uverbs_alloc()
130 ALIGN(new_used, sizeof(*pbundle->internal_buffer)); in _uverbs_alloc()
151 struct bundle_priv *pbundle = in uverbs_set_output() local
155 flags = pbundle->uattrs[attr->ptr_attr.uattr_idx].flags | in uverbs_set_output()
158 &pbundle->user_attrs[attr->ptr_attr.uattr_idx].flags)) in uverbs_set_output()
163 static int uverbs_process_idrs_array(struct bundle_priv *pbundle, in uverbs_process_idrs_array() argument
187 uverbs_alloc(&pbundle->bundle, in uverbs_process_idrs_array()
212 idr_vals[i], &pbundle->bundle); in uverbs_process_idrs_array()
220 __set_bit(attr_bkey, pbundle->spec_finalize); in uverbs_process_idrs_array()
238 static int uverbs_process_attr(struct bundle_priv *pbundle, in uverbs_process_attr() argument
243 struct uverbs_attr *e = &pbundle->bundle.attrs[attr_bkey]; in uverbs_process_attr()
285 e->ptr_attr.uattr_idx = uattr - pbundle->uattrs; in uverbs_process_attr()
291 p = uverbs_alloc(&pbundle->bundle, uattr->len); in uverbs_process_attr()
324 uattr->data_s64, &pbundle->bundle); in uverbs_process_attr()
327 __set_bit(attr_bkey, pbundle->uobj_finalize); in uverbs_process_attr()
330 unsigned int uattr_idx = uattr - pbundle->uattrs; in uverbs_process_attr()
334 if (put_user(id, &pbundle->user_attrs[uattr_idx].data)) in uverbs_process_attr()
341 return uverbs_process_idrs_array(pbundle, attr_uapi, in uverbs_process_attr()
361 static void __rcu **uapi_get_attr_for_method(struct bundle_priv *pbundle, in uapi_get_attr_for_method() argument
366 if (likely(attr_key < pbundle->radix_slots_len)) { in uapi_get_attr_for_method()
369 slot = pbundle->radix_slots + attr_key; in uapi_get_attr_for_method()
375 return radix_tree_lookup_slot(pbundle->radix, in uapi_get_attr_for_method()
376 pbundle->method_key | attr_key); in uapi_get_attr_for_method()
379 static int uverbs_set_attr(struct bundle_priv *pbundle, in uverbs_set_attr() argument
388 slot = uapi_get_attr_for_method(pbundle, attr_key); in uverbs_set_attr()
401 if (test_bit(attr_bkey, pbundle->bundle.attr_present)) in uverbs_set_attr()
404 ret = uverbs_process_attr(pbundle, attr, uattr, attr_bkey); in uverbs_set_attr()
408 __set_bit(attr_bkey, pbundle->bundle.attr_present); in uverbs_set_attr()
413 static int ib_uverbs_run_method(struct bundle_priv *pbundle, in ib_uverbs_run_method() argument
417 size_t uattrs_size = array_size(sizeof(*pbundle->uattrs), num_attrs); in ib_uverbs_run_method()
418 unsigned int destroy_bkey = pbundle->method_elm->destroy_bkey; in ib_uverbs_run_method()
424 pbundle->method_elm->handler, in ib_uverbs_run_method()
425 &pbundle->bundle.ufile->device->disassociate_srcu); in ib_uverbs_run_method()
429 pbundle->uattrs = uverbs_alloc(&pbundle->bundle, uattrs_size); in ib_uverbs_run_method()
430 if (IS_ERR(pbundle->uattrs)) in ib_uverbs_run_method()
431 return PTR_ERR(pbundle->uattrs); in ib_uverbs_run_method()
432 if (copy_from_user(pbundle->uattrs, pbundle->user_attrs, uattrs_size)) in ib_uverbs_run_method()
436 ret = uverbs_set_attr(pbundle, &pbundle->uattrs[i]); in ib_uverbs_run_method()
442 if (unlikely(!bitmap_subset(pbundle->method_elm->attr_mandatory, in ib_uverbs_run_method()
443 pbundle->bundle.attr_present, in ib_uverbs_run_method()
444 pbundle->method_elm->key_bitmap_len))) in ib_uverbs_run_method()
447 if (pbundle->method_elm->has_udata) in ib_uverbs_run_method()
448 uverbs_fill_udata(&pbundle->bundle, in ib_uverbs_run_method()
449 &pbundle->bundle.driver_udata, in ib_uverbs_run_method()
452 pbundle->bundle.driver_udata = (struct ib_udata){}; in ib_uverbs_run_method()
456 &pbundle->bundle.attrs[destroy_bkey].obj_attr; in ib_uverbs_run_method()
458 ret = uobj_destroy(destroy_attr->uobject, &pbundle->bundle); in ib_uverbs_run_method()
461 __clear_bit(destroy_bkey, pbundle->uobj_finalize); in ib_uverbs_run_method()
463 ret = handler(&pbundle->bundle); in ib_uverbs_run_method()
466 ret = handler(&pbundle->bundle); in ib_uverbs_run_method()
474 if (!ret && pbundle->method_elm->has_udata) { in ib_uverbs_run_method()
476 uverbs_attr_get(&pbundle->bundle, UVERBS_ATTR_UHW_OUT); in ib_uverbs_run_method()
479 ret = uverbs_set_output(&pbundle->bundle, attr); in ib_uverbs_run_method()
493 static void bundle_destroy(struct bundle_priv *pbundle, bool commit) in bundle_destroy() argument
495 unsigned int key_bitmap_len = pbundle->method_elm->key_bitmap_len; in bundle_destroy()
501 while ((i = find_next_bit(pbundle->uobj_finalize, key_bitmap_len, in bundle_destroy()
503 struct uverbs_attr *attr = &pbundle->bundle.attrs[i]; in bundle_destroy()
508 test_bit(i, pbundle->uobj_hw_obj_valid), in bundle_destroy()
510 &pbundle->bundle); in bundle_destroy()
514 while ((i = find_next_bit(pbundle->spec_finalize, key_bitmap_len, in bundle_destroy()
516 struct uverbs_attr *attr = &pbundle->bundle.attrs[i]; in bundle_destroy()
521 pbundle, in bundle_destroy()
522 pbundle->method_key | uapi_bkey_to_key_attr(i)); in bundle_destroy()
530 commit, &pbundle->bundle); in bundle_destroy()
534 for (memblock = pbundle->allocated_mem; memblock;) { in bundle_destroy()
549 struct bundle_priv *pbundle; in ib_uverbs_cmd_verbs() local
566 pbundle = kmalloc(method_elm->bundle_size, GFP_KERNEL); in ib_uverbs_cmd_verbs()
567 if (!pbundle) in ib_uverbs_cmd_verbs()
569 pbundle->internal_avail = in ib_uverbs_cmd_verbs()
572 pbundle->alloc_head.next = NULL; in ib_uverbs_cmd_verbs()
573 pbundle->allocated_mem = &pbundle->alloc_head; in ib_uverbs_cmd_verbs()
575 pbundle = &onstack; in ib_uverbs_cmd_verbs()
576 pbundle->internal_avail = sizeof(pbundle->internal_buffer); in ib_uverbs_cmd_verbs()
577 pbundle->allocated_mem = NULL; in ib_uverbs_cmd_verbs()
581 pbundle->method_elm = method_elm; in ib_uverbs_cmd_verbs()
582 pbundle->method_key = attrs_iter.index; in ib_uverbs_cmd_verbs()
583 pbundle->bundle.ufile = ufile; in ib_uverbs_cmd_verbs()
584 pbundle->bundle.context = NULL; /* only valid if bundle has uobject */ in ib_uverbs_cmd_verbs()
585 pbundle->radix = &uapi->radix; in ib_uverbs_cmd_verbs()
586 pbundle->radix_slots = slot; in ib_uverbs_cmd_verbs()
587 pbundle->radix_slots_len = radix_tree_chunk_size(&attrs_iter); in ib_uverbs_cmd_verbs()
588 pbundle->user_attrs = user_attrs; in ib_uverbs_cmd_verbs()
590 pbundle->internal_used = ALIGN(pbundle->method_elm->key_bitmap_len * in ib_uverbs_cmd_verbs()
591 sizeof(*pbundle->bundle.attrs), in ib_uverbs_cmd_verbs()
592 sizeof(*pbundle->internal_buffer)); in ib_uverbs_cmd_verbs()
593 memset(pbundle->bundle.attr_present, 0, in ib_uverbs_cmd_verbs()
594 sizeof(pbundle->bundle.attr_present)); in ib_uverbs_cmd_verbs()
595 memset(pbundle->uobj_finalize, 0, sizeof(pbundle->uobj_finalize)); in ib_uverbs_cmd_verbs()
596 memset(pbundle->spec_finalize, 0, sizeof(pbundle->spec_finalize)); in ib_uverbs_cmd_verbs()
597 memset(pbundle->uobj_hw_obj_valid, 0, in ib_uverbs_cmd_verbs()
598 sizeof(pbundle->uobj_hw_obj_valid)); in ib_uverbs_cmd_verbs()
600 ret = ib_uverbs_run_method(pbundle, hdr->num_attrs); in ib_uverbs_cmd_verbs()
601 bundle_destroy(pbundle, ret == 0); in ib_uverbs_cmd_verbs()
694 struct bundle_priv *pbundle = in uverbs_fill_udata() local
697 uverbs_attr_get(&pbundle->bundle, attr_in); in uverbs_fill_udata()
699 uverbs_attr_get(&pbundle->bundle, attr_out); in uverbs_fill_udata()
705 &pbundle->user_attrs[in->ptr_attr.uattr_idx] in uverbs_fill_udata()
823 struct bundle_priv *pbundle = in uverbs_finalize_uobj_create() local
827 pbundle->uobj_hw_obj_valid); in uverbs_finalize_uobj_create()