RE: [PATCH v4 05/23] iommufd/driver: Let iommufd_viommu_alloc helper save ictx to viommu->ictx

Tian, Kevin
2025-05-15T05:48:24Z

> From: Nicolin Chen <nicolinc@nvidia.com>
> Sent: Friday, May 9, 2025 11:02 AM
>
> When an IOMMU driver calls iommufd_viommu_alloc(), it must pass in an
> ictx
> pointer as the underlying _iommufd_object_alloc() helper function requires
> that to allocate a new object. However, neither the iommufd_viommu_alloc()
> nor its underlying _iommufd_object_alloc() saves the ictx in the allocated
> viommu object, although viommu could hold an ictx pointer.
>
> When the IOMMU driver wants to use another iommufd function passing in
> the
> allocated viommu, it could have avoided passing in the ictx pointer again,
> if viommu->ictx is valid.
>
> Save ictx to viommu->ictx in the iommufd_viommu_alloc(), in order to ease
> a new vIOMMU-based helper that would then get the ictx from viommu->ictx.
>
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>