From: Baolu Lu <baolu.lu@linux.intel.com>
To: "Tian, Kevin" <kevin.tian@intel.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: baolu.lu@linux.intel.com,
"iommu@lists.linux-foundation.org"
<iommu@lists.linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
"dmaengine@vger.kernel.org" <dmaengine@vger.kernel.org>,
Joerg Roedel <joro@8bytes.org>,
David Woodhouse <dwmw2@infradead.org>,
Jean-Philippe Brucker <jean-philippe@linaro.com>,
Christoph Hellwig <hch@infradead.org>,
"vkoul@kernel.org" <vkoul@kernel.org>,
"robin.murphy@arm.com" <robin.murphy@arm.com>,
"will@kernel.org" <will@kernel.org>,
"Liu, Yi L" <yi.l.liu@intel.com>,
"Jiang, Dave" <dave.jiang@intel.com>,
"Raj, Ashok" <ashok.raj@intel.com>,
Eric Auger <eric.auger@redhat.com>
Subject: Re: [PATCH v4 1/6] iommu: Add a per domain PASID for DMA API
Date: Tue, 31 May 2022 20:45:28 +0800 [thread overview]
Message-ID: <628aa885-dd12-8bcd-bfc6-446345bf69ed@linux.intel.com> (raw)
In-Reply-To: <BN9PR11MB52768105FC4FB959298F8A188CDC9@BN9PR11MB5276.namprd11.prod.outlook.com>
On 2022/5/31 18:12, Tian, Kevin wrote:
>>>> +++ b/include/linux/iommu.h
>>>> @@ -105,6 +105,8 @@ struct iommu_domain {
>>>> enum iommu_page_response_code (*iopf_handler)(struct
>> iommu_fault *fault,
>>>> void *data);
>>>> void *fault_data;
>>>> + ioasid_t pasid; /* Used for DMA requests with PASID */
>>>> + atomic_t pasid_users;
>>> These are poorly named, this is really the DMA API global PASID and
>>> shouldn't be used for other things.
>>>
>>>
>>>
>>> Perhaps I misunderstood, do you mind explaining more?
>> You still haven't really explained what this is for in this patch,
>> maybe it just needs a better commit message, or maybe something is
>> wrong.
>>
>> I keep saying the DMA API usage is not special, so why do we need to
>> create a new global pasid and refcount? Realistically this is only
>> going to be used by IDXD, why can't we just allocate a PASID and
>> return it to the driver every time a driver asks for DMA API on PASI
>> mode? Why does the core need to do anything special?
>>
> Agree. I guess it was a mistake caused by treating ENQCMD as the
> only user although the actual semantics of the invented interfaces
> have already evolved to be quite general.
>
> This is very similar to what we have been discussing for iommufd.
> a PASID is just an additional routing info when attaching a device
> to an I/O address space (DMA API in this context) and by default
> it should be a per-device resource except when ENQCMD is
> explicitly opt in.
>
> Hence it's right time for us to develop common facility working
> for both this DMA API usage and iommufd, i.e.:
>
> for normal PASID attach to a domain, driver:
>
> allocates a local pasid from device local space;
> attaches the local pasid to a domain;
>
> for PASID attach in particular for ENQCMD, driver:
>
> allocates a global pasid in system-wide;
> attaches the global pasid to a domain;
> set the global pasid in PASID_MSR;
>
> In both cases the pasid is stored in the attach data instead of the
> domain.
>
> DMA API pasid is no special from above except it needs to allow
> one device attached to the same domain twice (one with RID
> and the other with RID+PASID).
>
> for iommufd those operations are initiated by userspace via
> iommufd uAPI.
My understanding is that device driver owns its PASID policy. If ENQCMD
is supported on the device, the PASIDs should be allocated through
ioasid_alloc(). Otherwise, the whole PASID pool is managed by the device
driver.
For kernel DMA w/ PASID, after the driver has a PASID for this purpose,
it can just set the default domain to the PASID on device. There's no
need for enable/disable() interfaces.
Best regards,
baolu
WARNING: multiple messages have this Message-ID (diff)
From: Baolu Lu <baolu.lu@linux.intel.com>
To: "Tian, Kevin" <kevin.tian@intel.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: "vkoul@kernel.org" <vkoul@kernel.org>,
"Jiang, Dave" <dave.jiang@intel.com>,
"Raj, Ashok" <ashok.raj@intel.com>,
"will@kernel.org" <will@kernel.org>,
Jean-Philippe Brucker <jean-philippe@linaro.com>,
LKML <linux-kernel@vger.kernel.org>,
Christoph Hellwig <hch@infradead.org>,
"iommu@lists.linux-foundation.org"
<iommu@lists.linux-foundation.org>,
"dmaengine@vger.kernel.org" <dmaengine@vger.kernel.org>,
"robin.murphy@arm.com" <robin.murphy@arm.com>,
David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH v4 1/6] iommu: Add a per domain PASID for DMA API
Date: Tue, 31 May 2022 20:45:28 +0800 [thread overview]
Message-ID: <628aa885-dd12-8bcd-bfc6-446345bf69ed@linux.intel.com> (raw)
In-Reply-To: <BN9PR11MB52768105FC4FB959298F8A188CDC9@BN9PR11MB5276.namprd11.prod.outlook.com>
On 2022/5/31 18:12, Tian, Kevin wrote:
>>>> +++ b/include/linux/iommu.h
>>>> @@ -105,6 +105,8 @@ struct iommu_domain {
>>>> enum iommu_page_response_code (*iopf_handler)(struct
>> iommu_fault *fault,
>>>> void *data);
>>>> void *fault_data;
>>>> + ioasid_t pasid; /* Used for DMA requests with PASID */
>>>> + atomic_t pasid_users;
>>> These are poorly named, this is really the DMA API global PASID and
>>> shouldn't be used for other things.
>>>
>>>
>>>
>>> Perhaps I misunderstood, do you mind explaining more?
>> You still haven't really explained what this is for in this patch,
>> maybe it just needs a better commit message, or maybe something is
>> wrong.
>>
>> I keep saying the DMA API usage is not special, so why do we need to
>> create a new global pasid and refcount? Realistically this is only
>> going to be used by IDXD, why can't we just allocate a PASID and
>> return it to the driver every time a driver asks for DMA API on PASI
>> mode? Why does the core need to do anything special?
>>
> Agree. I guess it was a mistake caused by treating ENQCMD as the
> only user although the actual semantics of the invented interfaces
> have already evolved to be quite general.
>
> This is very similar to what we have been discussing for iommufd.
> a PASID is just an additional routing info when attaching a device
> to an I/O address space (DMA API in this context) and by default
> it should be a per-device resource except when ENQCMD is
> explicitly opt in.
>
> Hence it's right time for us to develop common facility working
> for both this DMA API usage and iommufd, i.e.:
>
> for normal PASID attach to a domain, driver:
>
> allocates a local pasid from device local space;
> attaches the local pasid to a domain;
>
> for PASID attach in particular for ENQCMD, driver:
>
> allocates a global pasid in system-wide;
> attaches the global pasid to a domain;
> set the global pasid in PASID_MSR;
>
> In both cases the pasid is stored in the attach data instead of the
> domain.
>
> DMA API pasid is no special from above except it needs to allow
> one device attached to the same domain twice (one with RID
> and the other with RID+PASID).
>
> for iommufd those operations are initiated by userspace via
> iommufd uAPI.
My understanding is that device driver owns its PASID policy. If ENQCMD
is supported on the device, the PASIDs should be allocated through
ioasid_alloc(). Otherwise, the whole PASID pool is managed by the device
driver.
For kernel DMA w/ PASID, after the driver has a PASID for this purpose,
it can just set the default domain to the PASID on device. There's no
need for enable/disable() interfaces.
Best regards,
baolu
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2022-05-31 12:45 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-18 18:21 [PATCH v4 0/6] Enable PASID for DMA API users Jacob Pan
2022-05-18 18:21 ` Jacob Pan
2022-05-18 18:21 ` [PATCH v4 1/6] iommu: Add a per domain PASID for DMA API Jacob Pan
2022-05-18 18:21 ` Jacob Pan
2022-05-19 6:50 ` Baolu Lu
2022-05-19 6:50 ` Baolu Lu
2022-05-24 13:50 ` Jason Gunthorpe
2022-05-24 13:50 ` Jason Gunthorpe via iommu
2022-05-24 15:17 ` Jacob Pan
2022-05-24 15:17 ` Jacob Pan
2022-05-30 12:22 ` Jason Gunthorpe
2022-05-30 12:22 ` Jason Gunthorpe via iommu
2022-05-31 10:12 ` Tian, Kevin
2022-05-31 10:12 ` Tian, Kevin
2022-05-31 12:45 ` Baolu Lu [this message]
2022-05-31 12:45 ` Baolu Lu
2022-05-31 16:03 ` Jason Gunthorpe
2022-05-31 16:03 ` Jason Gunthorpe via iommu
2022-05-31 17:29 ` Jacob Pan
2022-05-31 17:29 ` Jacob Pan
2022-05-31 19:05 ` Jason Gunthorpe
2022-05-31 19:05 ` Jason Gunthorpe via iommu
2022-05-31 20:44 ` Jacob Pan
2022-05-31 20:44 ` Jacob Pan
2022-06-01 1:50 ` Tian, Kevin
2022-06-01 1:50 ` Tian, Kevin
2022-06-01 1:43 ` Tian, Kevin
2022-06-01 1:43 ` Tian, Kevin
2022-06-01 9:37 ` Baolu Lu
2022-06-01 9:37 ` Baolu Lu
2022-06-01 10:05 ` Tian, Kevin
2022-06-01 10:05 ` Tian, Kevin
2022-05-18 18:21 ` [PATCH v4 2/6] iommu: Add a helper to do PASID lookup from domain Jacob Pan
2022-05-18 18:21 ` Jacob Pan
2022-05-19 6:41 ` Baolu Lu
2022-05-19 6:41 ` Baolu Lu
2022-05-19 20:10 ` Jacob Pan
2022-05-19 20:10 ` Jacob Pan
2022-05-19 6:48 ` Christoph Hellwig
2022-05-19 6:48 ` Christoph Hellwig
2022-05-20 15:18 ` Jacob Pan
2022-05-20 15:18 ` Jacob Pan
2022-05-23 7:55 ` Tian, Kevin
2022-05-23 7:55 ` Tian, Kevin
2022-05-23 9:14 ` Tian, Kevin
2022-05-23 9:14 ` Tian, Kevin
2022-05-23 18:01 ` Jacob Pan
2022-05-23 18:01 ` Jacob Pan
2022-05-18 18:21 ` [PATCH v4 3/6] iommu/vt-d: Implement domain ops for attach_dev_pasid Jacob Pan
2022-05-18 18:21 ` Jacob Pan
2022-05-24 13:51 ` Jason Gunthorpe
2022-05-24 13:51 ` Jason Gunthorpe via iommu
2022-05-24 16:12 ` Jacob Pan
2022-05-24 16:12 ` Jacob Pan
2022-05-24 18:02 ` Jason Gunthorpe
2022-05-24 18:02 ` Jason Gunthorpe via iommu
2022-05-24 20:45 ` Jacob Pan
2022-05-24 20:45 ` Jacob Pan
2022-05-24 21:10 ` Jason Gunthorpe
2022-05-24 21:10 ` Jason Gunthorpe via iommu
2022-05-18 18:21 ` [PATCH v4 4/6] iommu: Add PASID support for DMA mapping API users Jacob Pan
2022-05-18 18:21 ` Jacob Pan
2022-05-23 8:25 ` Tian, Kevin
2022-05-23 8:25 ` Tian, Kevin
2022-05-23 15:23 ` Jacob Pan
2022-05-23 15:23 ` Jacob Pan
2022-05-18 18:21 ` [PATCH v4 5/6] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID Jacob Pan
2022-05-18 18:21 ` Jacob Pan
2022-05-18 18:21 ` [PATCH v4 6/6] iommu/vt-d: Delete unused SVM flag Jacob Pan
2022-05-18 18:21 ` 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=628aa885-dd12-8bcd-bfc6-446345bf69ed@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=eric.auger@redhat.com \
--cc=hch@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--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=robin.murphy@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.