Re: [PATCH v3 4/4] vfio: Require that devices support DMA cache coherence

2022-07-04 Thread chenxiang (M) via iommu
Hi, We encounter a issue with the patch: our platform is ARM64, and we run DPDK with smmu disable on VM (without iommu=smmuv3 etc), so we use noiommu mode with enable_unsafe_noiommu_mode=1 to passthrough the device to VM with following steps (those steps are on VM) : insmod vfio.ko

[PATCH] MAINTAINERS: Update maintainer list of DMA MAPPING BENCHMARK

2022-02-07 Thread chenxiang via iommu
From: Xiang Chen Barry Song will not focus on this area, and Xiang Chen will continue his work to maintain this module. Signed-off-by: Xiang Chen --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index ea3e6c914384..48335022b0e4

[PATCH 0/2] Implement [map/unmap]_pages callbacks for ARM SMMUV3

2021-07-30 Thread chenxiang
From: Xiang Chen The series ("Optimizing iommu_[map/unmap] performance") improve the iommu_[map/unmap] performance. Based on the series, implement [map/unmap]_pages callbacks for ARM SMMUV3. Use tool dma_map_benchmark to test the latency of map/unmap, and it promotes much on it. The test result

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

2021-07-30 Thread chenxiang
From: Xiang Chen Implement the map_pages() callback for ARM SMMUV3 driver to allow calls from iommu_map to map multiple pages of the same size in one call. Also remove the map() callback for the ARM SMMUV3 driver as it will no longer be used. Signed-off-by: Xiang Chen ---

[PATCH 1/2] iommu/arm-smmu-v3: Implement the unmap_pages() IOMMU driver callback

2021-07-30 Thread chenxiang
From: Xiang Chen Implement the unmap_pages() callback for ARM SMMUV3 driver to allow calls from iommu_unmap to unmap multiple pages of the same size in one call. Also remove the unmap() callback for the ARM SMMUV3 driver as it will no longer be used. Signed-off-by: Xiang Chen ---

Re: [PATCH v2 00/24] iommu: Refactor DMA domain strictness

2021-07-29 Thread chenxiang (M)
在 2021/7/29 18:59, Robin Murphy 写道: On 2021-07-29 03:55, chenxiang (M) wrote: Hi Robin, 在 2021/7/28 23:58, Robin Murphy 写道: Hi all, Here's v2 where things start to look more realistic, hence the expanded CC list. The patches are now based on the current iommu/core branch to take John's

Re: [PATCH v2 00/24] iommu: Refactor DMA domain strictness

2021-07-28 Thread chenxiang (M)
Hi Robin, 在 2021/7/28 23:58, Robin Murphy 写道: Hi all, Here's v2 where things start to look more realistic, hence the expanded CC list. The patches are now based on the current iommu/core branch to take John's iommu_set_dma_strict() cleanup into account. The series remiains in two (or

Re: [PATCH v7 00/15] Optimizing iommu_[map/unmap] performance

2021-07-14 Thread chenxiang (M)
在 2021/7/15 9:23, Lu Baolu 写道: On 7/14/21 10:24 PM, Georgi Djakov wrote: On 16.06.21 16:38, Georgi Djakov wrote: 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

Re: [Linuxarm] Re: [PATCH 0/4] Free cached iovas when rmmod the driver of the last device in group

2021-06-08 Thread chenxiang (M)
Hi Robin, 在 2021/6/7 19:23, Robin Murphy 写道: On 2021-06-07 03:42, chenxiang wrote: From: Xiang Chen When rmmod the driver of the last device in the group, cached iovas are not used, and it is better to free them to save memories. And also export function free_rcache_cached_iovas

[PATCH 4/4] iommu: free cached iovas when rmmod the driver of the last device in the group

2021-06-06 Thread chenxiang
From: Xiang Chen When rmmod the driver of the last device in the domain, cached iovas are not used and it is better to free them to save memories. Signed-off-by: Xiang Chen --- drivers/iommu/iommu.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/iommu/iommu.c

[PATCH 1/4] iommu/iova: add a function to free all rcached iovas and export it

2021-06-06 Thread chenxiang
From: Xiang Chen Add a function to free all rcached iovas including cpu rcache iovas and global rcache iovas, and export it. Signed-off-by: Xiang Chen --- drivers/iommu/iova.c | 11 +++ include/linux/iova.h | 5 + 2 files changed, 16 insertions(+) diff --git

[PATCH 2/4] iommu/iova: use function free_rcache_cached_iovas() to free all rcached iovas

2021-06-06 Thread chenxiang
From: Xiang Chen Use function free_rcached_iovas() to free all rcached iovas instead. Signed-off-by: Xiang Chen --- drivers/iommu/iova.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index f595867..59926d5 100644 ---

[PATCH 3/4] dma-iommu: add a interface to get iova_domain from iommu domain

2021-06-06 Thread chenxiang
From: Xiang Chen Add a function iommu_domain_to_iova() to get iova_domain from iommu domain. Signed-off-by: Xiang Chen --- drivers/iommu/dma-iommu.c | 7 +++ include/linux/dma-iommu.h | 6 ++ 2 files changed, 13 insertions(+) diff --git a/drivers/iommu/dma-iommu.c

[PATCH 0/4] Free cached iovas when rmmod the driver of the last device in group

2021-06-06 Thread chenxiang
From: Xiang Chen When rmmod the driver of the last device in the group, cached iovas are not used, and it is better to free them to save memories. And also export function free_rcache_cached_iovas() and iommu_domain_to_iova(). Xiang Chen (4): iommu/iova: add a function to free all rcached

Re: [PATCH] dma-iommu: Add a check to avoid dereference null pointer in function iommu_dma_map_sg()

2021-05-21 Thread chenxiang (M)
在 2021/5/21 18:36, Robin Murphy 写道: On 2021-05-21 04:05, chenxiang wrote: From: Xiang Chen The issue is reported by tool TscanCode, and it is possible to deference null pointer when prev is NULL which is the initial value. No it isn't. This is literally explained in the comment visible

[PATCH] dma-iommu: Add a check to avoid dereference null pointer in function iommu_dma_map_sg()

2021-05-20 Thread chenxiang
From: Xiang Chen The issue is reported by tool TscanCode, and it is possible to deference null pointer when prev is NULL which is the initial value. Signed-off-by: Xiang Chen --- drivers/iommu/dma-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git

Re: [PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock

2021-05-18 Thread chenxiang (M)
Hi Joerg, 在 2021/5/18 17:08, Joerg Roedel 写道: On Mon, Apr 19, 2021 at 03:13:35PM +0800, chenxiang wrote: From: Xiang Chen It is not necessary to put free_iova_mem() inside of spinlock/unlock iova_rbtree_lock which only leads to more completion for the spinlock. It has a small promote

[RESEND PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock

2021-05-10 Thread chenxiang
From: Xiang Chen It is not necessary to put free_iova_mem() inside of spinlock/unlock iova_rbtree_lock which only leads to more completion for the spinlock. It has a small promote on the performance after the change. And also rename private_free_iova() as remove_iova() because the function will

Re: [RFC PATCH v5 11/15] iommu/io-pgtable-arm: Implement arm_lpae_map_pages()

2021-04-19 Thread chenxiang (M)
Hi Isaac, 在 2021/4/9 1:13, Isaac J. Manjarres 写道: Implement the map_pages() callback for the ARM LPAE io-pgtable format. Signed-off-by: Isaac J. Manjarres --- drivers/iommu/io-pgtable-arm.c | 42 ++ 1 file changed, 32 insertions(+), 10 deletions(-) diff

[PATCH v3] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock

2021-04-19 Thread chenxiang
From: Xiang Chen It is not necessary to put free_iova_mem() inside of spinlock/unlock iova_rbtree_lock which only leads to more completion for the spinlock. It has a small promote on the performance after the change. And also rename private_free_iova() as remove_iova() because the function will

Re: [PATCH v2] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock

2021-04-16 Thread chenxiang (M)
在 2021/4/16 16:53, John Garry 写道: On 16/04/2021 04:30, chenxiang (M) wrote: you need to make this: if (iova) free_iova_mem(iova); as free_iova_mem(iova) dereferences iova: if (iova->pfn_lo != IOVA_ANCHOR) kmem_cache_free(iova_cache, iova) So if iova were NULL, we cr

Re: [PATCH v2] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock

2021-04-15 Thread chenxiang (M)
在 2021/4/15 17:49, John Garry 写道: On 15/04/2021 04:52, chenxiang wrote: From: Xiang Chen It is not necessary to put free_iova_mem() inside of spinlock/unlock iova_rbtree_lock which only leads to more completion for the spinlock. It has a small promote on the performance after the change

[PATCH v2] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock

2021-04-14 Thread chenxiang
From: Xiang Chen It is not necessary to put free_iova_mem() inside of spinlock/unlock iova_rbtree_lock which only leads to more completion for the spinlock. It has a small promote on the performance after the change. And also rename private_free_iova() as remove_iova() because the function will

Re: [PATCH] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock

2021-04-14 Thread chenxiang (M)
Hi Robin, 在 2021/4/14 21:17, Robin Murphy 写道: On 2021-04-14 07:38, chenxiang wrote: From: Xiang Chen It is not necessary to put free_iova_mem() inside of spinlock/unlock iova_rbtree_lock which only leads to more completion for the spinlock. It has a small promote on the performance after

[PATCH] iommu/iova: put free_iova_mem() outside of spinlock iova_rbtree_lock

2021-04-14 Thread chenxiang
From: Xiang Chen It is not necessary to put free_iova_mem() inside of spinlock/unlock iova_rbtree_lock which only leads to more completion for the spinlock. It has a small promote on the performance after the change. Signed-off-by: Xiang Chen --- drivers/iommu/iova.c | 5 +++-- 1 file

Re: [PATCH] iommu: Add device name to iommu map/unmap trace events

2021-04-06 Thread chenxiang (M)
Hi, 在 2021/2/12 18:50, Joerg Roedel 写道: On Tue, Feb 09, 2021 at 06:06:20PM +0530, Sai Prakash Ranjan wrote: diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 5e7fe519430a..6064187d9bb6 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -87,6 +87,7 @@ struct

Re: [RFC PATCH 0/5] Optimization for unmapping iommu mapped buffers

2021-03-31 Thread chenxiang (M)
Hi Isaac, 在 2021/3/31 11:00, 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

[PATCH v2] iommu/arm-smmu-v3: Add a check to avoid invalid iotlb sync

2021-03-30 Thread chenxiang
From: Xiang Chen It may send a invalid tlb sync for smmuv3 if iotlb_gather is not valid (iotlb_gather->pgsize = 0). So add a check to avoid invalid iotlb sync for it. Signed-off-by: Xiang Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 3 +++ 1 file changed, 3 insertions(+) diff --git

Re: [PATCH] iommu: Add a check to avoid invalid iotlb sync

2021-03-30 Thread chenxiang (M)
在 2021/3/30 17:25, Will Deacon 写道: On Tue, Mar 30, 2021 at 10:04:53AM +0100, Robin Murphy wrote: On 2021-03-30 02:22, chenxiang (M) wrote: Hi Will, 在 2021/3/29 22:45, Will Deacon 写道: On Sat, Mar 27, 2021 at 02:23:10PM +0800, chenxiang wrote: From: Xiang Chen Currently it will send

Re: [PATCH] iommu: Add a check to avoid invalid iotlb sync

2021-03-29 Thread chenxiang (M)
Hi Will, 在 2021/3/29 22:45, Will Deacon 写道: On Sat, Mar 27, 2021 at 02:23:10PM +0800, chenxiang wrote: From: Xiang Chen Currently it will send a iotlb sync at end of iommu unmap even if iotlb_gather is not valid (iotlb_gather->pgsize = 0). Actually it is not necessary, so add a ch

[PATCH] iommu: Add a check to avoid invalid iotlb sync

2021-03-27 Thread chenxiang
From: Xiang Chen Currently it will send a iotlb sync at end of iommu unmap even if iotlb_gather is not valid (iotlb_gather->pgsize = 0). Actually it is not necessary, so add a check to avoid invalid iotlb sync. Signed-off-by: Xiang Chen --- include/linux/iommu.h | 3 +++ 1 file changed, 3

[PATCH] iommu: Fix a boundary issue to avoid performance drop

2021-03-24 Thread chenxiang
From: Xiang Chen After the change of patch ("iommu: Switch gather->end to the inclusive end"), the performace drops from 1600+K IOPS to 1200K in our kunpeng ARM64 platform. We find that the range [start1, end1) actually is joint from the range [end1, end2), but it is considered as disjoint

Re: [Linuxarm] Re: [PATCH v14 07/13] iommu/smmuv3: Implement cache_invalidate

2021-03-22 Thread chenxiang (M)
Hi Eric, 在 2021/3/22 17:05, Auger Eric 写道: Hi Chenxiang, On 3/22/21 7:40 AM, chenxiang (M) wrote: Hi Eric, 在 2021/3/20 1:36, Auger Eric 写道: Hi Chenxiang, On 3/4/21 8:55 AM, chenxiang (M) wrote: Hi Eric, 在 2021/2/24 4:56, Eric Auger 写道: Implement domain-selective, pasid selective

Re: [Linuxarm] Re: [PATCH v14 07/13] iommu/smmuv3: Implement cache_invalidate

2021-03-22 Thread chenxiang (M)
Hi Eric, 在 2021/3/20 1:36, Auger Eric 写道: Hi Chenxiang, On 3/4/21 8:55 AM, chenxiang (M) wrote: Hi Eric, 在 2021/2/24 4:56, Eric Auger 写道: Implement domain-selective, pasid selective and page-selective IOTLB invalidations. Signed-off-by: Eric Auger --- v13 -> v14: - Add dom

Re: [PATCH] iommu/dma: Fix a typo in a comment

2021-03-21 Thread chenxiang (M)
在 2021/3/19 19:02, Robin Murphy 写道: On 2021-03-19 01:02, chenxiang (M) wrote: Hi, 在 2021/3/18 19:01, Robin Murphy 写道: On 2021-03-18 09:55, chenxiang (M) wrote: Hi will, 在 2021/3/18 17:34, Will Deacon 写道: On Thu, Mar 18, 2021 at 11:21:24AM +0800, chenxiang wrote: From: Xiang Chen Fix

Re: [PATCH] iommu/dma: Fix a typo in a comment

2021-03-18 Thread chenxiang (M)
Hi, 在 2021/3/18 19:01, Robin Murphy 写道: On 2021-03-18 09:55, chenxiang (M) wrote: Hi will, 在 2021/3/18 17:34, Will Deacon 写道: On Thu, Mar 18, 2021 at 11:21:24AM +0800, chenxiang wrote: From: Xiang Chen Fix a type "SAC" to "DAC" in the comment of function iommu_dma_a

Re: [PATCH] iommu/dma: Fix a typo in a comment

2021-03-18 Thread chenxiang (M)
Hi will, 在 2021/3/18 17:34, Will Deacon 写道: On Thu, Mar 18, 2021 at 11:21:24AM +0800, chenxiang wrote: From: Xiang Chen Fix a type "SAC" to "DAC" in the comment of function iommu_dma_alloc_iova(). Signed-off-by: Xiang Chen --- drivers/iommu/dma-iommu.c | 2 +-

[PATCH] dma-mapping: benchmark: Add support for multi-pages map/unmap

2021-03-18 Thread chenxiang
From: Xiang Chen Currently it only support one page map/unmap once a time for dma-map benchmark, but there are some other scenaries which need to support for multi-page map/unmap: for those multi-pages interfaces such as dma_alloc_coherent() and dma_map_sg(), the time spent on multi-pages

[PATCH] iommu/dma: Fix a typo in a comment

2021-03-17 Thread chenxiang
From: Xiang Chen Fix a type "SAC" to "DAC" in the comment of function iommu_dma_alloc_iova(). Signed-off-by: Xiang Chen --- drivers/iommu/dma-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index

Re: [PATCH v14 07/13] iommu/smmuv3: Implement cache_invalidate

2021-03-03 Thread chenxiang (M)
Hi Eric, 在 2021/2/24 4:56, Eric Auger 写道: Implement domain-selective, pasid selective and page-selective IOTLB invalidations. Signed-off-by: Eric Auger --- v13 -> v14: - Add domain invalidation - do global inval when asid is not provided with addr granularity v7 -> v8: - ASID based

Re: [PATCH 1/1] Revert "iommu/iova: Retry from last rb tree node if iova search fails"

2021-01-29 Thread chenxiang (M)
Hi Robin, 在 2021/1/29 20:03, Robin Murphy 写道: On 2021-01-29 09:48, Leizhen (ThunderTown) wrote: Currently, we are thinking about the solution to the problem. However, because the end time of v5.11 is approaching, this patch is sent first. However, that commit was made for a reason - how

Re: [PATCH v13 08/15] iommu/smmuv3: Implement cache_invalidate

2021-01-15 Thread chenxiang (M)
Hi Eric, 在 2020/11/18 19:21, Eric Auger 写道: Implement domain-selective and page-selective IOTLB invalidations. Signed-off-by: Eric Auger --- v7 -> v8: - ASID based invalidation using iommu_inv_pasid_info - check ARCHID/PASID flags in addr based invalidation - use __arm_smmu_tlb_inv_context

Re: Consult on ARM SMMU debugfs

2021-01-15 Thread chenxiang (M)
在 2021/1/12 4:01, Robin Murphy 写道: On 2021-01-07 02:45, chenxiang (M) wrote: Hi Will, Robin or other guys, When debugging SMMU/SVA issue on huawei ARM64 board, we find that it lacks of enough debugfs for ARM SMMU driver (such as the value of STE/CD which we need to check sometimes

Consult on ARM SMMU debugfs

2021-01-06 Thread chenxiang (M)
Hi Will, Robin or other guys, When debugging SMMU/SVA issue on huawei ARM64 board, we find that it lacks of enough debugfs for ARM SMMU driver (such as the value of STE/CD which we need to check sometimes). Currently it creates top-level iommu directory in debugfs, but there is no debugfs