All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] microblaze: Wire CMA allocator
@ 2020-01-14 11:57 Michal Simek
  2020-01-14 15:47 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Simek @ 2020-01-14 11:57 UTC (permalink / raw)
  To: linux-kernel, monstr, michal.simek, git, Christoph Hellwig
  Cc: Andrew Morton, Geert Uytterhoeven, Greg Kroah-Hartman,
	Juergen Gross, Kate Stewart, Linus Walleij, Manish Narani,
	Manjukumar Matha, Masahiro Yamada, Max Filippov, Mike Rapoport,
	Stafford Horne, Will Deacon

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.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

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/include/asm/Kbuild    | 1 +
 arch/microblaze/mm/init.c             | 4 ++++
 4 files changed, 8 insertions(+)

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 5f46ebe7bfe3..e6289294e7fc 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -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
diff --git a/arch/microblaze/configs/mmu_defconfig b/arch/microblaze/configs/mmu_defconfig
index dd63766c2d19..9b8a50f30662 100644
--- a/arch/microblaze/configs/mmu_defconfig
+++ b/arch/microblaze/configs/mmu_defconfig
@@ -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
diff --git a/arch/microblaze/include/asm/Kbuild b/arch/microblaze/include/asm/Kbuild
index e5c9170a07fc..acb2d246002f 100644
--- a/arch/microblaze/include/asm/Kbuild
+++ b/arch/microblaze/include/asm/Kbuild
@@ -7,6 +7,7 @@ generic-y += bugs.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
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 050fc621c920..1056f1674065 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -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. */
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] microblaze: Wire CMA allocator
  2020-01-14 11:57 [PATCH] microblaze: Wire CMA allocator Michal Simek
@ 2020-01-14 15:47 ` Christoph Hellwig
  2020-01-17  7:51   ` Michal Simek
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2020-01-14 15:47 UTC (permalink / raw)
  To: Michal Simek
  Cc: linux-kernel, monstr, git, Christoph Hellwig, Andrew Morton,
	Geert Uytterhoeven, Greg Kroah-Hartman, Juergen Gross,
	Kate Stewart, Linus Walleij, Manish Narani, Manjukumar Matha,
	Masahiro Yamada, Max Filippov, Mike Rapoport, Stafford Horne,
	Will Deacon

On Tue, Jan 14, 2020 at 12:57:28PM +0100, Michal Simek wrote:
> 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.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Christoph: Can you please review this patch?

Looks sensible to me.  If you touch this area anyway I have a request,
though:

> +++ b/arch/microblaze/include/asm/Kbuild
> @@ -7,6 +7,7 @@ generic-y += bugs.h
>  generic-y += compat.h
>  generic-y += device.h
>  generic-y += div64.h
> +generic-y += dma-contiguous.h

Can you add a prep patch to add a

mandatory-y += dma-contiguous.h

to include/asm-generic/Kbuild and remove the generic-y in all the
arch files?  That reduces the arch churn a little.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] microblaze: Wire CMA allocator
  2020-01-14 15:47 ` Christoph Hellwig
@ 2020-01-17  7:51   ` Michal Simek
  0 siblings, 0 replies; 3+ messages in thread
From: Michal Simek @ 2020-01-17  7:51 UTC (permalink / raw)
  To: Christoph Hellwig, Michal Simek
  Cc: linux-kernel, monstr, git, Andrew Morton, Geert Uytterhoeven,
	Greg Kroah-Hartman, Juergen Gross, Kate Stewart, Linus Walleij,
	Manish Narani, Manjukumar Matha, Masahiro Yamada, Max Filippov,
	Mike Rapoport, Stafford Horne, Will Deacon

On 14. 01. 20 16:47, Christoph Hellwig wrote:
> On Tue, Jan 14, 2020 at 12:57:28PM +0100, Michal Simek wrote:
>> 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.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>>
>> Christoph: Can you please review this patch?
> 
> Looks sensible to me.  If you touch this area anyway I have a request,
> though:
> 
>> +++ b/arch/microblaze/include/asm/Kbuild
>> @@ -7,6 +7,7 @@ generic-y += bugs.h
>>  generic-y += compat.h
>>  generic-y += device.h
>>  generic-y += div64.h
>> +generic-y += dma-contiguous.h
> 
> Can you add a prep patch to add a
> 
> mandatory-y += dma-contiguous.h
> 
> to include/asm-generic/Kbuild and remove the generic-y in all the
> arch files?  That reduces the arch churn a little.

Sure not a problem.
M




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-17  7:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 11:57 [PATCH] microblaze: Wire CMA allocator Michal Simek
2020-01-14 15:47 ` Christoph Hellwig
2020-01-17  7:51   ` Michal Simek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.