[PATCH] x86, 64: let zone DMA cover low 4G if no ISA-style devices

From: Baoquan He
Date: Wed Jul 06 2022 - 03:26:15 EST


It doesn't make sense to let the rare legacy ISA-style devies
drag x86_64 to have a tiny zone DMA of 16M which cause many
troubles.

Signed-off-by: Baoquan He <bhe@xxxxxxxxxx>
---
arch/x86/Kconfig | 1 -
arch/x86/mm/init.c | 5 ++++-
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5aa4c2ecf5c7..93af781f9445 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2761,7 +2761,6 @@ config ISA_BUS
# x86_64 have no ISA slots, but can have ISA-style DMA.
config ISA_DMA_API
bool "ISA-style DMA support" if (X86_64 && EXPERT)
- default y
help
Enables ISA-style DMA support for devices requiring such controllers.
If unsure, say Y.
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 82a042c03824..c9ffb38dcc6a 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -1024,9 +1024,12 @@ void __init zone_sizes_init(void)

memset(max_zone_pfns, 0, sizeof(max_zone_pfns));

-#ifdef CONFIG_ZONE_DMA
+#if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ISA_DMA_API)
max_zone_pfns[ZONE_DMA] = min(MAX_DMA_PFN, max_low_pfn);
+#else
+ max_zone_pfns[ZONE_DMA] = min(MAX_DMA32_PFN, max_low_pfn);
#endif
+
#ifdef CONFIG_ZONE_DMA32
max_zone_pfns[ZONE_DMA32] = min(MAX_DMA32_PFN, max_low_pfn);
#endif
--
2.34.1