Re: [PATCH v6 07/25] iommufd/access: Add internal APIs for HW queue to use

From: Baolu Lu
Date: Tue Jun 17 2025 - 00:24:43 EST


On 6/17/25 10:25, Nicolin Chen wrote:
struct iommufd_eventq {
struct iommufd_object obj;
struct iommufd_ctx *ictx;
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index 9293722b9cff..ad33f1e41a24 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -1084,7 +1084,39 @@ void iommufd_access_destroy_object(struct iommufd_object *obj)
if (access->ioas)
WARN_ON(iommufd_access_change_ioas(access, NULL));
mutex_unlock(&access->ioas_lock);
- iommufd_ctx_put(access->ictx);
+ if (access->ops)
+ iommufd_ctx_put(access->ictx);
I was hoping we could null the ictx to signal internal? That didn't
work out?
access->ictx should be NULL for internal. It should have been:
+ if (access->ictx)
+ iommufd_ctx_put(access->ictx);

access->ictx could be treated as user ownership token. If it's NULL,
there is no user ownership, indicating it's owned by the kernel. This is
the concept here?

Thanks,
baolu