summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolin Chen <nicolinc@nvidia.com>2025-07-09 22:59:15 -0700
committerJason Gunthorpe <jgg@nvidia.com>2025-07-11 14:34:35 -0300
commit61dd912ee02e4d1d412e1090c6e5d7f8cd0779df (patch)
tree3c58b83921f966ca13a4f0be4abae88cf0f10a47
parent3a35f7d4a4673edf6f02422bb2d78b17c667e167 (diff)
iommu/arm-smmu-v3-iommufd: Add vsmmu_size/type and vsmmu_init impl ops
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(). Link: https://patch.msgid.link/r/375ac2b056764534bb7c10ecc4f34a0bae82b108.1752126748.git.nicolinc@nvidia.com Reviewed-by: Pranjal Shrivastava <praan@google.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
-rw-r--r--drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c8
-rw-r--r--drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h5
2 files changed, 13 insertions, 0 deletions
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 eb9fe1f6311a..2ab1c6cf4aac 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
@@ -416,6 +416,10 @@ size_t arm_smmu_get_viommu_size(struct device *dev,
!(smmu->features & ARM_SMMU_FEAT_S2FWB))
return 0;
+ if (smmu->impl_ops && smmu->impl_ops->vsmmu_size &&
+ viommu_type == smmu->impl_ops->vsmmu_type)
+ return smmu->impl_ops->vsmmu_size;
+
if (viommu_type != IOMMU_VIOMMU_TYPE_ARM_SMMUV3)
return 0;
@@ -439,6 +443,10 @@ int arm_vsmmu_init(struct iommufd_viommu *viommu,
/* FIXME Move VMID allocation from the S2 domain allocation to here */
vsmmu->vmid = s2_parent->s2_cfg.vmid;
+ if (smmu->impl_ops && smmu->impl_ops->vsmmu_init &&
+ viommu->type == smmu->impl_ops->vsmmu_type)
+ return smmu->impl_ops->vsmmu_init(vsmmu, user_data);
+
viommu->ops = &arm_vsmmu_ops;
return 0;
}
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);
};
/* An SMMUv3 instance */