Skip to content

Commit 49db2ed

Browse files
jgunthorpewilldeacon
authored andcommitted
iommu/arm-smmu-v3: Keep track of arm_smmu_master_domain for SVA
Fill in the smmu_domain->devices list in the new struct arm_smmu_domain that SVA allocates. Keep track of every SSID and master that is using the domain reusing the logic for the RID attach. This is the first step to making the SVA invalidation follow the same design as S1/S2 invalidation. At present nothing will read this list. Tested-by: Nicolin Chen <[email protected]> Tested-by: Shameer Kolothum <[email protected]> Reviewed-by: Nicolin Chen <[email protected]> Reviewed-by: Jerry Snitselaar <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent d7b2d2b commit 49db2ed

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,7 +2587,8 @@ to_smmu_domain_devices(struct iommu_domain *domain)
25872587
/* The domain can be NULL only when processing the first attach */
25882588
if (!domain)
25892589
return NULL;
2590-
if (domain->type & __IOMMU_DOMAIN_PAGING)
2590+
if ((domain->type & __IOMMU_DOMAIN_PAGING) ||
2591+
domain->type == IOMMU_DOMAIN_SVA)
25912592
return to_smmu_domain(domain);
25922593
return NULL;
25932594
}
@@ -2820,7 +2821,16 @@ int arm_smmu_set_pasid(struct arm_smmu_master *master,
28202821
struct arm_smmu_domain *smmu_domain, ioasid_t pasid,
28212822
const struct arm_smmu_cd *cd)
28222823
{
2824+
struct arm_smmu_attach_state state = {
2825+
.master = master,
2826+
/*
2827+
* For now the core code prevents calling this when a domain is
2828+
* already attached, no need to set old_domain.
2829+
*/
2830+
.ssid = pasid,
2831+
};
28232832
struct arm_smmu_cd *cdptr;
2833+
int ret;
28242834

28252835
/* The core code validates pasid */
28262836

@@ -2830,14 +2840,30 @@ int arm_smmu_set_pasid(struct arm_smmu_master *master,
28302840
cdptr = arm_smmu_alloc_cd_ptr(master, pasid);
28312841
if (!cdptr)
28322842
return -ENOMEM;
2843+
2844+
mutex_lock(&arm_smmu_asid_lock);
2845+
ret = arm_smmu_attach_prepare(&state, &smmu_domain->domain);
2846+
if (ret)
2847+
goto out_unlock;
2848+
28332849
arm_smmu_write_cd_entry(master, pasid, cdptr, cd);
2834-
return 0;
2850+
2851+
arm_smmu_attach_commit(&state);
2852+
2853+
out_unlock:
2854+
mutex_unlock(&arm_smmu_asid_lock);
2855+
return ret;
28352856
}
28362857

28372858
void arm_smmu_remove_pasid(struct arm_smmu_master *master,
28382859
struct arm_smmu_domain *smmu_domain, ioasid_t pasid)
28392860
{
2861+
mutex_lock(&arm_smmu_asid_lock);
28402862
arm_smmu_clear_cd(master, pasid);
2863+
if (master->ats_enabled)
2864+
arm_smmu_atc_inv_master(master, pasid);
2865+
arm_smmu_remove_master_domain(master, &smmu_domain->domain, pasid);
2866+
mutex_unlock(&arm_smmu_asid_lock);
28412867
}
28422868

28432869
static int arm_smmu_attach_dev_ste(struct iommu_domain *domain,

0 commit comments

Comments
 (0)