From 417f7da139826b478b10addafec8edd90ae33b6a Mon Sep 17 00:00:00 2001 From: Laura Abbott <lauraa@codeaurora.org> Date: Mon, 17 Jun 2013 10:53:05 -0700 Subject: [PATCH] drivers: Add option to reserve default CMA region CMA provides good utilization of memory but for some use cases, the allocation time is too costly. Add a Kconfig option to allow the default region to be permanently set aside for contiguous use cases. Change-Id: I1eef508d37cf6ae3b7b7a652fc59391b186fc122 Signed-off-by: Laura Abbott <lauraa@codeaurora.org> --- drivers/base/Kconfig | 13 +++++++++++++ drivers/base/dma-contiguous.c | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 07abd9d76f7f..4a5b00b542f3 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 531c166f1b7b..b71e50bbfc78 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 -- GitLab