Re: [PATCH v4 1/6] iommu: Add a per domain PASID for DMA API

2022-05-31 Thread Jacob Pan
Hi Jason, On Tue, 31 May 2022 16:05:50 -0300, Jason Gunthorpe wrote: > On Tue, May 31, 2022 at 10:29:55AM -0700, Jacob Pan wrote: > > > The reason why I store PASID at IOMMU domain is for IOTLB flush within > > the domain. Device driver is not aware of domain level IOTLB

Re: [PATCH v4 1/6] iommu: Add a per domain PASID for DMA API

2022-05-31 Thread Jacob Pan
Hi Baolu, On Tue, 31 May 2022 20:45:28 +0800, Baolu Lu wrote: > 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, >

Re: [PATCH v4 3/6] iommu/vt-d: Implement domain ops for attach_dev_pasid

2022-05-24 Thread Jacob Pan
Hi Jason, On Tue, 24 May 2022 15:02:41 -0300, Jason Gunthorpe wrote: > On Tue, May 24, 2022 at 09:12:35AM -0700, Jacob Pan wrote: > > Hi Jason, > > > > On Tue, 24 May 2022 10:51:35 -0300, Jason Gunthorpe > > wrote: > > > On Wed, May 18, 2022

Re: [PATCH v4 3/6] iommu/vt-d: Implement domain ops for attach_dev_pasid

2022-05-24 Thread Jacob Pan
Hi Jason, On Tue, 24 May 2022 10:51:35 -0300, Jason Gunthorpe wrote: > On Wed, May 18, 2022 at 11:21:17AM -0700, Jacob Pan wrote: > > On VT-d platforms with scalable mode enabled, devices issue DMA requests > > with PASID need to attach PASIDs to given IOMMU domains. The attac

Re: [PATCH v4 1/6] iommu: Add a per domain PASID for DMA API

2022-05-24 Thread Jacob Pan
Hi Jason, On Tue, 24 May 2022 10:50:34 -0300, Jason Gunthorpe wrote: > On Wed, May 18, 2022 at 11:21:15AM -0700, Jacob Pan wrote: > > DMA requests tagged with PASID can target individual IOMMU domains. > > Introduce a domain-wide PASID for DMA API, it will be used on the s

Re: [PATCH v4 2/6] iommu: Add a helper to do PASID lookup from domain

2022-05-23 Thread Jacob Pan
Hi Kevin, On Mon, 23 May 2022 09:14:04 +, "Tian, Kevin" wrote: > > From: Tian, Kevin > > Sent: Monday, May 23, 2022 3:55 PM > > > > > From: Jacob Pan > > > +ioasid_t iommu_get_pasid_from_domain(struct device *dev, struct > > > iom

Re: [PATCH v4 4/6] iommu: Add PASID support for DMA mapping API users

2022-05-23 Thread Jacob Pan
Hi Kevin, On Mon, 23 May 2022 08:25:33 +, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Thursday, May 19, 2022 2:21 AM > > > > DMA mapping API is the de facto standard for in-kernel DMA. It operates > > on a per device/RID basis which is not P

Re: [PATCH v4 2/6] iommu: Add a helper to do PASID lookup from domain

2022-05-20 Thread Jacob Pan
Hi Christoph, On Wed, 18 May 2022 23:48:44 -0700, Christoph Hellwig wrote: > On Wed, May 18, 2022 at 11:21:16AM -0700, Jacob Pan wrote: > > +ioasid_t iommu_get_pasid_from_domain(struct device *dev, struct > > iommu_domain *domain) > > Overly long line here. will

Re: [PATCH v3 1/4] iommu/vt-d: Implement domain ops for attach_dev_pasid

2022-05-19 Thread Jacob Pan
Hi Jason, On Wed, 18 May 2022 15:52:05 -0300, Jason Gunthorpe wrote: > On Wed, May 18, 2022 at 11:42:04AM -0700, Jacob Pan wrote: > > > > Yes.. It seems inefficient to iterate over that xarray multiple times > > > on the flush hot path, but maybe there is little choi

Re: [PATCH v4 2/6] iommu: Add a helper to do PASID lookup from domain

2022-05-19 Thread Jacob Pan
Hi Baolu, On Thu, 19 May 2022 14:41:06 +0800, Baolu Lu wrote: > > IOMMU group maintains a PASID array which stores the associated IOMMU > > domains. This patch introduces a helper function to do domain to PASID > > look up. It will be used by TLB flush and device-PASID attach > > verification.

Re: [PATCH v3 1/4] iommu/vt-d: Implement domain ops for attach_dev_pasid

2022-05-18 Thread Jacob Pan
Hi Jason, On Wed, 11 May 2022 15:29:08 -0300, Jason Gunthorpe wrote: > On Wed, May 11, 2022 at 10:25:21AM -0700, Jacob Pan wrote: > > Hi Jason, > > > > On Wed, 11 May 2022 14:00:25 -0300, Jason Gunthorpe > > wrote: > > > On Wed, May 11, 2022

[PATCH v4 6/6] iommu/vt-d: Delete unused SVM flag

2022-05-18 Thread Jacob Pan
Supervisor PASID for SVA/SVM is no longer supported, delete the unused flag. Signed-off-by: Jacob Pan --- drivers/iommu/intel/svm.c | 2 +- include/linux/intel-svm.h | 13 - 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu

[PATCH v4 2/6] iommu: Add a helper to do PASID lookup from domain

2022-05-18 Thread Jacob Pan
IOMMU group maintains a PASID array which stores the associated IOMMU domains. This patch introduces a helper function to do domain to PASID look up. It will be used by TLB flush and device-PASID attach verification. Signed-off-by: Jacob Pan --- drivers/iommu/iommu.c | 22

[PATCH v4 5/6] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID

2022-05-18 Thread Jacob Pan
both DMA requests with and without PASIDs are mapped identically, there is no change to how DMA APIs are used after the kernel PASID is enabled. Link: https://lore.kernel.org/linux-iommu/20210511194726.gp1002...@nvidia.com/ Signed-off-by: Jacob Pan --- drivers/dma/idxd/idxd.h | 1 - drivers/dma

[PATCH v4 4/6] iommu: Add PASID support for DMA mapping API users

2022-05-18 Thread Jacob Pan
introduces a driver facing API that enables DMA API PASID usage. Once enabled, device drivers can continue to use DMA APIs as is. There is no difference in dma_handle between without PASID and with PASID. Signed-off-by: Jacob Pan --- drivers/iommu/dma-iommu.c | 114

[PATCH v4 0/6] Enable PASID for DMA API users

2022-05-18 Thread Jacob Pan
nd_device parameters - Use IOMMU specific data instead of struct device to store PASID info *** SUBJECT HERE *** *** BLURB HERE *** Jacob Pan (6): iommu: Add a per domain PASID for DMA API iommu: Add a helper to do PASID lookup from domain iommu/vt-d: Implement domain ops

[PATCH v4 1/6] iommu: Add a per domain PASID for DMA API

2022-05-18 Thread Jacob Pan
DMA requests tagged with PASID can target individual IOMMU domains. Introduce a domain-wide PASID for DMA API, it will be used on the same mapping as legacy DMA without PASID. Let it be IOVA or PA in case of identity domain. Signed-off-by: Jacob Pan --- include/linux/iommu.h | 2 ++ 1 file

[PATCH v4 3/6] iommu/vt-d: Implement domain ops for attach_dev_pasid

2022-05-18 Thread Jacob Pan
and device TLB invalidations This patch add attach_dev_pasid functions to the default domain ops which is used by DMA and identity domain types. It could be extended to support other domain types whenever necessary. Signed-off-by: Lu Baolu Signed-off-by: Jacob Pan --- drivers/iommu/intel

Re: [PATCH 6/7] x86/boot/tboot: Move tboot_force_iommu() to Intel IOMMU

2022-05-16 Thread Jacob Pan
Hi Jason, On Mon, 16 May 2022 15:06:28 -0300, Jason Gunthorpe wrote: > Unrelated, but when we are in the special secure IOMMU modes, do we > force ATS off? Specifically does the IOMMU reject TLPs that are marked > as translated? Yes, VT-d context entry has a Device TLB Enable bit, if 0, it

Re: [PATCH v3 1/4] iommu/vt-d: Implement domain ops for attach_dev_pasid

2022-05-11 Thread Jacob Pan
Hi Jason, On Wed, 11 May 2022 14:00:25 -0300, Jason Gunthorpe wrote: > On Wed, May 11, 2022 at 10:02:16AM -0700, Jacob Pan wrote: > > > > If not global, perhaps we could have a list of pasids (e.g. xarray) > > > > attached to the device_domain_info. The TLB flush

Re: [PATCH v3 1/4] iommu/vt-d: Implement domain ops for attach_dev_pasid

2022-05-11 Thread Jacob Pan
Hi Jason, On Wed, 11 May 2022 13:12:37 -0300, Jason Gunthorpe wrote: > On Wed, May 11, 2022 at 08:35:18AM -0700, Jacob Pan wrote: > > > > Huh? The intel driver shares the same ops between UNMANAGED and DMA - > > > and in general I do not think we should be putting speci

Re: [PATCH v3 1/4] iommu/vt-d: Implement domain ops for attach_dev_pasid

2022-05-11 Thread Jacob Pan
Hi Jason, On Wed, 11 May 2022 08:54:27 -0300, Jason Gunthorpe wrote: > On Tue, May 10, 2022 at 05:23:09PM -0700, Jacob Pan wrote: > > > > > diff --git a/include/linux/intel-iommu.h > > > > b/include/linux/intel-iommu.h index 5af24befc9f1..55845a8c4f4d > >

Re: [PATCH v3 2/4] iommu: Add PASID support for DMA mapping API users

2022-05-10 Thread Jacob Pan
Hi Jason, On Tue, 10 May 2022 20:28:04 -0300, Jason Gunthorpe wrote: > On Tue, May 10, 2022 at 02:07:02PM -0700, Jacob Pan wrote: > > DMA mapping API is the de facto standard for in-kernel DMA. It operates > > on a per device/RID basis which is not PASID-aware. > > &g

Re: [PATCH v3 1/4] iommu/vt-d: Implement domain ops for attach_dev_pasid

2022-05-10 Thread Jacob Pan
Hi Jason, On Tue, 10 May 2022 20:21:21 -0300, Jason Gunthorpe wrote: > On Tue, May 10, 2022 at 02:07:01PM -0700, Jacob Pan wrote: > > +static int intel_iommu_attach_dev_pasid(struct iommu_domain *domain, > > + str

[PATCH v3 3/4] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID

2022-05-10 Thread Jacob Pan
both DMA requests with and without PASIDs are mapped identically, there is no change to how DMA APIs are used after the kernel PASID is enabled. Link: https://lore.kernel.org/linux-iommu/20210511194726.gp1002...@nvidia.com/ Signed-off-by: Jacob Pan --- drivers/dma/idxd/idxd.h | 1 - drivers/dma

[PATCH v3 2/4] iommu: Add PASID support for DMA mapping API users

2022-05-10 Thread Jacob Pan
introduces a driver facing API that enables DMA API PASID usage. Once enabled, device drivers can continue to use DMA APIs as is. There is no difference in dma_handle between without PASID and with PASID. Signed-off-by: Jacob Pan --- drivers/iommu/dma-iommu.c | 107

[PATCH v3 4/4] iommu/vt-d: Delete unused SVM flag

2022-05-10 Thread Jacob Pan
Supervisor PASID for SVA/SVM is no longer supported, delete the unused flag. Signed-off-by: Jacob Pan --- drivers/iommu/intel/svm.c | 2 +- include/linux/intel-svm.h | 13 - 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu

[PATCH v3 0/4] Enable PASID for DMA API users

2022-05-10 Thread Jacob Pan
ed the DMA API only IOMMU op. - Removed supervisor SVA support in VT-d - Removed unused sva_bind_device parameters - Use IOMMU specific data instead of struct device to store PASID info Jacob Pan (4): iommu/vt-d: Implement domain ops for attach_dev_pasid iommu:

[PATCH v3 1/4] iommu/vt-d: Implement domain ops for attach_dev_pasid

2022-05-10 Thread Jacob Pan
and device TLB invalidations This patch add attach_dev_pasid functions to the default domain ops which is used by DMA and identity domain types. It could be extended to support other domain types whenever necessary. Signed-off-by: Lu Baolu Signed-off-by: Jacob Pan --- drivers/iommu/intel

Re: [PATCH 4/5] iommu/vt-d: Remove domain_update_iommu_snooping()

2022-05-02 Thread Jacob Pan
Hi BaoLu, On Sun, 1 May 2022 19:24:33 +0800, Lu Baolu wrote: > The IOMMU force snooping capability is not required to be consistent > among all the IOMMUs anymore. Remove force snooping capability check > in the IOMMU hot-add path and domain_update_iommu_snooping() becomes > a dead code now. >

Re: [PATCH 3/5] iommu/vt-d: Check domain force_snooping against attached devices

2022-05-02 Thread Jacob Pan
Hi BaoLu, On Sun, 1 May 2022 19:24:32 +0800, Lu Baolu wrote: > As domain->force_snooping only impacts the devices attached with the > domain, there's no need to check against all IOMMU units. At the same > time, for a brand new domain (hasn't been attached to any device), the > force_snooping

Re: [PATCH] Documentation: x86: rework IOMMU documentation

2022-04-26 Thread Jacob Pan
Hi Alex, Thanks for doing this, really helps to catch up the current state. Please see my comments inline. On Fri, 22 Apr 2022 16:06:07 -0400, Alex Deucher wrote: > Add preliminary documentation for AMD IOMMU and combine > with the existing Intel IOMMU documentation and clean > up and

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-25 Thread Jacob Pan
Hi Jean-Philippe, On Mon, 25 Apr 2022 17:13:02 +0100, Jean-Philippe Brucker wrote: > Hi Jacob, > > On Mon, Apr 25, 2022 at 08:34:44AM -0700, Jacob Pan wrote: > > Hi Jean-Philippe, > > > > On Mon, 25 Apr 2022 15:26:40 +0100, Jean-Philippe Brucker > > wrote:

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-25 Thread Jacob Pan
Hi Jean-Philippe, On Mon, 25 Apr 2022 15:26:40 +0100, Jean-Philippe Brucker wrote: > On Mon, Apr 25, 2022 at 07:18:36AM -0700, Dave Hansen wrote: > > On 4/25/22 06:53, Jean-Philippe Brucker wrote: > > > On Sat, Apr 23, 2022 at 07:13:39PM +0800, zhangfei@foxmail.com > > > wrote: > >

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-18 Thread Jacob Pan
Hi zhangfei@foxmail.com, On Sat, 16 Apr 2022 09:43:07 +0800, "zhangfei@foxmail.com" wrote: > On 2022/4/16 上午5:00, Jacob Pan wrote: > > Hi zhangfei@foxmail.com, > > > > On Fri, 15 Apr 2022 19:52:03 +0800, "zhangfei@foxmail.com" > &g

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-18 Thread Jacob Pan
Hi Kevin, On Mon, 18 Apr 2022 06:34:19 +, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Saturday, April 16, 2022 5:00 AM > > > > Hi zhangfei@foxmail.com, > > > > On Fri, 15 Apr 2022 19:52:03 +0800, "zhangfei@foxmail.com&q

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-15 Thread Jacob Pan
Hi zhangfei@foxmail.com, On Fri, 15 Apr 2022 19:52:03 +0800, "zhangfei@foxmail.com" wrote: > >>> A PASID might be still used even though it is freed on mm exit. > >>> > >>> process A: > >>> sva_bind(); > >>> ioasid_alloc() = N; // Get PASID N for the mm > >>> fork(): // spawn

Re: [PATCH RFC v2 08/11] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

2022-03-31 Thread Jacob Pan
Hi Lu, On Tue, 29 Mar 2022 13:37:57 +0800, Lu Baolu wrote: > The existing iommu SVA interfaces are implemented by calling the SVA > specific iommu ops provided by the IOMMU drivers. There's no need for > any SVA specific ops in iommu_ops vector anymore as we can achieve > this through the

Re: [PATCH RFC v2 03/11] iommu/sva: Add iommu_domain type for SVA

2022-03-29 Thread Jacob Pan
Hi BaoLu, On Tue, 29 Mar 2022 13:37:52 +0800, Lu Baolu wrote: > Add a new iommu domain type IOMMU_DOMAIN_SVA to represent an I/O page > table which is shared from CPU host VA. Add some helpers to get and > put an SVA domain and implement SVA domain life cycle management. > > Signed-off-by: Lu

Re: [PATCH RFC v2 01/11] iommu: Add pasid_bits field in struct dev_iommu

2022-03-29 Thread Jacob Pan
Hi BaoLu, On Tue, 29 Mar 2022 13:37:50 +0800, Lu Baolu wrote: > Use this field to save the pasid/ssid bits that a device is able to > support with its IOMMU hardware. It is a generic attribute of a device > and lifting it into the per-device dev_iommu struct makes it possible > to allocate a

Re: [PATCH v2 7/8] iommu/vt-d: Delete supervisor/kernel SVA

2022-03-29 Thread Jacob Pan
Hi Kevin, On Fri, 18 Mar 2022 06:16:58 +, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Tuesday, March 15, 2022 1:07 PM > > > > In-kernel DMA with PASID should use DMA API now, remove supervisor > > PASID > > SVA support. Remove spe

Re: [PATCH v2 6/8] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID

2022-03-29 Thread Jacob Pan
Hi Kevin, On Fri, 18 Mar 2022 06:10:40 +, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Tuesday, March 15, 2022 1:07 PM > > > > The current in-kernel supervisor PASID support is based on the SVM/SVA > > machinery in SVA lib. The binding betwe

Re: [PATCH v2 5/8] iommu: Add PASID support for DMA mapping API users

2022-03-28 Thread Jacob Pan
Hi BaoLu, On Fri, 18 Mar 2022 20:43:54 +0800, Lu Baolu wrote: > On 2022/3/15 13:07, Jacob Pan wrote: > > DMA mapping API is the de facto standard for in-kernel DMA. It operates > > on a per device/RID basis which is not PASID-aware. > > > > Some modern devices s

Re: [PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach ops

2022-03-28 Thread Jacob Pan
Hi Kevin, On Fri, 18 Mar 2022 05:33:38 +, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Thursday, March 17, 2022 5:02 AM > > > > Hi Kevin, > > > > On Wed, 16 Mar 2022 07:41:34 +, "Tian, Kevin" > > wrote: > >

Re: [PATCH v2 4/8] iommu/vt-d: Use device_pasid attach op for RID2PASID

2022-03-17 Thread Jacob Pan
Hi Kevin, On Wed, 16 Mar 2022 07:54:19 +, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Tuesday, March 15, 2022 1:07 PM > > > > With the availability of a generic device-PASID-domain attachment API, > > there's no need to special case RID2PASID

Re: [PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach ops

2022-03-17 Thread Jacob Pan
Hi Jason, On Thu, 17 Mar 2022 10:23:08 -0300, Jason Gunthorpe wrote: > On Wed, Mar 16, 2022 at 05:49:59PM -0700, Jacob Pan wrote: > > > > I would expect real applications will try to use the same PASID for > > > the same IOVA map to optimize IOTLB caching. > >

Re: [PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach ops

2022-03-16 Thread Jacob Pan
Hi Jason, On Wed, 16 Mar 2022 19:15:50 -0300, Jason Gunthorpe wrote: > On Wed, Mar 16, 2022 at 01:50:04PM -0700, Jacob Pan wrote: > > > I guess a list of (device, pasid) tuples as you suggested could work > > but it will have duplicated device entries since each device could

Re: [PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach ops

2022-03-16 Thread Jacob Pan
Hi Kevin, On Wed, 16 Mar 2022 07:41:34 +, "Tian, Kevin" wrote: > > From: Jason Gunthorpe > > Sent: Tuesday, March 15, 2022 10:33 PM > > > > On Mon, Mar 14, 2022 at 10:07:07PM -0700, Jacob Pan wrote: > > > + /* > > > + * Each domain co

Re: [PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach ops

2022-03-16 Thread Jacob Pan
Hi Kevin, On Wed, 16 Mar 2022 07:39:09 +, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Tuesday, March 15, 2022 1:07 PM > > +static int intel_iommu_attach_dev_pasid(struct iommu_domain *domain, > > + stru

Re: [PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach ops

2022-03-16 Thread Jacob Pan
Hi Jason, On Tue, 15 Mar 2022 20:04:57 -0300, Jason Gunthorpe wrote: > On Tue, Mar 15, 2022 at 03:36:20PM -0700, Jacob Pan wrote: > > Hi Jason, > > > > On Tue, 15 Mar 2022 11:33:22 -0300, Jason Gunthorpe > > wrote: > > > On Mon, Mar 14, 2022

Re: [PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach ops

2022-03-15 Thread Jacob Pan
Hi Jason, On Tue, 15 Mar 2022 11:33:22 -0300, Jason Gunthorpe wrote: > On Mon, Mar 14, 2022 at 10:07:07PM -0700, Jacob Pan wrote: > > + /* > > +* Each domain could have multiple devices attached with > > shared or per > > +* device PASIDs. At the domain lev

Re: [PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach ops

2022-03-15 Thread Jacob Pan
Hi Kevin, On Tue, 15 Mar 2022 10:33:08 +, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Tuesday, March 15, 2022 1:07 PM > > > > On VT-d platforms with scalable mode enabled, devices issue DMA requests > > with PASID need to attach to t

Re: [PATCH v2 5/8] iommu: Add PASID support for DMA mapping API users

2022-03-15 Thread Jacob Pan
Hi Jason, On Tue, 15 Mar 2022 14:05:07 -0300, Jason Gunthorpe wrote: > On Tue, Mar 15, 2022 at 09:31:35AM -0700, Jacob Pan wrote: > > > > IMHO it is a device mis-design of IDXD to require all DMA be PASID > > > tagged. Devices should be able to do DMA on their RID wh

Re: [PATCH v2 5/8] iommu: Add PASID support for DMA mapping API users

2022-03-15 Thread Jacob Pan
Hi Jason, On Tue, 15 Mar 2022 11:35:35 -0300, Jason Gunthorpe wrote: > On Mon, Mar 14, 2022 at 10:07:09PM -0700, Jacob Pan wrote: > > DMA mapping API is the de facto standard for in-kernel DMA. It operates > > on a per device/RID basis which is not PASID-aware. > > &g

Re: [PATCH v2 5/8] iommu: Add PASID support for DMA mapping API users

2022-03-15 Thread Jacob Pan
Hi Jason, On Tue, 15 Mar 2022 11:22:16 -0300, Jason Gunthorpe wrote: > On Tue, Mar 15, 2022 at 11:16:41AM +, Robin Murphy wrote: > > On 2022-03-15 05:07, Jacob Pan wrote: > > > DMA mapping API is the de facto standard for in-kernel DMA. It > > > operates on a

Re: [PATCH v2 2/8] iommu: Add attach/detach_dev_pasid domain ops

2022-03-15 Thread Jacob Pan
Hi Kevin, On Tue, 15 Mar 2022 11:49:57 +, "Tian, Kevin" wrote: > > From: Jean-Philippe Brucker > > Sent: Tuesday, March 15, 2022 7:27 PM > > > > On Mon, Mar 14, 2022 at 10:07:06PM -0700, Jacob Pan wrote: > > > From: Lu Baolu > > > >

Re: [PATCH v2 0/8] Enable PASID for DMA API users

2022-03-15 Thread Jacob Pan
Hi Kevin, On Tue, 15 Mar 2022 08:16:59 +, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Tuesday, March 15, 2022 1:07 PM > > > > Some modern accelerators such as Intel's Data Streaming Accelerator > > (DSA) require PASID in DMA requests to be

[PATCH v2 1/8] iommu: Assign per device max PASID

2022-03-14 Thread Jacob Pan
-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 4 +++- include/linux/iommu.h | 13 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 50666d250b36..881f8361eca2 100644 --- a/drivers/iommu/intel

[PATCH v2 4/8] iommu/vt-d: Use device_pasid attach op for RID2PASID

2022-03-14 Thread Jacob Pan
With the availability of a generic device-PASID-domain attachment API, there's no need to special case RID2PASID. Use the API to replace duplicated code. Signed-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 18 ++ 1 file changed, 2 insertions(+), 16 deletions(-) diff

[PATCH v2 7/8] iommu/vt-d: Delete supervisor/kernel SVA

2022-03-14 Thread Jacob Pan
In-kernel DMA with PASID should use DMA API now, remove supervisor PASID SVA support. Remove special cases in bind mm and page request service. Signed-off-by: Jacob Pan --- drivers/iommu/intel/svm.c | 42 --- 1 file changed, 8 insertions(+), 34 deletions

[PATCH v2 6/8] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID

2022-03-14 Thread Jacob Pan
both DMA requests with and without PASIDs are mapped identically, there is no change to how DMA APIs are used after the kernel PASID is enabled. Link: https://lore.kernel.org/linux-iommu/20210511194726.gp1002...@nvidia.com/ Signed-off-by: Jacob Pan --- drivers/dma/idxd/idxd.h | 1 - drivers/dma

[PATCH v2 9/9] dmaengine: idxd: separate user and kernel pasid enabling

2022-03-14 Thread Jacob Pan
uot; flags. Signed-off-by: Dave Jiang Signed-off-by: Jacob Pan --- drivers/dma/idxd/cdev.c | 4 ++-- drivers/dma/idxd/idxd.h | 6 ++ drivers/dma/idxd/init.c | 30 ++ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/dma/idxd/cdev.c b/driver

[PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach ops

2022-03-14 Thread Jacob Pan
and device TLB invalidations This patch extends DMAR domain and device domain info with xarrays to track per domain and per device PASIDs. It provides the flexibility to be used beyond DMA API PASID support. Signed-off-by: Lu Baolu Signed-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 194

[PATCH v2 8/8] iommu: Remove unused driver data in sva_bind_device

2022-03-14 Thread Jacob Pan
No one is using drvdata for sva_bind_device after kernel SVA support is removed from VT-d driver. Remove the drvdata parameter as well. Signed-off-by: Jacob Pan --- drivers/dma/idxd/cdev.c | 2 +- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 2 +- drivers/iommu/arm

[PATCH v2 2/8] iommu: Add attach/detach_dev_pasid domain ops

2022-03-14 Thread Jacob Pan
devices attached to a given domain. This patch introduces a new IOMMU op which support device, PASID, and IOMMU domain attachment. The immediate use case is for PASID capable devices to perform DMA under DMA APIs. Signed-off-by: Lu Baolu Signed-off-by: Jacob Pan --- include/linux/iommu.h | 6

[PATCH v2 5/8] iommu: Add PASID support for DMA mapping API users

2022-03-14 Thread Jacob Pan
introduces a driver facing API that enables DMA API PASID usage. Once enabled, device drivers can continue to use DMA APIs as is. There is no difference in dma_handle between without PASID and with PASID. Signed-off-by: Jacob Pan --- drivers/iommu/dma-iommu.c | 65

[PATCH v2 0/8] Enable PASID for DMA API users

2022-03-14 Thread Jacob Pan
unused sva_bind_device parameters - Use IOMMU specific data instead of struct device to store PASID info Jacob Pan (6): iommu/vt-d: Implement device_pasid domain attach ops iommu/vt-d: Use device_pasid attach op for RID2PASID iommu: Add PASID support for DMA mapping API users

Re: [PATCH v1 09/10] iommu/vt-d: Refactor dmar_insert_one_dev_info()

2022-02-25 Thread Jacob Pan
Hi BaoLu, On Mon, 7 Feb 2022 14:41:41 +0800, Lu Baolu wrote: > > - if (dev && domain_context_mapping(domain, dev)) { > - dev_err(dev, "Domain context map failed\n"); > - dmar_remove_one_dev_info(dev); > - return NULL; > - } > + /* Setup the

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-02-10 Thread Jacob Pan
On Wed, 9 Feb 2022 19:16:14 -0800, Jacob Pan wrote: > Hi Fenghua, > > On Mon, 7 Feb 2022 15:02:48 -0800, Fenghua Yu > wrote: > > > @@ -1047,8 +1040,6 @@ struct iommu_sva *intel_svm_bind(struct device > > *dev, struct mm_struct *mm, void } > > > >

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-02-09 Thread Jacob Pan
Hi Fenghua, On Mon, 7 Feb 2022 15:02:48 -0800, Fenghua Yu wrote: > @@ -1047,8 +1040,6 @@ struct iommu_sva *intel_svm_bind(struct device > *dev, struct mm_struct *mm, void } > > sva = intel_svm_bind_mm(iommu, dev, mm, flags); > - if (IS_ERR_OR_NULL(sva)) > -

Re: [PATCH 1/2] iommu/vt-d: Fix PCI bus rescan device hot add

2022-02-09 Thread Jacob Pan
Hi Joerg, On Thu, 3 Feb 2022 09:25:58 +0100, Joerg Roedel wrote: > On Tue, Feb 01, 2022 at 11:19:18AM -0800, Jacob Pan wrote: > > Do you mean having an IRQ remapping notifier regardless IOMMU-API is > > enabled, right? > > It make sense, I will give it a try. > >

Re: [PATCH v1 09/10] iommu/vt-d: Refactor dmar_insert_one_dev_info()

2022-02-07 Thread Jacob Pan
Hi BaoLu, On Mon, 7 Feb 2022 14:41:41 +0800, Lu Baolu wrote: > static void intel_iommu_release_device(struct device *dev) > { > - struct intel_iommu *iommu; > - > - iommu = device_to_iommu(dev, NULL, NULL); > - if (!iommu) > - return; > - > -

Re: [PATCH 1/2] iommu/vt-d: Fix PCI bus rescan device hot add

2022-02-01 Thread Jacob Pan
Hi Joerg, On Mon, 31 Jan 2022 16:52:10 +0100, Joerg Roedel wrote: > On Mon, Jan 31, 2022 at 01:53:06PM +, Robin Murphy wrote: > > Indeed I very nearly asked whether we couldn't just call these from > > intel_iommu_{probe,release}_device() directly, but it looks like they > > also interact

Re: [PATCH 1/2] iommu/vt-d: Fix PCI bus rescan device hot add

2022-02-01 Thread Jacob Pan
Hi Joerg, On Sun, 30 Jan 2022 08:43:19 +0100, Joerg Roedel wrote: > Hi Jacob, Baolu, > > On Fri, Jan 28, 2022 at 11:10:01AM +0800, Lu Baolu wrote: > > During PCI bus rescan, adding new devices involve two notifiers. > > 1. dmar_pci_bus_notifier() > > 2. iommu_bus_notifier() > > The current

Re: [PATCH v2] iommu/vt-d: Fix PCI bus rescan device hot add

2022-01-25 Thread Jacob Pan
Hi all, Just wondering if there are any other comments? This fixes a regression that can cause system hang. On Fri, 14 Jan 2022 00:21:10 -0800, Jacob Pan wrote: > During PCI bus rescan, adding new devices involve two notifiers. > 1. dmar_pci_bus_notifier() > 2. iommu_bus

[PATCH v2] iommu/vt-d: Fix PCI bus rescan device hot add

2022-01-14 Thread Jacob Pan
llowing: 1. dmar_pci_bus_add_dev() 2. iommu_probe_device() 3. iommu_release_device() 4. dmar_pci_bus_remove_dev() Fixes: 59ce0515cdaf ("iommu/vt-d: Update DRHD/RMRR/ATSR device scope") Reported-by: Zhang, Bernice Suggested-by: Lu Baolu Signed-off-by: Jacob Pan --- drivers/iom

Re: [PATCH] iommu/vt-d: Fix PCI bus rescan device hot add

2022-01-14 Thread Jacob Pan
Hi Lu, On Fri, 14 Jan 2022 11:12:45 +0800, Lu Baolu wrote: > On 1/14/22 11:11 AM, Jacob Pan wrote: > > On Fri, 14 Jan 2022 08:58:53 +0800, Lu Baolu > > wrote: > > > >> Hi Jacob, > >> > >> On 1/13/22 9:23 PM, Jacob Pan wrote: > >&g

Re: [PATCH] iommu/vt-d: Fix PCI bus rescan device hot add

2022-01-13 Thread Jacob Pan
Hi BaoLu, On Fri, 14 Jan 2022 08:58:53 +0800, Lu Baolu wrote: > Hi Jacob, > > On 1/13/22 9:23 PM, Jacob Pan wrote: > > During PCI bus rescan, adding new devices involve two notifiers. > > 1. dmar_pci_bus_notifier() > > 2. iommu_bus_notifier() > > The cur

[PATCH] iommu/vt-d: Fix PCI bus rescan device hot add

2022-01-13 Thread Jacob Pan
g a higher priority for dmar_pci_bus_notifier. DRHD search for a new device will find the correct IOMMU. Fixes: 59ce0515cdaf ("iommu/vt-d: Update DRHD/RMRR/ATSR device scope") Reported-by: Zhang, Bernice Signed-off-by: Jacob Pan --- drivers/iommu/intel/dmar.c | 2 +- 1 file change

Re: [PATCH 3/4] iommu/vt-d: Support PASID DMA for in-kernel usage

2021-12-10 Thread Jacob Pan
Hi Jason, On Fri, 10 Dec 2021 13:48:48 -0400, Jason Gunthorpe wrote: > On Fri, Dec 10, 2021 at 09:50:25AM -0800, Jacob Pan wrote: > > > > Tying pasid to an iommu_domain is not a good idea. An iommu_domain > > > represents an I/O address translation table. It could be at

Re: [PATCH 1/4] ioasid: Reserve a global PASID for in-kernel DMA

2021-12-10 Thread Jacob Pan
Hi Jason, On Fri, 10 Dec 2021 08:31:09 -0400, Jason Gunthorpe wrote: > On Fri, Dec 10, 2021 at 09:06:24AM +, Jean-Philippe Brucker wrote: > > On Thu, Dec 09, 2021 at 10:14:04AM -0800, Jacob Pan wrote: > > > > This looks like we're just one step away from d

Re: [PATCH 3/4] iommu/vt-d: Support PASID DMA for in-kernel usage

2021-12-10 Thread Jacob Pan
Hi Lu, On Fri, 10 Dec 2021 14:46:32 +0800, Lu Baolu wrote: > On 2021/12/10 7:21, Jacob Pan wrote: > > On Thu, 9 Dec 2021 10:32:43 +0800, Lu Baolu > > wrote: > > > >> On 12/9/21 3:16 AM, Jacob Pan wrote: > >>> Hi Jason, > >>> &g

Re: [PATCH 3/4] iommu/vt-d: Support PASID DMA for in-kernel usage

2021-12-09 Thread Jacob Pan
Hi Lu, On Thu, 9 Dec 2021 10:32:43 +0800, Lu Baolu wrote: > On 12/9/21 3:16 AM, Jacob Pan wrote: > > Hi Jason, > > > > On Wed, 8 Dec 2021 09:22:55 -0400, Jason Gunthorpe > > wrote: > >> On Tue, Dec 07, 2021 at 05:47:13AM -0800, Jacob Pan wrote: > &g

Re: [PATCH 4/4] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID

2021-12-09 Thread Jacob Pan
Hi Kevin, On Thu, 9 Dec 2021 01:48:09 +, "Tian, Kevin" wrote: > > From: Jason Gunthorpe > > Sent: Thursday, December 9, 2021 1:51 AM > > > > > > > + /* > > > > > + * Try to enable both in-kernel and user DMA request > > > > > with PASID. > > > > > + * PASID is supported

Re: [PATCH 1/4] ioasid: Reserve a global PASID for in-kernel DMA

2021-12-09 Thread Jacob Pan
Hi Jean-Philippe, On Thu, 9 Dec 2021 11:03:23 +, Jean-Philippe Brucker wrote: > Hi Jacob, > > On Tue, Dec 07, 2021 at 05:47:11AM -0800, Jacob Pan wrote: > > In-kernel DMA is managed by DMA mapping APIs, which supports per device > > addressing mode fo

Re: [PATCH 2/4] iommu: Add PASID support for DMA mapping API users

2021-12-09 Thread Jacob Pan
Hi Ashok, On Thu, 9 Dec 2021 08:57:15 -0800, "Raj, Ashok" wrote: > > Prefixes is disabled > > - Root Complexes may optionally support TLPs with PASID TLP Prefixes. > > The mechanism used to detect whether a Root Complex supports the PASID > > TLP Prefix is implementation specific > > Isn't

Re: [PATCH 2/4] iommu: Add PASID support for DMA mapping API users

2021-12-09 Thread Jacob Pan
Hi Lu, On Thu, 9 Dec 2021 10:21:38 +0800, Lu Baolu wrote: > On 12/9/21 9:56 AM, Tian, Kevin wrote: > >> From: Jacob Pan > >> Sent: Thursday, December 9, 2021 2:50 AM > >> > >>> Can a device issue DMA requests with PASID even there's no syste

Re: [PATCH 4/4] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID

2021-12-08 Thread Jacob Pan
Hi Jason, On Wed, 8 Dec 2021 16:30:22 -0400, Jason Gunthorpe wrote: > On Wed, Dec 08, 2021 at 11:55:16AM -0800, Jacob Pan wrote: > > Hi Jason, > > > > On Wed, 8 Dec 2021 09:13:58 -0400, Jason Gunthorpe > > wrote: > > > > This patch utilizes

Re: [PATCH 4/4] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID

2021-12-08 Thread Jacob Pan
Hi Jason, On Wed, 8 Dec 2021 09:13:58 -0400, Jason Gunthorpe wrote: > > This patch utilizes iommu_enable_pasid_dma() to enable DSA to perform > > DMA requests with PASID under the same mapping managed by DMA mapping > > API. In addition, SVA-related bits for kernel DMA are removed. As a > >

Re: [PATCH 3/4] iommu/vt-d: Support PASID DMA for in-kernel usage

2021-12-08 Thread Jacob Pan
Hi Jason, On Wed, 8 Dec 2021 09:22:55 -0400, Jason Gunthorpe wrote: > On Tue, Dec 07, 2021 at 05:47:13AM -0800, Jacob Pan wrote: > > Between DMA requests with and without PASID (legacy), DMA mapping APIs > > are used indiscriminately on a device. Therefore, we shou

Re: [PATCH 2/4] iommu: Add PASID support for DMA mapping API users

2021-12-08 Thread Jacob Pan
Hi Lu, On Wed, 8 Dec 2021 10:31:36 +0800, Lu Baolu wrote: > Hi Jacob, > > On 12/7/21 9:47 PM, Jacob Pan wrote: > > DMA mapping API is the de facto standard for in-kernel DMA. It operates > > on a per device/RID basis which is not PASID-aware. > > > > Some

Re: [PATCH 0/4] Enable PASID for DMA API users

2021-12-08 Thread Jacob Pan
Hi Jason, Thanks for the quick review. On Wed, 8 Dec 2021 09:10:38 -0400, Jason Gunthorpe wrote: > On Tue, Dec 07, 2021 at 05:47:10AM -0800, Jacob Pan wrote: > > Modern accelerators such as Intel's Data Streaming Accelerator (DSA) can > > perform DMA requests with PASID, w

Re: [PATCH 4/4] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID

2021-12-08 Thread Jacob Pan
Hi Vinod, On Wed, 8 Dec 2021 10:26:22 +0530, Vinod Koul wrote: > Pls resend collecting acks. I dont have this in my queue Will do. Sorry I missed the dmaengine list. Thanks, Jacob ___ iommu mailing list iommu@lists.linux-foundation.org

[PATCH 2/4] iommu: Add PASID support for DMA mapping API users

2021-12-07 Thread Jacob Pan
. This also serves as a flag indicating whether PASID is being used for the device to perform in-kernel DMA. Signed-off-by: Jacob Pan --- drivers/iommu/dma-iommu.c | 71 +++ include/linux/device.h| 1 + include/linux/dma-iommu.h | 7 include/linux/iommu.h

[PATCH 1/4] ioasid: Reserve a global PASID for in-kernel DMA

2021-12-07 Thread Jacob Pan
will fit the bill. Signed-off-by: Jacob Pan --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 2 +- drivers/iommu/intel/iommu.c | 4 ++-- drivers/iommu/intel/pasid.h | 3 +-- drivers/iommu/intel/svm.c | 2 +- drivers/iommu/ioasid.c

[PATCH 0/4] Enable PASID for DMA API users

2021-12-07 Thread Jacob Pan
. Once this set is accepted, more cleanup patches will follow. The plan is to remove the usage of sva_bind_device() for in-kernel usages. Removing page requests and other special cases around kernel SVA in VT-d driver. Jacob Pan (4): ioasid: Reserve a global PASID for in-kernel DMA iommu

[PATCH 3/4] iommu/vt-d: Support PASID DMA for in-kernel usage

2021-12-07 Thread Jacob Pan
is also on a per-domain basis; whereas device TLB flush is per device. Note that IOTLBs are used even when devices are in pass-through mode. ATS is enabled device-wide, but the device drivers can choose to manage ATS at per PASID level whenever control is available. Signed-off-by: Jacob Pan

[PATCH 4/4] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID

2021-12-07 Thread Jacob Pan
: https://lore.kernel.org/linux-iommu/20210511194726.gp1002...@nvidia.com/ Signed-off-by: Jacob Pan --- .../admin-guide/kernel-parameters.txt | 6 -- drivers/dma/Kconfig | 10 drivers/dma/idxd/idxd.h | 1 - drivers/dma/idxd/init.c

Re: [RFC 01/20] iommu/iommufd: Add /dev/iommu core

2021-10-19 Thread Jacob Pan
Hi Jason, On Tue, 19 Oct 2021 13:57:47 -0300, Jason Gunthorpe wrote: > On Tue, Oct 19, 2021 at 09:57:34AM -0700, Jacob Pan wrote: > > Hi Jason, > > > > On Fri, 15 Oct 2021 08:18:07 -0300, Jason Gunthorpe > > wrote: > > > On Fri, Oct 15, 2021

Re: [RFC 01/20] iommu/iommufd: Add /dev/iommu core

2021-10-19 Thread Jacob Pan
Hi Jason, On Fri, 15 Oct 2021 08:18:07 -0300, Jason Gunthorpe wrote: > On Fri, Oct 15, 2021 at 09:18:06AM +, Liu, Yi L wrote: > > > > Acquire from the xarray is > > >rcu_lock() > > >ioas = xa_load() > > >if (ioas) > > > if (down_read_trylock(>destroying_lock)) > > >

  1   2   3   4   5   6   7   8   9   10   >