Skip to content

Commit f825c73

Browse files
kvaneeshmszyprow
authored andcommitted
mm/cma: Move dma contiguous changes into a seperate config
We want to use CMA for allocating hash page table and real mode area for PPC64. Hence move DMA contiguous related changes into a seperate config so that ppc64 can enable CMA without requiring DMA contiguous. Acked-by: Michal Nazarewicz <mina86@mina86.com> Acked-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> [removed defconfig changes] Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
1 parent 8bb495e commit f825c73

6 files changed

Lines changed: 34 additions & 22 deletions

File tree

‎arch/arm/include/asm/dma-contiguous.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define ASMARM_DMA_CONTIGUOUS_H
33

44
#ifdef __KERNEL__
5-
#ifdef CONFIG_CMA
5+
#ifdef CONFIG_DMA_CMA
66

77
#include <linux/types.h>
88
#include <asm-generic/dma-contiguous.h>

‎arch/arm/mm/dma-mapping.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static int __init atomic_pool_init(void)
358358
if (!pages)
359359
goto no_pages;
360360

361-
if (IS_ENABLED(CONFIG_CMA))
361+
if (IS_ENABLED(CONFIG_DMA_CMA))
362362
ptr = __alloc_from_contiguous(NULL, pool->size, prot, &page,
363363
atomic_pool_init);
364364
else
@@ -670,7 +670,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
670670
addr = __alloc_simple_buffer(dev, size, gfp, &page);
671671
else if (!(gfp & __GFP_WAIT))
672672
addr = __alloc_from_pool(size, &page);
673-
else if (!IS_ENABLED(CONFIG_CMA))
673+
else if (!IS_ENABLED(CONFIG_DMA_CMA))
674674
addr = __alloc_remap_buffer(dev, size, gfp, prot, &page, caller);
675675
else
676676
addr = __alloc_from_contiguous(dev, size, prot, &page, caller);
@@ -759,7 +759,7 @@ static void __arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
759759
__dma_free_buffer(page, size);
760760
} else if (__free_from_pool(cpu_addr, size)) {
761761
return;
762-
} else if (!IS_ENABLED(CONFIG_CMA)) {
762+
} else if (!IS_ENABLED(CONFIG_DMA_CMA)) {
763763
__dma_free_remap(cpu_addr, size);
764764
__dma_free_buffer(page, size);
765765
} else {

‎drivers/base/Kconfig‎

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,9 @@ config DMA_SHARED_BUFFER
202202
APIs extension; the file's descriptor can then be passed on to other
203203
driver.
204204

205-
config CMA
206-
bool "Contiguous Memory Allocator"
207-
depends on HAVE_DMA_CONTIGUOUS && HAVE_MEMBLOCK
208-
select MIGRATION
209-
select MEMORY_ISOLATION
205+
config DMA_CMA
206+
bool "DMA Contiguous Memory Allocator"
207+
depends on HAVE_DMA_CONTIGUOUS && CMA
210208
help
211209
This enables the Contiguous Memory Allocator which allows drivers
212210
to allocate big physically-contiguous blocks of memory for use with
@@ -215,17 +213,7 @@ config CMA
215213
For more information see <include/linux/dma-contiguous.h>.
216214
If unsure, say "n".
217215

218-
if CMA
219-
220-
config CMA_DEBUG
221-
bool "CMA debug messages (DEVELOPMENT)"
222-
depends on DEBUG_KERNEL
223-
help
224-
Turns on debug messages in CMA. This produces KERN_DEBUG
225-
messages for every CMA call as well as various messages while
226-
processing calls such as dma_alloc_from_contiguous().
227-
This option does not affect warning and error messages.
228-
216+
if DMA_CMA
229217
comment "Default contiguous memory area size:"
230218

231219
config CMA_SIZE_MBYTES

‎drivers/base/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ obj-y := core.o bus.o dd.o syscore.o \
66
attribute_container.o transport_class.o \
77
topology.o
88
obj-$(CONFIG_DEVTMPFS) += devtmpfs.o
9-
obj-$(CONFIG_CMA) += dma-contiguous.o
9+
obj-$(CONFIG_DMA_CMA) += dma-contiguous.o
1010
obj-y += power/
1111
obj-$(CONFIG_HAS_DMA) += dma-mapping.o
1212
obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o

‎include/linux/dma-contiguous.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct cma;
5757
struct page;
5858
struct device;
5959

60-
#ifdef CONFIG_CMA
60+
#ifdef CONFIG_DMA_CMA
6161

6262
/*
6363
* There is always at least global CMA area and a few optional device

‎mm/Kconfig‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,27 @@ config FRONTSWAP
477477
and swap data is stored as normal on the matching swap device.
478478

479479
If unsure, say Y to enable frontswap.
480+
481+
config CMA
482+
bool "Contiguous Memory Allocator"
483+
depends on HAVE_MEMBLOCK
484+
select MIGRATION
485+
select MEMORY_ISOLATION
486+
help
487+
This enables the Contiguous Memory Allocator which allows other
488+
subsystems to allocate big physically-contiguous blocks of memory.
489+
CMA reserves a region of memory and allows only movable pages to
490+
be allocated from it. This way, the kernel can use the memory for
491+
pagecache and when a subsystem requests for contiguous area, the
492+
allocated pages are migrated away to serve the contiguous request.
493+
494+
If unsure, say "n".
495+
496+
config CMA_DEBUG
497+
bool "CMA debug messages (DEVELOPMENT)"
498+
depends on DEBUG_KERNEL && CMA
499+
help
500+
Turns on debug messages in CMA. This produces KERN_DEBUG
501+
messages for every CMA call as well as various messages while
502+
processing calls such as dma_alloc_from_contiguous().
503+
This option does not affect warning and error messages.

0 commit comments

Comments
 (0)