diff --git a/drivers/dma-buf/rk_heaps/rk-dma-cma.c b/drivers/dma-buf/rk_heaps/rk-dma-cma.c index e771843754ab..b6521f7dcc06 100644 --- a/drivers/dma-buf/rk_heaps/rk-dma-cma.c +++ b/drivers/dma-buf/rk_heaps/rk-dma-cma.c @@ -7,10 +7,7 @@ */ #include -#include #include -#include -#include #include "rk-dma-heap.h" @@ -59,14 +56,17 @@ int __init rk_dma_heap_cma_setup(void) if (rk_dma_heap_base) fix = true; - ret = cma_declare_contiguous(rk_dma_heap_base, size, 0x0, 0, 0, fix, - "rk-dma-heap-cma", &rk_dma_heap_cma); + ret = cma_declare_contiguous(rk_dma_heap_base, PAGE_ALIGN(size), 0x0, + PAGE_SIZE, 0, fix, "rk-dma-heap-cma", + &rk_dma_heap_cma); if (ret) return ret; +#if !IS_ENABLED(CONFIG_CMA_INACTIVE) /* Architecture specific contiguous memory fixup. */ dma_contiguous_early_fixup(cma_get_base(rk_dma_heap_cma), cma_get_size(rk_dma_heap_cma)); +#endif return 0; } diff --git a/mm/cma.c b/mm/cma.c index c8b32947318a..ce3531d355a5 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -181,7 +181,9 @@ int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, struct cma **res_cma) { struct cma *cma; +#if !IS_ENABLED(CONFIG_CMA_INACTIVE) phys_addr_t alignment; +#endif /* Sanity checks */ if (cma_area_count == ARRAY_SIZE(cma_areas)) { @@ -192,6 +194,7 @@ int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, if (!size || !memblock_is_region_reserved(base, size)) return -EINVAL; +#if !IS_ENABLED(CONFIG_CMA_INACTIVE) /* ensure minimal alignment required by mm core */ alignment = PAGE_SIZE << max_t(unsigned long, MAX_ORDER - 1, pageblock_order); @@ -202,6 +205,7 @@ int __init cma_init_reserved_mem(phys_addr_t base, phys_addr_t size, if (ALIGN(base, alignment) != base || ALIGN(size, alignment) != size) return -EINVAL; +#endif /* * Each reserved area must be initialised later, when more kernel @@ -275,6 +279,7 @@ int __init cma_declare_contiguous_nid(phys_addr_t base, if (alignment && !is_power_of_2(alignment)) return -EINVAL; +#if !IS_ENABLED(CONFIG_CMA_INACTIVE) /* * Sanitise input arguments. * Pages both ends in CMA area could be merged into adjacent unmovable @@ -289,6 +294,7 @@ int __init cma_declare_contiguous_nid(phys_addr_t base, &base, &alignment); goto err; } +#endif base = ALIGN(base, alignment); size = ALIGN(size, alignment); limit &= ~(alignment - 1); @@ -386,14 +392,23 @@ int __init cma_declare_contiguous_nid(phys_addr_t base, if (ret) goto free_mem; +#if !IS_ENABLED(CONFIG_CMA_INACTIVE) pr_info("Reserved %ld MiB at %pa\n", (unsigned long)size / SZ_1M, &base); +#else + pr_info("Reserved %ld KiB at %pa\n", (unsigned long)size / SZ_1K, + &base); +#endif return 0; free_mem: memblock_free(base, size); err: +#if !IS_ENABLED(CONFIG_CMA_INACTIVE) pr_err("Failed to reserve %ld MiB\n", (unsigned long)size / SZ_1M); +#else + pr_err("Failed to reserve %ld KiB\n", (unsigned long)size / SZ_1K); +#endif return ret; }