[PATCH RESEND v9 09/13] iommu/arm-smmu-v3: Seize private ASID
Jean-Philippe Brucker
jean-philippe at linaro.org
Thu Sep 17 10:38:46 EDT 2020
On Mon, Sep 07, 2020 at 06:41:11PM +0200, Auger Eric wrote:
> > +/*
> > + * Try to reserve this ASID in the SMMU. If it is in use, try to steal it from
> > + * the private entry. Careful here, we may be modifying the context tables of
> > + * another SMMU!
> Not sure I got what you meant by this comment.
That comment does need refreshing:
/*
* Check if the CPU ASID is available on the SMMU side. If a private context
* descriptor is using it, try to replace it.
*/
> > + */
> > static struct arm_smmu_ctx_desc *
> > arm_smmu_share_asid(struct mm_struct *mm, u16 asid)
> > {
> > + int ret;
> > + u32 new_asid;
> > struct arm_smmu_ctx_desc *cd;
> > + struct arm_smmu_device *smmu;
> > + struct arm_smmu_domain *smmu_domain;
> >
> > cd = xa_load(&arm_smmu_asid_xa, asid);
> > if (!cd)
> > @@ -27,8 +36,31 @@ arm_smmu_share_asid(struct mm_struct *mm, u16 asid)
> > return cd;
> > }
> >
> > - /* Ouch, ASID is already in use for a private cd. */
> > - return ERR_PTR(-EBUSY);
> > + smmu_domain = container_of(cd, struct arm_smmu_domain, s1_cfg.cd);
> > + smmu = smmu_domain->smmu;
> > +
> > + ret = xa_alloc(&arm_smmu_asid_xa, &new_asid, cd,
> > + XA_LIMIT(1, 1 << smmu->asid_bits), GFP_KERNEL);
> XA_LIMIT(1, (1 << smmu->asid_bits) - 1), GFP_KERNEL)
Good catch
Thanks,
Jean
More information about the linux-arm-kernel
mailing list