Skip to content

Commit 874b87c

Browse files
jgunthorpewilldeacon
authored andcommitted
iommu/arm-smmu-v3: Implement IOMMU_HWPT_ALLOC_NEST_PARENT
For SMMUv3 the parent must be a S2 domain, which can be composed into a IOMMU_DOMAIN_NESTED. In future the S2 parent will also need a VMID linked to the VIOMMU and even to KVM. Reviewed-by: Nicolin Chen <nicolinc@nvidia.com> Tested-by: Nicolin Chen <nicolinc@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> Reviewed-by: Mostafa Saleh <smostafa@google.com> Reviewed-by: Donald Dutile <ddutile@redhat.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/6-v4-9e99b76f3518+3a8-smmuv3_nesting_jgg@nvidia.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 6912ec9 commit 874b87c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3114,7 +3114,8 @@ arm_smmu_domain_alloc_user(struct device *dev, u32 flags,
31143114
const struct iommu_user_data *user_data)
31153115
{
31163116
struct arm_smmu_master *master = dev_iommu_priv_get(dev);
3117-
const u32 PAGING_FLAGS = IOMMU_HWPT_ALLOC_DIRTY_TRACKING;
3117+
const u32 PAGING_FLAGS = IOMMU_HWPT_ALLOC_DIRTY_TRACKING |
3118+
IOMMU_HWPT_ALLOC_NEST_PARENT;
31183119
struct arm_smmu_domain *smmu_domain;
31193120
int ret;
31203121

@@ -3127,6 +3128,14 @@ arm_smmu_domain_alloc_user(struct device *dev, u32 flags,
31273128
if (IS_ERR(smmu_domain))
31283129
return ERR_CAST(smmu_domain);
31293130

3131+
if (flags & IOMMU_HWPT_ALLOC_NEST_PARENT) {
3132+
if (!(master->smmu->features & ARM_SMMU_FEAT_NESTING)) {
3133+
ret = -EOPNOTSUPP;
3134+
goto err_free;
3135+
}
3136+
smmu_domain->stage = ARM_SMMU_DOMAIN_S2;
3137+
}
3138+
31303139
smmu_domain->domain.type = IOMMU_DOMAIN_UNMANAGED;
31313140
smmu_domain->domain.ops = arm_smmu_ops.default_domain_ops;
31323141
ret = arm_smmu_domain_finalise(smmu_domain, master->smmu, flags);

0 commit comments

Comments
 (0)