[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230302085441.15a4c523@jacob-builder>
Date: Thu, 2 Mar 2023 08:54:41 -0800
From: Jacob Pan <jacob.jun.pan@...ux.intel.com>
To: Baolu Lu <baolu.lu@...ux.intel.com>
Cc: LKML <linux-kernel@...r.kernel.org>, iommu@...ts.linux.dev,
Jason Gunthorpe <jgg@...dia.com>,
Joerg Roedel <joro@...tes.org>,
Jean-Philippe Brucker <jean-philippe@...aro.com>,
Dave Hansen <dave.hansen@...el.com>,
Thomas Gleixner <tglx@...utronix.de>,
X86 Kernel <x86@...nel.org>, bp@...en8.de,
"H. Peter Anvin" <hpa@...or.com>,
Peter Zijlstra <peterz@...radead.org>, corbet@....net,
vkoul@...nel.org, dmaengine@...r.kernel.org,
linux-doc@...r.kernel.org, Robin Murphy <robin.murphy@....com>,
Will Deacon <will@...nel.org>,
David Woodhouse <dwmw2@...radead.org>,
Raj Ashok <ashok.raj@...el.com>,
"Tian, Kevin" <kevin.tian@...el.com>, Yi Liu <yi.l.liu@...el.com>,
"Yu, Fenghua" <fenghua.yu@...el.com>,
Dave Jiang <dave.jiang@...el.com>,
Kirill Shutemov <kirill.shutemov@...ux.intel.com>,
jacob.jun.pan@...ux.intel.com
Subject: Re: [PATCH v4 2/6] iommu/sva: Move PASID helpers to sva code
Hi Baolu,
On Thu, 2 Mar 2023 20:21:33 +0800, Baolu Lu <baolu.lu@...ux.intel.com>
wrote:
> On 2023/3/2 7:56, Jacob Pan wrote:
> > Preparing to remove IOASID infrastructure, PASID management will be
> > under SVA code. Decouple mm code from IOASID. Use iommu-help.h instead
> > of iommu.h to prevent circular inclusion.
> >
> > Signed-off-by: Jacob Pan <jacob.jun.pan@...ux.intel.com>
> > ---
> > v4: (Jason's comments)
> > - delete and open code mm_set_pasid
> > - keep mm_init_pasid() as inline for fork performance
> > ---
> > drivers/iommu/iommu-sva.c | 10 +++++++++-
> > include/linux/ioasid.h | 2 +-
> > include/linux/iommu-helper.h | 1 +
> > include/linux/sched/mm.h | 18 ++----------------
> > 4 files changed, 13 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c
> > index 24bf9b2b58aa..376b2a9e2543 100644
> > --- a/drivers/iommu/iommu-sva.c
> > +++ b/drivers/iommu/iommu-sva.c
> > @@ -44,7 +44,7 @@ int iommu_sva_alloc_pasid(struct mm_struct *mm,
> > ioasid_t min, ioasid_t max) if (!pasid_valid(pasid))
> > ret = -ENOMEM;
> > else
> > - mm_pasid_set(mm, pasid);
> > + mm->pasid = ret;
>
> This seems obviously incorrect.
>
> mm->pasid = pasid;
>
you are right, it got messed up while partitioning. the final was correct.
>
> > out:
> > mutex_unlock(&iommu_sva_lock);
> > return ret;
> > @@ -238,3 +238,11 @@ iommu_sva_handle_iopf(struct iommu_fault *fault,
> > void *data)
> > return status;
> > }
> > +
> > +void mm_pasid_drop(struct mm_struct *mm)
> > +{
> > + if (pasid_valid(mm->pasid)) {
> > + ioasid_free(mm->pasid);
> > + mm->pasid = INVALID_IOASID;
> > + }
> > +}
> > diff --git a/include/linux/ioasid.h b/include/linux/ioasid.h
> > index af1c9d62e642..2c502e77ee78 100644
> > --- a/include/linux/ioasid.h
> > +++ b/include/linux/ioasid.h
> > @@ -4,8 +4,8 @@
> >
> > #include <linux/types.h>
> > #include <linux/errno.h>
> > +#include <linux/iommu-helper.h>
> >
> > -#define INVALID_IOASID ((ioasid_t)-1)
> > typedef unsigned int ioasid_t;
> > typedef ioasid_t (*ioasid_alloc_fn_t)(ioasid_t min, ioasid_t max,
> > void *data); typedef void (*ioasid_free_fn_t)(ioasid_t ioasid, void
> > *data); diff --git a/include/linux/iommu-helper.h
> > b/include/linux/iommu-helper.h index 74be34f3a20a..0aa922f6bfad 100644
> > --- a/include/linux/iommu-helper.h
> > +++ b/include/linux/iommu-helper.h
> > @@ -40,5 +40,6 @@ static inline unsigned long iommu_num_pages(unsigned
> > long addr,
> > return DIV_ROUND_UP(size, io_page_size);
> > }
> > +#define INVALID_IOASID (-1U)
> >
> > #endif
> > diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
> > index 2a243616f222..ae5a3f16b321 100644
> > --- a/include/linux/sched/mm.h
> > +++ b/include/linux/sched/mm.h
> > @@ -8,7 +8,7 @@
> > #include <linux/mm_types.h>
> > #include <linux/gfp.h>
> > #include <linux/sync_core.h>
> > -#include <linux/ioasid.h>
> > +#include <linux/iommu-helper.h>
> >
> > /*
> > * Routines for handling mm_structs
> > @@ -456,23 +456,9 @@ static inline void mm_pasid_init(struct mm_struct
> > *mm) {
> > mm->pasid = INVALID_IOASID;
> > }
> > -
> > -/* Associate a PASID with an mm_struct: */
> > -static inline void mm_pasid_set(struct mm_struct *mm, u32 pasid)
> > -{
> > - mm->pasid = pasid;
> > -}
> > -
> > -static inline void mm_pasid_drop(struct mm_struct *mm)
> > -{
> > - if (pasid_valid(mm->pasid)) {
> > - ioasid_free(mm->pasid);
> > - mm->pasid = INVALID_IOASID;
> > - }
> > -}
> > +void mm_pasid_drop(struct mm_struct *mm);
> > #else
> > static inline void mm_pasid_init(struct mm_struct *mm) {}
> > -static inline void mm_pasid_set(struct mm_struct *mm, u32 pasid) {}
> > static inline void mm_pasid_drop(struct mm_struct *mm) {}
>
> Above mm_pasid_drop() should also be removed.
will do,
Thanks,
Jacob
Powered by blists - more mailing lists