Message ID | 20230818021629.RFC.v1.6.I65dd382de382428dcb3cf61342b35405903ac768@changeid (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Install domain onto multiple smmus | expand |
On Fri, Aug 18, 2023 at 02:16:28AM +0800, Michael Shavit wrote: > This will allow installing a domain onto multiple smmu devices. > > Signed-off-by: Michael Shavit <mshavit@google.com> > --- > > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) The VMID is basically a different ASID, eg ASID is the cahage tag for a S1 and VMID is the cache tag for S2. It is strange that it has a different lifecycle. It seems like the issue is that the VMID IDA is per smmu while the ASID xarray is global? So, I'd suggest consistency. Either the domain ASID/VMID is global and assigned at allocation time. Or it is local to the instance, assigned at bind time, and stored in the domain's attached device list. Some logic is needed to optimize this - probably keep the instance list sorted by instance. Having per-instance cache-tags avoids the limit problem a prior patch was struggling with, at the cost of some more complexity in other places. 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 208fec5fba462..7f88b2b19cbe5 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2112,7 +2112,6 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type) static void arm_smmu_domain_free(struct iommu_domain *domain) { struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); - struct arm_smmu_device *smmu = smmu_domain->smmu; free_io_pgtable_ops(smmu_domain->pgtbl_ops); @@ -2122,10 +2121,6 @@ static void arm_smmu_domain_free(struct iommu_domain *domain) mutex_lock(&arm_smmu_asid_lock); arm_smmu_free_asid(&smmu_domain->cd); mutex_unlock(&arm_smmu_asid_lock); - } else { - struct arm_smmu_s2_cfg *cfg = &smmu_domain->s2_cfg; - if (cfg->vmid) - ida_free(&smmu->vmid_map, cfg->vmid); } kfree(smmu_domain); @@ -2484,6 +2479,14 @@ static void arm_smmu_installed_smmus_remove_device( continue; list_del(&master->list); if (list_empty(&installed_smmu->devices)) { + if (smmu_domain->stage == ARM_SMMU_DOMAIN_S2) { + struct arm_smmu_s2_cfg *cfg = + &smmu_domain->s2_cfg; + + if (cfg->vmid) + ida_free(&smmu->vmid_map, + cfg->vmid); + } list_del(&installed_smmu->list); kfree(installed_smmu); }
This will allow installing a domain onto multiple smmu devices. Signed-off-by: Michael Shavit <mshavit@google.com> --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)