linux/arch
Akinobu Mita d92ef66c4f x86: make dma_alloc_coherent() return zeroed memory if CMA is enabled
This patchset enhances the DMA Contiguous Memory Allocator on x86.

Currently the DMA CMA is only supported with pci-nommu dma_map_ops and
furthermore it can't be enabled on x86_64.  But I would like to allocate
big contiguous memory with dma_alloc_coherent() and tell it to the device
that requires it, regardless of which dma mapping implementation is
actually used in the system.

So this makes it work with swiotlb and intel-iommu dma_map_ops, too.  And
this also extends "cma=" kernel parameter to specify placement constraint
by the physical address range of memory allocations.  For example, CMA
allocates memory below 4GB by "cma=64M@0-4G", it is required for the
devices only supporting 32-bit addressing on 64-bit systems without iommu.

This patch (of 5):

Calling dma_alloc_coherent() with __GFP_ZERO must return zeroed memory.

But when the contiguous memory allocator (CMA) is enabled on x86 and the
memory region is allocated by dma_alloc_from_contiguous(), it doesn't
return zeroed memory.  Because dma_generic_alloc_coherent() forgot to fill
the memory region with zero if it was allocated by
dma_alloc_from_contiguous()

Most implementations of dma_alloc_coherent() return zeroed memory
regardless of whether __GFP_ZERO is specified.  So this fixes it by
unconditionally zeroing the allocated memory region.

Alternatively, we could fix dma_alloc_from_contiguous() to return zeroed
out memory and remove memset() from all caller of it.  But we can't simply
remove the memset on arm because __dma_clear_buffer() is used there for
ensuring cache flushing and it is used in many places.  Of course we can
do redundant memset in dma_alloc_from_contiguous(), but I think this patch
is less impact for fixing this problem.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Don Dutile <ddutile@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-06-04 16:53:57 -07:00
..
alpha Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into next 2014-06-03 14:00:15 -07:00
arc DeviceTree for 3.16: 2014-06-04 10:02:38 -07:00
arm hugetlb: restrict hugepage_migration_support() to x86_64 2014-06-04 16:53:51 -07:00
arm64 hugetlb: restrict hugepage_migration_support() to x86_64 2014-06-04 16:53:51 -07:00
avr32 Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into next 2014-06-03 12:57:53 -07:00
blackfin Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into next 2014-06-03 12:57:53 -07:00
c6x DeviceTree for 3.16: 2014-06-04 10:02:38 -07:00
cris Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into next 2014-06-03 12:57:53 -07:00
frv Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into next 2014-06-03 12:57:53 -07:00
hexagon Hexagon: Delete stale barrier.h 2014-05-01 10:09:47 -07:00
ia64 hugetlb: restrict hugepage_migration_support() to x86_64 2014-06-04 16:53:51 -07:00
m32r arch,m32r: Convert smp_mb__*() 2014-04-18 14:20:36 +02:00
m68k Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into next 2014-06-03 12:57:53 -07:00
metag hugetlb: restrict hugepage_migration_support() to x86_64 2014-06-04 16:53:51 -07:00
microblaze DeviceTree for 3.16: 2014-06-04 10:02:38 -07:00
mips hugetlb: restrict hugepage_migration_support() to x86_64 2014-06-04 16:53:51 -07:00
mn10300 Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into next 2014-06-03 12:57:53 -07:00
openrisc DeviceTree for 3.16: 2014-06-04 10:02:38 -07:00
parisc Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into next 2014-06-03 12:57:53 -07:00
powerpc x86: define _PAGE_NUMA by reusing software bits on the PMD and PTE levels 2014-06-04 16:53:55 -07:00
s390 hugetlb: restrict hugepage_migration_support() to x86_64 2014-06-04 16:53:51 -07:00
score arch,score: Convert smp_mb__*() 2014-04-18 14:20:43 +02:00
sh sh: Replace __get_cpu_var uses 2014-06-04 16:53:52 -07:00
sparc hugetlb: restrict hugepage_migration_support() to x86_64 2014-06-04 16:53:51 -07:00
tile hugetlb: restrict hugepage_migration_support() to x86_64 2014-06-04 16:53:51 -07:00
um mm: split 'tlb_flush_mmu()' into tlb flushing and memory freeing parts 2014-04-25 16:05:40 -07:00
unicore32 arch/unicore32/mm/ioremap.c: return NULL on invalid pfn 2014-06-04 16:53:53 -07:00
x86 x86: make dma_alloc_coherent() return zeroed memory if CMA is enabled 2014-06-04 16:53:57 -07:00
xtensa DeviceTree for 3.16: 2014-06-04 10:02:38 -07:00
.gitignore
Kconfig