]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/arm-smmu-v3-iommufd: Add hw_info to impl_ops
authorNicolin Chen <nicolinc@nvidia.com>
Thu, 10 Jul 2025 05:59:16 +0000 (22:59 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 11 Jul 2025 17:34:35 +0000 (14:34 -0300)
This will be used by Tegra241 CMDQV implementation to report a non-default
HW info data.

Link: https://patch.msgid.link/r/8a3bf5709358eb21aed2e8434534c30ecf83917c.1752126748.git.nicolinc@nvidia.com
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h

index 2ab1c6cf4aac37951c3a2b178d7e1daa8a01f27b..1cf9646e776f8c0fb90d68dcd70977bb5289f698 100644 (file)
@@ -11,13 +11,17 @@ void *arm_smmu_hw_info(struct device *dev, u32 *length,
                       enum iommu_hw_info_type *type)
 {
        struct arm_smmu_master *master = dev_iommu_priv_get(dev);
+       const struct arm_smmu_impl_ops *impl_ops = master->smmu->impl_ops;
        struct iommu_hw_info_arm_smmuv3 *info;
        u32 __iomem *base_idr;
        unsigned int i;
 
        if (*type != IOMMU_HW_INFO_TYPE_DEFAULT &&
-           *type != IOMMU_HW_INFO_TYPE_ARM_SMMUV3)
-               return ERR_PTR(-EOPNOTSUPP);
+           *type != IOMMU_HW_INFO_TYPE_ARM_SMMUV3) {
+               if (!impl_ops || !impl_ops->hw_info)
+                       return ERR_PTR(-EOPNOTSUPP);
+               return impl_ops->hw_info(master->smmu, length, type);
+       }
 
        info = kzalloc(sizeof(*info), GFP_KERNEL);
        if (!info)
index 6183f212539acec0999f28bb9d0844eaa377873d..b7c7fdef531e49f2539d66437cbcaf6959f9f031 100644 (file)
@@ -721,6 +721,13 @@ 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);
+       /*
+        * An implementation should define its own type other than the default
+        * IOMMU_HW_INFO_TYPE_ARM_SMMUV3. And it must validate the input @type
+        * to return its own structure.
+        */
+       void *(*hw_info)(struct arm_smmu_device *smmu, u32 *length,
+                        enum iommu_hw_info_type *type);
        const size_t vsmmu_size;
        const enum iommu_viommu_type vsmmu_type;
        int (*vsmmu_init)(struct arm_vsmmu *vsmmu,