public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	Lu Baolu <baolu.lu@linux.intel.com>,
	Joerg Roedel <joro@8bytes.org>,
	Jean-Philippe Brucker <jean-philippe@linaro.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Will Deacon <will@kernel.org>,
	David Woodhouse <dwmw2@infradead.org>,
	"Raj, Ashok" <ashok.raj@intel.com>,
	"Liu, Yi L" <yi.l.liu@intel.com>
Subject: Re: [PATCH v2 2/3] iommu/sva: Stop using ioasid_set for SVA
Date: Wed, 15 Feb 2023 14:46:43 -0400	[thread overview]
Message-ID: <Y+0okzkbTh6mw0EM@nvidia.com> (raw)
In-Reply-To: <20230215103822.6235ada9@jacob-builder>

On Wed, Feb 15, 2023 at 10:38:22AM -0800, Jacob Pan wrote:
> Hi Kevin,
> 
> On Wed, 15 Feb 2023 03:24:18 +0000, "Tian, Kevin" <kevin.tian@intel.com>
> wrote:
> 
> > > From: Jacob Pan <jacob.jun.pan@linux.intel.com>
> > > Sent: Tuesday, February 14, 2023 2:44 PM
> > > 
> > > From: Jason Gunthorpe <jgg@nvidia.com>
> > > 
> > > Instead SVA drivers can use a simple global IDA to allocate PASIDs for
> > > each mm_struct.
> > > 
> > > Future work would be to allow drivers using the SVA APIs to reserve
> > > global PASIDs from this IDA for their internal use, eg with the DMA API
> > > PASID support.  
> > 
> > I think DMA API PASID will need new API around this IDA. SVA APIs should
> > be just for SVA.
> > 
> > > +void mm_pasid_drop(struct mm_struct *mm)
> > >  {
> > > -	return mmget_not_zero(mm);
> > > -}
> > > +	pr_alert("%s %d", __func__, mm->pasid);
> > > +	if (likely(!pasid_valid(mm->pasid)))
> > > +		return;
> > > 
> > > -/**
> > > - * iommu_sva_find() - Find mm associated to the given PASID
> > > - * @pasid: Process Address Space ID assigned to the mm
> > > - *
> > > - * On success a reference to the mm is taken, and must be released with
> > > mmput().
> > > - *
> > > - * Returns the mm corresponding to this PASID, or an error if not
> > > found.
> > > - */
> > > -struct mm_struct *iommu_sva_find(ioasid_t pasid)
> > > -{
> > > -	return ioasid_find(&iommu_sva_pasid, pasid, __mmget_not_zero);
> > > +	ida_free(&iommu_global_pasid_ida, mm->pasid);
> > >  }  
> > 
> > when moving this function following line is missed:
> > 
> > 	mm->pasid = INVALID_IOASID;
> > 
> not needed, mm is gone by now.
> 
> > btw the current placement looks asymmetric. We now have
> > mm_pasid_init() and mm_pasid_set() in mm.h while mm_pasid_drop()
> > in iommu-sva.c.
> > Is it cleaner to introduce a iommu_sva_free_pasid() helper and then
> > call it from mm_pasid_drop() in mm.h?
> That is what we had before, it seems logical to me. Jason?

I don't much like a maze of functions calling each other.

Renaming the helper might help, especially if it comes from iommu.h

Jason

  reply	other threads:[~2023-02-15 18:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14  6:44 [PATCH v2 0/3] Remove VT-d virtual command interface and IOASID Jacob Pan
2023-02-14  6:44 ` [PATCH v2 1/3] iommu/vt-d: Remove virtual command interface Jacob Pan
2023-02-14 11:26   ` Baolu Lu
2023-02-14  6:44 ` [PATCH v2 2/3] iommu/sva: Stop using ioasid_set for SVA Jacob Pan
2023-02-14  9:39   ` Jean-Philippe Brucker
2023-02-15 21:36     ` Jacob Pan
2023-02-24 17:44       ` Jean-Philippe Brucker
2023-02-15  3:24   ` Tian, Kevin
2023-02-15 18:38     ` Jacob Pan
2023-02-15 18:46       ` Jason Gunthorpe [this message]
2023-02-14  6:44 ` [PATCH v2 3/3] iommu: Remove ioasid infrastructure Jacob Pan
2023-02-14  9:32   ` Jean-Philippe Brucker
2023-02-14 13:06     ` Jason Gunthorpe
2023-02-14 17:31       ` Jacob Pan
2023-02-14 17:57         ` Jason Gunthorpe
2023-02-14 21:33           ` Jacob Pan
2023-02-15 12:49             ` Jason Gunthorpe
2023-02-14 17:04     ` Jacob Pan
2023-02-15  3:27       ` Tian, Kevin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y+0okzkbTh6mw0EM@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=ashok.raj@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux.dev \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=jean-philippe@linaro.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    --cc=yi.l.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox