diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 6052ab2..1c0a769 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -518,10 +518,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
a hypervisor.
Default: yes
- coherent_pool=nn[KMG] [ARM,KNL]
- Sets the size of memory pool for coherent, atomic dma
- allocations if Contiguous Memory Allocator (CMA) is used.
-
code_bytes [X86] How many bytes of object code to print
in an oops report.
Range: 0 - 8192
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index b6d9c32..89ea346 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -4,8 +4,6 @@ config ARM
select HAVE_AOUT
select HAVE_DMA_API_DEBUG
select HAVE_IDE if PCI || ISA || PCMCIA
- 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/include/asm/dma-contiguous.h b/arch/arm/include/asm/dma-contiguous.h
deleted file mode 100644
index c7ba05e..0000000
--- a/arch/arm/include/asm/dma-contiguous.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef ASMARM_DMA_CONTIGUOUS_H
-#define ASMARM_DMA_CONTIGUOUS_H
-
-#ifdef __KERNEL__
-
-#include <linux/device.h>
-#include <linux/dma-contiguous.h>
-#include <asm-generic/dma-contiguous.h>
-
-#ifdef CONFIG_CMA
-
-void dma_contiguous_early_fixup(phys_addr_t base, unsigned long size);
-
-#endif
-#endif
-#endif
diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
index a6efcdd..b36f365 100644
--- a/arch/arm/include/asm/mach/map.h
+++ b/arch/arm/include/asm/mach/map.h
@@ -30,7 +30,6 @@ struct map_desc {
#define MT_MEMORY_DTCM 12
#define MT_MEMORY_ITCM 13
#define MT_MEMORY_SO 14
-#define MT_MEMORY_DMA_READY 15
-static void __dma_clear_buffer(struct page *page, size_t size)
-{
- void *ptr;
- /*
- * Ensure that the allocated pages are zeroed, and that any data
- * lurking in the kernel direct-mapped region is invalidated.
- */
- ptr = page_address(page);
- memset(ptr, 0, size);
- dmac_flush_range(ptr, ptr + size);
- outer_flush_range(__pa(ptr), __pa(ptr) + size);
-}
-
/*
* Allocate a DMA buffer for 'dev' of size 'size' using the
* specified gfp mask. Note that 'size' must be page aligned.
@@ -81,6 +64,23 @@ static struct page *__dma_alloc_buffer(struct device *dev, size_t size, gfp_t gf
{
unsigned long order = get_order(size);
struct page *page, *p, *e;
+ void *ptr;
+ u64 mask = get_coherent_dma_mask(dev);
+
+#ifdef CONFIG_DMA_API_DEBUG
+ u64 limit = (mask + 1) & ~mask;
+ if (limit && size >= limit) {
+ dev_warn(dev, "coherent allocation too big (requested %#x mask %#llx)
",
+ size, mask);
+ return NULL;
+ }
+#endif
+
+ if (!mask)
+ return NULL;
+
+ if (mask < 0xffffffffULL)
+ gfp |= GFP_DMA;
page = alloc_pages(gfp, order);
if (!page)
@@ -93,7 +93,14 @@ static struct page *__dma_alloc_buffer(struct device *dev, size_t size, gfp_t gf
for (p = page + (size >> PAGE_SHIFT), e = page + (1 << order); p < e; p++)
__free_page(p);
- __dma_clear_buffer(page, size);
+ /*
+ * Ensure that the allocated pages are zeroed, and that any data
+ * lurking in the kernel direct-mapped region is invalidated.
+ */
+ ptr = page_address(page);
+ memset(ptr, 0, size);
+ dmac_flush_range(ptr, ptr + size);
+ outer_flush_range(__pa(ptr), __pa(ptr) + size);
return page;
}
@@ -163,9 +170,6 @@ static int __init consistent_init(void)
unsigned long base = consistent_base;
unsigned long num_ptes = (CONSISTENT_END - base) >> PMD_SHIFT;
- if (cpu_architecture() >= CPU_ARCH_ARMv6)
- return 0;
-
consistent_pte = kmalloc(num_ptes * sizeof(pte_t), GFP_KERNEL);
if (!consistent_pte) {
pr_err("%s: no memory
", __func__);
@@ -206,100 +210,8 @@ static int __init consistent_init(void)
return ret;
}
-core_initcall(consistent_init);
-
-static void *__alloc_from_contiguous(struct device *dev, size_t size,
- pgprot_t prot, struct page **ret_page);
-
-static struct arm_vmregion_head coherent_head = {
- .vm_lock = __SPIN_LOCK_UNLOCKED(&coherent_head.vm_lock),
- .vm_list = LIST_HEAD_INIT(coherent_head.vm_list),
-};
-
-size_t coherent_pool_size = DEFAULT_CONSISTENT_DMA_SIZE / 8;
-
-static int __init early_coherent_pool(char *p)
-{
- coherent_pool_size = memparse(p, &p);
- return 0;
-}
-early_param("coherent_pool", early_coherent_pool);
-
-/*
- * Initialise the coherent pool for atomic allocations.
- */
-static int __init coherent_init(void)
-{
- pgprot_t prot = pgprot_dmacoherent(pgprot_kernel);
- size_t size = coherent_pool_size;
- struct page *page;
- void *ptr;
-
- if (cpu_architecture() < CPU_ARCH_ARMv6)
- return 0;
-
- ptr = __alloc_from_contiguous(NULL, size, prot, &page);
- if (ptr) {
- coherent_head.vm_start = (unsigned long) ptr;
- coherent_head.vm_end = (unsigned long) ptr + size;
- printk(KERN_INFO "DMA: preallocated %u KiB pool for atomic coherent allocations
",
- (unsigned)size / 1024);
- return 0;
- }
- printk(KERN_ERR "DMA: failed to allocate %u KiB pool for atomic coherent allocation
",
- (unsigned)size / 1024);
- return -ENOMEM;
-}
-/*
- * CMA is activated by core_initcall, so we must be called after it
- */
-postcore_initcall(coherent_init);
-
/*
- * Free a buffer as defined by the above mapping.
+ * free a page as defined by the above mapping.
+ * Must not be called with IRQs disabled.
*/
void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, dma_addr_t handle)
{
- struct page *page = pfn_to_page(dma_to_pfn(dev, handle));
+ WARN_ON(irqs_disabled());
if (dma_release_from_coherent(dev, get_order(size), cpu_addr))
return;
@@ -577,7 +569,7 @@ static void __init alloc_init_section(pud_t *pud, unsigned long addr,
* L1 entries, whereas PGDs refer to a group of L1 entries making
* up one logical pointer to an L2 table.
*/
- if (type->prot_sect && ((addr | end | phys) & ~SECTION_MASK) == 0) {
+ if (((addr | end | phys) & ~SECTION_MASK) == 0) {
pmd_t *p = pmd;
if (addr & SECTION_SIZE)
@@ -773,7 +765,7 @@ static int __init early_vmalloc(char *arg)
}
early_param("vmalloc", early_vmalloc);
static inline void prepare_page_table(void)
@@ -893,8 +885,8 @@ static inline void prepare_page_table(void)
* Find the end of the first block of lowmem.
*/
end = memblock.memory.regions[0].base + memblock.memory.regions[0].size;
- if (end >= arm_lowmem_limit)
- end = arm_lowmem_limit;
+ if (end >= lowmem_limit)
+ end = lowmem_limit;
/*
* Clear out all the kernel space mappings, except for the first
@@ -1028,8 +1020,8 @@ static void __init map_lowmem(void)
phys_addr_t end = start + reg->size;
struct map_desc map;
- if (end > arm_lowmem_limit)
- end = arm_lowmem_limit;
+ if (end > lowmem_limit)
+ end = lowmem_limit;
if (start >= end)
break;