iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v8 0/7] iommu: enhance IOMMU default DMA mode build options
@ 2019-05-30  3:48 Zhen Lei
  2019-05-30  3:48 ` [PATCH v8 1/7] " Zhen Lei
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Zhen Lei @ 2019-05-30  3:48 UTC (permalink / raw)
  To: Jean-Philippe Brucker, John Garry, Robin Murphy, Will Deacon,
	Joerg Roedel, Jonathan Corbet, linux-doc, Sebastian Ott,
	Gerald Schaefer, Martin Schwidefsky, Heiko Carstens,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Tony Luck, Fenghua Yu, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin, David Woodhouse, iommu,
	linux-kernel, linux-s390, linuxppc-dev, x86, linux-ia64
  Cc: Hanjun Guo

v7--> v8
1. Split into multiple small patches base on ARCHs or IOMMU drivers.
2. Hide the unsupported build options on the related ARCH or IOMMU.

v6 --> v7:
1. Fix some text editing errors

v5 --> v6:
1. give up adding boot option iommu.dma_mode

v4 --> v5:
As Hanjun and Thomas Gleixner's suggestion:
1. Keep the old ARCH specific boot options no change.
2. Keep build option CONFIG_IOMMU_DEFAULT_PASSTHROUGH no change.

v4:
As Robin Murphy's suggestion:
"It's also not necessarily obvious to the user how this interacts with
IOMMU_DEFAULT_PASSTHROUGH, so if we really do go down this route, maybe it
would be better to refactor the whole lot into a single selection of something
like IOMMU_DEFAULT_MODE anyway."

In this version, I tried to normalize the IOMMU dma mode boot options for all
ARCHs. When IOMMU is enabled, there are 3 dma modes: paasthrough(bypass),
lazy(mapping but defer the IOTLB invalidation), strict. But currently each
ARCHs defined their private boot options, different with each other. For
example, to enable/disable "passthrough", ARM64 use iommu.passthrough=1/0,
X86 use iommu=pt/nopt, PPC/POWERNV use iommu=nobypass.

Zhen Lei (7):
  iommu: enhance IOMMU default DMA mode build options
  x86/dma: use IS_ENABLED() to simplify the code
  s390/pci: add support for IOMMU default DMA mode build options
  powernv/iommu: add support for IOMMU default DMA mode build options
  iommu/vt-d: add support for IOMMU default DMA mode build options
  iommu/amd: add support for IOMMU default DMA mode build options
  ia64: hide build option IOMMU_DEFAULT_PASSTHROUGH

 arch/powerpc/platforms/powernv/pci-ioda.c |  3 +-
 arch/s390/pci/pci_dma.c                   |  2 +-
 arch/x86/kernel/pci-dma.c                 |  7 ++---
 drivers/iommu/Kconfig                     | 46 ++++++++++++++++++++++++++-----
 drivers/iommu/amd_iommu_init.c            |  3 +-
 drivers/iommu/intel-iommu.c               |  2 +-
 drivers/iommu/iommu.c                     |  3 +-
 7 files changed, 49 insertions(+), 17 deletions(-)

-- 
1.8.3


_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v8 1/7] iommu: enhance IOMMU default DMA mode build options
  2019-05-30  3:48 [PATCH v8 0/7] iommu: enhance IOMMU default DMA mode build options Zhen Lei
@ 2019-05-30  3:48 ` Zhen Lei
  2019-05-30 12:20   ` John Garry
  2019-05-30  3:48 ` [PATCH v8 2/7] x86/dma: use IS_ENABLED() to simplify the code Zhen Lei
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Zhen Lei @ 2019-05-30  3:48 UTC (permalink / raw)
  To: Jean-Philippe Brucker, John Garry, Robin Murphy, Will Deacon,
	Joerg Roedel, Jonathan Corbet, linux-doc, Sebastian Ott,
	Gerald Schaefer, Martin Schwidefsky, Heiko Carstens,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Tony Luck, Fenghua Yu, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin, David Woodhouse, iommu,
	linux-kernel, linux-s390, linuxppc-dev, x86, linux-ia64
  Cc: Hanjun Guo

First, add build option IOMMU_DEFAULT_{LAZY|STRICT}, so that we have the
opportunity to set {lazy|strict} mode as default at build time. Then put
the three config options in an choice, make people can only choose one of
the three at a time.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/iommu/Kconfig | 42 +++++++++++++++++++++++++++++++++++-------
 drivers/iommu/iommu.c |  3 ++-
 2 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index 83664db5221df02..d6a1a45f80ffbf5 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -75,17 +75,45 @@ config IOMMU_DEBUGFS
 	  debug/iommu directory, and then populate a subdirectory with
 	  entries as required.
 
-config IOMMU_DEFAULT_PASSTHROUGH
-	bool "IOMMU passthrough by default"
+choice
+	prompt "IOMMU default DMA mode"
 	depends on IOMMU_API
-        help
-	  Enable passthrough by default, removing the need to pass in
-	  iommu.passthrough=on or iommu=pt through command line. If this
-	  is enabled, you can still disable with iommu.passthrough=off
-	  or iommu=nopt depending on the architecture.
+	default IOMMU_DEFAULT_STRICT
+	help
+	  This option allows IOMMU DMA mode to be chose at build time, to
+	  override the default DMA mode of each ARCHs, removing the need to
+	  pass in kernel parameters through command line. You can still use
+	  ARCHs specific boot options to override this option again.
+
+config IOMMU_DEFAULT_PASSTHROUGH
+	bool "passthrough"
+	help
+	  In this mode, the DMA access through IOMMU without any addresses
+	  translation. That means, the wrong or illegal DMA access can not
+	  be caught, no error information will be reported.
 
 	  If unsure, say N here.
 
+config IOMMU_DEFAULT_LAZY
+	bool "lazy"
+	help
+	  Support lazy mode, where for every IOMMU DMA unmap operation, the
+	  flush operation of IOTLB and the free operation of IOVA are deferred.
+	  They are only guaranteed to be done before the related IOVA will be
+	  reused.
+
+config IOMMU_DEFAULT_STRICT
+	bool "strict"
+	help
+	  For every IOMMU DMA unmap operation, the flush operation of IOTLB and
+	  the free operation of IOVA are guaranteed to be done in the unmap
+	  function.
+
+	  This mode is safer than the two above, but it maybe slower in some
+	  high performace scenarios.
+
+endchoice
+
 config OF_IOMMU
        def_bool y
        depends on OF && IOMMU_API
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 67ee6623f9b2a4d..56bce221285b15f 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -43,7 +43,8 @@
 #else
 static unsigned int iommu_def_domain_type = IOMMU_DOMAIN_DMA;
 #endif
-static bool iommu_dma_strict __read_mostly = true;
+static bool iommu_dma_strict __read_mostly =
+			IS_ENABLED(CONFIG_IOMMU_DEFAULT_STRICT);
 
 struct iommu_group {
 	struct kobject kobj;
-- 
1.8.3


_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v8 2/7] x86/dma: use IS_ENABLED() to simplify the code
  2019-05-30  3:48 [PATCH v8 0/7] iommu: enhance IOMMU default DMA mode build options Zhen Lei
  2019-05-30  3:48 ` [PATCH v8 1/7] " Zhen Lei
@ 2019-05-30  3:48 ` Zhen Lei
  2019-06-12  5:16   ` Borislav Petkov
  2019-05-30  3:48 ` [PATCH v8 3/7] s390/pci: add support for IOMMU default DMA mode build options Zhen Lei
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Zhen Lei @ 2019-05-30  3:48 UTC (permalink / raw)
  To: Jean-Philippe Brucker, John Garry, Robin Murphy, Will Deacon,
	Joerg Roedel, Jonathan Corbet, linux-doc, Sebastian Ott,
	Gerald Schaefer, Martin Schwidefsky, Heiko Carstens,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Tony Luck, Fenghua Yu, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin, David Woodhouse, iommu,
	linux-kernel, linux-s390, linuxppc-dev, x86, linux-ia64
  Cc: Hanjun Guo

This patch removes the ifdefs around CONFIG_IOMMU_DEFAULT_PASSTHROUGH to
improve readablity.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 arch/x86/kernel/pci-dma.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index dcd272dbd0a9330..9f2b19c35a060df 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -43,11 +43,8 @@
  * It is also possible to disable by default in kernel config, and enable with
  * iommu=nopt at boot time.
  */
-#ifdef CONFIG_IOMMU_DEFAULT_PASSTHROUGH
-int iommu_pass_through __read_mostly = 1;
-#else
-int iommu_pass_through __read_mostly;
-#endif
+int iommu_pass_through __read_mostly =
+			IS_ENABLED(CONFIG_IOMMU_DEFAULT_PASSTHROUGH);
 
 extern struct iommu_table_entry __iommu_table[], __iommu_table_end[];
 
-- 
1.8.3


_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v8 3/7] s390/pci: add support for IOMMU default DMA mode build options
  2019-05-30  3:48 [PATCH v8 0/7] iommu: enhance IOMMU default DMA mode build options Zhen Lei
  2019-05-30  3:48 ` [PATCH v8 1/7] " Zhen Lei
  2019-05-30  3:48 ` [PATCH v8 2/7] x86/dma: use IS_ENABLED() to simplify the code Zhen Lei
@ 2019-05-30  3:48 ` Zhen Lei
  2019-06-03 11:51   ` Sebastian Ott
  2019-05-30  3:48 ` [PATCH v8 4/7] powernv/iommu: " Zhen Lei
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Zhen Lei @ 2019-05-30  3:48 UTC (permalink / raw)
  To: Jean-Philippe Brucker, John Garry, Robin Murphy, Will Deacon,
	Joerg Roedel, Jonathan Corbet, linux-doc, Sebastian Ott,
	Gerald Schaefer, Martin Schwidefsky, Heiko Carstens,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Tony Luck, Fenghua Yu, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin, David Woodhouse, iommu,
	linux-kernel, linux-s390, linuxppc-dev, x86, linux-ia64
  Cc: Hanjun Guo

The default DMA mode is LAZY on s390, this patch make it can be set to
STRICT at build time. It can be overridden by boot option.

There is no functional change.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 arch/s390/pci/pci_dma.c | 2 +-
 drivers/iommu/Kconfig   | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c
index 9e52d1527f71495..784ad1e0acecfb1 100644
--- a/arch/s390/pci/pci_dma.c
+++ b/arch/s390/pci/pci_dma.c
@@ -17,7 +17,7 @@
 
 static struct kmem_cache *dma_region_table_cache;
 static struct kmem_cache *dma_page_table_cache;
-static int s390_iommu_strict;
+static int s390_iommu_strict = IS_ENABLED(CONFIG_IOMMU_DEFAULT_STRICT);
 
 static int zpci_refresh_global(struct zpci_dev *zdev)
 {
diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index d6a1a45f80ffbf5..9b48c2fc20e14d3 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -78,6 +78,7 @@ config IOMMU_DEBUGFS
 choice
 	prompt "IOMMU default DMA mode"
 	depends on IOMMU_API
+	default IOMMU_DEFAULT_LAZY if S390_IOMMU
 	default IOMMU_DEFAULT_STRICT
 	help
 	  This option allows IOMMU DMA mode to be chose at build time, to
@@ -87,6 +88,7 @@ choice
 
 config IOMMU_DEFAULT_PASSTHROUGH
 	bool "passthrough"
+	depends on !S390_IOMMU
 	help
 	  In this mode, the DMA access through IOMMU without any addresses
 	  translation. That means, the wrong or illegal DMA access can not
-- 
1.8.3


_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v8 4/7] powernv/iommu: add support for IOMMU default DMA mode build options
  2019-05-30  3:48 [PATCH v8 0/7] iommu: enhance IOMMU default DMA mode build options Zhen Lei
                   ` (2 preceding siblings ...)
  2019-05-30  3:48 ` [PATCH v8 3/7] s390/pci: add support for IOMMU default DMA mode build options Zhen Lei
@ 2019-05-30  3:48 ` Zhen Lei
  2019-05-30  3:48 ` [PATCH v8 5/7] iommu/vt-d: " Zhen Lei
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 15+ messages in thread
From: Zhen Lei @ 2019-05-30  3:48 UTC (permalink / raw)
  To: Jean-Philippe Brucker, John Garry, Robin Murphy, Will Deacon,
	Joerg Roedel, Jonathan Corbet, linux-doc, Sebastian Ott,
	Gerald Schaefer, Martin Schwidefsky, Heiko Carstens,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Tony Luck, Fenghua Yu, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin, David Woodhouse, iommu,
	linux-kernel, linux-s390, linuxppc-dev, x86, linux-ia64
  Cc: Hanjun Guo

The default DMA mode is PASSTHROUGH on powernv, this patch make it can be
set to STRICT at build time. It can be overridden by boot option.

There is no functional change.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 3 ++-
 drivers/iommu/Kconfig                     | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 126602b4e39972d..40208b9019be890 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -85,7 +85,8 @@ void pe_level_printk(const struct pnv_ioda_pe *pe, const char *level,
 	va_end(args);
 }
 
-static bool pnv_iommu_bypass_disabled __read_mostly;
+static bool pnv_iommu_bypass_disabled __read_mostly =
+			!IS_ENABLED(CONFIG_IOMMU_DEFAULT_PASSTHROUGH);
 static bool pci_reset_phbs __read_mostly;
 
 static int __init iommu_setup(char *str)
diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index 9b48c2fc20e14d3..b5af859956c4fda 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -78,6 +78,7 @@ config IOMMU_DEBUGFS
 choice
 	prompt "IOMMU default DMA mode"
 	depends on IOMMU_API
+	default IOMMU_DEFAULT_PASSTHROUGH if (PPC_POWERNV && PCI)
 	default IOMMU_DEFAULT_LAZY if S390_IOMMU
 	default IOMMU_DEFAULT_STRICT
 	help
@@ -98,6 +99,7 @@ config IOMMU_DEFAULT_PASSTHROUGH
 
 config IOMMU_DEFAULT_LAZY
 	bool "lazy"
+	depends on !PPC_POWERNV
 	help
 	  Support lazy mode, where for every IOMMU DMA unmap operation, the
 	  flush operation of IOTLB and the free operation of IOVA are deferred.
-- 
1.8.3


_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v8 5/7] iommu/vt-d: add support for IOMMU default DMA mode build options
  2019-05-30  3:48 [PATCH v8 0/7] iommu: enhance IOMMU default DMA mode build options Zhen Lei
                   ` (3 preceding siblings ...)
  2019-05-30  3:48 ` [PATCH v8 4/7] powernv/iommu: " Zhen Lei
@ 2019-05-30  3:48 ` Zhen Lei
  2019-05-30  3:48 ` [PATCH v8 6/7] iommu/amd: " Zhen Lei
  2019-05-30  3:48 ` [PATCH v8 7/7] ia64: hide build option IOMMU_DEFAULT_PASSTHROUGH Zhen Lei
  6 siblings, 0 replies; 15+ messages in thread
From: Zhen Lei @ 2019-05-30  3:48 UTC (permalink / raw)
  To: Jean-Philippe Brucker, John Garry, Robin Murphy, Will Deacon,
	Joerg Roedel, Jonathan Corbet, linux-doc, Sebastian Ott,
	Gerald Schaefer, Martin Schwidefsky, Heiko Carstens,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Tony Luck, Fenghua Yu, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin, David Woodhouse, iommu,
	linux-kernel, linux-s390, linuxppc-dev, x86, linux-ia64
  Cc: Hanjun Guo

The default DMA mode of INTEL IOMMU is LAZY, this patch make it can be
set to STRICT at build time. It can be overridden by boot option.

There is no functional change.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/iommu/Kconfig       | 2 +-
 drivers/iommu/intel-iommu.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index b5af859956c4fda..af580274b7c5270 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -79,7 +79,7 @@ choice
 	prompt "IOMMU default DMA mode"
 	depends on IOMMU_API
 	default IOMMU_DEFAULT_PASSTHROUGH if (PPC_POWERNV && PCI)
-	default IOMMU_DEFAULT_LAZY if S390_IOMMU
+	default IOMMU_DEFAULT_LAZY if (INTEL_IOMMU || S390_IOMMU)
 	default IOMMU_DEFAULT_STRICT
 	help
 	  This option allows IOMMU DMA mode to be chose at build time, to
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index a209199f3af6460..50d74ea0acdbdca 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -362,7 +362,7 @@ static int domain_detach_iommu(struct dmar_domain *domain,
 
 static int dmar_map_gfx = 1;
 static int dmar_forcedac;
-static int intel_iommu_strict;
+static int intel_iommu_strict = IS_ENABLED(CONFIG_IOMMU_DEFAULT_STRICT);
 static int intel_iommu_superpage = 1;
 static int intel_iommu_sm;
 static int iommu_identity_mapping;
-- 
1.8.3


_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v8 6/7] iommu/amd: add support for IOMMU default DMA mode build options
  2019-05-30  3:48 [PATCH v8 0/7] iommu: enhance IOMMU default DMA mode build options Zhen Lei
                   ` (4 preceding siblings ...)
  2019-05-30  3:48 ` [PATCH v8 5/7] iommu/vt-d: " Zhen Lei
@ 2019-05-30  3:48 ` Zhen Lei
  2019-05-30  3:48 ` [PATCH v8 7/7] ia64: hide build option IOMMU_DEFAULT_PASSTHROUGH Zhen Lei
  6 siblings, 0 replies; 15+ messages in thread
From: Zhen Lei @ 2019-05-30  3:48 UTC (permalink / raw)
  To: Jean-Philippe Brucker, John Garry, Robin Murphy, Will Deacon,
	Joerg Roedel, Jonathan Corbet, linux-doc, Sebastian Ott,
	Gerald Schaefer, Martin Schwidefsky, Heiko Carstens,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Tony Luck, Fenghua Yu, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin, David Woodhouse, iommu,
	linux-kernel, linux-s390, linuxppc-dev, x86, linux-ia64
  Cc: Hanjun Guo

The default DMA mode of AMD IOMMU is LAZY, this patch make it can be set
to STRICT at build time. It can be overridden by boot option.

There is no functional change.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/iommu/Kconfig          | 2 +-
 drivers/iommu/amd_iommu_init.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index af580274b7c5270..f6c030433d38048 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -79,7 +79,7 @@ choice
 	prompt "IOMMU default DMA mode"
 	depends on IOMMU_API
 	default IOMMU_DEFAULT_PASSTHROUGH if (PPC_POWERNV && PCI)
-	default IOMMU_DEFAULT_LAZY if (INTEL_IOMMU || S390_IOMMU)
+	default IOMMU_DEFAULT_LAZY if (AMD_IOMMU || INTEL_IOMMU || S390_IOMMU)
 	default IOMMU_DEFAULT_STRICT
 	help
 	  This option allows IOMMU DMA mode to be chose at build time, to
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index f977df90d2a4912..6b0bfa43f6faa32 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -166,7 +166,8 @@ struct ivmd_header {
 					   to handle */
 LIST_HEAD(amd_iommu_unity_map);		/* a list of required unity mappings
 					   we find in ACPI */
-bool amd_iommu_unmap_flush;		/* if true, flush on every unmap */
+bool amd_iommu_unmap_flush = IS_ENABLED(CONFIG_IOMMU_DEFAULT_STRICT);
+					/* if true, flush on every unmap */
 
 LIST_HEAD(amd_iommu_list);		/* list of all AMD IOMMUs in the
 					   system */
-- 
1.8.3


_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v8 7/7] ia64: hide build option IOMMU_DEFAULT_PASSTHROUGH
  2019-05-30  3:48 [PATCH v8 0/7] iommu: enhance IOMMU default DMA mode build options Zhen Lei
                   ` (5 preceding siblings ...)
  2019-05-30  3:48 ` [PATCH v8 6/7] iommu/amd: " Zhen Lei
@ 2019-05-30  3:48 ` Zhen Lei
  6 siblings, 0 replies; 15+ messages in thread
From: Zhen Lei @ 2019-05-30  3:48 UTC (permalink / raw)
  To: Jean-Philippe Brucker, John Garry, Robin Murphy, Will Deacon,
	Joerg Roedel, Jonathan Corbet, linux-doc, Sebastian Ott,
	Gerald Schaefer, Martin Schwidefsky, Heiko Carstens,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Tony Luck, Fenghua Yu, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin, David Woodhouse, iommu,
	linux-kernel, linux-s390, linuxppc-dev, x86, linux-ia64
  Cc: Hanjun Guo

The DMA mode PASSTHROUGH is not used on ia64.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/iommu/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index f6c030433d38048..f7400e35628dce4 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -89,7 +89,7 @@ choice
 
 config IOMMU_DEFAULT_PASSTHROUGH
 	bool "passthrough"
-	depends on !S390_IOMMU
+	depends on (!S390_IOMMU && !IA64)
 	help
 	  In this mode, the DMA access through IOMMU without any addresses
 	  translation. That means, the wrong or illegal DMA access can not
-- 
1.8.3


_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v8 1/7] iommu: enhance IOMMU default DMA mode build options
  2019-05-30  3:48 ` [PATCH v8 1/7] " Zhen Lei
@ 2019-05-30 12:20   ` John Garry
  2019-05-31 10:03     ` Leizhen (ThunderTown)
  0 siblings, 1 reply; 15+ messages in thread
From: John Garry @ 2019-05-30 12:20 UTC (permalink / raw)
  To: Zhen Lei, Jean-Philippe Brucker, Robin Murphy, Will Deacon,
	Joerg Roedel, Jonathan Corbet, linux-doc, Sebastian Ott,
	Gerald Schaefer, Martin Schwidefsky, Heiko Carstens,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Tony Luck, Fenghua Yu, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin, David Woodhouse, iommu,
	linux-kernel, linux-s390, linuxppc-dev, x86, linux-ia64
  Cc: Linuxarm, Hanjun Guo

On 30/05/2019 04:48, Zhen Lei wrote:
> First, add build option IOMMU_DEFAULT_{LAZY|STRICT}, so that we have the
> opportunity to set {lazy|strict} mode as default at build time. Then put
> the three config options in an choice, make people can only choose one of
> the three at a time.
>

Since this was not picked up, but modulo (somtimes same) comments below:

Reviewed-by: John Garry <john.garry@huawei.com>

> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
>  drivers/iommu/Kconfig | 42 +++++++++++++++++++++++++++++++++++-------
>  drivers/iommu/iommu.c |  3 ++-
>  2 files changed, 37 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
> index 83664db5221df02..d6a1a45f80ffbf5 100644
> --- a/drivers/iommu/Kconfig
> +++ b/drivers/iommu/Kconfig
> @@ -75,17 +75,45 @@ config IOMMU_DEBUGFS
>  	  debug/iommu directory, and then populate a subdirectory with
>  	  entries as required.
>
> -config IOMMU_DEFAULT_PASSTHROUGH
> -	bool "IOMMU passthrough by default"
> +choice
> +	prompt "IOMMU default DMA mode"
>  	depends on IOMMU_API
> -        help
> -	  Enable passthrough by default, removing the need to pass in
> -	  iommu.passthrough=on or iommu=pt through command line. If this
> -	  is enabled, you can still disable with iommu.passthrough=off
> -	  or iommu=nopt depending on the architecture.
> +	default IOMMU_DEFAULT_STRICT
> +	help
> +	  This option allows IOMMU DMA mode to be chose at build time, to

As before:
/s/chose/chosen/, /s/allows IOMMU/allows an IOMMU/

> +	  override the default DMA mode of each ARCHs, removing the need to

Again, as before:
ARCHs should be singular

> +	  pass in kernel parameters through command line. You can still use
> +	  ARCHs specific boot options to override this option again.
> +
> +config IOMMU_DEFAULT_PASSTHROUGH
> +	bool "passthrough"
> +	help
> +	  In this mode, the DMA access through IOMMU without any addresses
> +	  translation. That means, the wrong or illegal DMA access can not
> +	  be caught, no error information will be reported.
>
>  	  If unsure, say N here.
>
> +config IOMMU_DEFAULT_LAZY
> +	bool "lazy"
> +	help
> +	  Support lazy mode, where for every IOMMU DMA unmap operation, the
> +	  flush operation of IOTLB and the free operation of IOVA are deferred.
> +	  They are only guaranteed to be done before the related IOVA will be
> +	  reused.

why no advisory on how to set if unsure?

> +
> +config IOMMU_DEFAULT_STRICT
> +	bool "strict"
> +	help
> +	  For every IOMMU DMA unmap operation, the flush operation of IOTLB and
> +	  the free operation of IOVA are guaranteed to be done in the unmap
> +	  function.
> +
> +	  This mode is safer than the two above, but it maybe slower in some
> +	  high performace scenarios.

and here?

> +
> +endchoice
> +
>  config OF_IOMMU
>         def_bool y
>         depends on OF && IOMMU_API
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 67ee6623f9b2a4d..56bce221285b15f 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -43,7 +43,8 @@
>  #else
>  static unsigned int iommu_def_domain_type = IOMMU_DOMAIN_DMA;
>  #endif
> -static bool iommu_dma_strict __read_mostly = true;
> +static bool iommu_dma_strict __read_mostly =
> +			IS_ENABLED(CONFIG_IOMMU_DEFAULT_STRICT);
>
>  struct iommu_group {
>  	struct kobject kobj;
>


_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v8 1/7] iommu: enhance IOMMU default DMA mode build options
  2019-05-30 12:20   ` John Garry
@ 2019-05-31 10:03     ` Leizhen (ThunderTown)
  2019-05-31 10:42       ` John Garry
  0 siblings, 1 reply; 15+ messages in thread
From: Leizhen (ThunderTown) @ 2019-05-31 10:03 UTC (permalink / raw)
  To: John Garry, Jean-Philippe Brucker, Robin Murphy, Will Deacon,
	Joerg Roedel, Jonathan Corbet, linux-doc, Sebastian Ott,
	Gerald Schaefer, Martin Schwidefsky, Heiko Carstens,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Tony Luck, Fenghua Yu, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin, David Woodhouse, iommu,
	linux-kernel, linux-s390, linuxppc-dev, x86, linux-ia64
  Cc: Linuxarm, Hanjun Guo



On 2019/5/30 20:20, John Garry wrote:
> On 30/05/2019 04:48, Zhen Lei wrote:
>> First, add build option IOMMU_DEFAULT_{LAZY|STRICT}, so that we have the
>> opportunity to set {lazy|strict} mode as default at build time. Then put
>> the three config options in an choice, make people can only choose one of
>> the three at a time.
>>
> 
> Since this was not picked up, but modulo (somtimes same) comments below:
> 
> Reviewed-by: John Garry <john.garry@huawei.com>
> 
>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
>> ---
>>  drivers/iommu/Kconfig | 42 +++++++++++++++++++++++++++++++++++-------
>>  drivers/iommu/iommu.c |  3 ++-
>>  2 files changed, 37 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
>> index 83664db5221df02..d6a1a45f80ffbf5 100644
>> --- a/drivers/iommu/Kconfig
>> +++ b/drivers/iommu/Kconfig
>> @@ -75,17 +75,45 @@ config IOMMU_DEBUGFS
>>        debug/iommu directory, and then populate a subdirectory with
>>        entries as required.
>>
>> -config IOMMU_DEFAULT_PASSTHROUGH
>> -    bool "IOMMU passthrough by default"
>> +choice
>> +    prompt "IOMMU default DMA mode"
>>      depends on IOMMU_API
>> -        help
>> -      Enable passthrough by default, removing the need to pass in
>> -      iommu.passthrough=on or iommu=pt through command line. If this
>> -      is enabled, you can still disable with iommu.passthrough=off
>> -      or iommu=nopt depending on the architecture.
>> +    default IOMMU_DEFAULT_STRICT
>> +    help
>> +      This option allows IOMMU DMA mode to be chose at build time, to
> 
> As before:
> /s/chose/chosen/, /s/allows IOMMU/allows an IOMMU/
I'm sorry that the previous version was not modified.

> 
>> +      override the default DMA mode of each ARCHs, removing the need to
> 
> Again, as before:
> ARCHs should be singular
OK

> 
>> +      pass in kernel parameters through command line. You can still use
>> +      ARCHs specific boot options to override this option again.
>> +
>> +config IOMMU_DEFAULT_PASSTHROUGH
>> +    bool "passthrough"
>> +    help
>> +      In this mode, the DMA access through IOMMU without any addresses
>> +      translation. That means, the wrong or illegal DMA access can not
>> +      be caught, no error information will be reported.
>>
>>        If unsure, say N here.
>>
>> +config IOMMU_DEFAULT_LAZY
>> +    bool "lazy"
>> +    help
>> +      Support lazy mode, where for every IOMMU DMA unmap operation, the
>> +      flush operation of IOTLB and the free operation of IOVA are deferred.
>> +      They are only guaranteed to be done before the related IOVA will be
>> +      reused.
> 
> why no advisory on how to set if unsure?
Because the LAZY and STRICT have their own advantages and disadvantages.

Should I say: If unsure, keep the default。

> 
>> +
>> +config IOMMU_DEFAULT_STRICT
>> +    bool "strict"
>> +    help
>> +      For every IOMMU DMA unmap operation, the flush operation of IOTLB and
>> +      the free operation of IOVA are guaranteed to be done in the unmap
>> +      function.
>> +
>> +      This mode is safer than the two above, but it maybe slower in some
>> +      high performace scenarios.
> 
> and here?
> 
>> +
>> +endchoice
>> +
>>  config OF_IOMMU
>>         def_bool y
>>         depends on OF && IOMMU_API
>> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
>> index 67ee6623f9b2a4d..56bce221285b15f 100644
>> --- a/drivers/iommu/iommu.c
>> +++ b/drivers/iommu/iommu.c
>> @@ -43,7 +43,8 @@
>>  #else
>>  static unsigned int iommu_def_domain_type = IOMMU_DOMAIN_DMA;
>>  #endif
>> -static bool iommu_dma_strict __read_mostly = true;
>> +static bool iommu_dma_strict __read_mostly =
>> +            IS_ENABLED(CONFIG_IOMMU_DEFAULT_STRICT);
>>
>>  struct iommu_group {
>>      struct kobject kobj;
>>
> 
> 
> 
> .
> 

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v8 1/7] iommu: enhance IOMMU default DMA mode build options
  2019-05-31 10:03     ` Leizhen (ThunderTown)
@ 2019-05-31 10:42       ` John Garry
  2019-06-13  8:30         ` Leizhen (ThunderTown)
  0 siblings, 1 reply; 15+ messages in thread
From: John Garry @ 2019-05-31 10:42 UTC (permalink / raw)
  To: Leizhen (ThunderTown),
	Jean-Philippe Brucker, Robin Murphy, Will Deacon, Joerg Roedel,
	Jonathan Corbet, linux-doc, Sebastian Ott, Gerald Schaefer,
	Martin Schwidefsky, Heiko Carstens, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, Tony Luck, Fenghua Yu,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, H . Peter Anvin,
	David Woodhouse, iommu, linux-kernel, linux-s390, linuxppc-dev,
	x86, linux-ia64
  Cc: Linuxarm, Hanjun Guo


>>> -config IOMMU_DEFAULT_PASSTHROUGH
>>> -    bool "IOMMU passthrough by default"
>>> +choice
>>> +    prompt "IOMMU default DMA mode"
>>>      depends on IOMMU_API
>>> -        help
>>> -      Enable passthrough by default, removing the need to pass in
>>> -      iommu.passthrough=on or iommu=pt through command line. If this
>>> -      is enabled, you can still disable with iommu.passthrough=off
>>> -      or iommu=nopt depending on the architecture.
>>> +    default IOMMU_DEFAULT_STRICT
>>> +    help
>>> +      This option allows IOMMU DMA mode to be chose at build time, to
>>
>> As before:
>> /s/chose/chosen/, /s/allows IOMMU/allows an IOMMU/
> I'm sorry that the previous version was not modified.
>
>>
>>> +      override the default DMA mode of each ARCHs, removing the need to
>>
>> Again, as before:
>> ARCHs should be singular
> OK
>
>>
>>> +      pass in kernel parameters through command line. You can still use
>>> +      ARCHs specific boot options to override this option again.

*

>>> +
>>> +config IOMMU_DEFAULT_PASSTHROUGH
>>> +    bool "passthrough"
>>> +    help
>>> +      In this mode, the DMA access through IOMMU without any addresses
>>> +      translation. That means, the wrong or illegal DMA access can not
>>> +      be caught, no error information will be reported.
>>>
>>>        If unsure, say N here.
>>>
>>> +config IOMMU_DEFAULT_LAZY
>>> +    bool "lazy"
>>> +    help
>>> +      Support lazy mode, where for every IOMMU DMA unmap operation, the
>>> +      flush operation of IOTLB and the free operation of IOVA are deferred.
>>> +      They are only guaranteed to be done before the related IOVA will be
>>> +      reused.
>>
>> why no advisory on how to set if unsure?
> Because the LAZY and STRICT have their own advantages and disadvantages.
>
> Should I say: If unsure, keep the default。

Maybe. So you could put this in the help for the choice, * above, and 
remove the advisory on IOMMU_DEFAULT_PASSTHROUGH.

However the maintainer may have a different view.

Thanks,
John

>
>>
>>> +
>>> +config IOMMU_DEFAULT_STRICT
>>> +    bool "strict"
>>> +    help
>>> +      For every IOMMU DMA unmap operation, the flush operation of IOTLB and
>>> +      the free operation of IOVA are guaranteed to be done in the unmap
>>> +      function.
>>> +
>>> +      This mode is safer than the two above, but it maybe slower in some
>>> +      high performace scenarios.
>>
>> and here?

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v8 3/7] s390/pci: add support for IOMMU default DMA mode build options
  2019-05-30  3:48 ` [PATCH v8 3/7] s390/pci: add support for IOMMU default DMA mode build options Zhen Lei
@ 2019-06-03 11:51   ` Sebastian Ott
  0 siblings, 0 replies; 15+ messages in thread
From: Sebastian Ott @ 2019-06-03 11:51 UTC (permalink / raw)
  To: Zhen Lei
  Cc: linux-ia64, linux-doc, Benjamin Herrenschmidt, Hanjun Guo,
	Heiko Carstens, Paul Mackerras, H . Peter Anvin, linux-s390,
	Jonathan Corbet, Jean-Philippe Brucker, Michael Ellerman, x86,
	Ingo Molnar, Fenghua Yu, Will Deacon, linuxppc-dev,
	Borislav Petkov, Thomas Gleixner, Gerald Schaefer, Tony Luck,
	David Woodhouse, linux-kernel, iommu, Martin Schwidefsky,
	Robin Murphy


On Thu, 30 May 2019, Zhen Lei wrote:
> The default DMA mode is LAZY on s390, this patch make it can be set to
> STRICT at build time. It can be overridden by boot option.
> 
> There is no functional change.
> 
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

Acked-by: Sebastian Ott <sebott@linux.ibm.com>

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v8 2/7] x86/dma: use IS_ENABLED() to simplify the code
  2019-05-30  3:48 ` [PATCH v8 2/7] x86/dma: use IS_ENABLED() to simplify the code Zhen Lei
@ 2019-06-12  5:16   ` Borislav Petkov
  2019-06-12  6:26     ` Leizhen (ThunderTown)
  0 siblings, 1 reply; 15+ messages in thread
From: Borislav Petkov @ 2019-06-12  5:16 UTC (permalink / raw)
  To: Zhen Lei
  Cc: linux-ia64, Sebastian Ott, linux-doc, Benjamin Herrenschmidt,
	Hanjun Guo, Heiko Carstens, Paul Mackerras, H . Peter Anvin,
	linux-s390, Jonathan Corbet, Jean-Philippe Brucker,
	Michael Ellerman, x86, Ingo Molnar, Fenghua Yu, Will Deacon,
	linuxppc-dev, Thomas Gleixner, Gerald Schaefer, Tony Luck,
	David Woodhouse, linux-kernel, iommu, Martin Schwidefsky,
	Robin Murphy

On Thu, May 30, 2019 at 11:48:26AM +0800, Zhen Lei wrote:
> This patch removes the ifdefs around CONFIG_IOMMU_DEFAULT_PASSTHROUGH to
> improve readablity.

Avoid having "This patch" or "This commit" in the commit message. It is
tautologically useless.

Also, do

$ git grep 'This patch' Documentation/process

for more details.

> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
>  arch/x86/kernel/pci-dma.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
> index dcd272dbd0a9330..9f2b19c35a060df 100644
> --- a/arch/x86/kernel/pci-dma.c
> +++ b/arch/x86/kernel/pci-dma.c
> @@ -43,11 +43,8 @@
>   * It is also possible to disable by default in kernel config, and enable with
>   * iommu=nopt at boot time.
>   */
> -#ifdef CONFIG_IOMMU_DEFAULT_PASSTHROUGH
> -int iommu_pass_through __read_mostly = 1;
> -#else
> -int iommu_pass_through __read_mostly;
> -#endif
> +int iommu_pass_through __read_mostly =
> +			IS_ENABLED(CONFIG_IOMMU_DEFAULT_PASSTHROUGH);

Let that line stick out.

Thx.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v8 2/7] x86/dma: use IS_ENABLED() to simplify the code
  2019-06-12  5:16   ` Borislav Petkov
@ 2019-06-12  6:26     ` Leizhen (ThunderTown)
  0 siblings, 0 replies; 15+ messages in thread
From: Leizhen (ThunderTown) @ 2019-06-12  6:26 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: linux-ia64, Sebastian Ott, linux-doc, Benjamin Herrenschmidt,
	Hanjun Guo, Heiko Carstens, Paul Mackerras, H . Peter Anvin,
	linux-s390, Jonathan Corbet, Jean-Philippe Brucker,
	Michael Ellerman, x86, Ingo Molnar, Fenghua Yu, Will Deacon,
	linuxppc-dev, Thomas Gleixner, Gerald Schaefer, Tony Luck,
	David Woodhouse, linux-kernel, iommu, Martin Schwidefsky,
	Robin Murphy



On 2019/6/12 13:16, Borislav Petkov wrote:
> On Thu, May 30, 2019 at 11:48:26AM +0800, Zhen Lei wrote:
>> This patch removes the ifdefs around CONFIG_IOMMU_DEFAULT_PASSTHROUGH to
>> improve readablity.
> 
> Avoid having "This patch" or "This commit" in the commit message. It is
> tautologically useless.

OK, thanks.

> 
> Also, do
> 
> $ git grep 'This patch' Documentation/process
> 
> for more details.
> 
>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
>> ---
>>  arch/x86/kernel/pci-dma.c | 7 ++-----
>>  1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
>> index dcd272dbd0a9330..9f2b19c35a060df 100644
>> --- a/arch/x86/kernel/pci-dma.c
>> +++ b/arch/x86/kernel/pci-dma.c
>> @@ -43,11 +43,8 @@
>>   * It is also possible to disable by default in kernel config, and enable with
>>   * iommu=nopt at boot time.
>>   */
>> -#ifdef CONFIG_IOMMU_DEFAULT_PASSTHROUGH
>> -int iommu_pass_through __read_mostly = 1;
>> -#else
>> -int iommu_pass_through __read_mostly;
>> -#endif
>> +int iommu_pass_through __read_mostly =
>> +			IS_ENABLED(CONFIG_IOMMU_DEFAULT_PASSTHROUGH);
> 
> Let that line stick out.

OK, I will merge them on the same line.

> 
> Thx.
> 

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v8 1/7] iommu: enhance IOMMU default DMA mode build options
  2019-05-31 10:42       ` John Garry
@ 2019-06-13  8:30         ` Leizhen (ThunderTown)
  0 siblings, 0 replies; 15+ messages in thread
From: Leizhen (ThunderTown) @ 2019-06-13  8:30 UTC (permalink / raw)
  To: John Garry, Jean-Philippe Brucker, Robin Murphy, Will Deacon,
	Joerg Roedel, Jonathan Corbet, linux-doc, Sebastian Ott,
	Gerald Schaefer, Martin Schwidefsky, Heiko Carstens,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Tony Luck, Fenghua Yu, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin, David Woodhouse, iommu,
	linux-kernel, linux-s390, linuxppc-dev, x86, linux-ia64
  Cc: Linuxarm, Hanjun Guo



On 2019/5/31 18:42, John Garry wrote:
> 
>>>> -config IOMMU_DEFAULT_PASSTHROUGH
>>>> -    bool "IOMMU passthrough by default"
>>>> +choice
>>>> +    prompt "IOMMU default DMA mode"
>>>>      depends on IOMMU_API
>>>> -        help
>>>> -      Enable passthrough by default, removing the need to pass in
>>>> -      iommu.passthrough=on or iommu=pt through command line. If this
>>>> -      is enabled, you can still disable with iommu.passthrough=off
>>>> -      or iommu=nopt depending on the architecture.
>>>> +    default IOMMU_DEFAULT_STRICT
>>>> +    help
>>>> +      This option allows IOMMU DMA mode to be chose at build time, to
>>>
>>> As before:
>>> /s/chose/chosen/, /s/allows IOMMU/allows an IOMMU/
>> I'm sorry that the previous version was not modified.
>>
>>>
>>>> +      override the default DMA mode of each ARCHs, removing the need to
>>>
>>> Again, as before:
>>> ARCHs should be singular
>> OK
>>
>>>
>>>> +      pass in kernel parameters through command line. You can still use
>>>> +      ARCHs specific boot options to override this option again.
> 
> *
> 
>>>> +
>>>> +config IOMMU_DEFAULT_PASSTHROUGH
>>>> +    bool "passthrough"
>>>> +    help
>>>> +      In this mode, the DMA access through IOMMU without any addresses
>>>> +      translation. That means, the wrong or illegal DMA access can not
>>>> +      be caught, no error information will be reported.
>>>>
>>>>        If unsure, say N here.
>>>>
>>>> +config IOMMU_DEFAULT_LAZY
>>>> +    bool "lazy"
>>>> +    help
>>>> +      Support lazy mode, where for every IOMMU DMA unmap operation, the
>>>> +      flush operation of IOTLB and the free operation of IOVA are deferred.
>>>> +      They are only guaranteed to be done before the related IOVA will be
>>>> +      reused.
>>>
>>> why no advisory on how to set if unsure?
>> Because the LAZY and STRICT have their own advantages and disadvantages.
>>
>> Should I say: If unsure, keep the default。
> 
> Maybe. So you could put this in the help for the choice, * above, and remove the advisory on IOMMU_DEFAULT_PASSTHROUGH.

OK, I'll revise it according to this idea in v9.

> 
> However the maintainer may have a different view.
> 
> Thanks,
> John
> 
>>
>>>
>>>> +
>>>> +config IOMMU_DEFAULT_STRICT
>>>> +    bool "strict"
>>>> +    help
>>>> +      For every IOMMU DMA unmap operation, the flush operation of IOTLB and
>>>> +      the free operation of IOVA are guaranteed to be done in the unmap
>>>> +      function.
>>>> +
>>>> +      This mode is safer than the two above, but it maybe slower in some
>>>> +      high performace scenarios.
>>>
>>> and here?
> 
> 
> .
> 

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-06-13  8:30 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30  3:48 [PATCH v8 0/7] iommu: enhance IOMMU default DMA mode build options Zhen Lei
2019-05-30  3:48 ` [PATCH v8 1/7] " Zhen Lei
2019-05-30 12:20   ` John Garry
2019-05-31 10:03     ` Leizhen (ThunderTown)
2019-05-31 10:42       ` John Garry
2019-06-13  8:30         ` Leizhen (ThunderTown)
2019-05-30  3:48 ` [PATCH v8 2/7] x86/dma: use IS_ENABLED() to simplify the code Zhen Lei
2019-06-12  5:16   ` Borislav Petkov
2019-06-12  6:26     ` Leizhen (ThunderTown)
2019-05-30  3:48 ` [PATCH v8 3/7] s390/pci: add support for IOMMU default DMA mode build options Zhen Lei
2019-06-03 11:51   ` Sebastian Ott
2019-05-30  3:48 ` [PATCH v8 4/7] powernv/iommu: " Zhen Lei
2019-05-30  3:48 ` [PATCH v8 5/7] iommu/vt-d: " Zhen Lei
2019-05-30  3:48 ` [PATCH v8 6/7] iommu/amd: " Zhen Lei
2019-05-30  3:48 ` [PATCH v8 7/7] ia64: hide build option IOMMU_DEFAULT_PASSTHROUGH Zhen Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).