Re: [PATCH v2 2/5] iommu: Introduce mm_get_pasid() helper function

From: Jason Gunthorpe
Date: Thu Aug 31 2023 - 13:01:57 EST


On Thu, Aug 31, 2023 at 10:24:31AM +0800, Baolu Lu wrote:
> On 2023/8/27 16:43, Tina Zhang wrote:
> > Use the helper function mm_get_pasid() to get a mm assigned pasid
> > value. The motivation is to replace mm->pasid with an iommu private
> > data structure that is introduced in a later patch.
> >
> > v2:
> > - Update commit message
> > - Let mm_get_enqcmd_pasid() call mm_get_pasid() to get pasid
>
> Ditto.
>
> > Signed-off-by: Tina Zhang<tina.zhang@xxxxxxxxx>
> > ---
> > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 12 ++++++------
> > drivers/iommu/intel/svm.c | 8 ++++----
> > drivers/iommu/iommu-sva.c | 14 +++++++-------
> > include/linux/iommu.h | 10 +++++++++-
> > 4 files changed, 26 insertions(+), 18 deletions(-)
>
> Eventually perhaps we should have something like sva_domain_get_pasid().

There is never just a single PASID for a domain. That should not be
part of any of our APIs.

If we want to provide core code aide then the core code should have a
means to help the drvier maintain the attachment database for the
domain.

Eg maintain the list of RIDs, PASIDs, etc that the domain is linked
to.

But this is such trivial code I'm not sure it helps much

> Finally the iommu drivers only need mm->pgd, nothing else.

Yes, attaching the notifier and accessing the arch specific mm->pgd
should be the only driver touches of the mm_struct..

Jason