Lines Matching defs:obj

26 	void (*destroy)(struct iommufd_object *obj);
27 void (*abort)(struct iommufd_object *obj);
37 struct iommufd_object *obj;
40 obj = kzalloc(size, GFP_KERNEL_ACCOUNT);
41 if (!obj)
43 obj->type = type;
51 __init_rwsem(&obj->destroy_rwsem, "iommufd_object::destroy_rwsem",
53 refcount_set(&obj->users, 1);
62 rc = xa_alloc(&ictx->objects, &obj->id, XA_ZERO_ENTRY,
66 return obj;
68 kfree(obj);
82 struct iommufd_object *obj)
86 old = xa_store(&ictx->objects, obj->id, obj, GFP_KERNEL);
87 /* obj->id was returned from xa_alloc() so the xa_store() cannot fail */
92 void iommufd_object_abort(struct iommufd_ctx *ictx, struct iommufd_object *obj)
96 old = xa_erase(&ictx->objects, obj->id);
98 kfree(obj);
106 struct iommufd_object *obj)
108 if (iommufd_object_ops[obj->type].abort)
109 iommufd_object_ops[obj->type].abort(obj);
111 iommufd_object_ops[obj->type].destroy(obj);
112 iommufd_object_abort(ictx, obj);
118 struct iommufd_object *obj;
124 obj = xa_load(&ictx->objects, id);
125 if (!obj || (type != IOMMUFD_OBJ_ANY && obj->type != type) ||
126 !iommufd_lock_obj(obj))
127 obj = ERR_PTR(-ENOENT);
129 return obj;
139 struct iommufd_object *obj;
143 obj = xas_load(&xas);
144 if (xa_is_zero(obj) || !obj) {
145 obj = ERR_PTR(-ENOENT);
150 * If the caller is holding a ref on obj we put it here under the
154 refcount_dec(&obj->users);
156 if (!refcount_dec_if_one(&obj->users)) {
157 obj = ERR_PTR(-EBUSY);
162 if (ictx->vfio_ioas == container_of(obj, struct iommufd_ioas, obj))
169 return obj;
175 * reference on obj.
178 struct iommufd_object *obj, bool allow_fail)
188 down_write(&obj->destroy_rwsem);
189 ret = iommufd_object_remove(ictx, obj->id, true);
190 up_write(&obj->destroy_rwsem);
203 iommufd_object_ops[obj->type].destroy(obj);
204 kfree(obj);
210 struct iommufd_object *obj;
212 obj = iommufd_object_remove(ucmd->ictx, cmd->id, false);
213 if (IS_ERR(obj))
214 return PTR_ERR(obj);
215 iommufd_object_ops[obj->type].destroy(obj);
216 kfree(obj);
248 struct iommufd_object *obj;
263 xa_for_each(&ictx->objects, index, obj) {
264 if (!refcount_dec_if_one(&obj->users))
268 iommufd_object_ops[obj->type].destroy(obj);
269 kfree(obj);