Lines Matching defs:ictx

32 struct iommufd_object *_iommufd_object_alloc(struct iommufd_ctx *ictx,
62 rc = xa_alloc(&ictx->objects, &obj->id, XA_ZERO_ENTRY,
81 void iommufd_object_finalize(struct iommufd_ctx *ictx,
86 old = xa_store(&ictx->objects, obj->id, obj, GFP_KERNEL);
92 void iommufd_object_abort(struct iommufd_ctx *ictx, struct iommufd_object *obj)
96 old = xa_erase(&ictx->objects, obj->id);
105 void iommufd_object_abort_and_destroy(struct iommufd_ctx *ictx,
112 iommufd_object_abort(ictx, obj);
115 struct iommufd_object *iommufd_get_object(struct iommufd_ctx *ictx, u32 id,
123 xa_lock(&ictx->objects);
124 obj = xa_load(&ictx->objects, id);
128 xa_unlock(&ictx->objects);
136 static struct iommufd_object *iommufd_object_remove(struct iommufd_ctx *ictx,
140 XA_STATE(xas, &ictx->objects, id);
142 xa_lock(&ictx->objects);
162 if (ictx->vfio_ioas == container_of(obj, struct iommufd_ioas, obj))
163 ictx->vfio_ioas = NULL;
166 xa_unlock(&ictx->objects);
177 void __iommufd_object_destroy_user(struct iommufd_ctx *ictx,
189 ret = iommufd_object_remove(ictx, obj->id, true);
212 obj = iommufd_object_remove(ucmd->ictx, cmd->id, false);
222 struct iommufd_ctx *ictx;
224 ictx = kzalloc(sizeof(*ictx), GFP_KERNEL_ACCOUNT);
225 if (!ictx)
234 ictx->account_mode = IOPT_PAGES_ACCOUNT_MM;
238 xa_init_flags(&ictx->objects, XA_FLAGS_ALLOC1 | XA_FLAGS_ACCOUNT);
239 xa_init(&ictx->groups);
240 ictx->file = filp;
241 filp->private_data = ictx;
247 struct iommufd_ctx *ictx = filp->private_data;
259 while (!xa_empty(&ictx->objects)) {
263 xa_for_each(&ictx->objects, index, obj) {
267 xa_erase(&ictx->objects, index);
275 WARN_ON(!xa_empty(&ictx->groups));
276 kfree(ictx);
290 rc = iommufd_option_rlimit_mode(cmd, ucmd->ictx);
369 struct iommufd_ctx *ictx = filp->private_data;
379 return iommufd_vfio_ioctl(ictx, cmd, arg);
381 ucmd.ictx = ictx;
411 * @ictx: Context to get
413 * The caller must already hold a valid reference to ictx.
415 void iommufd_ctx_get(struct iommufd_ctx *ictx)
417 get_file(ictx->file);
431 struct iommufd_ctx *ictx;
435 ictx = file->private_data;
436 iommufd_ctx_get(ictx);
437 return ictx;
467 * @ictx: Context to put back
469 void iommufd_ctx_put(struct iommufd_ctx *ictx)
471 fput(ictx->file);