Hi Linus,
I would like to ask for pulling Contiguous Memory Allocator (CMA) and ARM DMA-mapping framework updates for v3.5.
The following changes since commit 76e10d158efb6d4516018846f60c2ab5501900bc:
Linux 3.4 (2012-05-20 15:29:13 -0700)
with the top-most commit 0f51596bd39a5c928307ffcffc9ba07f90f42a8b
Merge branch 'for-next-arm-dma' into for-linus
are available in the git repository at: git://git.linaro.org/people/mszyprowski/linux-dma-mapping.git for-linus
These patches contains 2 major updates for DMA mapping subsystem (mainly for ARM architecture). First one is Contiguous Memory Allocator (CMA) which makes it possible for device drivers to allocate big contiguous chunks of memory after the system has booted.
The main difference from the similar frameworks is the fact that CMA allows to transparently reuse memory region reserved for the big chunk allocation as a system memory, so no memory is wasted when no big chunk is allocated. Once the alloc request is issued, the framework migrates system pages to create a space for the required big chunk of physically contiguous memory.
For more information one can refer to nice LWN articles: 'A reworked contiguous memory allocator': http://lwn.net/Articles/447405/ 'CMA and ARM': http://lwn.net/Articles/450286/ 'A deep dive into CMA': http://lwn.net/Articles/486301/ and the following thread with the patches and links to all previous versions: https://lkml.org/lkml/2012/4/3/204
The main client for this new framework is ARM DMA-mapping subsystem.
The second part provides a complete redesign in ARM DMA-mapping subsystem. The core implementation has been changed to use common struct dma_map_ops based infrastructure with the recent updates for new dma attributes merged in v3.4-rc2. This allows to use more than one implementation of dma-mapping calls and change/select them on the struct device basis. The first client of this new infractructure is dmabounce implementation which has been completely cut out of the core, common code.
The last patch of this redesign update introduces a new, experimental implementation of dma-mapping calls on top of generic IOMMU framework. This lets ARM sub-platform to transparently use IOMMU for DMA-mapping calls if one provides required IOMMU hardware.
For more information please refer to the following thread: http://www.spinics.net/lists/arm-kernel/msg175729.html
The last patch merges changes from both updates and provides a resolution for the conflicts which cannot be avoided when patches have been applied on the same files (mainly arch/arm/mm/dma-mapping.c).
Thanks!
Best regards Marek Szyprowski Samsung Poland R&D Center
Patch summary:
Marek Szyprowski (17): common: add dma_mmap_from_coherent() function ARM: dma-mapping: use dma_mmap_from_coherent() ARM: dma-mapping: use pr_* instread of printk ARM: dma-mapping: introduce DMA_ERROR_CODE constant ARM: dma-mapping: remove offset parameter to prepare for generic dma_ops ARM: dma-mapping: use asm-generic/dma-mapping-common.h ARM: dma-mapping: implement dma sg methods on top of any generic dma ops ARM: dma-mapping: move all dma bounce code to separate dma ops structure ARM: dma-mapping: remove redundant code and do the cleanup ARM: dma-mapping: use alloc, mmap, free from dma_ops ARM: dma-mapping: add support for IOMMU mapper mm: extract reclaim code from __alloc_pages_direct_reclaim() mm: trigger page reclaim in alloc_contig_range() to stabilise watermarks drivers: add Contiguous Memory Allocator X86: integrate CMA with DMA-mapping subsystem ARM: integrate CMA with DMA-mapping subsystem Merge branch 'for-next-arm-dma' into for-linus
Mel Gorman (1): mm: Serialize access to min_free_kbytes
Michal Nazarewicz (9): mm: page_alloc: remove trailing whitespace mm: compaction: introduce isolate_migratepages_range() mm: compaction: introduce map_pages() mm: compaction: introduce isolate_freepages_range() mm: compaction: export some of the functions mm: page_alloc: introduce alloc_contig_range() mm: page_alloc: change fallbacks array handling mm: mmzone: MIGRATE_CMA migration type added mm: page_isolation: MIGRATE_CMA isolation functions added
Minchan Kim (1): cma: fix migration mode
Vitaly Andrianov (1): ARM: dma-mapping: use PMD size for section unmap
Documentation/kernel-parameters.txt | 9 + arch/Kconfig | 3 + arch/arm/Kconfig | 11 + arch/arm/common/dmabounce.c | 84 ++- arch/arm/include/asm/device.h | 4 + arch/arm/include/asm/dma-contiguous.h | 15 + arch/arm/include/asm/dma-iommu.h | 34 + arch/arm/include/asm/dma-mapping.h | 407 +++-------- arch/arm/include/asm/mach/map.h | 1 + arch/arm/kernel/setup.c | 9 +- arch/arm/mm/dma-mapping.c | 1348 ++++++++++++++++++++++++++++----- arch/arm/mm/init.c | 23 +- arch/arm/mm/mm.h | 3 + arch/arm/mm/mmu.c | 31 +- arch/arm/mm/vmregion.h | 2 +- arch/x86/Kconfig | 1 + arch/x86/include/asm/dma-contiguous.h | 13 + arch/x86/include/asm/dma-mapping.h | 5 + arch/x86/kernel/pci-dma.c | 18 +- arch/x86/kernel/pci-nommu.c | 8 +- arch/x86/kernel/setup.c | 2 + drivers/base/Kconfig | 89 +++ drivers/base/Makefile | 1 + drivers/base/dma-coherent.c | 42 + drivers/base/dma-contiguous.c | 401 ++++++++++ include/asm-generic/dma-coherent.h | 4 +- include/asm-generic/dma-contiguous.h | 28 + include/linux/device.h | 4 + include/linux/dma-contiguous.h | 110 +++ include/linux/gfp.h | 12 + include/linux/mmzone.h | 47 +- include/linux/page-isolation.h | 18 +- mm/Kconfig | 2 +- mm/Makefile | 3 +- mm/compaction.c | 418 +++++++---- mm/internal.h | 33 + mm/memory-failure.c | 2 +- mm/memory_hotplug.c | 6 +- mm/page_alloc.c | 409 +++++++++-- mm/page_isolation.c | 15 +- mm/vmstat.c | 3 + 41 files changed, 2898 insertions(+), 780 deletions(-) create mode 100644 arch/arm/include/asm/dma-contiguous.h create mode 100644 arch/arm/include/asm/dma-iommu.h create mode 100644 arch/x86/include/asm/dma-contiguous.h create mode 100644 drivers/base/dma-contiguous.c create mode 100644 include/asm-generic/dma-contiguous.h create mode 100644 include/linux/dma-contiguous.h
Hi Marek,
2012/5/22 Marek Szyprowski m.szyprowski@samsung.com:
Hi Linus,
I would like to ask for pulling Contiguous Memory Allocator (CMA) and ARM DMA-mapping framework updates for v3.5.
The following changes since commit 76e10d158efb6d4516018846f60c2ab5501900bc:
Linux 3.4 (2012-05-20 15:29:13 -0700)
with the top-most commit 0f51596bd39a5c928307ffcffc9ba07f90f42a8b
Merge branch 'for-next-arm-dma' into for-linus
are available in the git repository at: git://git.linaro.org/people/mszyprowski/linux-dma-mapping.git for-linus
Patch summary:
Marek Szyprowski (17): common: add dma_mmap_from_coherent() function ARM: dma-mapping: use dma_mmap_from_coherent() ARM: dma-mapping: use pr_* instread of printk ARM: dma-mapping: introduce DMA_ERROR_CODE constant ARM: dma-mapping: remove offset parameter to prepare for generic dma_ops ARM: dma-mapping: use asm-generic/dma-mapping-common.h ARM: dma-mapping: implement dma sg methods on top of any generic dma ops ARM: dma-mapping: move all dma bounce code to separate dma ops structure ARM: dma-mapping: remove redundant code and do the cleanup ARM: dma-mapping: use alloc, mmap, free from dma_ops ARM: dma-mapping: add support for IOMMU mapper mm: extract reclaim code from __alloc_pages_direct_reclaim() mm: trigger page reclaim in alloc_contig_range() to stabilise watermarks drivers: add Contiguous Memory Allocator X86: integrate CMA with DMA-mapping subsystem ARM: integrate CMA with DMA-mapping subsystem Merge branch 'for-next-arm-dma' into for-linus
Mel Gorman (1): mm: Serialize access to min_free_kbytes
Michal Nazarewicz (9): mm: page_alloc: remove trailing whitespace mm: compaction: introduce isolate_migratepages_range() mm: compaction: introduce map_pages() mm: compaction: introduce isolate_freepages_range() mm: compaction: export some of the functions mm: page_alloc: introduce alloc_contig_range() mm: page_alloc: change fallbacks array handling mm: mmzone: MIGRATE_CMA migration type added mm: page_isolation: MIGRATE_CMA isolation functions added
Minchan Kim (1): cma: fix migration mode
Vitaly Andrianov (1): ARM: dma-mapping: use PMD size for section unmap
would you pls add CMA test module in this patchset too?
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-March/088412.html
mm: cma: add a simple kernel module as the helper to test CMA
Signed-off-by: Barry Song Baohua.Song@csr.com Reviewed-by: Michal Nazarewicz mina86@mina86.com
Thanks barry
I notice we have new warnings as a result of CMA being merged, though thankfully they're just in Kconfig:
warning: (ARM) selects CMA which has unmet direct dependencies (HAVE_DMA_CONTIGUOUS && HAVE_MEMBLOCK && EXPERIMENTAL)
This seems totally weird: you're mandating that ARM must have CMA selected, but it's an experimental feature? So you're implying that the entire ARM kernel becomes totally experimental for the next release cycle?
I think this needs fixing.
Hello,
On Tuesday, May 29, 2012 2:30 PM Russell King - ARM Linux wrote:
I notice we have new warnings as a result of CMA being merged, though thankfully they're just in Kconfig:
warning: (ARM) selects CMA which has unmet direct dependencies (HAVE_DMA_CONTIGUOUS && HAVE_MEMBLOCK && EXPERIMENTAL)
This seems totally weird: you're mandating that ARM must have CMA selected, but it's an experimental feature? So you're implying that the entire ARM kernel becomes totally experimental for the next release cycle?
I think this needs fixing.
No, that wasn't my intention. I will provide a patch which removes unconditional dependency on CMA - it will let one to disable CMA and use old allocation method if needed, but this requires a few more changes in the dma-mapping implementation. I wasn't aware of the consequences and no one has complained about this since v15 of CMA patches (Aug 2011).
Best regards
On Tue, May 29, 2012 at 04:50:45PM +0200, Marek Szyprowski wrote:
Hello,
On Tuesday, May 29, 2012 2:30 PM Russell King - ARM Linux wrote:
I notice we have new warnings as a result of CMA being merged, though thankfully they're just in Kconfig:
warning: (ARM) selects CMA which has unmet direct dependencies (HAVE_DMA_CONTIGUOUS && HAVE_MEMBLOCK && EXPERIMENTAL)
This seems totally weird: you're mandating that ARM must have CMA selected, but it's an experimental feature? So you're implying that the entire ARM kernel becomes totally experimental for the next release cycle?
I think this needs fixing.
No, that wasn't my intention. I will provide a patch which removes unconditional dependency on CMA - it will let one to disable CMA and use old allocation method if needed, but this requires a few more changes in the dma-mapping implementation. I wasn't aware of the consequences and no one has complained about this since v15 of CMA patches (Aug 2011).
I've just been looking at the automatic build and boot logs, and CMA looks like it has the potential to cause regressions:
Linux version 3.4.0+ (rmk@rmk-PC.arm.linux.org.uk) (gcc version 4.3.5 (GCC) ) #1 PREEMPT Fri Jun 1 02:01:58 BST 2012 CPU: ARMv7 Processor [411fc082] revision 2 (ARMv7), cr=10c53c7d CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache Machine: OMAP LDP board vmalloc area is too big, limiting to 976MB Reserving 2097152 bytes SDRAM for VRAM cma: CMA: failed to reserve 16 MiB ... Kernel command line: console=ttyO2,115200n8 noinitrd vmalloc=1G mem=128M root=/dev/mmcblk0p2 rw ip=none rootdelay=2 video=omap24xxfb:rotation=270 ... NET: Registered protocol family 16 initlevel:2=postcore, 16 registered initcalls DMA: failed to allocate 256 KiB pool for atomic coherent allocation
I don't see any other failures, but that doesn't look good...
Note that that command line has worked perfectly well up until now.
CMA has been enabled unconditionally on all ARMv6+ systems to solve the long standing issue of double kernel mappings for all dma coherent buffers. This however created a dependency on CONFIG_EXPERIMENTAL for the whole ARM architecture what should be really avoided. This patch removes this dependency and lets one use old, well-tested dma-mapping implementation also on ARMv6+ systems without the need to use EXPERIMENTAL stuff.
Reported-by: Russell King linux@arm.linux.org.uk Signed-off-by: Marek Szyprowski m.szyprowski@samsung.com --- arch/arm/Kconfig | 1 - arch/arm/mm/dma-mapping.c | 10 ++++------ 2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 5e76013..ca7354f 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -7,7 +7,6 @@ config ARM select HAVE_IDE if PCI || ISA || PCMCIA select HAVE_DMA_ATTRS select HAVE_DMA_CONTIGUOUS if (CPU_V6 || CPU_V6K || CPU_V7) - select CMA if (CPU_V6 || CPU_V6K || CPU_V7) select HAVE_MEMBLOCK select RTC_LIB select SYS_SUPPORTS_APM_EMULATION diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index ea6b431..106c4c0 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -268,10 +268,8 @@ static int __init consistent_init(void) unsigned long base = consistent_base; unsigned long num_ptes = (CONSISTENT_END - base) >> PMD_SHIFT;
-#ifndef CONFIG_ARM_DMA_USE_IOMMU - if (cpu_architecture() >= CPU_ARCH_ARMv6) + if (IS_ENABLED(CONFIG_CMA) && !IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) return 0; -#endif
consistent_pte = kmalloc(num_ptes * sizeof(pte_t), GFP_KERNEL); if (!consistent_pte) { @@ -342,7 +340,7 @@ static int __init coherent_init(void) struct page *page; void *ptr;
- if (cpu_architecture() < CPU_ARCH_ARMv6) + if (!IS_ENABLED(CONFIG_CMA)) return 0;
ptr = __alloc_from_contiguous(NULL, size, prot, &page); @@ -704,7 +702,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
if (arch_is_coherent() || nommu()) addr = __alloc_simple_buffer(dev, size, gfp, &page); - else if (cpu_architecture() < CPU_ARCH_ARMv6) + else if (!IS_ENABLED(CONFIG_CMA)) addr = __alloc_remap_buffer(dev, size, gfp, prot, &page, caller); else if (gfp & GFP_ATOMIC) addr = __alloc_from_pool(dev, size, &page, caller); @@ -773,7 +771,7 @@ void arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
if (arch_is_coherent() || nommu()) { __dma_free_buffer(page, size); - } else if (cpu_architecture() < CPU_ARCH_ARMv6) { + } else if (!IS_ENABLED(CONFIG_CMA)) { __dma_free_remap(cpu_addr, size); __dma_free_buffer(page, size); } else {
linaro-mm-sig@lists.linaro.org