Message ID | 19-v2-16665a652079+5947-smmuv3_newapi_p2_jgg@nvidia.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Update SMMUv3 to the modern iommu API (part 2/3) | expand |
On Wed, Nov 01, 2023 at 08:36:37PM -0300, Jason Gunthorpe wrote: > Currently the smmu_domain->devices list is unused for SVA domains. > Fill it in with the SSID and master of every arm_smmu_set_pasid() > using the same logic as the RID attach. > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > index 326c82fad90b8a..23bcdf1630c23e 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > @@ -2712,6 +2712,8 @@ int arm_smmu_set_pasid(struct arm_smmu_master *master, > struct arm_smmu_domain *sid_smmu_domain = > to_smmu_domain_safe(iommu_get_domain_for_dev(master->dev)); > struct arm_smmu_cd *cdptr; > + struct attach_state state; > + int ret; > > if (!sid_smmu_domain || sid_smmu_domain->stage != ARM_SMMU_DOMAIN_S1) > return -ENODEV; > @@ -2719,14 +2721,30 @@ int arm_smmu_set_pasid(struct arm_smmu_master *master, > cdptr = arm_smmu_get_cd_ptr(master, pasid); > if (!cdptr) > return -ENOMEM; > + > + mutex_lock(&arm_smmu_asid_lock); > + ret = arm_smmu_attach_prepare(master, smmu_domain, pasid, &state); > + if (ret) > + goto out_unlock; > + > arm_smmu_write_cd_entry(master, pasid, cdptr, cd); > + > + arm_smmu_attach_commit(master, pasid, &state); > + > +out_unlock: > + mutex_unlock(&arm_smmu_asid_lock); > return 0; > } This should be 'return ret' Jason
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 326c82fad90b8a..23bcdf1630c23e 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2712,6 +2712,8 @@ int arm_smmu_set_pasid(struct arm_smmu_master *master, struct arm_smmu_domain *sid_smmu_domain = to_smmu_domain_safe(iommu_get_domain_for_dev(master->dev)); struct arm_smmu_cd *cdptr; + struct attach_state state; + int ret; if (!sid_smmu_domain || sid_smmu_domain->stage != ARM_SMMU_DOMAIN_S1) return -ENODEV; @@ -2719,14 +2721,30 @@ int arm_smmu_set_pasid(struct arm_smmu_master *master, cdptr = arm_smmu_get_cd_ptr(master, pasid); if (!cdptr) return -ENOMEM; + + mutex_lock(&arm_smmu_asid_lock); + ret = arm_smmu_attach_prepare(master, smmu_domain, pasid, &state); + if (ret) + goto out_unlock; + arm_smmu_write_cd_entry(master, pasid, cdptr, cd); + + arm_smmu_attach_commit(master, pasid, &state); + +out_unlock: + mutex_unlock(&arm_smmu_asid_lock); return 0; } void arm_smmu_remove_pasid(struct arm_smmu_master *master, struct arm_smmu_domain *smmu_domain, ioasid_t pasid) { + mutex_lock(&arm_smmu_asid_lock); arm_smmu_clear_cd(master, pasid); + if (master->ats_enabled) + arm_smmu_atc_inv_master(master, pasid); + arm_smmu_remove_master_domain(master, smmu_domain, pasid); + mutex_unlock(&arm_smmu_asid_lock); } static int arm_smmu_attach_dev_ste(struct device *dev,
Currently the smmu_domain->devices list is unused for SVA domains. Fill it in with the SSID and master of every arm_smmu_set_pasid() using the same logic as the RID attach. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)