RE: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-04-05 Thread Tian, Kevin
> From: Tian, Kevin > Sent: Tuesday, April 6, 2021 9:02 AM > > > From: Jason Gunthorpe > > Sent: Tuesday, April 6, 2021 7:40 AM > > > > On Fri, Apr 02, 2021 at 07:58:02AM +, Tian, Kevin wrote: > > > > From: Jason Gunthorpe > > > > Sent: Thursday, April 1, 2021 9:47 PM > > > > > > > > On

Re: [RFC PATCH v3 04/12] iommu: Add a map_pages() op for IOMMU drivers

2021-04-05 Thread Lu Baolu
On 4/6/21 3:11 AM, Isaac J. Manjarres wrote: Add a callback for IOMMU drivers to provide a path for the IOMMU framework to call into an IOMMU driver, which can call into the io-pgtable code, to map a physically contiguous rnage of pages of the same size. For IOMMU drivers that do not specify a

Re: [RFC PATCH v3 02/12] iommu: Add an unmap_pages() op for IOMMU drivers

2021-04-05 Thread Lu Baolu
On 4/6/21 3:11 AM, Isaac J. Manjarres wrote: Add a callback for IOMMU drivers to provide a path for the IOMMU framework to call into an IOMMU driver, which can call into the io-pgtable code, to unmap a virtually contiguous range of pages of the same size. For IOMMU drivers that do not specify

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-04-05 Thread Jason Wang
在 2021/4/6 上午7:42, Jason Gunthorpe 写道: On Fri, Apr 02, 2021 at 08:22:28AM +, Tian, Kevin wrote: From: Jason Gunthorpe Sent: Tuesday, March 30, 2021 9:29 PM First, userspace may use ioasid in a non-SVA scenario where ioasid is bound to specific security context (e.g. a control vq in

RE: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-04-05 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Tuesday, April 6, 2021 7:43 AM > > On Fri, Apr 02, 2021 at 08:22:28AM +, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Tuesday, March 30, 2021 9:29 PM > > > > > > > > > > > First, userspace may use ioasid in a non-SVA scenario where ioasid is > >

Re: [PATCH v2 4/5] iommu/vt-d: Use user privilege for RID2PASID translation

2021-04-05 Thread Lu Baolu
On 3/20/21 10:54 AM, Lu Baolu wrote: When first-level page tables are used for IOVA translation, we use user privilege by setting U/S bit in the page table entry. This is to make it consistent with the second level translation, where the U/S enforcement is not available. Clear the SRE

RE: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-04-05 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Tuesday, April 6, 2021 7:40 AM > > On Fri, Apr 02, 2021 at 07:58:02AM +, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Thursday, April 1, 2021 9:47 PM > > > > > > On Thu, Apr 01, 2021 at 01:43:36PM +, Liu, Yi L wrote: > > > > > From: Jason

RE: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-04-05 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Tuesday, April 6, 2021 7:35 AM > > On Fri, Apr 02, 2021 at 07:30:23AM +, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Friday, April 2, 2021 12:04 AM > > > > > > On Thu, Apr 01, 2021 at 02:08:17PM +, Liu, Yi L wrote: > > > > > > > DMA page

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-04-05 Thread Jason Gunthorpe
On Fri, Apr 02, 2021 at 08:22:28AM +, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Tuesday, March 30, 2021 9:29 PM > > > > > > > > First, userspace may use ioasid in a non-SVA scenario where ioasid is > > > bound to specific security context (e.g. a control vq in vDPA) instead of >

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-04-05 Thread Jason Gunthorpe
On Fri, Apr 02, 2021 at 07:58:02AM +, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Thursday, April 1, 2021 9:47 PM > > > > On Thu, Apr 01, 2021 at 01:43:36PM +, Liu, Yi L wrote: > > > > From: Jason Gunthorpe > > > > Sent: Thursday, April 1, 2021 9:16 PM > > > > > > > > On Thu,

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-04-05 Thread Jason Gunthorpe
On Fri, Apr 02, 2021 at 07:30:23AM +, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Friday, April 2, 2021 12:04 AM > > > > On Thu, Apr 01, 2021 at 02:08:17PM +, Liu, Yi L wrote: > > > > > DMA page faults are delivered to root-complex via page request message > > and > > > it is

Re: [PATCH v2 07/12] iommu: Hook up '->unmap_pages' driver callback

2021-04-05 Thread isaacm
On 2021-04-04 23:00, Lu Baolu wrote: Hi, On 4/2/21 9:34 AM, Isaac J. Manjarres wrote: static size_t __iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size, struct iommu_iotlb_gather *iotlb_gather) @@ -2476,7 +2519,7

[RFC PATCH v3 09/12] iommu/io-pgtable-arm: Implement arm_lpae_unmap_pages()

2021-04-05 Thread Isaac J. Manjarres
Implement the unmap_pages() callback for the ARM LPAE io-pgtable format. Signed-off-by: Isaac J. Manjarres Suggested-by: Will Deacon --- drivers/iommu/io-pgtable-arm.c | 124 +++-- 1 file changed, 104 insertions(+), 20 deletions(-) diff --git

[RFC PATCH v3 12/12] iommu/arm-smmu: Implement the map_pages() IOMMU driver callback

2021-04-05 Thread Isaac J. Manjarres
Implement the unmap_pages() callback for the ARM SMMU driver to allow calls from iommu_unmap to unmap multiple pages of the same size in one call. Signed-off-by: Isaac J. Manjarres Suggested-by: Will Deacon --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 19 +++ 1 file changed, 19

[RFC PATCH v3 05/12] iommu: Use bitmap to calculate page size in iommu_pgsize()

2021-04-05 Thread Isaac J. Manjarres
From: Will Deacon Avoid the potential for shifting values by amounts greater than the width of their type by using a bitmap to compute page size in iommu_pgsize(). Signed-off-by: Will Deacon Signed-off-by: Isaac J. Manjarres --- drivers/iommu/iommu.c | 31 --- 1

[RFC PATCH v3 02/12] iommu: Add an unmap_pages() op for IOMMU drivers

2021-04-05 Thread Isaac J. Manjarres
Add a callback for IOMMU drivers to provide a path for the IOMMU framework to call into an IOMMU driver, which can call into the io-pgtable code, to unmap a virtually contiguous range of pages of the same size. For IOMMU drivers that do not specify an unmap_pages() callback, the existing logic of

[RFC PATCH v3 08/12] iommu: Add support for the map_pages() callback

2021-04-05 Thread Isaac J. Manjarres
Since iommu_pgsize can calculate how many pages of the same size can be mapped/unmapped before the next largest page size boundary, add support for invoking an IOMMU driver's map_pages() callback, if it provides one. Signed-off-by: Isaac J. Manjarres Suggested-by: Will Deacon ---

[RFC PATCH v3 10/12] iommu/io-pgtable-arm: Implement arm_lpae_map_pages()

2021-04-05 Thread Isaac J. Manjarres
Implement the map_pages() callback for the ARM LPAE io-pgtable format. Signed-off-by: Isaac J. Manjarres Suggested-by: Will Deacon --- drivers/iommu/io-pgtable-arm.c | 95 +++--- 1 file changed, 88 insertions(+), 7 deletions(-) diff --git

[RFC PATCH v3 11/12] iommu/arm-smmu: Implement the unmap_pages() IOMMU driver callback

2021-04-05 Thread Isaac J. Manjarres
Implement the unmap_pages() callback for the ARM SMMU driver to allow calls from iommu_unmap to unmap multiple pages of the same size in one call. Signed-off-by: Isaac J. Manjarres Suggested-by: Will Deacon --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 19 +++ 1 file changed, 19

[RFC PATCH v3 01/12] iommu/io-pgtable: Introduce unmap_pages() as a page table op

2021-04-05 Thread Isaac J. Manjarres
The io-pgtable code expects to operate on a single block or granule of memory that is supported by the IOMMU hardware when unmapping memory. This means that when a large buffer that consists of multiple such blocks is unmapped, the io-pgtable code will walk the page tables to the correct level to

[RFC PATCH v3 07/12] iommu: Hook up '->unmap_pages' driver callback

2021-04-05 Thread Isaac J. Manjarres
From: Will Deacon Extend iommu_pgsize() to populate an optional 'count' paramater so that we can direct unmapping operation to the ->unmap_pages callback if it has been provided by the driver. Signed-off-by: Will Deacon Signed-off-by: Isaac J. Manjarres --- drivers/iommu/iommu.c | 60

[RFC PATCH v3 06/12] iommu: Split 'addr_merge' argument to iommu_pgsize() into separate parts

2021-04-05 Thread Isaac J. Manjarres
From: Will Deacon The 'addr_merge' parameter to iommu_pgsize() is a fabricated address intended to describe the alignment requirements to consider when choosing an appropriate page size. On the iommu_map() path, this address is the logical OR of the virtual and physical addresses. Subsequent

[RFC PATCH v3 04/12] iommu: Add a map_pages() op for IOMMU drivers

2021-04-05 Thread Isaac J. Manjarres
Add a callback for IOMMU drivers to provide a path for the IOMMU framework to call into an IOMMU driver, which can call into the io-pgtable code, to map a physically contiguous rnage of pages of the same size. For IOMMU drivers that do not specify a map_pages() callback, the existing logic of

[RFC PATCH v3 03/12] iommu/io-pgtable: Introduce map_pages() as a page table op

2021-04-05 Thread Isaac J. Manjarres
Mapping memory into io-pgtables follows the same semantics that unmapping memory used to follow (i.e. a buffer will be mapped one page block per call to the io-pgtable code). This means that it can be optimized in the same way that unmapping memory was, so add a map_pages() callback to the

[RFC PATCH v3 00/12] Optimizing iommu_[map/unmap] performance

2021-04-05 Thread Isaac J. Manjarres
When unmapping a buffer from an IOMMU domain, the IOMMU framework unmaps the buffer at a granule of the largest page size that is supported by the IOMMU hardware and fits within the buffer. For every block that is unmapped, the IOMMU framework will call into the IOMMU driver, and then the

Re: [PATCHv2 2/2] iommu/arm-smmu-qcom: Move the adreno smmu specific impl earlier

2021-04-05 Thread Sai Prakash Ranjan
Hi Bjorn, On 2021-03-25 20:35, Will Deacon wrote: On Thu, Mar 25, 2021 at 01:10:12PM +0530, Sai Prakash Ranjan wrote: ... I think there is consensus on this series. I can resend if required but it still applies cleanly, let me know if you have any comments? Please resend with the

Re: [PATCH v2 07/12] iommu: Hook up '->unmap_pages' driver callback

2021-04-05 Thread Lu Baolu
Hi, On 4/2/21 9:34 AM, Isaac J. Manjarres wrote: static size_t __iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size, struct iommu_iotlb_gather *iotlb_gather) @@ -2476,7 +2519,7 @@ static size_t __iommu_unmap(struct