[PATCH v1 08/12] iommufd/viommu: Replace ops->viommu_alloc with ops->viommu_init
Baolu Lu
baolu.lu at linux.intel.com
Mon Jun 9 22:55:05 PDT 2025
On 6/10/25 01:13, Nicolin Chen wrote:
> To ease the for-driver iommufd APIs, get_viommu_size and viommu_init ops
> are introduced. Now, those existing vIOMMU supported drivers implemented
> these two ops too.
>
> Relace the ops->viommu_alloc call with the two new ones.
>
> Note that this will fail a !viommu->ops case from now on, since a vIOMMU
> is expected to support alloc_domain_nested at least.
Does this mean that the viommu implementation in the iommu driver is
required to implement alloc_domain_nested? I suppose viommu should soon
be extended to support TEE/IO.
>
> Suggested-by: Jason Gunthorpe<jgg at nvidia.com>
> Signed-off-by: Nicolin Chen<nicolinc at nvidia.com>
> ---
> drivers/iommu/iommufd/viommu.c | 30 +++++++++++++++++++++++++++---
> 1 file changed, 27 insertions(+), 3 deletions(-)
>
<...>
> @@ -68,6 +82,16 @@ int iommufd_viommu_alloc_ioctl(struct iommufd_ucmd *ucmd)
> */
> viommu->iommu_dev = __iommu_get_iommu_dev(idev->dev);
>
> + rc = ops->viommu_init(viommu, hwpt_paging->common.domain);
> + if (rc)
> + goto out_abort;
> +
> + /* It is a driver bug that viommu->ops isn't filled */
> + if (WARN_ON_ONCE(!viommu->ops)) {
> + rc = -EINVAL;
> + goto out_abort;
> + }
> +
> cmd->out_viommu_id = viommu->obj.id;
> rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd));
> if (rc)
Thanks,
baolu
More information about the linux-arm-kernel
mailing list