dma-buf: rk_heaps: separate rk_dma_cma early setup from dma heap
The "rk_dma_heap_cma" is a early param to setup a cma crea. Separate it from the dma heap driver makes driver reasonable more. This patch only do codingstyle without any fix to driver. Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com> Change-Id: I885082f44fc8aff2d07f403fca0cfe70b16abcbd
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 <xxm@rock-chips.com>
|
||||
*/
|
||||
|
||||
#include <linux/cma.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/dma-map-ops.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/syscalls.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user