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()
349 return uverbs_process_idrs_array(pbundle, attr_uapi, in uverbs_process_attr()
369 static void __rcu **uapi_get_attr_for_method(struct bundle_priv *pbundle, in uapi_get_attr_for_method() argument
374 if (likely(attr_key < pbundle->radix_slots_len)) { in uapi_get_attr_for_method()
377 slot = pbundle->radix_slots + attr_key; in uapi_get_attr_for_method()
383 return radix_tree_lookup_slot(pbundle->radix, in uapi_get_attr_for_method()
384 pbundle->method_key | attr_key); in uapi_get_attr_for_method()
387 static int uverbs_set_attr(struct bundle_priv *pbundle, in uverbs_set_attr() argument
396 slot = uapi_get_attr_for_method(pbundle, attr_key); in uverbs_set_attr()
409 if (test_bit(attr_bkey, pbundle->bundle.attr_present)) in uverbs_set_attr()
412 ret = uverbs_process_attr(pbundle, attr, uattr, attr_bkey); in uverbs_set_attr()
416 __set_bit(attr_bkey, pbundle->bundle.attr_present); in uverbs_set_attr()
421 static int ib_uverbs_run_method(struct bundle_priv *pbundle, in ib_uverbs_run_method() argument
425 size_t uattrs_size = array_size(sizeof(*pbundle->uattrs), num_attrs); in ib_uverbs_run_method()
426 unsigned int destroy_bkey = pbundle->method_elm->destroy_bkey; in ib_uverbs_run_method()
432 pbundle->method_elm->handler, in ib_uverbs_run_method()
433 &pbundle->bundle.ufile->device->disassociate_srcu); in ib_uverbs_run_method()
437 pbundle->uattrs = uverbs_alloc(&pbundle->bundle, uattrs_size); in ib_uverbs_run_method()
438 if (IS_ERR(pbundle->uattrs)) in ib_uverbs_run_method()
439 return PTR_ERR(pbundle->uattrs); in ib_uverbs_run_method()
440 if (copy_from_user(pbundle->uattrs, pbundle->user_attrs, uattrs_size)) in ib_uverbs_run_method()
444 ret = uverbs_set_attr(pbundle, &pbundle->uattrs[i]); in ib_uverbs_run_method()
450 if (unlikely(!bitmap_subset(pbundle->method_elm->attr_mandatory, in ib_uverbs_run_method()
451 pbundle->bundle.attr_present, in ib_uverbs_run_method()
452 pbundle->method_elm->key_bitmap_len))) in ib_uverbs_run_method()
455 if (pbundle->method_elm->has_udata) in ib_uverbs_run_method()
456 uverbs_fill_udata(&pbundle->bundle, in ib_uverbs_run_method()
457 &pbundle->bundle.driver_udata, in ib_uverbs_run_method()
460 pbundle->bundle.driver_udata = (struct ib_udata){}; in ib_uverbs_run_method()
464 &pbundle->bundle.attrs[destroy_bkey].obj_attr; in ib_uverbs_run_method()
466 ret = uobj_destroy(destroy_attr->uobject, &pbundle->bundle); in ib_uverbs_run_method()
469 __clear_bit(destroy_bkey, pbundle->uobj_finalize); in ib_uverbs_run_method()
471 ret = handler(&pbundle->bundle); in ib_uverbs_run_method()
474 ret = handler(&pbundle->bundle); in ib_uverbs_run_method()
482 if (!ret && pbundle->method_elm->has_udata) { in ib_uverbs_run_method()
484 uverbs_attr_get(&pbundle->bundle, UVERBS_ATTR_UHW_OUT); in ib_uverbs_run_method()
487 ret = uverbs_set_output(&pbundle->bundle, attr); in ib_uverbs_run_method()
501 static void bundle_destroy(struct bundle_priv *pbundle, bool commit) in bundle_destroy() argument
503 unsigned int key_bitmap_len = pbundle->method_elm->key_bitmap_len; in bundle_destroy()
509 while ((i = find_next_bit(pbundle->uobj_finalize, key_bitmap_len, in bundle_destroy()
511 struct uverbs_attr *attr = &pbundle->bundle.attrs[i]; in bundle_destroy()
516 test_bit(i, pbundle->uobj_hw_obj_valid), in bundle_destroy()
518 &pbundle->bundle); in bundle_destroy()
522 while ((i = find_next_bit(pbundle->spec_finalize, key_bitmap_len, in bundle_destroy()
524 struct uverbs_attr *attr = &pbundle->bundle.attrs[i]; in bundle_destroy()
529 pbundle, in bundle_destroy()
530 pbundle->method_key | uapi_bkey_to_key_attr(i)); in bundle_destroy()
538 commit, &pbundle->bundle); in bundle_destroy()
542 for (memblock = pbundle->allocated_mem; memblock;) { in bundle_destroy()
557 struct bundle_priv *pbundle; in ib_uverbs_cmd_verbs() local
574 pbundle = kmalloc(method_elm->bundle_size, GFP_KERNEL); in ib_uverbs_cmd_verbs()
575 if (!pbundle) in ib_uverbs_cmd_verbs()
577 pbundle->internal_avail = in ib_uverbs_cmd_verbs()
580 pbundle->alloc_head.next = NULL; in ib_uverbs_cmd_verbs()
581 pbundle->allocated_mem = &pbundle->alloc_head; in ib_uverbs_cmd_verbs()
583 pbundle = &onstack; in ib_uverbs_cmd_verbs()
584 pbundle->internal_avail = sizeof(pbundle->internal_buffer); in ib_uverbs_cmd_verbs()
585 pbundle->allocated_mem = NULL; in ib_uverbs_cmd_verbs()
589 pbundle->method_elm = method_elm; in ib_uverbs_cmd_verbs()
590 pbundle->method_key = attrs_iter.index; in ib_uverbs_cmd_verbs()
591 pbundle->bundle.ufile = ufile; in ib_uverbs_cmd_verbs()
592 pbundle->bundle.context = NULL; /* only valid if bundle has uobject */ in ib_uverbs_cmd_verbs()
593 pbundle->radix = &uapi->radix; in ib_uverbs_cmd_verbs()
594 pbundle->radix_slots = slot; in ib_uverbs_cmd_verbs()
595 pbundle->radix_slots_len = radix_tree_chunk_size(&attrs_iter); in ib_uverbs_cmd_verbs()
596 pbundle->user_attrs = user_attrs; in ib_uverbs_cmd_verbs()
598 pbundle->internal_used = ALIGN(pbundle->method_elm->key_bitmap_len * in ib_uverbs_cmd_verbs()
599 sizeof(*pbundle->bundle.attrs), in ib_uverbs_cmd_verbs()
600 sizeof(*pbundle->internal_buffer)); in ib_uverbs_cmd_verbs()
601 memset(pbundle->bundle.attr_present, 0, in ib_uverbs_cmd_verbs()
602 sizeof(pbundle->bundle.attr_present)); in ib_uverbs_cmd_verbs()
603 memset(pbundle->uobj_finalize, 0, sizeof(pbundle->uobj_finalize)); in ib_uverbs_cmd_verbs()
604 memset(pbundle->spec_finalize, 0, sizeof(pbundle->spec_finalize)); in ib_uverbs_cmd_verbs()
605 memset(pbundle->uobj_hw_obj_valid, 0, in ib_uverbs_cmd_verbs()
606 sizeof(pbundle->uobj_hw_obj_valid)); in ib_uverbs_cmd_verbs()
608 ret = ib_uverbs_run_method(pbundle, hdr->num_attrs); in ib_uverbs_cmd_verbs()
609 bundle_destroy(pbundle, ret == 0); in ib_uverbs_cmd_verbs()
702 struct bundle_priv *pbundle = in uverbs_fill_udata() local
705 uverbs_attr_get(&pbundle->bundle, attr_in); in uverbs_fill_udata()
707 uverbs_attr_get(&pbundle->bundle, attr_out); in uverbs_fill_udata()
713 &pbundle->user_attrs[in->ptr_attr.uattr_idx] in uverbs_fill_udata()
831 struct bundle_priv *pbundle = in uverbs_finalize_uobj_create() local
835 pbundle->uobj_hw_obj_valid); in uverbs_finalize_uobj_create()