Mark Salter
2014-06-23 05:05:24 UTC
Commit 19e7640d1f (arm64: Replace ZONE_DMA32 with ZONE_DMA)
moves support for 32-bit DMA addressing into ZONE_DMA and renames
CONFIG_ZONE_DMA32 to CONFIG_ZONE_DMA.
Commit 2d5a5612bc (arm64: Limit the CMA buffer to 32-bit if ZONE_DMA)
forces the CMA buffer to be 32-bit addressable if CONFIG_ZONE_DMA is
defined.
These two patches pose a problem for platforms which have no 32-bit
addressable DRAM. If CONFIG_ZONE_DMA is turned on for such platforms,
CMA is unable to reserve a buffer for allocations. CONFIG_ZONE_DMA is
not user settable however, so there is no way to turn it off without
editing arch/arm64/Kconfig. Even if one edits Kconfig to turn off
CONFIG_ZONE_DMA, the kernel fails to build with such a config:
arch/arm64/mm/init.c: In function =E2=80=98zone_sizes_init=E2=80=99:
arch/arm64/mm/init.c:76:13: error: =E2=80=98ZONE_DMA=E2=80=99 undecla=
red (first use in this function)
zone_size[ZONE_DMA] =3D max_dma - min;
^
This patch makes CONFIG_ZONE_DMA user settable and fixes the kernel
build when it is turned off.
Signed-off-by: Mark Salter <***@redhat.com>
---
arch/arm64/Kconfig | 11 ++++++++---
arch/arm64/mm/init.c | 8 ++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index c8b1d0b..f669597 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -99,9 +99,6 @@ config GENERIC_CSUM
config GENERIC_CALIBRATE_DELAY
def_bool y
=20
-config ZONE_DMA
- def_bool y
-
config ARCH_DMA_ADDR_T_64BIT
def_bool y
=20
@@ -211,6 +208,14 @@ config HOTPLUG_CPU
Say Y here to experiment with turning CPUs off and on. CPUs
can be controlled through /sys/devices/system/cpu.
=20
+config ZONE_DMA
+ bool "32-bit DMA memory allocation"
+ def_bool y
+ help
+ 32-bit DMA memory allocation supports devices limited to 32-bit
+ DMA addressing to allocate within the first 4GiB of address space.
+ Disable if no such devices will be used.
+
source kernel/Kconfig.preempt
=20
config HZ
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index f43db8a..c5415e2 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -69,12 +69,14 @@ static void __init zone_sizes_init(unsigned long mi=
n, unsigned long max)
memset(zone_size, 0, sizeof(zone_size));
=20
/* 4GB maximum for 32-bit only capable devices */
- if (IS_ENABLED(CONFIG_ZONE_DMA)) {
+#ifdef CONFIG_ZONE_DMA
+ {
unsigned long max_dma_phys =3D
(unsigned long)(dma_to_phys(NULL, DMA_BIT_MASK(32)) + 1);
max_dma =3D max(min, min(max, max_dma_phys >> PAGE_SHIFT));
zone_size[ZONE_DMA] =3D max_dma - min;
}
+#endif
zone_size[ZONE_NORMAL] =3D max - max_dma;
=20
memcpy(zhole_size, zone_size, sizeof(zhole_size));
@@ -86,10 +88,12 @@ static void __init zone_sizes_init(unsigned long mi=
n, unsigned long max)
if (start >=3D max)
continue;
=20
- if (IS_ENABLED(CONFIG_ZONE_DMA) && start < max_dma) {
+#ifdef CONFIG_ZONE_DMA
+ if (start < max_dma) {
unsigned long dma_end =3D min(end, max_dma);
zhole_size[ZONE_DMA] -=3D dma_end - start;
}
+#endif
=20
if (end > max_dma) {
unsigned long normal_end =3D min(end, max);
--=20
1.8.3.1
moves support for 32-bit DMA addressing into ZONE_DMA and renames
CONFIG_ZONE_DMA32 to CONFIG_ZONE_DMA.
Commit 2d5a5612bc (arm64: Limit the CMA buffer to 32-bit if ZONE_DMA)
forces the CMA buffer to be 32-bit addressable if CONFIG_ZONE_DMA is
defined.
These two patches pose a problem for platforms which have no 32-bit
addressable DRAM. If CONFIG_ZONE_DMA is turned on for such platforms,
CMA is unable to reserve a buffer for allocations. CONFIG_ZONE_DMA is
not user settable however, so there is no way to turn it off without
editing arch/arm64/Kconfig. Even if one edits Kconfig to turn off
CONFIG_ZONE_DMA, the kernel fails to build with such a config:
arch/arm64/mm/init.c: In function =E2=80=98zone_sizes_init=E2=80=99:
arch/arm64/mm/init.c:76:13: error: =E2=80=98ZONE_DMA=E2=80=99 undecla=
red (first use in this function)
zone_size[ZONE_DMA] =3D max_dma - min;
^
This patch makes CONFIG_ZONE_DMA user settable and fixes the kernel
build when it is turned off.
Signed-off-by: Mark Salter <***@redhat.com>
---
arch/arm64/Kconfig | 11 ++++++++---
arch/arm64/mm/init.c | 8 ++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index c8b1d0b..f669597 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -99,9 +99,6 @@ config GENERIC_CSUM
config GENERIC_CALIBRATE_DELAY
def_bool y
=20
-config ZONE_DMA
- def_bool y
-
config ARCH_DMA_ADDR_T_64BIT
def_bool y
=20
@@ -211,6 +208,14 @@ config HOTPLUG_CPU
Say Y here to experiment with turning CPUs off and on. CPUs
can be controlled through /sys/devices/system/cpu.
=20
+config ZONE_DMA
+ bool "32-bit DMA memory allocation"
+ def_bool y
+ help
+ 32-bit DMA memory allocation supports devices limited to 32-bit
+ DMA addressing to allocate within the first 4GiB of address space.
+ Disable if no such devices will be used.
+
source kernel/Kconfig.preempt
=20
config HZ
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index f43db8a..c5415e2 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -69,12 +69,14 @@ static void __init zone_sizes_init(unsigned long mi=
n, unsigned long max)
memset(zone_size, 0, sizeof(zone_size));
=20
/* 4GB maximum for 32-bit only capable devices */
- if (IS_ENABLED(CONFIG_ZONE_DMA)) {
+#ifdef CONFIG_ZONE_DMA
+ {
unsigned long max_dma_phys =3D
(unsigned long)(dma_to_phys(NULL, DMA_BIT_MASK(32)) + 1);
max_dma =3D max(min, min(max, max_dma_phys >> PAGE_SHIFT));
zone_size[ZONE_DMA] =3D max_dma - min;
}
+#endif
zone_size[ZONE_NORMAL] =3D max - max_dma;
=20
memcpy(zhole_size, zone_size, sizeof(zhole_size));
@@ -86,10 +88,12 @@ static void __init zone_sizes_init(unsigned long mi=
n, unsigned long max)
if (start >=3D max)
continue;
=20
- if (IS_ENABLED(CONFIG_ZONE_DMA) && start < max_dma) {
+#ifdef CONFIG_ZONE_DMA
+ if (start < max_dma) {
unsigned long dma_end =3D min(end, max_dma);
zhole_size[ZONE_DMA] -=3D dma_end - start;
}
+#endif
=20
if (end > max_dma) {
unsigned long normal_end =3D min(end, max);
--=20
1.8.3.1