Lines Matching refs:ictx
31 struct iommufd_object *_iommufd_object_alloc(struct iommufd_ctx *ictx, in _iommufd_object_alloc() argument
52 rc = xa_alloc(&ictx->objects, &obj->id, XA_ZERO_ENTRY, in _iommufd_object_alloc()
71 void iommufd_object_finalize(struct iommufd_ctx *ictx, in iommufd_object_finalize() argument
76 old = xa_store(&ictx->objects, obj->id, obj, GFP_KERNEL); in iommufd_object_finalize()
82 void iommufd_object_abort(struct iommufd_ctx *ictx, struct iommufd_object *obj) in iommufd_object_abort() argument
86 old = xa_erase(&ictx->objects, obj->id); in iommufd_object_abort()
95 void iommufd_object_abort_and_destroy(struct iommufd_ctx *ictx, in iommufd_object_abort_and_destroy() argument
99 iommufd_object_abort(ictx, obj); in iommufd_object_abort_and_destroy()
102 struct iommufd_object *iommufd_get_object(struct iommufd_ctx *ictx, u32 id, in iommufd_get_object() argument
110 xa_lock(&ictx->objects); in iommufd_get_object()
111 obj = xa_load(&ictx->objects, id); in iommufd_get_object()
115 xa_unlock(&ictx->objects); in iommufd_get_object()
124 bool iommufd_object_destroy_user(struct iommufd_ctx *ictx, in iommufd_object_destroy_user() argument
134 xa_lock(&ictx->objects); in iommufd_object_destroy_user()
137 xa_unlock(&ictx->objects); in iommufd_object_destroy_user()
141 __xa_erase(&ictx->objects, obj->id); in iommufd_object_destroy_user()
142 if (ictx->vfio_ioas && &ictx->vfio_ioas->obj == obj) in iommufd_object_destroy_user()
143 ictx->vfio_ioas = NULL; in iommufd_object_destroy_user()
144 xa_unlock(&ictx->objects); in iommufd_object_destroy_user()
157 obj = iommufd_get_object(ucmd->ictx, cmd->id, IOMMUFD_OBJ_ANY); in iommufd_destroy()
162 if (!iommufd_object_destroy_user(ucmd->ictx, obj)) in iommufd_destroy()
169 struct iommufd_ctx *ictx; in iommufd_fops_open() local
171 ictx = kzalloc(sizeof(*ictx), GFP_KERNEL_ACCOUNT); in iommufd_fops_open()
172 if (!ictx) in iommufd_fops_open()
181 ictx->account_mode = IOPT_PAGES_ACCOUNT_MM; in iommufd_fops_open()
185 xa_init_flags(&ictx->objects, XA_FLAGS_ALLOC1 | XA_FLAGS_ACCOUNT); in iommufd_fops_open()
186 ictx->file = filp; in iommufd_fops_open()
187 filp->private_data = ictx; in iommufd_fops_open()
193 struct iommufd_ctx *ictx = filp->private_data; in iommufd_fops_release() local
205 while (!xa_empty(&ictx->objects)) { in iommufd_fops_release()
209 xa_for_each(&ictx->objects, index, obj) { in iommufd_fops_release()
213 xa_erase(&ictx->objects, index); in iommufd_fops_release()
221 kfree(ictx); in iommufd_fops_release()
235 rc = iommufd_option_rlimit_mode(cmd, ucmd->ictx); in iommufd_option()
308 struct iommufd_ctx *ictx = filp->private_data; in iommufd_fops_ioctl() local
318 return iommufd_vfio_ioctl(ictx, cmd, arg); in iommufd_fops_ioctl()
320 ucmd.ictx = ictx; in iommufd_fops_ioctl()
354 void iommufd_ctx_get(struct iommufd_ctx *ictx) in iommufd_ctx_get() argument
356 get_file(ictx->file); in iommufd_ctx_get()
370 struct iommufd_ctx *ictx; in iommufd_ctx_from_file() local
374 ictx = file->private_data; in iommufd_ctx_from_file()
375 iommufd_ctx_get(ictx); in iommufd_ctx_from_file()
376 return ictx; in iommufd_ctx_from_file()
384 void iommufd_ctx_put(struct iommufd_ctx *ictx) in iommufd_ctx_put() argument
386 fput(ictx->file); in iommufd_ctx_put()