[PATCH v3 00/25] iommu: Refactor DMA domain strictness

2021-08-04 Thread Robin Murphy
g CC: Maxime Ripard CC: Jean-Philippe Brucker CC: Sai Praneeth Prakhya Robin Murphy (25): iommu: Pull IOVA cookie management into the core iommu/amd: Drop IOVA cookie management iommu/arm-smmu: Drop IOVA cookie management iommu/vt-d: Drop IOVA cookie management iommu/exynos: Drop

Re: [PATCH v10 01/17] iova: Export alloc_iova_fast() and free_iova_fast()

2021-08-04 Thread Robin Murphy
On 2021-08-04 06:02, Yongji Xie wrote: On Tue, Aug 3, 2021 at 6:54 PM Robin Murphy wrote: On 2021-08-03 09:54, Yongji Xie wrote: On Tue, Aug 3, 2021 at 3:41 PM Jason Wang wrote: 在 2021/7/29 下午3:34, Xie Yongji 写道: Export alloc_iova_fast() and free_iova_fast() so that some modules can use

Re: [PATCH v2 23/24] iommu/arm-smmu: Allow non-strict in pgtable_quirks interface

2021-08-03 Thread Robin Murphy
On 2021-08-03 11:36, Will Deacon wrote: On Mon, Aug 02, 2021 at 03:15:50PM +0100, Robin Murphy wrote: On 2021-08-02 14:04, Will Deacon wrote: On Wed, Jul 28, 2021 at 04:58:44PM +0100, Robin Murphy wrote: To make io-pgtable aware of a flush queue being dynamically enabled, allow

Re: [PATCH v10 01/17] iova: Export alloc_iova_fast() and free_iova_fast()

2021-08-03 Thread Robin Murphy
On 2021-08-03 09:54, Yongji Xie wrote: On Tue, Aug 3, 2021 at 3:41 PM Jason Wang wrote: 在 2021/7/29 下午3:34, Xie Yongji 写道: Export alloc_iova_fast() and free_iova_fast() so that some modules can use it to improve iova allocation efficiency. It's better to explain why alloc_iova() is not su

Re: [PATCH v2 0/3] iommu: Enable non-strict DMA on QCom SD/MMC

2021-08-03 Thread Robin Murphy
On 2021-08-03 01:09, Rajat Jain wrote: Hi Robin, Doug, On Wed, Jul 14, 2021 at 8:14 AM Doug Anderson wrote: Hi, On Tue, Jul 13, 2021 at 11:07 AM Robin Murphy wrote: On 2021-07-08 15:36, Doug Anderson wrote: [...] Or document for the users that want performance how to change the setting

Re: [PATCH v4 5/6] iova: Add iova_len argument to init_iova_domain()

2021-08-02 Thread Robin Murphy
On 2021-08-02 17:06, John Garry wrote: On 02/08/2021 16:06, Will Deacon wrote: On Wed, Jul 14, 2021 at 06:36:42PM +0800, John Garry wrote: Add max opt argument to init_iova_domain(), and use it to set the rcaches range. Also fix up all users to set this value (at 0, meaning use default). Wra

Re: [PATCH v4 2/6] iova: Allow rcache range upper limit to be flexible

2021-08-02 Thread Robin Murphy
On 2021-08-02 16:23, John Garry wrote: On 02/08/2021 16:01, Will Deacon wrote: On Wed, Jul 14, 2021 at 06:36:39PM +0800, John Garry wrote: Some LLDs may request DMA mappings whose IOVA length exceeds that of the current rcache upper limit. What's an LLD? low-level driver maybe I'll stick

Re: [Patch V2 0/2] iommu/arm-smmu: Fix races in iommu domain/group creation

2021-08-02 Thread Robin Murphy
On 2021-08-02 16:16, Will Deacon wrote: On Fri, Jun 18, 2021 at 02:00:35AM +0530, Ashish Mhetre wrote: Multiple iommu domains and iommu groups are getting created for the devices sharing same SID. It is expected for devices sharing same SID to be in same iommu group and same iommu domain. This i

Re: [PATCH v2 23/24] iommu/arm-smmu: Allow non-strict in pgtable_quirks interface

2021-08-02 Thread Robin Murphy
On 2021-08-02 14:04, Will Deacon wrote: On Wed, Jul 28, 2021 at 04:58:44PM +0100, Robin Murphy wrote: To make io-pgtable aware of a flush queue being dynamically enabled, allow IO_PGTABLE_QUIRK_NON_STRICT to be set even after a domain has been attached to, and hook up the final piece of the

Re: [PATCH v7 3/4] iommu: rockchip: Add internal ops to handle variants

2021-07-30 Thread Robin Murphy
On 2021-07-30 13:52, Dafna Hirschfeld wrote: On 29.07.21 18:58, Robin Murphy wrote: On 2021-07-29 17:08, Heiko Stübner wrote: Hi Dafna, Am Donnerstag, 29. Juli 2021, 17:59:26 CEST schrieb Dafna Hirschfeld: On 25.05.21 14:15, Benjamin Gaignard wrote: @@ -879,7 +895,7 @@ static int

Re: [PATCH v7 3/4] iommu: rockchip: Add internal ops to handle variants

2021-07-29 Thread Robin Murphy
On 2021-07-29 17:08, Heiko Stübner wrote: Hi Dafna, Am Donnerstag, 29. Juli 2021, 17:59:26 CEST schrieb Dafna Hirschfeld: On 25.05.21 14:15, Benjamin Gaignard wrote: @@ -879,7 +895,7 @@ static int rk_iommu_enable(struct rk_iommu *iommu) for (i = 0; i < iommu->num_mmu; i++) {

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

2021-07-29 Thread Robin Murphy
On 2021-07-29 16:53, Heiko Stübner wrote: Am Donnerstag, 29. Juli 2021, 17:43:07 CEST schrieb Robin Murphy: On 2021-07-29 16:04, Heiko Stübner wrote: Hi Robin, Am Mittwoch, 28. Juli 2021, 17:58:21 CEST schrieb Robin Murphy: Hi all, Here's v2 where things start to look more realistic,

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

2021-07-29 Thread Robin Murphy
On 2021-07-29 16:04, Heiko Stübner wrote: Hi Robin, Am Mittwoch, 28. Juli 2021, 17:58:21 CEST schrieb 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 J

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

2021-07-29 Thread 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 iommu_set_dma_strict() cl

Re: [PATCH v2 18/24] iommu: Express DMA strictness via the domain type

2021-07-29 Thread Robin Murphy
On 2021-07-29 08:13, Lu Baolu wrote: Hi Robin, On 7/28/21 11:58 PM, Robin Murphy wrote: diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 982545234cf3..eecb5657de69 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -136,6 +136,9 @@ static int __init

[PATCH v2 24/24] iommu: Only log strictness for DMA domains

2021-07-28 Thread Robin Murphy
When passthrough is enabled, the default strictness policy becomes irrelevant, since any subsequent runtime override to a DMA domain type now embodies an explicit choice of strictness as well. Save on noise by only logging the default policy when it is meaningfully in effect. Signed-off-by: Robin

[PATCH v2 23/24] iommu/arm-smmu: Allow non-strict in pgtable_quirks interface

2021-07-28 Thread Robin Murphy
To make io-pgtable aware of a flush queue being dynamically enabled, allow IO_PGTABLE_QUIRK_NON_STRICT to be set even after a domain has been attached to, and hook up the final piece of the puzzle in iommu-dma. Signed-off-by: Robin Murphy --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 15

[PATCH v2 21/24] iommu/dma: Factor out flush queue init

2021-07-28 Thread Robin Murphy
Factor out flush queue setup from the initial domain init so that we can potentially trigger it from sysfs later on in a domain's lifetime. Signed-off-by: Robin Murphy --- drivers/iommu/dma-iommu.c | 30 -- include/linux/dma-iommu.h | 9 ++--- 2 files ch

[PATCH v2 22/24] iommu: Allow enabling non-strict mode dynamically

2021-07-28 Thread Robin Murphy
such a clear use-case for tightening up security *after* the device may already have done whatever it is that you don't trust it not to do, so we only consider the relaxation case. Signed-off-by: Robin Murphy --- drivers/iommu/iommu.c | 16 1 file changed, 12 insertions(+), 4

[PATCH v2 20/24] iommu: Merge strictness and domain type configs

2021-07-28 Thread Robin Murphy
To parallel the sysfs behaviour, merge the new build-time option for DMA domain strictness into the default domain type choice. Suggested-by: Joerg Roedel Signed-off-by: Robin Murphy --- drivers/iommu/Kconfig | 80 +-- drivers/iommu/iommu.c | 2 +- 2

[PATCH v2 18/24] iommu: Express DMA strictness via the domain type

2021-07-28 Thread Robin Murphy
. - Ensures that we only end up using flush queues for drivers which are aware of them and can actually benefit. - Allows us to handle flush queue init failure by falling back to strict mode instead of leaving it to possibly blow up later. Signed-off-by: Robin Murphy --- drivers/iommu/arm

[PATCH v2 19/24] iommu: Expose DMA domain strictness via sysfs

2021-07-28 Thread Robin Murphy
ce as well. Signed-off-by: Robin Murphy --- Documentation/ABI/testing/sysfs-kernel-iommu_groups | 2 ++ drivers/iommu/iommu.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-kernel-iommu_groups b/Documentation/ABI/testing/

[PATCH v2 17/24] iommu/vt-d: Prepare for multiple DMA domain types

2021-07-28 Thread Robin Murphy
simply be made unconditional, since iommu-dma already knows only to touch DMA domains. Signed-off-by: Robin Murphy --- drivers/iommu/intel/iommu.c | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index

[PATCH v2 16/24] iommu/arm-smmu: Prepare for multiple DMA domain types

2021-07-28 Thread Robin Murphy
In preparation for the strict vs. non-strict decision for DMA domains to be expressed in the domain type, make sure we expose our flush queue awareness by accepting the new domain type. Signed-off-by: Robin Murphy --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 1 + drivers/iommu/arm/arm-smmu

[PATCH v2 15/24] iommu/amd: Prepare for multiple DMA domain types

2021-07-28 Thread Robin Murphy
The DMA ops reset/setup can simply be unconditional, since iommu-dma already knows only to touch DMA domains. Signed-off-by: Robin Murphy --- drivers/iommu/amd/iommu.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd

[PATCH v2 13/24] iommu/dma: Remove redundant "!dev" checks

2021-07-28 Thread Robin Murphy
iommu_dma_init_domain() is now only called from iommu_setup_dma_ops(), which has already assumed dev to be non-NULL. Reviewed-by: John Garry Signed-off-by: Robin Murphy --- drivers/iommu/dma-iommu.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iommu/dma

[PATCH v2 14/24] iommu: Introduce explicit type for non-strict DMA domains

2021-07-28 Thread Robin Murphy
Promote the difference between strict and non-strict DMA domains from an internal detail to a distinct domain feature and type, to pave the road for exposing it through the sysfs default domain interface. Signed-off-by: Robin Murphy --- drivers/iommu/dma-iommu.c | 2 +- drivers/iommu/iommu.c

[PATCH v2 12/24] iommu/dma: Unexport IOVA cookie management

2021-07-28 Thread Robin Murphy
IOVA cookies are now got and put by core code, so we no longer need to export these to modular drivers. The export for getting MSI cookies stays, since VFIO can still be a module, but it was already relying on someone else putting them, so that aspect is unaffected. Signed-off-by: Robin Murphy

[PATCH v2 11/24] iommu/virtio: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. CC: Jean-Philippe Brucker Signed-off-by: Robin Murphy --- drivers/iommu/virtio-iommu.c | 8 1 file changed, 8 deletions(-) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index 6abdcab7273b..80930ce04a16 100644 --- a

[PATCH v2 10/24] iommu/sun50i: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. CC: Maxime Ripard Signed-off-by: Robin Murphy --- drivers/iommu/sun50i-iommu.c | 12 +--- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index 181bb1c3437c..c349a95ec7bd

[PATCH v2 09/24] iommu/sprd: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. CC: Chunyan Zhang Signed-off-by: Robin Murphy --- drivers/iommu/sprd-iommu.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/iommu/sprd-iommu.c b/drivers/iommu/sprd-iommu.c index 73dfd9946312..2bc1de6e823d 100644 --- a/drivers/iommu

[PATCH v2 08/24] iommu/rockchip: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. CC: Heiko Stuebner Signed-off-by: Robin Murphy --- drivers/iommu/rockchip-iommu.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 9febfb7f3025

[PATCH v2 07/24] iommu/mtk: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. CC: Yong Wu Signed-off-by: Robin Murphy --- drivers/iommu/mtk_iommu.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 6f7c69688ce2..e39a6d1da28d 100644 --- a/drivers/iommu/mtk_iommu.c

[PATCH v2 06/24] iommu/ipmmu-vmsa: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. CC: Yoshihiro Shimoda CC: Geert Uytterhoeven Signed-off-by: Robin Murphy --- drivers/iommu/ipmmu-vmsa.c | 27 --- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu

[PATCH v2 05/24] iommu/exynos: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. CC: Marek Szyprowski Signed-off-by: Robin Murphy --- drivers/iommu/exynos-iommu.c | 18 -- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index d0fbf1d10e18

[PATCH v2 04/24] iommu/vt-d: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/intel/iommu.c | 8 1 file changed, 8 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index c12cc955389a..7e168634c433 100644 --- a/drivers/iommu/intel/iommu.c

[PATCH v2 02/24] iommu/amd: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/amd/iommu.c | 12 1 file changed, 12 deletions(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 52fe2326042a..0fd98d35d73b 100644 --- a/drivers/iommu/amd/iommu.c +++ b

[PATCH v2 03/24] iommu/arm-smmu: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 7 --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 15 --- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 8 3 files changed, 4 insertions(+), 26

[PATCH v2 01/24] iommu: Pull IOVA cookie management into the core

2021-07-28 Thread Robin Murphy
Stuebner CC: Chunyan Zhang CC: Chunyan Zhang CC: Maxime Ripard CC: Jean-Philippe Brucker Signed-off-by: Robin Murphy --- drivers/iommu/iommu.c | 7 +++ include/linux/iommu.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu

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

2021-07-28 Thread Robin Murphy
. Once again, the whole lot is available on a branch here: https://gitlab.arm.com/linux-arm/linux-rm/-/tree/iommu/fq Thanks, Robin. CC: Marek Szyprowski CC: Yoshihiro Shimoda CC: Geert Uytterhoeven CC: Yong Wu CC: Heiko Stuebner CC: Chunyan Zhang CC: Chunyan Zhang CC: Maxime Ripard CC: J

Re: [bug report] iommu_dma_unmap_sg() is very slow then running IO from remote numa node

2021-07-28 Thread Robin Murphy
On 2021-07-28 16:17, Ming Lei wrote: On Wed, Jul 28, 2021 at 11:38:18AM +0100, John Garry wrote: On 28/07/2021 02:32, Ming Lei wrote: On Mon, Jul 26, 2021 at 3:51 PM John Garry wrote: On 23/07/2021 11:21, Ming Lei wrote: Thanks, I was also going to suggest the latter, since it's what arm_smm

Re: [bug report] iommu_dma_unmap_sg() is very slow then running IO from remote numa node

2021-07-27 Thread Robin Murphy
On 2021-07-23 11:21, Ming Lei wrote: On Thu, Jul 22, 2021 at 06:40:18PM +0100, Robin Murphy wrote: On 2021-07-22 16:54, Ming Lei wrote: [...] If you are still keen to investigate more, then can try either of these: - add iommu.strict=0 to the cmdline - use perf record+annotate to find the

Re: [PATCH] iommu/iova: kmemleak when disable SRIOV.

2021-07-27 Thread Robin Murphy
----Original Message- From: Robin Murphy Sent: Tuesday, July 27, 2021 4:52 PM To: Zhou, Peng Ju ; iommu@lists.linux- foundation.org Cc: Deucher, Alexander ; Wang, Yin ; w...@kernel.org Subject: Re: [PATCH] iommu/iova: kmemleak when disable SRIOV. On 2021-07-27 05:46, Zhou, Peng Ju wrote: [AMD Offi

Re: [PATCH -next v2] iommu/arm-smmu-v3: Add suspend and resume support

2021-07-27 Thread Robin Murphy
On 2021-07-27 13:14, Bixuan Cui wrote: Add suspend and resume support for arm-smmu-v3 by low-power mode. When the smmu is suspended, it is powered off and the registers are cleared. So saves the msi_msg context during msi interrupt initialization of smmu. When resume happens it calls arm_smmu_de

Re: [PATCH] iommu/arm-smmu: Add clk_bulk_{prepare/unprepare} to system pm callbacks

2021-07-27 Thread Robin Murphy
On 2021-07-27 11:25, Robin Murphy wrote: On 2021-07-27 10:33, Sai Prakash Ranjan wrote: Some clocks for SMMU can have parent as XO such as gpu_cc_hub_cx_int_clk of GPU SMMU in QTI SC7280 SoC and in order to enter deep sleep states in such cases, we would need to drop the XO clock vote in

Re: [PATCH] iommu/arm-smmu: Add clk_bulk_{prepare/unprepare} to system pm callbacks

2021-07-27 Thread Robin Murphy
On 2021-07-27 10:33, Sai Prakash Ranjan wrote: Some clocks for SMMU can have parent as XO such as gpu_cc_hub_cx_int_clk of GPU SMMU in QTI SC7280 SoC and in order to enter deep sleep states in such cases, we would need to drop the XO clock vote in unprepare call and this unprepare callback for XO

Re: [PATCH] iommu/iova: kmemleak when disable SRIOV.

2021-07-27 Thread Robin Murphy
/0x300 316676 Jul 19 02:14:20 z-u18 kernel: [ 108.969729] sriov_enable+0x254/0x410 ------ BW Pengju Zhou -Original Message- From: Robin Murphy Sent: Thursday, July 22, 2021 10:59 PM To: Zhou, Peng Ju ; iommu@lists.lin

Re: [PATCH 16/23] iommu/arm-smmu: Prepare for multiple DMA domain types

2021-07-26 Thread Robin Murphy
On 2021-07-26 13:46, Joerg Roedel wrote: On Wed, Jul 21, 2021 at 07:20:27PM +0100, Robin Murphy wrote: - if (type == IOMMU_DOMAIN_DMA && using_legacy_binding) + if ((type & __IOMMU_DOMAIN_DMA_API) && using_legacy_binding) Hmm, I wonder whether it is time to i

Re: [PATCH 18/23] iommu: Express DMA strictness via the domain type

2021-07-26 Thread Robin Murphy
On 2021-07-26 13:29, Lu Baolu wrote: [...] diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index b1af1ff324c5..a114a7ad88ec 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -363,13 +363,15 @@ static int iommu_dma_init_domain(struct iommu_domain *domain

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

2021-07-26 Thread Robin Murphy
On 2021-07-26 09:13, John Garry wrote: On 21/07/2021 19:20, Robin Murphy wrote: Hi all, First off, yes, this conflicts with just about everything else currently in-flight. Sorry about that. If it stands up to initial review then I'll start giving some thought to how to fit everything tog

Re: [PATCH 17/23] iommu/vt-d: Prepare for multiple DMA domain types

2021-07-26 Thread Robin Murphy
On 2021-07-24 06:23, Lu Baolu wrote: Hi Robin, On 2021/7/22 2:20, Robin Murphy wrote: In preparation for the strict vs. non-strict decision for DMA domains to be expressed in the domain type, make sure we expose our flush queue awareness by accepting the new domain type, and test the specific

Re: [PATCH 18/23] iommu: Express DMA strictness via the domain type

2021-07-26 Thread Robin Murphy
On 2021-07-24 06:29, Lu Baolu wrote: Hi Robin, On 2021/7/22 2:20, Robin Murphy wrote: Eliminate the iommu_get_dma_strict() indirection and pipe the information through the domain type from the beginning. Besides the flow simplification this also has several nice side-effects

Re: [bug report] iommu_dma_unmap_sg() is very slow then running IO from remote numa node

2021-07-22 Thread Robin Murphy
On 2021-07-22 16:54, Ming Lei wrote: [...] If you are still keen to investigate more, then can try either of these: - add iommu.strict=0 to the cmdline - use perf record+annotate to find the hotspot - For this you need to enable psuedo-NMI with 2x steps: CONFIG_ARM64_PSEUDO_NMI=y in def

Re: [PATCH 17/23] iommu/vt-d: Prepare for multiple DMA domain types

2021-07-22 Thread Robin Murphy
wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Robin-Murphy/iommu-Refactor-DMA-domain-strictness/20210722-022514 base: https://git.

Re: [PATCH] iommu/iova: kmemleak when disable SRIOV.

2021-07-22 Thread Robin Murphy
On 2021-07-22 09:16, Peng Ju Zhou via iommu wrote: the object iova->head allocated statically when enable SRIOV but freed dynamically when disable SRIOV which causing kmemleak. changing the allocation from statically to dynamically. Thanks for the glimpse into the kind of weird and wonderful th

Re: [PATCH] dma-debug: fix debugfs initialization order

2021-07-22 Thread Robin Murphy
On 2021-07-22 10:18, Anthony Iliopoulos wrote: Due to link order, dma_debug_init is called before debugfs has a chance to initialize (via debugfs_init which also happens in the core initcall stage), so the directories for dma-debug are never created. Move the dma_debug_init initcall from core to

[PATCH 23/23] iommu/arm-smmu: Allow non-strict in pgtable_quirks interface

2021-07-21 Thread Robin Murphy
To make io-pgtable aware of a flush queue being dynamically enabled, allow IO_PGTABLE_QUIRK_NON_STRICT to be set even after a domain has been attached to, and hook up the final piece of the puzzle in iommu-dma. Signed-off-by: Robin Murphy --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 15

[PATCH 22/23] iommu: Allow enabling non-strict mode dynamically

2021-07-21 Thread Robin Murphy
such a clear use-case for tightening up security *after* the device may already have done whatever it is that you don't trust it not to do, so we only consider the relaxation case. Signed-off-by: Robin Murphy --- drivers/iommu/iommu.c | 16 1 file changed, 12 insertions(+), 4

[PATCH 21/23] iommu/dma: Factor out flush queue init

2021-07-21 Thread Robin Murphy
Factor out flush queue setup from the initial domain init so that we can potentially trigger it from sysfs later on in a domain's lifetime. Signed-off-by: Robin Murphy --- drivers/iommu/dma-iommu.c | 31 --- include/linux/dma-iommu.h | 9 ++--- 2 files ch

[PATCH 20/23] iommu: Allow choosing DMA strictness at build time

2021-07-21 Thread Robin Murphy
To parallel the sysfs behaviour, extend the build-time configuration for default domains to include the new type as well. Signed-off-by: Robin Murphy --- This effectively replaces patch #3 of John's "iommu: Enhance IOMMU default DMA mode build options" series. --- drivers/iom

[PATCH 19/23] iommu: Expose DMA domain strictness via sysfs

2021-07-21 Thread Robin Murphy
ce as well. Signed-off-by: Robin Murphy --- Documentation/ABI/testing/sysfs-kernel-iommu_groups | 2 ++ drivers/iommu/iommu.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-kernel-iommu_groups b/Documentation/ABI/testing/

[PATCH 18/23] iommu: Express DMA strictness via the domain type

2021-07-21 Thread Robin Murphy
. - Ensures that we only ends up using flush queues for drivers which are aware of them and can actually benefit. - Allows us to handle flush queue init failure by falling back to strict mode instead of leaving it to possibly blow up later. Signed-off-by: Robin Murphy --- drivers/iommu

[PATCH 17/23] iommu/vt-d: Prepare for multiple DMA domain types

2021-07-21 Thread Robin Murphy
simply be made unconditional, since iommu-dma already knows not to touch identity domains. Signed-off-by: Robin Murphy --- drivers/iommu/intel/iommu.c | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index

[PATCH 16/23] iommu/arm-smmu: Prepare for multiple DMA domain types

2021-07-21 Thread Robin Murphy
In preparation for the strict vs. non-strict decision for DMA domains to be expressed in the domain type, make sure we expose our flush queue awareness by accepting the new domain type, and test the specific feature flag where we want to identify DMA domains in general. Signed-off-by: Robin

[PATCH 15/23] iommu/amd: Prepare for multiple DMA domain types

2021-07-21 Thread Robin Murphy
The DMA ops setup can simply be unconditional, since iommu-dma already knows not to touch identity domains. Signed-off-by: Robin Murphy --- drivers/iommu/amd/iommu.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd

[PATCH 14/23] iommu: Introduce explicit type for non-strict DMA domains

2021-07-21 Thread Robin Murphy
Promote the difference between strict and non-strict DMA domains from an internal detail to a distinct domain feature and type, to pave the road for exposing it through the sysfs default domain interface. Signed-off-by: Robin Murphy --- drivers/iommu/dma-iommu.c | 2 +- drivers/iommu/iommu.c

[PATCH 13/23] iommu/dma: Remove redundant "!dev" checks

2021-07-21 Thread Robin Murphy
iommu_dma_init_domain() is now only called from iommu_setup_dma_ops(), which has already assumed dev to be non-NULL. Signed-off-by: Robin Murphy --- drivers/iommu/dma-iommu.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma

[PATCH 11/23] iommu/virtio: Drop IOVA cookie management

2021-07-21 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/virtio-iommu.c | 8 1 file changed, 8 deletions(-) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index 6abdcab7273b..80930ce04a16 100644 --- a/drivers/iommu/virtio-iommu.c

[PATCH 12/23] iommu/dma: Unexport IOVA cookie management

2021-07-21 Thread Robin Murphy
IOVA cookies are now got and put by core code, so we no longer need to export these to modular drivers. The export for getting MSI cookies stays, since VFIO can still be a module, but it was already relying on someone else putting them, so that aspect is unaffected. Signed-off-by: Robin Murphy

[PATCH 10/23] iommu/sun50i: Drop IOVA cookie management

2021-07-21 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/sun50i-iommu.c | 12 +--- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index 181bb1c3437c..c349a95ec7bd 100644 --- a

[PATCH 09/23] iommu/sprd: Drop IOVA cookie management

2021-07-21 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/sprd-iommu.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/iommu/sprd-iommu.c b/drivers/iommu/sprd-iommu.c index 73dfd9946312..2bc1de6e823d 100644 --- a/drivers/iommu/sprd-iommu.c +++ b

[PATCH 08/23] iommu/rockchip: Drop IOVA cookie management

2021-07-21 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/rockchip-iommu.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 9febfb7f3025..c24561f54f32 100644 --- a

[PATCH 07/23] iommu/mtk: Drop IOVA cookie management

2021-07-21 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/mtk_iommu.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 6f7c69688ce2..e39a6d1da28d 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers

[PATCH 06/23] iommu/ipmmu-vmsa: Drop IOVA cookie management

2021-07-21 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/ipmmu-vmsa.c | 27 --- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index 51ea6f00db2f..31252268f0d0 100644

[PATCH 05/23] iommu/exynos: Drop IOVA cookie management

2021-07-21 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/exynos-iommu.c | 18 -- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index d0fbf1d10e18..34085d069cda 100644 --- a

[PATCH 04/23] iommu/vt-d: Drop IOVA cookie management

2021-07-21 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/intel/iommu.c | 8 1 file changed, 8 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index dd22fc7d5176..e2add5a0caef 100644 --- a/drivers/iommu/intel/iommu.c

[PATCH 03/23] iommu/arm-smmu: Drop IOVA cookie management

2021-07-21 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 7 --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 10 +++--- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 8 3 files changed, 3 insertions(+), 22

[PATCH 02/23] iommu/amd: Drop IOVA cookie management

2021-07-21 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/amd/iommu.c | 12 1 file changed, 12 deletions(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 811a49a95d04..40ae7130fc80 100644 --- a/drivers/iommu/amd/iommu.c +++ b

[PATCH 01/23] iommu: Pull IOVA cookie management into the core

2021-07-21 Thread Robin Murphy
Now that everyone has converged on iommu-dma for IOMMU_DOMAIN_DMA support, we can abandon the notion of drivers being responsible for the cookie type, and consolidate all the management into the core code. Signed-off-by: Robin Murphy --- drivers/iommu/iommu.c | 7 +++ include/linux/iommu.h

[PATCH 00/23] iommu: Refactor DMA domain strictness

2021-07-21 Thread Robin Murphy
m slightly surprised at how straightforward it's turned out, but it has survived some very basic smoke testing for arm-smmu using dmatest on my Arm Juno board. Branch here for convenience: https://gitlab.arm.com/linux-arm/linux-rm/-/tree/iommu/fq Please let me know what you think! Robin. R

Re: [PATCH -next] iommu/arm-smmu-v3: Add suspend and resume support

2021-07-21 Thread Robin Murphy
On 2021-07-21 14:12, Marc Zyngier wrote: On Wed, 21 Jul 2021 12:42:14 +0100, Robin Murphy wrote: [ +Marc for MSI bits ] On 2021-07-21 02:33, Bixuan Cui wrote: Add suspend and resume support for arm-smmu-v3 by low-power mode. When the smmu is suspended, it is powered off and the registers

Re: [PATCH -next] iommu/arm-smmu-v3: Add suspend and resume support

2021-07-21 Thread Robin Murphy
[ +Marc for MSI bits ] On 2021-07-21 02:33, Bixuan Cui wrote: Add suspend and resume support for arm-smmu-v3 by low-power mode. When the smmu is suspended, it is powered off and the registers are cleared. So saves the msi_msg context during msi interrupt initialization of smmu. When resume happ

Re: [PATCH 4/5] iommu/vt-d: Disallow SVA if devices don't support 64-bit address

2021-07-21 Thread Robin Murphy
On 2021-07-21 02:50, Lu Baolu wrote: Hi Robin, Thanks a lot for reviewing my patch! On 7/20/21 5:27 PM, Robin Murphy wrote: On 2021-07-20 02:38, Lu Baolu wrote: When the device and CPU share an address space (such as SVA), the device must support the same addressing capability as the CPU

Re: [PATCH 4/5] iommu/vt-d: Disallow SVA if devices don't support 64-bit address

2021-07-20 Thread Robin Murphy
On 2021-07-20 02:38, Lu Baolu wrote: When the device and CPU share an address space (such as SVA), the device must support the same addressing capability as the CPU. The CPU does not consider the addressing ability of any device when managing the page table of a process, so the device must have e

Re: [PATCH v4 3/3] iommu: dart: Add DART iommu driver

2021-07-19 Thread Robin Murphy
On 2021-07-15 17:41, Sven Peter via iommu wrote: [...] + u64 sw_bypass_cpu_start; + u64 sw_bypass_dma_start; + u64 sw_bypass_len; + + struct list_head streams; I'm staring to think this could just be a bitmap, in a u16 even. The problem is that these streams may come f

Re: [PATCH v4 6/6] dma-iommu: Pass iova len for IOVA domain init

2021-07-19 Thread Robin Murphy
er 2021-06-18  333 dma_addr_t limit, struct device *dev) 0db2e5d18f76a6 Robin Murphy  2015-10-01  334  { fdbe574eb69312 Robin Murphy  2017-01-19  335  struct iommu_dma_cookie *cookie = domain->iova_cookie; c61a4633a56aaa Shaokun Zhang 20

Re: [PATCH v4 0/3] Apple M1 DART IOMMU driver

2021-07-16 Thread Robin Murphy
On 2021-07-16 07:24, Christoph Hellwig wrote: On Wed, Jul 14, 2021 at 07:19:50PM +0100, Robin Murphy wrote: Even at the DMA API level you could hide *some* of it (at the cost of effectively only having 1/4 of the usable address space), but there are still cases like where v4l2 has a hard

Re: [PATCH v1 16/16] dma-mapping: Disallow .map_sg operations from returning zero on error

2021-07-16 Thread Robin Murphy
On 2021-07-16 07:33, Christoph Hellwig wrote: On Thu, Jul 15, 2021 at 10:45:44AM -0600, Logan Gunthorpe wrote: @@ -194,6 +194,8 @@ static int __dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, else ents = ops->map_sg(dev, sg, nents, dir, attrs); + WARN_ON_

Re: [PATCH v1 14/16] x86/amd_gart: return error code from gart_map_sg()

2021-07-16 Thread Robin Murphy
On 2021-07-16 07:32, Christoph Hellwig wrote: On Thu, Jul 15, 2021 at 10:45:42AM -0600, Logan Gunthorpe wrote: @@ -458,7 +460,7 @@ static int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, iommu_full(dev, pages << PAGE_SHIFT, dir); for_each_sg(sg, s, nents, i

Re: [PATCH v2] iommu: Streamline iommu_iova_to_phys()

2021-07-16 Thread Robin Murphy
On 2021-07-16 07:19, Christoph Hellwig wrote: On Thu, Jul 15, 2021 at 03:16:08PM +0100, Robin Murphy wrote: On 2021-07-15 15:07, Christoph Hellwig wrote: On Thu, Jul 15, 2021 at 02:04:24PM +0100, Robin Murphy wrote: If people are going to insist on calling iommu_iova_to_phys() pointlessly and

Re: [PATCH v2] iommu: Streamline iommu_iova_to_phys()

2021-07-15 Thread Robin Murphy
On 2021-07-15 15:07, Christoph Hellwig wrote: On Thu, Jul 15, 2021 at 02:04:24PM +0100, Robin Murphy wrote: If people are going to insist on calling iommu_iova_to_phys() pointlessly and expecting it to work, Maybe we need to fix that? Feel free to try, but we didn't have much luck pu

[PATCH v2] iommu: Streamline iommu_iova_to_phys()

2021-07-15 Thread Robin Murphy
internal callback, and any future ones are likely to want to work with iommu-dma which relies on iova_to_phys a fair bit, we may as well remove that currently-redundant check as well and consider it mandatory. Reviewed-by: Lu Baolu Signed-off-by: Robin Murphy --- v2: Lowered the priority of the ops

Re: [PATCH] iommu: Unify iova_to_phys for identity domains

2021-07-15 Thread Robin Murphy
On 2021-07-15 02:38, Lu Baolu wrote: On 7/15/21 1:28 AM, Robin Murphy wrote: If people are going to insist on calling iommu_iova_to_phys() pointlessly and expecting it to work, we can at least do ourselves a favour by handling those cases in the core code, rather than repeatedly across an

Re: [PATCH v4 0/3] Apple M1 DART IOMMU driver

2021-07-14 Thread Robin Murphy
On 2021-06-27 15:34, Sven Peter wrote: [...] In the long term, I'd like to extend the dma-iommu framework itself to support iommu pagesizes with a larger granule than the CPU pagesize if that is something you agree with. BTW this isn't something we can fully support in general. IOMMU API users

[PATCH] iommu: Unify iova_to_phys for identity domains

2021-07-14 Thread Robin Murphy
If people are going to insist on calling iommu_iova_to_phys() pointlessly and expecting it to work, we can at least do ourselves a favour by handling those cases in the core code, rather than repeatedly across an inconsistent handful of drivers. Signed-off-by: Robin Murphy --- drivers/iommu/amd

Re: [PATCH v2 0/3] iommu: Enable non-strict DMA on QCom SD/MMC

2021-07-14 Thread Robin Murphy
On 2021-07-14 11:15, Joerg Roedel wrote: Hi Robin, On Fri, Jul 09, 2021 at 02:56:47PM +0100, Robin Murphy wrote: As I mentioned before, conceptually I think this very much belongs in sysfs as a user decision. We essentially have 4 levels of "strictness": 1: DMA domain with bounce pa

Re: [PATCH v4 3/3] iommu: dart: Add DART iommu driver

2021-07-13 Thread Robin Murphy
^^ Nit: the subsystem style for the subject format should be "iommu/dart: Add..." - similarly on patch #1, which I just realised I missed (sorry!) On 2021-06-27 15:34, Sven Peter wrote: Apple's new SoCs use iommus for almost all peripherals. These Device Address Resolution Tables must be setup

Re: [PATCH v4 1/3] iommu: io-pgtable: add DART pagetable format

2021-07-13 Thread Robin Murphy
clude/linux/io-pgtable.h index 4d40dfa75b55..a4bfac7f85f7 100644 --- a/include/linux/io-pgtable.h +++ b/include/linux/io-pgtable.h @@ -16,6 +16,7 @@ enum io_pgtable_fmt { ARM_V7S, ARM_MALI_LPAE, AMD_IOMMU_V1, + ARM_APPLE_DART, s/ARM_// - this is pure Apple ;) With th

Re: [PATCH v5 5/7] iommu/amd: Tailored gather logic for AMD

2021-07-13 Thread Robin Murphy
tualized environments, check if the newly flushed region and the gathered one are disjoint and flush if it is. Cc: Joerg Roedel Cc: Will Deacon Cc: Jiajun Cao Cc: Lu Baolu Cc: iommu@lists.linux-foundation.org Cc: linux-ker...@vger.kernel.org> Cc: Robin Murphy Signed-off-by: Nadav Amit

Re: [PATCH v5 4/7] iommu: Factor iommu_iotlb_gather_is_disjoint() out

2021-07-13 Thread Robin Murphy
is zero, and "gather" already holds a range, so gather->pgsize is non-zero and (gather->pgsize && gather->pgsize != size) is true. Therefore, again, iommu_iotlb_sync() would be called and initialize the size. With the caveat of one comment on the next patch... Reviewed-by: Rob

<    2   3   4   5   6   7   8   9   10   11   >