iommu: Add config option to set lazy mode as default
PATCH 1/1 iommu: Add config option to set lazy mode as default
This allows the default behaviour to be controlled by a kernel config option instead of changing the command line for the kernel to include "iommu.strict=0" on ARM64 where this is desired.
This is similar to CONFIG_IOMMU_DEFAULT_PASSTHROUGH.
Note: At present, intel_iommu, amd_iommu and s390_iommu use lazy mode as defalut, so there is no need to add code for them.
--- drivers/iommu/Kconfig | 14 ++++++++++++++ drivers/iommu/iommu.c | 5 +++++ 2 files changed, 19 insertions(+)
drivers/iommu/Kconfig +14 -0
@@ -85,6 +85,20 @@ config IOMMU_DEFAULT_PASSTHROUGH If unsure, say N here. +config IOMMU_LAZY_MODE + bool "IOMMU use lazy mode to flush IOTLB and free IOVA" + depends on IOMMU_API + help + For every IOMMU 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. Removing the need to pass in iommu.strict=0 + through command line on ARM64(Now, intel_iommu, amd_iommu, s390_iommu use + lazy mode as deault). If this is enabled, you can still disable with kernel + parameters, such as iommu.strict=1, intel_iommu=strict, amd_iommu=fullflush + or s390_iommu=strict depending on the architecture. + + If unsure, say N here. + config OF_IOMMU def_bool y depends on OF && IOMMU_API
drivers/iommu/iommu.c +5 -0
@@ -43,7 +43,12 @@#else static unsigned int iommu_def_domain_type =IOMMU_DOMAIN_DMA ;#endif + +#ifdef CONFIG_IOMMU_LAZY_MODE +static bool iommu_dma_strict__read_mostly ; +#else static bool iommu_dma_strict__read_mostly = true; +#endif struct iommu_callback_data {const struct iommu_ops *ops;
--
1.8.3
Quoted 8 lines · Zhen Lei
This allows the default behaviour to be controlled by a kernel config option instead of changing the command line for the kernel to include "iommu.strict=0" on ARM64 where this is desired.
This is similar to
CONFIG_IOMMU_DEFAULT_PASSTHROUGHNote: At present,
intel_iommu,amd_iommuands390_iommuuse lazy mode as defalut, so there is no need to add code for them.
/s/defalut/default/
Quoted 5 lines
Signed-off-by Zhen Lei <[email protected]>--- drivers/iommu/Kconfig | 14 ++++++++++++++ drivers/iommu/iommu.c | 5 +++++
Do we need to update kernel-parameters.txt for iommu.strict?
drivers/iommu/Kconfig config IOMMU_DEFAULT_PASSTHROUGH · line 88
Quoted 11 lines
2 files changed, 19 insertions(+)drivers/iommu/Kconfig +1
-0@@ -85,6 +85,20 @@ config IOMMU_DEFAULT_PASSTHROUGH If unsure, say N here. +config IOMMU_LAZY_MODE
maybe should add "DMA" to the name, and even "DEFAULT"
drivers/iommu/Kconfig config IOMMU_DEFAULT_PASSTHROUGH
Quoted 5 lines
drivers/iommu/Kconfig +5
-0+ bool "IOMMU use lazy mode to flush IOTLB and free IOVA" + depends on IOMMU_API + help + For every IOMMU unmap operation, the flush operation of IOTLB and the free + operation of IOVA are deferred.
This is a bit unclear, as there is no context. I think that you need to say something like, "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
drivers/iommu/Kconfig config IOMMU_DEFAULT_PASSTHROUGH
Quoted 3 lines
drivers/iommu/Kconfig +3
-0+ the related IOVA will be reused. Removing the need to pass in iommu.strict=0 + through command line on ARM64(Now, intel_iommu, amd_iommu, s390_iommu use + lazy mode as deault).
prone to going out-of-date
If this is enabled, you can still disable with kernel
Quoted 26 lines
drivers/iommu/Kconfig +5
-0+ parameters, such as iommu.strict=1, intel_iommu=strict, amd_iommu=fullflush + or s390_iommu=strict depending on the architecture. + + If unsure, say N here. + config OF_IOMMU def_bool y depends on OF && IOMMU_APIdrivers/iommu/iommu.c +5
-1@@ -43,7 +43,12 @@#else static unsigned int iommu_def_domain_type =IOMMU_DOMAIN_DMA ;#endif + +#ifdef CONFIG_IOMMU_LAZY_MODE +static bool iommu_dma_strict__read_mostly ; +#else static bool iommu_dma_strict__read_mostly = true; +#endif struct iommu_callback_data {const struct iommu_ops *ops; --
Quoted 4 lines
1.8.3
Cheers
Quoted 29 lines · John Garry
Quoted 8 lines · Zhen Lei
This allows the default behaviour to be controlled by a kernel config option instead of changing the command line for the kernel to include "iommu.strict=0" on ARM64 where this is desired.
This is similar to
CONFIG_IOMMU_DEFAULT_PASSTHROUGHNote: At present,
intel_iommu,amd_iommuands390_iommuuse lazy mode as defalut, so there is no need to add code for them./s/defalut/default/
Quoted 5 lines
Signed-off-by Zhen Lei <[email protected]>--- drivers/iommu/Kconfig | 14 ++++++++++++++ drivers/iommu/iommu.c | 5 +++++Do we need to update kernel-parameters.txt for iommu.strict?
Quoted 8 lines
2 files changed, 19 insertions(+)drivers/iommu/Kconfig +0
-0@@ -85,6 +85,20 @@ config IOMMU_DEFAULT_PASSTHROUGH
Quoted 5 lines
drivers/iommu/Kconfig config IOMMU_DEFAULT_PASSTHROUGH · line 88
Quoted 3 lines
drivers/iommu/Kconfig +1
-0If unsure, say N here. +config IOMMU_LAZY_MODEmaybe should add "DMA" to the name, and even "DEFAULT"
OK, thanks
Quoted 56 lines
drivers/iommu/Kconfig config IOMMU_DEFAULT_PASSTHROUGH
Quoted 6 lines
drivers/iommu/Kconfig +5
-0+ bool "IOMMU use lazy mode to flush IOTLB and free IOVA" + depends on IOMMU_API + help + For every IOMMU unmap operation, the flush operation of IOTLB and the free + operation of IOVA are deferred.This is a bit unclear, as there is no context. I think that you need to say something like, "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
drivers/iommu/Kconfig config IOMMU_DEFAULT_PASSTHROUGH
Quoted 3 lines
drivers/iommu/Kconfig +3
-0+ the related IOVA will be reused. Removing the need to pass in iommu.strict=0 + through command line on ARM64(Now, intel_iommu, amd_iommu, s390_iommu use + lazy mode as deault).prone to going out-of-date
If this is enabled, you can still disable with kernel
Quoted 30 lines
drivers/iommu/Kconfig +5
-0+ parameters, such as iommu.strict=1, intel_iommu=strict, amd_iommu=fullflush + or s390_iommu=strict depending on the architecture. + + If unsure, say N here. + config OF_IOMMU def_bool y depends on OF && IOMMU_APIdrivers/iommu/iommu.c +5
-0@@ -43,7 +43,12 @@#else static unsigned int iommu_def_domain_type =IOMMU_DOMAIN_DMA ;#endif + +#ifdef CONFIG_IOMMU_LAZY_MODE +static bool iommu_dma_strict__read_mostly ; +#else static bool iommu_dma_strict__read_mostly = true; +#endif struct iommu_callback_data {const struct iommu_ops *ops;Signature · 1 line
1.8.3Cheers
.
Signature · 2 lines
Thanks! BestRegards