* [PATCH 0/4] mips: Add cma support to mips
@ 2014-07-16 15:51 Zubair Lutfullah Kakakhel
2014-07-16 15:51 ` [PATCH 1/4] asm-generic: Add dma-contiguous.h Zubair Lutfullah Kakakhel
` (5 more replies)
0 siblings, 6 replies; 14+ messages in thread
From: Zubair Lutfullah Kakakhel @ 2014-07-16 15:51 UTC (permalink / raw)
To: linux-arm-kernel
Here we have 4 patches that add cma support to mips.
Patch 1 adds dma-contiguous.h to asm-generic
Patch 2 and 3 make arm64 and x86 use dma-contiguous from asm-generic
Patch 4 adds cma to mips.
I'd like to request ralf to take these set of 4 patches via his tree.
acks from asm-generic, arm64 and x86 welcome.
patches based on linux-next b997a07604562f1a54cc531fe1cf7447f0ed6078
Zubair Lutfullah Kakakhel (4):
asm-generic: Add dma-contiguous.h
arm64: use generic dma-contiguous.h
x86: use generic dma-contiguous.h
mips: dma: Add cma support
arch/arm64/include/asm/Kbuild | 1 +
arch/arm64/include/asm/dma-contiguous.h | 28 -------------------------
arch/mips/Kconfig | 1 +
arch/mips/include/asm/Kbuild | 1 +
arch/mips/kernel/setup.c | 9 ++++++++
arch/mips/mm/dma-default.c | 37 ++++++++++++++++++++++-----------
arch/x86/include/asm/Kbuild | 1 +
arch/x86/include/asm/dma-contiguous.h | 12 -----------
include/asm-generic/dma-contiguous.h | 9 ++++++++
9 files changed, 47 insertions(+), 52 deletions(-)
delete mode 100644 arch/arm64/include/asm/dma-contiguous.h
delete mode 100644 arch/x86/include/asm/dma-contiguous.h
create mode 100644 include/asm-generic/dma-contiguous.h
--
1.9.1
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 1/4] asm-generic: Add dma-contiguous.h 2014-07-16 15:51 [PATCH 0/4] mips: Add cma support to mips Zubair Lutfullah Kakakhel @ 2014-07-16 15:51 ` Zubair Lutfullah Kakakhel 2014-07-16 15:59 ` Will Deacon 2014-07-16 16:20 ` Michal Nazarewicz 2014-07-16 15:51 ` [PATCH 2/4] arm64: use generic dma-contiguous.h Zubair Lutfullah Kakakhel ` (4 subsequent siblings) 5 siblings, 2 replies; 14+ messages in thread From: Zubair Lutfullah Kakakhel @ 2014-07-16 15:51 UTC (permalink / raw) To: linux-arm-kernel This header is used by arm64 and x86 individually. Adding to asm-generic to avoid further code repetition while adding cma to mips. Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> --- include/asm-generic/dma-contiguous.h | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 include/asm-generic/dma-contiguous.h diff --git a/include/asm-generic/dma-contiguous.h b/include/asm-generic/dma-contiguous.h new file mode 100644 index 0000000..292c571 --- /dev/null +++ b/include/asm-generic/dma-contiguous.h @@ -0,0 +1,9 @@ +#ifndef _ASM_GENERIC_DMA_CONTIGUOUS_H +#define _ASM_GENERIC_DMA_CONTIGUOUS_H + +#include <linux/types.h> + +static inline void +dma_contiguous_early_fixup(phys_addr_t base, unsigned long size) { } + +#endif -- 1.9.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 1/4] asm-generic: Add dma-contiguous.h 2014-07-16 15:51 ` [PATCH 1/4] asm-generic: Add dma-contiguous.h Zubair Lutfullah Kakakhel @ 2014-07-16 15:59 ` Will Deacon 2014-07-16 16:20 ` Michal Nazarewicz 1 sibling, 0 replies; 14+ messages in thread From: Will Deacon @ 2014-07-16 15:59 UTC (permalink / raw) To: linux-arm-kernel On Wed, Jul 16, 2014 at 04:51:29PM +0100, Zubair Lutfullah Kakakhel wrote: > This header is used by arm64 and x86 individually. > > Adding to asm-generic to avoid further code repetition while adding cma > to mips. > > Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> > --- > include/asm-generic/dma-contiguous.h | 9 +++++++++ > 1 file changed, 9 insertions(+) > create mode 100644 include/asm-generic/dma-contiguous.h > > diff --git a/include/asm-generic/dma-contiguous.h b/include/asm-generic/dma-contiguous.h > new file mode 100644 > index 0000000..292c571 > --- /dev/null > +++ b/include/asm-generic/dma-contiguous.h > @@ -0,0 +1,9 @@ > +#ifndef _ASM_GENERIC_DMA_CONTIGUOUS_H > +#define _ASM_GENERIC_DMA_CONTIGUOUS_H > + > +#include <linux/types.h> > + > +static inline void > +dma_contiguous_early_fixup(phys_addr_t base, unsigned long size) { } > + > +#endif Acked-by: Will Deacon <will.deacon@arm.com> Will ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/4] asm-generic: Add dma-contiguous.h 2014-07-16 15:51 ` [PATCH 1/4] asm-generic: Add dma-contiguous.h Zubair Lutfullah Kakakhel 2014-07-16 15:59 ` Will Deacon @ 2014-07-16 16:20 ` Michal Nazarewicz 1 sibling, 0 replies; 14+ messages in thread From: Michal Nazarewicz @ 2014-07-16 16:20 UTC (permalink / raw) To: linux-arm-kernel On Wed, Jul 16 2014, Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> wrote: > This header is used by arm64 and x86 individually. > > Adding to asm-generic to avoid further code repetition while adding cma > to mips. > > Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> > --- > include/asm-generic/dma-contiguous.h | 9 +++++++++ > 1 file changed, 9 insertions(+) > create mode 100644 include/asm-generic/dma-contiguous.h > > diff --git a/include/asm-generic/dma-contiguous.h b/include/asm-generic/dma-contiguous.h > new file mode 100644 > index 0000000..292c571 > --- /dev/null > +++ b/include/asm-generic/dma-contiguous.h > @@ -0,0 +1,9 @@ > +#ifndef _ASM_GENERIC_DMA_CONTIGUOUS_H > +#define _ASM_GENERIC_DMA_CONTIGUOUS_H > + > +#include <linux/types.h> > + > +static inline void > +dma_contiguous_early_fixup(phys_addr_t base, unsigned long size) { } > + > +#endif > -- > 1.9.1 > -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Micha? ?mina86? Nazarewicz (o o) ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo-- ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/4] arm64: use generic dma-contiguous.h 2014-07-16 15:51 [PATCH 0/4] mips: Add cma support to mips Zubair Lutfullah Kakakhel 2014-07-16 15:51 ` [PATCH 1/4] asm-generic: Add dma-contiguous.h Zubair Lutfullah Kakakhel @ 2014-07-16 15:51 ` Zubair Lutfullah Kakakhel 2014-07-16 16:20 ` Michal Nazarewicz 2014-07-17 10:23 ` Catalin Marinas 2014-07-16 15:51 ` [PATCH 3/4] x86: " Zubair Lutfullah Kakakhel ` (3 subsequent siblings) 5 siblings, 2 replies; 14+ messages in thread From: Zubair Lutfullah Kakakhel @ 2014-07-16 15:51 UTC (permalink / raw) To: linux-arm-kernel dma-contiguous.h is now in asm-generic. Use that to avoid code repetition in arm64. Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> --- arch/arm64/include/asm/Kbuild | 1 + arch/arm64/include/asm/dma-contiguous.h | 28 ---------------------------- 2 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 arch/arm64/include/asm/dma-contiguous.h diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild index 0b3fcf8..92bf7cb 100644 --- a/arch/arm64/include/asm/Kbuild +++ b/arch/arm64/include/asm/Kbuild @@ -9,6 +9,7 @@ generic-y += current.h generic-y += delay.h generic-y += div64.h generic-y += dma.h +generic-y += dma-contiguous.h generic-y += emergency-restart.h generic-y += early_ioremap.h generic-y += errno.h diff --git a/arch/arm64/include/asm/dma-contiguous.h b/arch/arm64/include/asm/dma-contiguous.h deleted file mode 100644 index 14c4c0c..0000000 --- a/arch/arm64/include/asm/dma-contiguous.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2013, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _ASM_DMA_CONTIGUOUS_H -#define _ASM_DMA_CONTIGUOUS_H - -#ifdef __KERNEL__ -#ifdef CONFIG_DMA_CMA - -#include <linux/types.h> - -static inline void -dma_contiguous_early_fixup(phys_addr_t base, unsigned long size) { } - -#endif -#endif - -#endif -- 1.9.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/4] arm64: use generic dma-contiguous.h 2014-07-16 15:51 ` [PATCH 2/4] arm64: use generic dma-contiguous.h Zubair Lutfullah Kakakhel @ 2014-07-16 16:20 ` Michal Nazarewicz 2014-07-17 10:23 ` Catalin Marinas 1 sibling, 0 replies; 14+ messages in thread From: Michal Nazarewicz @ 2014-07-16 16:20 UTC (permalink / raw) To: linux-arm-kernel On Wed, Jul 16 2014, Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> wrote: > dma-contiguous.h is now in asm-generic. Use that to avoid code > repetition in arm64. > > Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> > --- > arch/arm64/include/asm/Kbuild | 1 + > arch/arm64/include/asm/dma-contiguous.h | 28 ---------------------------- > 2 files changed, 1 insertion(+), 28 deletions(-) > delete mode 100644 arch/arm64/include/asm/dma-contiguous.h > > diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild > index 0b3fcf8..92bf7cb 100644 > --- a/arch/arm64/include/asm/Kbuild > +++ b/arch/arm64/include/asm/Kbuild > @@ -9,6 +9,7 @@ generic-y += current.h > generic-y += delay.h > generic-y += div64.h > generic-y += dma.h > +generic-y += dma-contiguous.h > generic-y += emergency-restart.h > generic-y += early_ioremap.h > generic-y += errno.h > diff --git a/arch/arm64/include/asm/dma-contiguous.h b/arch/arm64/include/asm/dma-contiguous.h > deleted file mode 100644 > index 14c4c0c..0000000 > --- a/arch/arm64/include/asm/dma-contiguous.h > +++ /dev/null > @@ -1,28 +0,0 @@ > -/* > - * Copyright (c) 2013, The Linux Foundation. All rights reserved. > - * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License version 2 and > - * only version 2 as published by the Free Software Foundation. > - * > - * This program is distributed in the hope that it will be useful, > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > - * GNU General Public License for more details. > - */ > - > -#ifndef _ASM_DMA_CONTIGUOUS_H > -#define _ASM_DMA_CONTIGUOUS_H > - > -#ifdef __KERNEL__ > -#ifdef CONFIG_DMA_CMA > - > -#include <linux/types.h> > - > -static inline void > -dma_contiguous_early_fixup(phys_addr_t base, unsigned long size) { } > - > -#endif > -#endif > - > -#endif > -- > 1.9.1 > -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Micha? ?mina86? Nazarewicz (o o) ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo-- ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/4] arm64: use generic dma-contiguous.h 2014-07-16 15:51 ` [PATCH 2/4] arm64: use generic dma-contiguous.h Zubair Lutfullah Kakakhel 2014-07-16 16:20 ` Michal Nazarewicz @ 2014-07-17 10:23 ` Catalin Marinas 1 sibling, 0 replies; 14+ messages in thread From: Catalin Marinas @ 2014-07-17 10:23 UTC (permalink / raw) To: linux-arm-kernel On Wed, Jul 16, 2014 at 04:51:30PM +0100, Zubair Lutfullah Kakakhel wrote: > dma-contiguous.h is now in asm-generic. Use that to avoid code > repetition in arm64. > > Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> > --- > arch/arm64/include/asm/Kbuild | 1 + > arch/arm64/include/asm/dma-contiguous.h | 28 ---------------------------- > 2 files changed, 1 insertion(+), 28 deletions(-) > delete mode 100644 arch/arm64/include/asm/dma-contiguous.h Acked-by: Catalin Marinas <catalin.marinas@arm.com> ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 3/4] x86: use generic dma-contiguous.h 2014-07-16 15:51 [PATCH 0/4] mips: Add cma support to mips Zubair Lutfullah Kakakhel 2014-07-16 15:51 ` [PATCH 1/4] asm-generic: Add dma-contiguous.h Zubair Lutfullah Kakakhel 2014-07-16 15:51 ` [PATCH 2/4] arm64: use generic dma-contiguous.h Zubair Lutfullah Kakakhel @ 2014-07-16 15:51 ` Zubair Lutfullah Kakakhel 2014-07-16 16:20 ` Michal Nazarewicz 2014-07-16 15:51 ` [PATCH 4/4] mips: dma: Add cma support Zubair Lutfullah Kakakhel ` (2 subsequent siblings) 5 siblings, 1 reply; 14+ messages in thread From: Zubair Lutfullah Kakakhel @ 2014-07-16 15:51 UTC (permalink / raw) To: linux-arm-kernel dma-contiguous.h is now in asm-generic. Use that to avoid code repetition in x86. Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> --- arch/x86/include/asm/Kbuild | 1 + arch/x86/include/asm/dma-contiguous.h | 12 ------------ 2 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 arch/x86/include/asm/dma-contiguous.h diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild index 3bf000f..d55a210 100644 --- a/arch/x86/include/asm/Kbuild +++ b/arch/x86/include/asm/Kbuild @@ -6,6 +6,7 @@ genhdr-y += unistd_x32.h generic-y += clkdev.h generic-y += cputime.h +generic-y += dma-contiguous.h generic-y += early_ioremap.h generic-y += mcs_spinlock.h generic-y += scatterlist.h diff --git a/arch/x86/include/asm/dma-contiguous.h b/arch/x86/include/asm/dma-contiguous.h deleted file mode 100644 index b4b38ba..0000000 --- a/arch/x86/include/asm/dma-contiguous.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef ASMX86_DMA_CONTIGUOUS_H -#define ASMX86_DMA_CONTIGUOUS_H - -#ifdef __KERNEL__ - -#include <linux/types.h> - -static inline void -dma_contiguous_early_fixup(phys_addr_t base, unsigned long size) { } - -#endif -#endif -- 1.9.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/4] x86: use generic dma-contiguous.h 2014-07-16 15:51 ` [PATCH 3/4] x86: " Zubair Lutfullah Kakakhel @ 2014-07-16 16:20 ` Michal Nazarewicz 2014-07-17 9:02 ` Zubair Lutfullah Kakakhel 0 siblings, 1 reply; 14+ messages in thread From: Michal Nazarewicz @ 2014-07-16 16:20 UTC (permalink / raw) To: linux-arm-kernel On Wed, Jul 16 2014, Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> wrote: > dma-contiguous.h is now in asm-generic. Use that to avoid code > repetition in x86. > > Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> But to be honest, I would fold the three into a single commit. > --- > arch/x86/include/asm/Kbuild | 1 + > arch/x86/include/asm/dma-contiguous.h | 12 ------------ > 2 files changed, 1 insertion(+), 12 deletions(-) > delete mode 100644 arch/x86/include/asm/dma-contiguous.h > > diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild > index 3bf000f..d55a210 100644 > --- a/arch/x86/include/asm/Kbuild > +++ b/arch/x86/include/asm/Kbuild > @@ -6,6 +6,7 @@ genhdr-y += unistd_x32.h > > generic-y += clkdev.h > generic-y += cputime.h > +generic-y += dma-contiguous.h > generic-y += early_ioremap.h > generic-y += mcs_spinlock.h > generic-y += scatterlist.h > diff --git a/arch/x86/include/asm/dma-contiguous.h b/arch/x86/include/asm/dma-contiguous.h > deleted file mode 100644 > index b4b38ba..0000000 > --- a/arch/x86/include/asm/dma-contiguous.h > +++ /dev/null > @@ -1,12 +0,0 @@ > -#ifndef ASMX86_DMA_CONTIGUOUS_H > -#define ASMX86_DMA_CONTIGUOUS_H > - > -#ifdef __KERNEL__ > - > -#include <linux/types.h> > - > -static inline void > -dma_contiguous_early_fixup(phys_addr_t base, unsigned long size) { } > - > -#endif > -#endif > -- > 1.9.1 > -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Micha? ?mina86? Nazarewicz (o o) ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo-- ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 3/4] x86: use generic dma-contiguous.h 2014-07-16 16:20 ` Michal Nazarewicz @ 2014-07-17 9:02 ` Zubair Lutfullah Kakakhel 0 siblings, 0 replies; 14+ messages in thread From: Zubair Lutfullah Kakakhel @ 2014-07-17 9:02 UTC (permalink / raw) To: linux-arm-kernel On 16/07/14 17:20, Michal Nazarewicz wrote: > On Wed, Jul 16 2014, Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> wrote: >> dma-contiguous.h is now in asm-generic. Use that to avoid code >> repetition in x86. >> >> Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> > > Acked-by: Michal Nazarewicz <mina86@mina86.com> > > But to be honest, I would fold the three into a single commit. Thank-you for the acks. I understand as its a trivial change. But architectures like it separate. They will obviously go together via one tree. ZubairLK ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 4/4] mips: dma: Add cma support 2014-07-16 15:51 [PATCH 0/4] mips: Add cma support to mips Zubair Lutfullah Kakakhel ` (2 preceding siblings ...) 2014-07-16 15:51 ` [PATCH 3/4] x86: " Zubair Lutfullah Kakakhel @ 2014-07-16 15:51 ` Zubair Lutfullah Kakakhel 2014-07-16 16:39 ` Michal Nazarewicz 2014-07-16 16:18 ` [PATCH 0/4] mips: Add cma support to mips Manuel Lauss 2014-07-17 12:31 ` Marek Szyprowski 5 siblings, 1 reply; 14+ messages in thread From: Zubair Lutfullah Kakakhel @ 2014-07-16 15:51 UTC (permalink / raw) To: linux-arm-kernel Adds cma support to the mips architecture. cma uses memblock. However, mips uses bootmem. bootmem is informed about any regions reserved by memblock dma api is modified to use cma reserved memory regions when available Tested using cma_test. cma_test is a simple driver that assigns blocks of memory from cma reserved sections. Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> --- arch/mips/Kconfig | 1 + arch/mips/include/asm/Kbuild | 1 + arch/mips/kernel/setup.c | 9 +++++++++ arch/mips/mm/dma-default.c | 37 +++++++++++++++++++++++++------------ 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 1f7bd32..7ebe54f 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -30,6 +30,7 @@ config MIPS select GENERIC_ATOMIC64 if !64BIT select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select HAVE_DMA_ATTRS + select HAVE_DMA_CONTIGUOUS select HAVE_DMA_API_DEBUG select GENERIC_IRQ_PROBE select GENERIC_IRQ_SHOW diff --git a/arch/mips/include/asm/Kbuild b/arch/mips/include/asm/Kbuild index 0543918..552ed28 100644 --- a/arch/mips/include/asm/Kbuild +++ b/arch/mips/include/asm/Kbuild @@ -1,6 +1,7 @@ # MIPS headers generic-y += cputime.h generic-y += current.h +generic-y += dma-contiguous.h generic-y += emergency-restart.h generic-y += hash.h generic-y += local64.h diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index a842154..217928f 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -24,6 +24,8 @@ #include <linux/debugfs.h> #include <linux/kexec.h> #include <linux/sizes.h> +#include <linux/device.h> +#include <linux/dma-contiguous.h> #include <asm/addrspace.h> #include <asm/bootinfo.h> @@ -476,6 +478,7 @@ static void __init bootmem_init(void) * o bootmem_init() * o sparse_init() * o paging_init() + * o dma_continguous_reserve() * * At this stage the bootmem allocator is ready to use. * @@ -609,6 +612,7 @@ static void __init request_crashkernel(struct resource *res) static void __init arch_mem_init(char **cmdline_p) { + struct memblock_region *reg; extern void plat_mem_setup(void); /* call board setup routine */ @@ -675,6 +679,11 @@ static void __init arch_mem_init(char **cmdline_p) sparse_init(); plat_swiotlb_setup(); paging_init(); + + dma_contiguous_reserve(PFN_PHYS(max_low_pfn)); + /* Tell bootmem about cma reserved memblock section */ + for_each_memblock(reserved, reg) + reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT); } static void __init resource_init(void) diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c index 44b6dff..33ba3c5 100644 --- a/arch/mips/mm/dma-default.c +++ b/arch/mips/mm/dma-default.c @@ -16,6 +16,7 @@ #include <linux/string.h> #include <linux/gfp.h> #include <linux/highmem.h> +#include <linux/dma-contiguous.h> #include <asm/cache.h> #include <asm/cpu-type.h> @@ -128,23 +129,30 @@ static void *mips_dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t * dma_handle, gfp_t gfp, struct dma_attrs *attrs) { void *ret; + struct page *page = NULL; + unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT; if (dma_alloc_from_coherent(dev, size, dma_handle, &ret)) return ret; gfp = massage_gfp_flags(dev, gfp); - ret = (void *) __get_free_pages(gfp, get_order(size)); - - if (ret) { - memset(ret, 0, size); - *dma_handle = plat_map_dma_mem(dev, ret, size); - - if (!plat_device_is_coherent(dev)) { - dma_cache_wback_inv((unsigned long) ret, size); - if (!hw_coherentio) - ret = UNCAC_ADDR(ret); - } + if (IS_ENABLED(CONFIG_DMA_CMA) && !(gfp & GFP_ATOMIC)) + page = dma_alloc_from_contiguous(dev, + count, get_order(size)); + if (!page) + page = alloc_pages(gfp, get_order(size)); + + if (!page) + return NULL; + + ret = page_address(page); + memset(ret, 0, size); + *dma_handle = plat_map_dma_mem(dev, ret, size); + if (!plat_device_is_coherent(dev)) { + dma_cache_wback_inv((unsigned long) ret, size); + if (!hw_coherentio) + ret = UNCAC_ADDR(ret); } return ret; @@ -164,6 +172,8 @@ static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr, { unsigned long addr = (unsigned long) vaddr; int order = get_order(size); + unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT; + struct page *page = NULL; if (dma_release_from_coherent(dev, order, vaddr)) return; @@ -173,7 +183,10 @@ static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr, if (!plat_device_is_coherent(dev) && !hw_coherentio) addr = CAC_ADDR(addr); - free_pages(addr, get_order(size)); + page = virt_to_page((void *) addr); + + if (!dma_release_from_contiguous(dev, page, count)) + __free_pages(page, get_order(size)); } static inline void __dma_sync_virtual(void *addr, size_t size, -- 1.9.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/4] mips: dma: Add cma support 2014-07-16 15:51 ` [PATCH 4/4] mips: dma: Add cma support Zubair Lutfullah Kakakhel @ 2014-07-16 16:39 ` Michal Nazarewicz 0 siblings, 0 replies; 14+ messages in thread From: Michal Nazarewicz @ 2014-07-16 16:39 UTC (permalink / raw) To: linux-arm-kernel On Wed, Jul 16 2014, Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> wrote: > Adds cma support to the mips architecture. > > cma uses memblock. However, mips uses bootmem. Does cma_early_percent_memory work correctly then? > bootmem is informed about any regions reserved by memblock Alternatively maybe it would make sense to create a new definition of dma_contiguous_reserve_area that uses bootmem and choose it based on some CONFIG_CMA_USE_BOOTMEM which would be selected by MIPS. > dma api is modified to use cma reserved memory regions when available > > Tested using cma_test. cma_test is a simple driver that assigns blocks > of memory from cma reserved sections. > > Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> > --- > arch/mips/Kconfig | 1 + > arch/mips/include/asm/Kbuild | 1 + > arch/mips/kernel/setup.c | 9 +++++++++ > arch/mips/mm/dma-default.c | 37 +++++++++++++++++++++++++------------ > 4 files changed, 36 insertions(+), 12 deletions(-) > -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Micha? ?mina86? Nazarewicz (o o) ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo-- ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 0/4] mips: Add cma support to mips 2014-07-16 15:51 [PATCH 0/4] mips: Add cma support to mips Zubair Lutfullah Kakakhel ` (3 preceding siblings ...) 2014-07-16 15:51 ` [PATCH 4/4] mips: dma: Add cma support Zubair Lutfullah Kakakhel @ 2014-07-16 16:18 ` Manuel Lauss 2014-07-17 12:31 ` Marek Szyprowski 5 siblings, 0 replies; 14+ messages in thread From: Manuel Lauss @ 2014-07-16 16:18 UTC (permalink / raw) To: linux-arm-kernel Hi, On Wed, Jul 16, 2014 at 5:51 PM, Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> wrote: > Here we have 4 patches that add cma support to mips. > > Patch 1 adds dma-contiguous.h to asm-generic > Patch 2 and 3 make arm64 and x86 use dma-contiguous from asm-generic > Patch 4 adds cma to mips. I've given this a try on mips32, I haven't dug into this error yet, maybe you have an idea: [...] Alchemy clocktree installed cma: CMA: reserved 32 MiB at 0a000000 [...] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ehci-pci: EHCI PCI platform driver ehci-platform: EHCI generic platform driver ehci-platform ehci-platform.0: EHCI Host Controller ehci-platform ehci-platform.0: new USB bus registered, assigned bus number 1 CPU 0 Unable to handle kernel paging request at virtual address 00000000, epc == 807669b0, ra == 8041a970 Oops[#1]: CPU: 0 PID: 1 Comm: swapper Not tainted 3.16.0-rc4-db1xxx-00062-g6c7bf71-dirty #1 task: 8bc34000 ti: 8bc1e000 task.ti: 8bc1e000 $ 0 : 00000000 10003c00 00000000 8bc1fb90 $ 4 : 80974f9c 00000000 00000093 00000093 $ 8 : 00000007 808d0000 00000010 00000093 $12 : 5f6d6f72 00000000 00000000 746e6f63 $16 : 80974f9c 00000001 8bc34000 808e6220 $20 : 00000000 80974fa0 80974f9c 8bc76380 $24 : 00000010 804091cc $28 : 8bc1e000 8bc1fb80 80970000 8041a970 Hi : 00000000 Lo : 3a699d00 epc : 807669b0 __mutex_lock_slowpath+0x4c/0x108 Not tainted ra : 8041a970 dma_alloc_from_contiguous+0xb8/0x1ec Status: 10003c03 KERNEL EXL IE Cause : 0080800c BadVA : 00000000 PrId : 800c8000 (Au1300) Process swapper (pid: 1, threadinfo=8bc1e000, task=8bc34000, tls=00000000) Stack : 8bc77010 80790000 808f0000 8bc76380 80974fa0 00000000 8bc1fbd8 00000013 00000006 80974f90 00000001 00000000 808e6220 00000000 80790000 8041a970 8b752c83 80790adc 80974f90 00000001 00000000 808932d5 8bc1fcb4 808932d3 00000fff 00001000 8b752e8c 000000d0 8bc77010 808f0000 808f0000 8bc76380 00000000 80111d58 ff0a0210 ffffffff 8b752c80 00000003 8b752c80 8bc1fcb0 ... Call Trace: [<807669b0>] __mutex_lock_slowpath+0x4c/0x108 [<8041a970>] dma_alloc_from_contiguous+0xb8/0x1ec [<80111d58>] mips_dma_alloc_coherent+0xa4/0x148 [<801c11f8>] dma_pool_alloc+0xe0/0x1bc [<804c755c>] ehci_qh_alloc+0x44/0xd4 [<804c8044>] ehci_setup+0x158/0x448 [<804cadfc>] ehci_platform_reset+0x74/0xd8 [<804af588>] usb_add_hcd+0x26c/0x79c [<804caca0>] ehci_platform_probe+0x2c4/0x3ac [<80417480>] platform_drv_probe+0x24/0x60 [<80415d8c>] driver_probe_device+0xec/0x244 [<80415fc4>] __driver_attach+0x7c/0xb4 [<80414190>] bus_for_each_dev+0x64/0xc0 [<80414cd0>] bus_add_driver+0xdc/0x1f8 [<804168d8>] driver_register+0xac/0x114 [<80901c7c>] do_one_initcall+0x174/0x240 [<80901ecc>] kernel_init_freeable+0x184/0x250 [<80761edc>] kernel_init+0x10/0x100 [<80108d88>] ret_from_kernel_thread+0x14/0x1c ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 0/4] mips: Add cma support to mips 2014-07-16 15:51 [PATCH 0/4] mips: Add cma support to mips Zubair Lutfullah Kakakhel ` (4 preceding siblings ...) 2014-07-16 16:18 ` [PATCH 0/4] mips: Add cma support to mips Manuel Lauss @ 2014-07-17 12:31 ` Marek Szyprowski 5 siblings, 0 replies; 14+ messages in thread From: Marek Szyprowski @ 2014-07-17 12:31 UTC (permalink / raw) To: linux-arm-kernel Hello, On 2014-07-16 17:51, Zubair Lutfullah Kakakhel wrote: > Here we have 4 patches that add cma support to mips. > > Patch 1 adds dma-contiguous.h to asm-generic > Patch 2 and 3 make arm64 and x86 use dma-contiguous from asm-generic > Patch 4 adds cma to mips. > > I'd like to request ralf to take these set of 4 patches via his tree. > > acks from asm-generic, arm64 and x86 welcome. > > patches based on linux-next b997a07604562f1a54cc531fe1cf7447f0ed6078 Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> > Zubair Lutfullah Kakakhel (4): > asm-generic: Add dma-contiguous.h > arm64: use generic dma-contiguous.h > x86: use generic dma-contiguous.h > mips: dma: Add cma support > > arch/arm64/include/asm/Kbuild | 1 + > arch/arm64/include/asm/dma-contiguous.h | 28 ------------------------- > arch/mips/Kconfig | 1 + > arch/mips/include/asm/Kbuild | 1 + > arch/mips/kernel/setup.c | 9 ++++++++ > arch/mips/mm/dma-default.c | 37 ++++++++++++++++++++++----------- > arch/x86/include/asm/Kbuild | 1 + > arch/x86/include/asm/dma-contiguous.h | 12 ----------- > include/asm-generic/dma-contiguous.h | 9 ++++++++ > 9 files changed, 47 insertions(+), 52 deletions(-) > delete mode 100644 arch/arm64/include/asm/dma-contiguous.h > delete mode 100644 arch/x86/include/asm/dma-contiguous.h > create mode 100644 include/asm-generic/dma-contiguous.h Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-07-17 12:31 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-07-16 15:51 [PATCH 0/4] mips: Add cma support to mips Zubair Lutfullah Kakakhel 2014-07-16 15:51 ` [PATCH 1/4] asm-generic: Add dma-contiguous.h Zubair Lutfullah Kakakhel 2014-07-16 15:59 ` Will Deacon 2014-07-16 16:20 ` Michal Nazarewicz 2014-07-16 15:51 ` [PATCH 2/4] arm64: use generic dma-contiguous.h Zubair Lutfullah Kakakhel 2014-07-16 16:20 ` Michal Nazarewicz 2014-07-17 10:23 ` Catalin Marinas 2014-07-16 15:51 ` [PATCH 3/4] x86: " Zubair Lutfullah Kakakhel 2014-07-16 16:20 ` Michal Nazarewicz 2014-07-17 9:02 ` Zubair Lutfullah Kakakhel 2014-07-16 15:51 ` [PATCH 4/4] mips: dma: Add cma support Zubair Lutfullah Kakakhel 2014-07-16 16:39 ` Michal Nazarewicz 2014-07-16 16:18 ` [PATCH 0/4] mips: Add cma support to mips Manuel Lauss 2014-07-17 12:31 ` Marek Szyprowski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).