[PATCH v11 3/3] iommu/amd: Add support for IOMMU default DMA mode build options

From: John Garry
Date: Tue Jun 08 2021 - 09:23:29 EST


From: Zhen Lei <thunder.leizhen@xxxxxxxxxx>

The default DMA mode lazy, but allow this to be set to strict mode at
build time. It may still be overridden by the relevant boot option.

Also make IOMMU_DEFAULT_LAZY default for when AMD_IOMMU config is set.

[jpg: Rebase for relocated file]
Signed-off-by: Zhen Lei <thunder.leizhen@xxxxxxxxxx>
Signed-off-by: John Garry <john.garry@xxxxxxxxxx>
---
drivers/iommu/Kconfig | 2 +-
drivers/iommu/amd/init.c | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index b68ec7ed23c0..6d99150050b9 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -95,7 +95,7 @@ choice
depends on IOMMU_API
depends on X86 || IA64 || X86_64 || ARM || ARM64

- default IOMMU_DEFAULT_LAZY if INTEL_IOMMU
+ default IOMMU_DEFAULT_LAZY if (AMD_IOMMU || INTEL_IOMMU)
default IOMMU_DEFAULT_STRICT
help
This option allows an IOMMU DMA mode to be chosen at build time, to
diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index d006724f4dc2..af662fc37cbe 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -160,7 +160,8 @@ u16 amd_iommu_last_bdf; /* largest PCI device id we have
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 */
+/* if true, flush on every unmap */
+bool amd_iommu_unmap_flush = IS_ENABLED(CONFIG_IOMMU_DEFAULT_STRICT);

LIST_HEAD(amd_iommu_list); /* list of all AMD IOMMUs in the
system */
--
2.26.2