Skip to content

Commit 61dd912

Browse files
nicolincjgunthorpe
authored andcommitted
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>
1 parent 3a35f7d commit 61dd912

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ size_t arm_smmu_get_viommu_size(struct device *dev,
416416
!(smmu->features & ARM_SMMU_FEAT_S2FWB))
417417
return 0;
418418

419+
if (smmu->impl_ops && smmu->impl_ops->vsmmu_size &&
420+
viommu_type == smmu->impl_ops->vsmmu_type)
421+
return smmu->impl_ops->vsmmu_size;
422+
419423
if (viommu_type != IOMMU_VIOMMU_TYPE_ARM_SMMUV3)
420424
return 0;
421425

@@ -439,6 +443,10 @@ int arm_vsmmu_init(struct iommufd_viommu *viommu,
439443
/* FIXME Move VMID allocation from the S2 domain allocation to here */
440444
vsmmu->vmid = s2_parent->s2_cfg.vmid;
441445

446+
if (smmu->impl_ops && smmu->impl_ops->vsmmu_init &&
447+
viommu->type == smmu->impl_ops->vsmmu_type)
448+
return smmu->impl_ops->vsmmu_init(vsmmu, user_data);
449+
442450
viommu->ops = &arm_vsmmu_ops;
443451
return 0;
444452
}

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/sizes.h>
1717

1818
struct arm_smmu_device;
19+
struct arm_vsmmu;
1920

2021
/* MMIO registers */
2122
#define ARM_SMMU_IDR0 0x0
@@ -720,6 +721,10 @@ struct arm_smmu_impl_ops {
720721
int (*init_structures)(struct arm_smmu_device *smmu);
721722
struct arm_smmu_cmdq *(*get_secondary_cmdq)(
722723
struct arm_smmu_device *smmu, struct arm_smmu_cmdq_ent *ent);
724+
const size_t vsmmu_size;
725+
const enum iommu_viommu_type vsmmu_type;
726+
int (*vsmmu_init)(struct arm_vsmmu *vsmmu,
727+
const struct iommu_user_data *user_data);
723728
};
724729

725730
/* An SMMUv3 instance */

0 commit comments

Comments
 (0)