Linux IOMMU Development
 help / color / mirror / Atom feed
From: Baolu Lu <baolu.lu@linux.intel.com>
To: Jason Gunthorpe <jgg@nvidia.com>, "Tian, Kevin" <kevin.tian@intel.com>
Cc: baolu.lu@linux.intel.com,
	Jacob Pan <jacob.jun.pan@linux.intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	Joerg Roedel <joro@8bytes.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Jean-Philippe Brucker <jean-philippe@linaro.com>,
	"dmaengine@vger.kernel.org" <dmaengine@vger.kernel.org>,
	"vkoul@kernel.org" <vkoul@kernel.org>,
	Will Deacon <will@kernel.org>,
	David Woodhouse <dwmw2@infradead.org>,
	"Raj, Ashok" <ashok.raj@intel.com>,
	"Liu, Yi L" <yi.l.liu@intel.com>,
	"Yu, Fenghua" <fenghua.yu@intel.com>,
	"Jiang, Dave" <dave.jiang@intel.com>,
	"Luck, Tony" <tony.luck@intel.com>,
	"Zanussi, Tom" <tom.zanussi@intel.com>,
	"Ranganathan, Narayan" <narayan.ranganathan@intel.com>
Subject: Re: [PATCH v7 3/4] iommu/vt-d: Add set_dev_pasid callback for dma domain
Date: Wed, 31 May 2023 12:59:44 +0800	[thread overview]
Message-ID: <c5a1a51d-b309-4237-b2c5-fbdaa1f4f9a8@linux.intel.com> (raw)
In-Reply-To: <ZHYtkioNR2YfC18C@nvidia.com>

On 5/31/23 1:08 AM, Jason Gunthorpe wrote:
>>> +	/*
>>> +	 * The SVA implementation needs to stop mm notification, drain the
>>> +	 * pending page fault requests before tearing down the pasid entry.
>>> +	 * The VT-d spec (section 6.2.3.1) also recommends that software
>>> +	 * could use a reserved domain id for all first-only and pass-through
>>> +	 * translations. Hence there's no need to call
>>> domain_detach_iommu()
>>> +	 * in the sva domain case.
>>> +	 */
>>
>> It's probably clearer to say:
> 
> Is this what is going on ??
> 
>> /*
>>   * SVA domain requires special treatment before tearing down the pasid
>>   * entry:
>>   *   1) pasid is stored in mm instead of in dev_pasid;
> 
> Why? The mm pasid should not be used by any driver code, the PASID the
> SVA is hooked to does NOT have to be the mm PASID.

Yes. The individual driver should not be aware of mm->pasid. The
set/remove_dev_pasid callbacks have already take pasid as the inputs.

> 
>>   *   2) all SVA domains share a reserved domain id per recommendation
>>   *      from VT-d spec (section 6.2.3.1) so domain_detach_iommu() is
>>   *      not required;
> 
> The DID should be managed and allocated for the S2 pointer and the
> flushing logic should work genericly by tracking the S2's being used
> and flushing their DIDs when all the S2s fall out of use. The special
> identity S2 just gets a static DID that never falls out of use.

The DID logic in this case is not about invalidating the DID. Instead,
it is about managing the DID's reference count to track its allocation
and release. The reference count is increased every time the DID is
assigned to hardware, and it is decreased when the DID is removed from
hardware. The DID is released when the count hits 0.

Some DIDs are reserved for special domains, like identity domain, SVA
domain, etc. For those DIDs, there's no need for reference count, hence
no need to call the helper.

For code simplify, perhaps we can enhance the helpers to take no action
for those special DIDs.

Best regards,
baolu

  reply	other threads:[~2023-05-31  5:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23 17:34 [PATCH v7 0/4] Re-enable IDXD kernel workqueue under DMA API Jacob Pan
2023-05-23 17:34 ` [PATCH v7 1/4] iommu: Generalize PASID 0 for normal DMA w/o PASID Jacob Pan
2023-05-25  6:25   ` Tian, Kevin
2023-06-01  4:31   ` Jacob Pan
2023-06-01  9:26   ` Jean-Philippe Brucker
2023-06-01 14:21     ` Jacob Pan
2023-05-23 17:34 ` [PATCH v7 2/4] iommu: Move global PASID allocation from SVA to core Jacob Pan
2023-05-25  6:27   ` Tian, Kevin
2023-05-25 15:54     ` Jacob Pan
2023-05-23 17:34 ` [PATCH v7 3/4] iommu/vt-d: Add set_dev_pasid callback for dma domain Jacob Pan
2023-05-25  6:56   ` Tian, Kevin
2023-05-26  2:43     ` Baolu Lu
2023-06-14  8:10       ` Tian, Kevin
2023-05-30 17:08     ` Jason Gunthorpe
2023-05-31  4:59       ` Baolu Lu [this message]
2023-06-14  8:13       ` Tian, Kevin
2023-05-23 17:34 ` [PATCH v7 4/4] dmaengine/idxd: Re-enable kernel workqueue under DMA API Jacob Pan
2023-05-24  5:44   ` Vinod Koul
2023-06-01  4:33 ` [PATCH v7 0/4] Re-enable IDXD " Jacob Pan
2023-06-01 14:21   ` Jason Gunthorpe
2023-06-01 15:58     ` Jacob Pan

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=c5a1a51d-b309-4237-b2c5-fbdaa1f4f9a8@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=ashok.raj@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=fenghua.yu@intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=jean-philippe@linaro.com \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=narayan.ranganathan@intel.com \
    --cc=robin.murphy@arm.com \
    --cc=tom.zanussi@intel.com \
    --cc=tony.luck@intel.com \
    --cc=vkoul@kernel.org \
    --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