diff --git a/drivers/dma-buf/rk_heaps/Makefile b/drivers/dma-buf/rk_heaps/Makefile index 21651338584a..30d44bb7d801 100644 --- a/drivers/dma-buf/rk_heaps/Makefile +++ b/drivers/dma-buf/rk_heaps/Makefile @@ -1,3 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 + +rk-cma-heap-objs := rk-dma-cma.o rk-cma-heap.o + obj-$(CONFIG_DMABUF_HEAPS_ROCKCHIP) += rk-dma-heap.o obj-$(CONFIG_DMABUF_HEAPS_ROCKCHIP_CMA_HEAP) += rk-cma-heap.o diff --git a/drivers/dma-buf/rk_heaps/rk-dma-cma.c b/drivers/dma-buf/rk_heaps/rk-dma-cma.c new file mode 100644 index 000000000000..2f74f818f1ab --- /dev/null +++ b/drivers/dma-buf/rk_heaps/rk-dma-cma.c @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Early setup for Rockchip DMA CMA + * + * Copyright (C) 2022 Rockchip Electronics Co. Ltd. + * Author: Simon Xue + */ + +#include +#include +#include +#include +#include + +#include "rk-dma-heap.h" + +#define RK_DMA_HEAP_CMA_DEFAULT_SIZE SZ_32M + +static unsigned long rk_dma_heap_size __initdata; +static unsigned long rk_dma_heap_base __initdata; + +static struct cma *rk_dma_heap_cma; + +static int __init early_dma_heap_cma(char *p) +{ + if (!p) { + pr_err("Config string not provided\n"); + return -EINVAL; + } + + rk_dma_heap_size = memparse(p, &p); + if (*p != '@') + return 0; + + rk_dma_heap_base = memparse(p + 1, &p); + + return 0; +} +early_param("rk_dma_heap_cma", early_dma_heap_cma); + +int __init rk_dma_heap_cma_setup(void) +{ + unsigned long size; + int ret; + bool fix = false; + + if (rk_dma_heap_size) + size = rk_dma_heap_size; + else + size = RK_DMA_HEAP_CMA_DEFAULT_SIZE; + + 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); + if (ret) + return ret; + + /* Architecture specific contiguous memory fixup. */ + dma_contiguous_early_fixup(cma_get_base(rk_dma_heap_cma), + cma_get_size(rk_dma_heap_cma)); + + return 0; +} + +struct cma *rk_dma_heap_get_cma(void) +{ + return rk_dma_heap_cma; +} diff --git a/drivers/dma-buf/rk_heaps/rk-dma-heap.c b/drivers/dma-buf/rk_heaps/rk-dma-heap.c index 2b0ea08fcdfd..b2687c2d81fd 100644 --- a/drivers/dma-buf/rk_heaps/rk-dma-heap.c +++ b/drivers/dma-buf/rk_heaps/rk-dma-heap.c @@ -37,61 +37,8 @@ static struct class *rk_dma_heap_class; static DEFINE_XARRAY_ALLOC(rk_dma_heap_minors); struct proc_dir_entry *proc_rk_dma_heap_dir; -#define RK_DMA_HEAP_CMA_DEFAULT_SIZE SZ_32M #define K(size) ((unsigned long)((size) >> 10)) -static unsigned long rk_dma_heap_size __initdata; -static unsigned long rk_dma_heap_base __initdata; - -static struct cma *rk_dma_heap_cma; - -static int __init early_dma_heap_cma(char *p) -{ - if (!p) { - pr_err("Config string not provided\n"); - return -EINVAL; - } - - rk_dma_heap_size = memparse(p, &p); - if (*p != '@') - return 0; - rk_dma_heap_base = memparse(p + 1, &p); - - return 0; -} -early_param("rk_dma_heap_cma", early_dma_heap_cma); - -int __init rk_dma_heap_cma_setup(void) -{ - unsigned long size; - int ret; - bool fix = false; - - if (rk_dma_heap_size) - size = rk_dma_heap_size; - else - size = RK_DMA_HEAP_CMA_DEFAULT_SIZE; - - 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); - if (ret) - return ret; - - /* Architecture specific contiguous memory fixup. */ - dma_contiguous_early_fixup(cma_get_base(rk_dma_heap_cma), - cma_get_size(rk_dma_heap_cma)); - - return 0; -} - -struct cma *rk_dma_heap_get_cma(void) -{ - return rk_dma_heap_cma; -} - static int rk_vmap_pfn_apply(pte_t *pte, unsigned long addr, void *private) { struct rk_vmap_pfn_data *data = private;