[PATCH 15/19] iommu/arm-smmu-v3: Add a global static IDENTITY domain

Jason Gunthorpe jgg at nvidia.com
Wed Oct 18 05:26:23 PDT 2023


On Wed, Oct 18, 2023 at 07:06:55PM +0800, Michael Shavit wrote:
> On Wed, Oct 11, 2023 at 8:33 AM Jason Gunthorpe <jgg at nvidia.com> wrote:
> >
> > Move to the new static global for identity domains. Move all the logic out
> > of arm_smmu_attach_dev into an identity only function.
> >
> > Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>
> > ---
> >  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 82 +++++++++++++++------
> >  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h |  1 -
> >  2 files changed, 58 insertions(+), 25 deletions(-)
> >
> > 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 26d3200c127450..1e03bdedfabad1 100644
> > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > @@ -2149,8 +2149,7 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type)
> >                 return arm_smmu_sva_domain_alloc();
> >
> >         if (type != IOMMU_DOMAIN_UNMANAGED &&
> > -           type != IOMMU_DOMAIN_DMA &&
> > -           type != IOMMU_DOMAIN_IDENTITY)
> > +           type != IOMMU_DOMAIN_DMA)
> >                 return NULL;
> >
> >         /*
> > @@ -2258,11 +2257,6 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain)
> >         struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
> >         struct arm_smmu_device *smmu = smmu_domain->smmu;
> >
> > -       if (domain->type == IOMMU_DOMAIN_IDENTITY) {
> > -               smmu_domain->stage = ARM_SMMU_DOMAIN_BYPASS;
> > -               return 0;
> > -       }
> > -
> >         /* Restrict the stage to what we can actually support */
> >         if (!(smmu->features & ARM_SMMU_FEAT_TRANS_S1))
> >                 smmu_domain->stage = ARM_SMMU_DOMAIN_S2;
> > @@ -2459,7 +2453,7 @@ static void arm_smmu_detach_dev(struct arm_smmu_master *master)
> >         struct arm_smmu_domain *smmu_domain;
> >         unsigned long flags;
> >
> > -       if (!domain)
> > +       if (!domain || !(domain->type & __IOMMU_DOMAIN_PAGING))
> >                 return;
> 
> Confused me why we were checking against __IOMMU_DOMAIN_PAGING instead
>  of IOMMU_DOMAIN_UNMANAGED/DMA to match domain_alloc, but ok it's
> clarified by the final patch in the series.

Long term I am trying to remove DMA/UNMANAGED from the drivers (we are
actually getting quite close!). A domain created by
domain_alloc_paging (later patch) should be tested like this.

Jason



More information about the linux-arm-kernel mailing list