On Fri, Apr 25, 2025 at 10:58:12PM -0700, Nicolin Chen wrote: > Repurpose the @__reserved field in the struct iommu_hw_info_arm_smmuv3, > to an HW implementation-defined field @impl. > > This will be used by Tegra241 CMDQV implementation on top of a standard > ARM SMMUv3 IOMMU. The @impl will be only valid if @flags is set with an > implementation-defined flag. > > Thus in the driver-level, add an hw_info impl op that will return such > a flag to use the impl field. > > Signed-off-by: Nicolin Chen <nicol...@nvidia.com>
Reviewed-by: Pranjal Shrivastava <pr...@google.com> > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 1 + > include/uapi/linux/iommufd.h | 4 ++-- > .../iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 16 +++++++++++++--- > 3 files changed, 16 insertions(+), 5 deletions(-) > > 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 a5835af72417..bab7a9ce1283 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h > @@ -726,6 +726,7 @@ struct arm_smmu_impl_ops { > struct arm_smmu_domain *smmu_domain, struct iommufd_ctx *ictx, > unsigned int viommu_type, > const struct iommu_user_data *user_data); > + u32 (*hw_info)(struct arm_smmu_device *smmu, u32 *impl); > }; > > /* An SMMUv3 instance */ > diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h > index 06a763fda47f..b2614f0f1547 100644 > --- a/include/uapi/linux/iommufd.h > +++ b/include/uapi/linux/iommufd.h > @@ -554,7 +554,7 @@ struct iommu_hw_info_vtd { > * (IOMMU_HW_INFO_TYPE_ARM_SMMUV3) > * > * @flags: Must be set to 0 > - * @__reserved: Must be 0 > + * @impl: Must be 0 > * @idr: Implemented features for ARM SMMU Non-secure programming interface > * @iidr: Information about the implementation and implementer of ARM SMMU, > * and architecture version supported > @@ -585,7 +585,7 @@ struct iommu_hw_info_vtd { > */ > struct iommu_hw_info_arm_smmuv3 { > __u32 flags; > - __u32 __reserved; > + __u32 impl; > __u32 idr[6]; > __u32 iidr; > __u32 aidr; > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c > b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c > index a8a78131702d..63861c60b615 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c > @@ -10,7 +10,9 @@ > void *arm_smmu_hw_info(struct device *dev, u32 *length, u32 *type) > { > struct arm_smmu_master *master = dev_iommu_priv_get(dev); > + struct arm_smmu_device *smmu = master->smmu; > struct iommu_hw_info_arm_smmuv3 *info; > + u32 flags = 0, impl = 0; > u32 __iomem *base_idr; > unsigned int i; > > @@ -18,15 +20,23 @@ void *arm_smmu_hw_info(struct device *dev, u32 *length, > u32 *type) > if (!info) > return ERR_PTR(-ENOMEM); > > - base_idr = master->smmu->base + ARM_SMMU_IDR0; > + base_idr = smmu->base + ARM_SMMU_IDR0; > for (i = 0; i <= 5; i++) > info->idr[i] = readl_relaxed(base_idr + i); > - info->iidr = readl_relaxed(master->smmu->base + ARM_SMMU_IIDR); > - info->aidr = readl_relaxed(master->smmu->base + ARM_SMMU_AIDR); > + info->iidr = readl_relaxed(smmu->base + ARM_SMMU_IIDR); > + info->aidr = readl_relaxed(smmu->base + ARM_SMMU_AIDR); > > *length = sizeof(*info); > *type = IOMMU_HW_INFO_TYPE_ARM_SMMUV3; > > + if (smmu->impl_ops && smmu->impl_ops->hw_info) { > + flags = smmu->impl_ops->hw_info(smmu, &impl); > + if (flags) { > + info->impl = impl; > + info->flags |= flags; > + } > + } > + > return info; > } > > -- > 2.43.0 >