diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 07abd9d76f7ff731eaef404c9eb84a3d227bc1e0..4a5b00b542f3b96779b082257af98c1141af04ea 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -290,6 +290,19 @@ config CMA_AREAS If unsure, leave the default value "7". +config CMA_RESERVE_DEFAULT_AREA + bool "Permanently reserve the default area" + help + By default, contiguous regions are given back to the page allocator so + the memory may be used when not in contiguous forms. This has better + utilization but the allocation time may be slower. Say Y here to + never have the default region be returned to the page allocator. + This means the memory will always be available for contiguous + allocations but the pages will never be available for anything else + except contiguous allocations. + + If unsure, say n. + endif endmenu diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c index 531c166f1b7b93df5d78775cfdce459a0b1b5d2e..b71e50bbfc78be8e368a28c4c7cbf3e34bf19674 100644 --- a/drivers/base/dma-contiguous.c +++ b/drivers/base/dma-contiguous.c @@ -97,6 +97,11 @@ static struct cma *cma_get_area_by_name(const char *name) #define CMA_SIZE_MBYTES 0 #endif +#ifdef CONFIG_CMA_RESERVE_DEFAULT_AREA +#define CMA_RESERVE_AREA 1 +#else +#define CMA_RESERVE_AREA 0 +#endif /* * Default global CMA area size can be defined in kernel's .config. * This is usefull mainly for distro maintainers to create a kernel @@ -275,7 +280,7 @@ void __init dma_contiguous_reserve(phys_addr_t limit) (unsigned long)sel_size / SZ_1M); if (dma_contiguous_reserve_area(sel_size, &base, limit, NULL, - true) == 0) + CMA_RESERVE_AREA) == 0) dma_contiguous_def_base = base; } #ifdef CONFIG_OF