2019-05-30 03:51:38

by Zhen Lei

[permalink] [raw]
Subject: [PATCH v8 0/7] iommu: enhance IOMMU default DMA mode build options

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



2019-05-30 03:51:48

by Zhen Lei

[permalink] [raw]
Subject: [PATCH v8 6/7] iommu/amd: add support for IOMMU default DMA mode build options

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 <[email protected]>
---
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


2019-05-30 03:51:49

by Zhen Lei

[permalink] [raw]
Subject: [PATCH v8 7/7] ia64: hide build option IOMMU_DEFAULT_PASSTHROUGH

The DMA mode PASSTHROUGH is not used on ia64.

Signed-off-by: Zhen Lei <[email protected]>
---
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


2019-05-30 03:52:46

by Zhen Lei

[permalink] [raw]
Subject: [PATCH v8 4/7] powernv/iommu: add support for IOMMU default DMA mode build options

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 <[email protected]>
---
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


2019-05-30 03:52:47

by Zhen Lei

[permalink] [raw]
Subject: [PATCH v8 5/7] iommu/vt-d: add support for IOMMU default DMA mode build options

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 <[email protected]>
---
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


2019-05-30 03:52:51

by Zhen Lei

[permalink] [raw]
Subject: [PATCH v8 3/7] s390/pci: add support for IOMMU default DMA mode build options

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 <[email protected]>
---
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


2019-05-30 03:53:00

by Zhen Lei

[permalink] [raw]
Subject: [PATCH v8 1/7] iommu: enhance IOMMU default DMA mode build options

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 <[email protected]>
---
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


2019-05-30 12:22:41

by John Garry

[permalink] [raw]
Subject: Re: [PATCH v8 1/7] iommu: enhance IOMMU default DMA mode build options

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 <[email protected]>

> Signed-off-by: Zhen Lei <[email protected]>
> ---
> 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;
>


2019-05-31 10:05:18

by Zhen Lei

[permalink] [raw]
Subject: Re: [PATCH v8 1/7] iommu: enhance IOMMU default DMA mode build options



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 <[email protected]>
>
>> Signed-off-by: Zhen Lei <[email protected]>
>> ---
>>  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;
>>
>
>
>
> .
>

2019-05-31 10:45:55

by John Garry

[permalink] [raw]
Subject: Re: [PATCH v8 1/7] iommu: enhance IOMMU default DMA mode build options


>>> -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?

2019-06-03 17:31:27

by Sebastian Ott

[permalink] [raw]
Subject: Re: [PATCH v8 3/7] s390/pci: add support for IOMMU default DMA mode build options


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 <[email protected]>

Acked-by: Sebastian Ott <[email protected]>

2019-06-13 16:31:45

by Zhen Lei

[permalink] [raw]
Subject: Re: [PATCH v8 1/7] iommu: enhance IOMMU default DMA mode build options



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?
>
>
> .
>