Hey Nicolin, On Wed, Jul 09, 2025 at 10:59:15PM -0700, Nicolin Chen wrote: > An impl driver might want to allocate its own type of vIOMMU object or the > standard IOMMU_VIOMMU_TYPE_ARM_SMMUV3 by setting up its own SW/HW bits, as > the tegra241-cmdqv driver will add IOMMU_VIOMMU_TYPE_TEGRA241_CMDQV. > > Add vsmmu_size/type and vsmmu_init to struct arm_smmu_impl_ops. Prioritize > them in arm_smmu_get_viommu_size() and arm_vsmmu_init(). > > Reviewed-by: Pranjal Shrivastava <praan@xxxxxxxxxx> > Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx> > Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx> > Signed-off-by: Nicolin Chen <nicolinc@xxxxxxxxxx> > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 5 +++++ > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 8 ++++++++ > 2 files changed, 13 insertions(+) > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h > index c1ced4d4b6d1..6183f212539a 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h > @@ -16,6 +16,7 @@ > #include <linux/sizes.h> > > struct arm_smmu_device; > +struct arm_vsmmu; > > /* MMIO registers */ > #define ARM_SMMU_IDR0 0x0 > @@ -720,6 +721,10 @@ struct arm_smmu_impl_ops { > int (*init_structures)(struct arm_smmu_device *smmu); > struct arm_smmu_cmdq *(*get_secondary_cmdq)( > struct arm_smmu_device *smmu, struct arm_smmu_cmdq_ent *ent); > + const size_t vsmmu_size; > + const enum iommu_viommu_type vsmmu_type; > + int (*vsmmu_init)(struct arm_vsmmu *vsmmu, > + const struct iommu_user_data *user_data); It would be nice to avoid adding data members to the ops structure, if at all possible. The easiest thing would probably be to add a function for getting the vsmmu size and then pushing the two checks against 'vsmmu_type' down into the impl_ops callbacks so that: 1. If the type is IOMMU_VIOMMU_TYPE_ARM_SMMUV3, we don't bother with the impl_ops at all in arm_vsmmu_init() and arm_smmu_get_viommu_size() 2. Otherwise, we pass the type into the impl_ops and they can check it Of course, that can be a patch on top of the series as there's no point respinning the whole just for this. Cheers, Will