Skip to contentSkip to conversation

microblaze: Enable CMA

PATCH Applied Michal Simek 7 participants 12 messages Jan 17, 2020 – Feb 4, 2020

Subsystems (9)
x86 MIPS RISC-V arm64 +5 more subsystems
lore
Share & tools
lore
#0 lore raw

v2 cover microblaze: Enable CMA

Hi,

the patchset enable CMA on Microblaze. Based on Christoph request I have created the first patch which makes dma-continugous.h mandatory for all archs before Microblaze wiring.

Thanks,
Michal

Changes in v2:
- New patch suggested by Christoph
- Align commit message
- Remove adding dma-contigous.h via Kbuild because it is done by previous patch

Michal Simek (2):
asm-generic: Make dma-contiguous.h a mandatory include/asm header
microblaze: Wire CMA allocator

 arch/arm64/include/asm/Kbuild         | 1 -
 arch/csky/include/asm/Kbuild          | 1 -
 arch/microblaze/Kconfig               | 1 +
 arch/microblaze/configs/mmu_defconfig | 2 ++
 arch/microblaze/mm/init.c             | 4 ++++
 arch/mips/include/asm/Kbuild          | 1 -
 arch/riscv/include/asm/Kbuild         | 1 -
 arch/s390/include/asm/Kbuild          | 1 -
 arch/x86/include/asm/Kbuild           | 1 -
 arch/xtensa/include/asm/Kbuild        | 1 -
 include/asm-generic/Kbuild            | 1 +
 11 files changed, 8 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.0
#1 lore raw

PATCH v2 1/2 asm-generic: Make dma-contiguous.h a mandatory include/asm header

dma-continuguous.h is generic for all architectures except arm32 which has its own version.

Similar change was done for msi.h by commit a1b39bae16a6 ("asm-generic: Make msi.h a mandatory include/asm header")

---

Changes in v2:
- New patch suggested by Christoph

 arch/arm64/include/asm/Kbuild  | 1 -
 arch/csky/include/asm/Kbuild   | 1 -
 arch/mips/include/asm/Kbuild   | 1 -
 arch/riscv/include/asm/Kbuild  | 1 -
 arch/s390/include/asm/Kbuild   | 1 -
 arch/x86/include/asm/Kbuild    | 1 -
 arch/xtensa/include/asm/Kbuild | 1 -
 include/asm-generic/Kbuild     | 1 +
 8 files changed, 1 insertion(+), 7 deletions(-)
arch/arm64/include/asm/Kbuild +0 -1
index bd23f87d6c55..d3077c991962 100644
@@ -3,7 +3,6 @@ generic-y += bugs.h
 generic-y += delay.h
 generic-y += div64.h
 generic-y += dma.h
-generic-y += dma-contiguous.h
 generic-y += dma-mapping.h
 generic-y += early_ioremap.h
 generic-y += emergency-restart.h
arch/csky/include/asm/Kbuild +0 -1
index 4d4754e6bf89..bc15a26c782f 100644
@@ -7,7 +7,6 @@ generic-y += delay.h
 generic-y += device.h
 generic-y += div64.h
 generic-y += dma.h
-generic-y += dma-contiguous.h
 generic-y += dma-mapping.h
 generic-y += emergency-restart.h
 generic-y += exec.h
arch/mips/include/asm/Kbuild +0 -1
index 61b0fc2026e6..179403ae5837 100644
@@ -6,7 +6,6 @@ generated-y += syscall_table_64_n64.h
 generated-y += syscall_table_64_o32.h
 generic-y += current.h
 generic-y += device.h
-generic-y += dma-contiguous.h
 generic-y += emergency-restart.h
 generic-y += export.h
 generic-y += irq_work.h
arch/riscv/include/asm/Kbuild +0 -1
index 1efaeddf1e4b..ec0ca8c6ab64 100644
@@ -7,7 +7,6 @@ generic-y += div64.h
 generic-y += extable.h
 generic-y += flat.h
 generic-y += dma.h
-generic-y += dma-contiguous.h
 generic-y += dma-mapping.h
 generic-y += emergency-restart.h
 generic-y += exec.h
arch/s390/include/asm/Kbuild +0 -1
index 2531f673f099..1832ae6442ef 100644
@@ -7,7 +7,6 @@ generated-y += unistd_nr.h
 generic-y += asm-offsets.h
 generic-y += cacheflush.h
 generic-y += device.h
-generic-y += dma-contiguous.h
 generic-y += dma-mapping.h
 generic-y += div64.h
 generic-y += emergency-restart.h
arch/x86/include/asm/Kbuild +0 -1
index 8b52bc5ddf69..ea34464d6221 100644
@@ -7,7 +7,6 @@ generated-y += unistd_32_ia32.h
 generated-y += unistd_64_x32.h
 generated-y += xen-hypercalls.h
 
-generic-y += dma-contiguous.h
 generic-y += early_ioremap.h
 generic-y += export.h
 generic-y += mcs_spinlock.h
arch/xtensa/include/asm/Kbuild +0 -1
index 3acc31e55e02..271917c24b7f 100644
@@ -4,7 +4,6 @@ generic-y += bug.h
 generic-y += compat.h
 generic-y += device.h
 generic-y += div64.h
-generic-y += dma-contiguous.h
 generic-y += dma-mapping.h
 generic-y += emergency-restart.h
 generic-y += exec.h
include/asm-generic/Kbuild +1 -0
index ddfee1bd9dc1..cd17d50697cc 100644
@@ -4,5 +4,6 @@
 # (This file is not included when SRCARCH=um since UML borrows several
 # asm headers from the host architecutre.)
 
+mandatory-y += dma-contiguous.h
 mandatory-y += msi.h
 mandatory-y += simd.h
Signature · 1 line
2.25.0
#9 lore raw

PATCH v2 2/2 microblaze: Wire CMA allocator

In reply to Michal Simek

Based on commit 04e3543e228f ("microblaze: use the generic dma coherent remap allocator")
CMA can be easily enabled by calling dma_contiguous_reserve() at the end of mmu_init(). High limit is end of lowmem space which is completely unused at this point of time.

---

Changes in v2:
- Align commit message
- Remove adding dma-contigous.h via Kbuild because it is done by previous patch

Christoph: Can you please review this patch?
I have used this cma allocator
https://lwn.net/Articles/485193/
also together with allocating and freeing via debugfs interface.

If there is any other good way how to test cma please let me know.

---
 arch/microblaze/Kconfig               | 1 +
 arch/microblaze/configs/mmu_defconfig | 2 ++
 arch/microblaze/mm/init.c             | 4 ++++
 3 files changed, 7 insertions(+)
arch/microblaze/Kconfig +1 -0
index 5f46ebe7bfe3..e6289294e7fc 100644
@@ -27,6 +27,7 @@ config MICROBLAZE
 	select HAVE_ARCH_HASH
 	select HAVE_ARCH_KGDB
 	select HAVE_DEBUG_KMEMLEAK
+	select HAVE_DMA_CONTIGUOUS
 	select HAVE_DYNAMIC_FTRACE
 	select HAVE_FTRACE_MCOUNT_RECORD
 	select HAVE_FUNCTION_GRAPH_TRACER
arch/microblaze/configs/mmu_defconfig +2 -0
index dd63766c2d19..9b8a50f30662 100644
@@ -26,6 +26,7 @@ CONFIG_MODULE_UNLOAD=y
 # CONFIG_BLK_DEV_BSG is not set
 CONFIG_PARTITION_ADVANCED=y
 # CONFIG_EFI_PARTITION is not set
+CONFIG_CMA=y
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
@@ -82,6 +83,7 @@ CONFIG_NFS_FS=y
 CONFIG_CIFS=y
 CONFIG_CIFS_STATS2=y
 CONFIG_ENCRYPTED_KEYS=y
+CONFIG_DMA_CMA=y
 CONFIG_DEBUG_INFO=y
 CONFIG_KGDB=y
 CONFIG_KGDB_TESTS=y
arch/microblaze/mm/init.c +4 -0
index 050fc621c920..1056f1674065 100644
@@ -7,6 +7,7 @@
  * for more details.
  */
 
+#include <linux/dma-contiguous.h>
 #include <linux/memblock.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -345,6 +346,9 @@ asmlinkage void __init mmu_init(void)
 	/* This will also cause that unflatten device tree will be allocated
 	 * inside 768MB limit */
 	memblock_set_current_limit(memory_start + lowmem_size - 1);
+
+	/* CMA initialization */
+	dma_contiguous_reserve(memory_start + lowmem_size - 1);
 }
 
 /* This is only called until mem_init is done. */
Signature · 1 line
2.25.0
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] asm-generic: Make dma-contiguous.h a mandatory include/asm header

In reply to Michal Simek
Quoted 8 lines · Michal Simek

dma-continuguous.h is generic for all architectures except arm32 which has its own version.

Similar change was done for msi.h by commit a1b39bae16a6 ("asm-generic: Make msi.h a mandatory include/asm header")

Looks good,

Reviewed-by on v2 2/2
#10 lore raw

Re: [PATCH v2 2/2] microblaze: Wire CMA allocator

In reply to Michal Simek
Quoted 7 lines · Michal Simek

Based on commit 04e3543e228f ("microblaze: use the generic dma coherent remap allocator")
CMA can be easily enabled by calling dma_contiguous_reserve() at the end of mmu_init(). High limit is end of lowmem space which is completely unused at this point of time.

Looks good,

Acked-by on v2 1/2
#3 lore raw

Re: [PATCH v2 1/2] asm-generic: Make dma-contiguous.h a mandatory include/asm header

In reply to Michal Simek
Quoted 8 lines · Michal Simek

dma-continuguous.h is generic for all architectures except arm32 which has its own version.

Similar change was done for msi.h by commit a1b39bae16a6 ("asm-generic: Make msi.h a mandatory include/asm header")

maintainer Acked-by on v2 1/2
#4 lore raw

Re: [PATCH v2 1/2] asm-generic: Make dma-contiguous.h a mandatory include/asm header

In reply to Michal Simek
Quoted 7 lines · Michal Simek

dma-continuguous.h is generic for all architectures except arm32 which has its own version.

Similar change was done for msi.h by commit a1b39bae16a6 ("asm-generic: Make msi.h a mandatory include/asm header")

Quoted 6 lines

---

Changes in v2:
- New patch suggested by Christoph

maintainer Acked-by on v2 1/2
#5 lore raw

Re: [PATCH v2 1/2] asm-generic: Make dma-contiguous.h a mandatory include/asm header

In reply to Michal Simek
Quoted 10 lines · Michal Simek

dma-continuguous.h is generic for all architectures except arm32 which has its own version.

Similar change was done for msi.h by commit a1b39bae16a6 ("asm-generic: Make msi.h a mandatory include/asm header")

---

Acked-by on v2 1/2
#6 lore raw

Re: [PATCH v2 1/2] asm-generic: Make dma-contiguous.h a mandatory include/asm header

In reply to Michal Simek
Quoted 8 lines · Michal Simek

dma-continuguous.h is generic for all architectures except arm32 which has its own version.

Similar change was done for msi.h by commit a1b39bae16a6 ("asm-generic: Make msi.h a mandatory include/asm header")

- Paul

#7 lore raw

Re: [PATCH v2 1/2] asm-generic: Make dma-contiguous.h a mandatory include/asm header

In reply to Michal Simek

Hi.

Quoted 3 lines · Michal Simek

dma-continuguous.h is generic for all architectures except arm32 which has its own version.

Currently, <asm/dma-contiguous.h> is present for only architectures that select HAVE_DMA_CONTIGUOUS.

After this commit, the other architectures will end up with generating the unused header.

That would not be a big deal, but
it could be mentioned in the commit message?

Quoted 119 lines

Similar change was done for msi.h by commit a1b39bae16a6 ("asm-generic: Make msi.h a mandatory include/asm header")

---

Changes in v2:
- New patch suggested by Christoph

 arch/arm64/include/asm/Kbuild  | 1 -
 arch/csky/include/asm/Kbuild   | 1 -
 arch/mips/include/asm/Kbuild   | 1 -
 arch/riscv/include/asm/Kbuild  | 1 -
 arch/s390/include/asm/Kbuild   | 1 -
 arch/x86/include/asm/Kbuild    | 1 -
 arch/xtensa/include/asm/Kbuild | 1 -
 include/asm-generic/Kbuild     | 1 +
 8 files changed, 1 insertion(+), 7 deletions(-)
arch/arm64/include/asm/Kbuild +0 -1
index bd23f87d6c55..d3077c991962 100644
@@ -3,7 +3,6 @@ generic-y += bugs.h
 generic-y += delay.h
 generic-y += div64.h
 generic-y += dma.h
-generic-y += dma-contiguous.h
 generic-y += dma-mapping.h
 generic-y += early_ioremap.h
 generic-y += emergency-restart.h
arch/csky/include/asm/Kbuild +0 -1
index 4d4754e6bf89..bc15a26c782f 100644
@@ -7,7 +7,6 @@ generic-y += delay.h
 generic-y += device.h
 generic-y += div64.h
 generic-y += dma.h
-generic-y += dma-contiguous.h
 generic-y += dma-mapping.h
 generic-y += emergency-restart.h
 generic-y += exec.h
arch/mips/include/asm/Kbuild +0 -1
index 61b0fc2026e6..179403ae5837 100644
@@ -6,7 +6,6 @@ generated-y += syscall_table_64_n64.h
 generated-y += syscall_table_64_o32.h
 generic-y += current.h
 generic-y += device.h
-generic-y += dma-contiguous.h
 generic-y += emergency-restart.h
 generic-y += export.h
 generic-y += irq_work.h
arch/riscv/include/asm/Kbuild +0 -1
index 1efaeddf1e4b..ec0ca8c6ab64 100644
@@ -7,7 +7,6 @@ generic-y += div64.h
 generic-y += extable.h
 generic-y += flat.h
 generic-y += dma.h
-generic-y += dma-contiguous.h
 generic-y += dma-mapping.h
 generic-y += emergency-restart.h
 generic-y += exec.h
arch/s390/include/asm/Kbuild +0 -1
index 2531f673f099..1832ae6442ef 100644
@@ -7,7 +7,6 @@ generated-y += unistd_nr.h
 generic-y += asm-offsets.h
 generic-y += cacheflush.h
 generic-y += device.h
-generic-y += dma-contiguous.h
 generic-y += dma-mapping.h
 generic-y += div64.h
 generic-y += emergency-restart.h
arch/x86/include/asm/Kbuild +0 -1
index 8b52bc5ddf69..ea34464d6221 100644
@@ -7,7 +7,6 @@ generated-y += unistd_32_ia32.h
 generated-y += unistd_64_x32.h
 generated-y += xen-hypercalls.h
 
-generic-y += dma-contiguous.h
 generic-y += early_ioremap.h
 generic-y += export.h
 generic-y += mcs_spinlock.h
arch/xtensa/include/asm/Kbuild +0 -1
index 3acc31e55e02..271917c24b7f 100644
@@ -4,7 +4,6 @@ generic-y += bug.h
 generic-y += compat.h
 generic-y += device.h
 generic-y += div64.h
-generic-y += dma-contiguous.h
 generic-y += dma-mapping.h
 generic-y += emergency-restart.h
 generic-y += exec.h
include/asm-generic/Kbuild +1 -1
index ddfee1bd9dc1..cd17d50697cc 100644
@@ -4,5 +4,6 @@
 # (This file is not included when SRCARCH=um since UML borrows several
 # asm headers from the host architecutre.)
 
+mandatory-y += dma-contiguous.h
 mandatory-y += msi.h
 mandatory-y += simd.h
--

2.25.0

Signature · 2 lines
Best Regards
Masahiro Yamada
maintainer
#8 lore raw

Re: [PATCH v2 1/2] asm-generic: Make dma-contiguous.h a mandatory include/asm header

Quoted 9 lines · Masahiro Yamada

Hi.

Quoted 3 lines · Michal Simek

dma-continuguous.h is generic for all architectures except arm32 which has its own version.

Quoted 8 lines

Currently, <asm/dma-contiguous.h> is present for only architectures that select HAVE_DMA_CONTIGUOUS.

After this commit, the other architectures will end up with generating the unused header.

That would not be a big deal, but
it could be mentioned in the commit message?

I have not a problem with mentioning it but not sure if this was done in past.

Thanks,
Michal

Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
maintainer Applied
#11 lore raw
In reply to Michal Simek
Quoted 19 lines · Michal Simek

Hi,

the patchset enable CMA on Microblaze. Based on Christoph request I have created the first patch which makes dma-continugous.h mandatory for all archs before Microblaze wiring.

Thanks,
Michal

Changes in v2:
- New patch suggested by Christoph
- Align commit message
- Remove adding dma-contigous.h via Kbuild because it is done by previous patch

Michal Simek (2):
asm-generic: Make dma-contiguous.h a mandatory include/asm header
microblaze: Wire CMA allocator

Quoted 13 lines
 arch/arm64/include/asm/Kbuild         | 1 -
 arch/csky/include/asm/Kbuild          | 1 -
 arch/microblaze/Kconfig               | 1 +
 arch/microblaze/configs/mmu_defconfig | 2 ++
 arch/microblaze/mm/init.c             | 4 ++++
 arch/mips/include/asm/Kbuild          | 1 -
 arch/riscv/include/asm/Kbuild         | 1 -
 arch/s390/include/asm/Kbuild          | 1 -
 arch/x86/include/asm/Kbuild           | 1 -
 arch/xtensa/include/asm/Kbuild        | 1 -
 include/asm-generic/Kbuild            | 1 +
 11 files changed, 8 insertions(+), 7 deletions(-)

Applied.

Thanks,
Michal

Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs