Commit 9955d906 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: atomisp: remove kvmalloc/kvcalloc abstractions

The sh_css layer adds an abstraction for kvmalloc/kvcalloc.

Get rid of them. Most of the work here was done by this
small coccinelle script:

<cocci>
@@
expression size;
@@

- sh_css_malloc(size)
+ kvmalloc(size, GFP_KERNEL)

@@
expression n;
expression size;
@@

- sh_css_calloc(n, size)
+ kvcalloc(n, size, GFP_KERNEL)
</cocci>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 591e6a0a
......@@ -81,7 +81,7 @@ enum ia_css_err ia_css_refcount_init(uint32_t size)
return IA_CSS_ERR_INTERNAL_ERROR;
}
myrefcount.items =
sh_css_malloc(sizeof(struct ia_css_refcount_entry) * size);
kvmalloc(sizeof(struct ia_css_refcount_entry) * size, GFP_KERNEL);
if (!myrefcount.items)
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
if (err == IA_CSS_SUCCESS) {
......@@ -115,7 +115,7 @@ void ia_css_refcount_uninit(void)
entry->id = 0;
}
}
sh_css_free(myrefcount.items);
kvfree(myrefcount.items);
myrefcount.items = NULL;
myrefcount.size = 0;
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
......
......@@ -318,7 +318,7 @@ ia_css_isp_dvs_statistics_allocate(
if (!grid->enable)
return NULL;
me = sh_css_calloc(1, sizeof(*me));
me = kvcalloc(1, sizeof(*me), GFP_KERNEL);
if (!me)
goto err;
......@@ -359,7 +359,7 @@ ia_css_isp_dvs_statistics_map_allocate(
* so we use a local char * instead. */
char *base_ptr;
me = sh_css_malloc(sizeof(*me));
me = kvmalloc(sizeof(*me), GFP_KERNEL);
if (!me) {
IA_CSS_LOG("cannot allocate memory");
goto err;
......@@ -369,7 +369,7 @@ ia_css_isp_dvs_statistics_map_allocate(
me->data_allocated = !data_ptr;
if (!me->data_ptr) {
me->data_ptr = sh_css_malloc(isp_stats->size);
me->data_ptr = kvmalloc(isp_stats->size, GFP_KERNEL);
if (!me->data_ptr) {
IA_CSS_LOG("cannot allocate memory");
goto err;
......@@ -386,7 +386,7 @@ ia_css_isp_dvs_statistics_map_allocate(
return me;
err:
if (me)
sh_css_free(me);
kvfree(me);
return NULL;
}
......@@ -395,8 +395,8 @@ ia_css_isp_dvs_statistics_map_free(struct ia_css_isp_dvs_statistics_map *me)
{
if (me) {
if (me->data_allocated)
sh_css_free(me->data_ptr);
sh_css_free(me);
kvfree(me->data_ptr);
kvfree(me);
}
}
......@@ -405,7 +405,7 @@ ia_css_isp_dvs_statistics_free(struct ia_css_isp_dvs_statistics *me)
{
if (me) {
hmm_free(me->data_ptr);
sh_css_free(me);
kvfree(me);
}
}
......
......@@ -285,7 +285,7 @@ ia_css_isp_dvs2_statistics_allocate(
if (!grid->enable)
return NULL;
me = sh_css_calloc(1, sizeof(*me));
me = kvcalloc(1, sizeof(*me), GFP_KERNEL);
if (!me)
goto err;
......@@ -318,7 +318,7 @@ ia_css_isp_dvs2_statistics_free(struct ia_css_isp_dvs_statistics *me)
{
if (me) {
hmm_free(me->data_ptr);
sh_css_free(me);
kvfree(me);
}
}
......
......@@ -927,8 +927,8 @@ ia_css_binary_init_infos(void) {
if (num_of_isp_binaries == 0)
return IA_CSS_SUCCESS;
all_binaries = sh_css_malloc(num_of_isp_binaries *
sizeof(*all_binaries));
all_binaries = kvmalloc(num_of_isp_binaries * sizeof(*all_binaries),
GFP_KERNEL);
if (!all_binaries)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
......@@ -966,7 +966,7 @@ ia_css_binary_uninit(void) {
}
binary_infos[i] = NULL;
}
sh_css_free(all_binaries);
kvfree(all_binaries);
return IA_CSS_SUCCESS;
}
......
......@@ -189,7 +189,7 @@ enum ia_css_err ia_css_frame_map(struct ia_css_frame **frame,
error:
if (err != IA_CSS_SUCCESS) {
sh_css_free(me);
kvfree(me);
me = NULL;
}
......@@ -228,7 +228,7 @@ enum ia_css_err ia_css_frame_create_from_info(struct ia_css_frame **frame,
err = ia_css_frame_init_planes(me);
if (err != IA_CSS_SUCCESS) {
sh_css_free(me);
kvfree(me);
me = NULL;
}
......@@ -321,7 +321,7 @@ void ia_css_frame_free(struct ia_css_frame *frame)
if (frame) {
hmm_free(frame->data);
sh_css_free(frame);
kvfree(frame);
}
IA_CSS_LEAVE_PRIVATE("void");
......@@ -551,7 +551,7 @@ enum ia_css_err ia_css_frame_allocate_with_buffer_size(
err = frame_allocate_buffer_data(me);
if (err != IA_CSS_SUCCESS) {
sh_css_free(me);
kvfree(me);
me = NULL;
}
......@@ -837,7 +837,7 @@ static enum ia_css_err frame_allocate_with_data(struct ia_css_frame **frame,
err = frame_allocate_buffer_data(me);
if (err != IA_CSS_SUCCESS) {
sh_css_free(me);
kvfree(me);
#ifndef ISP2401
return err;
#else
......@@ -858,7 +858,7 @@ static struct ia_css_frame *frame_create(unsigned int width,
bool contiguous,
bool valid)
{
struct ia_css_frame *me = sh_css_malloc(sizeof(*me));
struct ia_css_frame *me = kvmalloc(sizeof(*me), GFP_KERNEL);
if (!me)
return NULL;
......
......@@ -122,7 +122,9 @@ ia_css_isp_param_allocate_isp_parameters(
css_params->params[pclass][mem].size = size;
css_params->params[pclass][mem].address = 0x0;
if (size) {
mem_params->params[pclass][mem].address = sh_css_calloc(1, size);
mem_params->params[pclass][mem].address = kvcalloc(1,
size,
GFP_KERNEL);
if (!mem_params->params[pclass][mem].address) {
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
goto cleanup;
......@@ -153,7 +155,7 @@ ia_css_isp_param_destroy_isp_parameters(
for (mem = 0; mem < IA_CSS_NUM_MEMORIES; mem++) {
for (pclass = 0; pclass < IA_CSS_NUM_PARAM_CLASSES; pclass++) {
if (mem_params->params[pclass][mem].address)
sh_css_free(mem_params->params[pclass][mem].address);
kvfree(mem_params->params[pclass][mem].address);
if (css_params->params[pclass][mem].address)
hmm_free(css_params->params[pclass][mem].address);
mem_params->params[pclass][mem].address = NULL;
......
......@@ -512,7 +512,7 @@ static void pipeline_stage_destroy(struct ia_css_pipeline_stage *stage)
ia_css_frame_free(stage->args.out_vf_frame);
stage->args.out_vf_frame = NULL;
}
sh_css_free(stage);
kvfree(stage);
}
static void pipeline_init_sp_thread_map(void)
......@@ -593,7 +593,7 @@ static enum ia_css_err pipeline_stage_create(
out_frame[i] = stage_desc->out_frame[i];
}
stage = sh_css_malloc(sizeof(*stage));
stage = kvmalloc(sizeof(*stage), GFP_KERNEL);
if (!stage) {
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
goto ERR;
......
......@@ -152,7 +152,7 @@ enum ia_css_err ia_css_rmgr_init_vbuf(struct ia_css_rmgr_vbuf_pool *pool)
bytes_needed =
sizeof(void *) *
pool->size;
pool->handles = sh_css_malloc(bytes_needed);
pool->handles = kvmalloc(bytes_needed, GFP_KERNEL);
if (pool->handles)
memset(pool->handles, 0, bytes_needed);
else
......@@ -196,7 +196,7 @@ void ia_css_rmgr_uninit_vbuf(struct ia_css_rmgr_vbuf_pool *pool)
}
}
/* now free the pool handles list */
sh_css_free(pool->handles);
kvfree(pool->handles);
pool->handles = NULL;
}
}
......
......@@ -1862,35 +1862,6 @@ ia_css_enable_isys_event_queue(bool enable) {
return IA_CSS_SUCCESS;
}
void *sh_css_malloc(size_t size)
{
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "sh_css_malloc() enter: size=%zu\n",
size);
/* FIXME: This first test can probably go away */
if (size == 0)
return NULL;
if (size > PAGE_SIZE)
return vmalloc(size);
return kmalloc(size, GFP_KERNEL);
}
void *sh_css_calloc(size_t N, size_t size)
{
void *p;
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
"sh_css_calloc() enter: N=%zu, size=%zu\n", N, size);
/* FIXME: this test can probably go away */
if (size > 0) {
p = sh_css_malloc(N * size);
if (p)
memset(p, 0, size);
return p;
}
return NULL;
}
void sh_css_free(void *ptr)
{
if (is_vmalloc_addr(ptr))
......@@ -9035,7 +9006,7 @@ ia_css_pipe_create_extra(const struct ia_css_pipe_config *config,
i);
if (err != IA_CSS_SUCCESS) {
IA_CSS_LEAVE_ERR_PRIVATE(err);
sh_css_free(internal_pipe);
kvfree(internal_pipe);
internal_pipe = NULL;
return err;
}
......@@ -9054,7 +9025,7 @@ ia_css_pipe_create_extra(const struct ia_css_pipe_config *config,
i);
if (err != IA_CSS_SUCCESS) {
IA_CSS_LEAVE_ERR_PRIVATE(err);
sh_css_free(internal_pipe);
kvfree(internal_pipe);
internal_pipe = NULL;
return err;
}
......@@ -9066,7 +9037,7 @@ ia_css_pipe_create_extra(const struct ia_css_pipe_config *config,
internal_pipe->config.acc_extension);
if (err != IA_CSS_SUCCESS) {
IA_CSS_LEAVE_ERR_PRIVATE(err);
sh_css_free(internal_pipe);
kvfree(internal_pipe);
return err;
}
}
......
......@@ -24,7 +24,7 @@ struct ia_css_host_data *ia_css_host_data_allocate(size_t size)
if (!me)
return NULL;
me->size = (uint32_t)size;
me->address = sh_css_malloc(size);
me->address = kvmalloc(size, GFP_KERNEL);
if (!me->address) {
kfree(me);
return NULL;
......@@ -35,7 +35,7 @@ struct ia_css_host_data *ia_css_host_data_allocate(size_t size)
void ia_css_host_data_free(struct ia_css_host_data *me)
{
if (me) {
sh_css_free(me->address);
kvfree(me->address);
me->address = NULL;
kfree(me);
}
......
......@@ -968,12 +968,6 @@ sh_css_params_init(void);
void
sh_css_params_uninit(void);
void *sh_css_malloc(size_t size);
void *sh_css_calloc(size_t N, size_t size);
void sh_css_free(void *ptr);
/* For Acceleration API: Flush FW (shared buffer pointer) arguments */
void sh_css_flush(struct ia_css_acc_fw *fw);
......
......@@ -67,13 +67,16 @@ make_histogram(struct sh_css_pc_histogram *histogram, unsigned int length)
return;
if (histogram->run)
return;
histogram->run = sh_css_malloc(length * sizeof(*histogram->run));
histogram->run = kvmalloc(length * sizeof(*histogram->run),
GFP_KERNEL);
if (!histogram->run)
return;
histogram->stall = sh_css_malloc(length * sizeof(*histogram->stall));
histogram->stall = kvmalloc(length * sizeof(*histogram->stall),
GFP_KERNEL);
if (!histogram->stall)
return;
histogram->msink = sh_css_malloc(length * sizeof(*histogram->msink));
histogram->msink = kvmalloc(length * sizeof(*histogram->msink),
GFP_KERNEL);
if (!histogram->msink)
return;
......
......@@ -30,8 +30,8 @@ alloc_dvs_6axis_table(const struct ia_css_resolution *frame_res,
enum ia_css_err err = IA_CSS_SUCCESS;
struct ia_css_dvs_6axis_config *dvs_config = NULL;
dvs_config = (struct ia_css_dvs_6axis_config *)sh_css_malloc(sizeof(
struct ia_css_dvs_6axis_config));
dvs_config = kvmalloc(sizeof(struct ia_css_dvs_6axis_config),
GFP_KERNEL);
if (!dvs_config) {
IA_CSS_ERROR("out of memory");
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
......@@ -57,16 +57,16 @@ alloc_dvs_6axis_table(const struct ia_css_resolution *frame_res,
}
/* Generate Y buffers */
dvs_config->xcoords_y = (uint32_t *)sh_css_malloc(width_y * height_y * sizeof(
uint32_t));
dvs_config->xcoords_y = kvmalloc(width_y * height_y * sizeof(uint32_t),
GFP_KERNEL);
if (!dvs_config->xcoords_y) {
IA_CSS_ERROR("out of memory");
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
goto exit;
}
dvs_config->ycoords_y = (uint32_t *)sh_css_malloc(width_y * height_y * sizeof(
uint32_t));
dvs_config->ycoords_y = kvmalloc(width_y * height_y * sizeof(uint32_t),
GFP_KERNEL);
if (!dvs_config->ycoords_y) {
IA_CSS_ERROR("out of memory");
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
......@@ -76,16 +76,16 @@ alloc_dvs_6axis_table(const struct ia_css_resolution *frame_res,
/* Generate UV buffers */
IA_CSS_LOG("UV W %d H %d", width_uv, height_uv);
dvs_config->xcoords_uv = (uint32_t *)sh_css_malloc(width_uv * height_uv *
sizeof(uint32_t));
dvs_config->xcoords_uv = kvmalloc(width_uv * height_uv * sizeof(uint32_t),
GFP_KERNEL);
if (!dvs_config->xcoords_uv) {
IA_CSS_ERROR("out of memory");
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
goto exit;
}
dvs_config->ycoords_uv = (uint32_t *)sh_css_malloc(width_uv * height_uv *
sizeof(uint32_t));
dvs_config->ycoords_uv = kvmalloc(width_uv * height_uv * sizeof(uint32_t),
GFP_KERNEL);
if (!dvs_config->ycoords_uv) {
IA_CSS_ERROR("out of memory");
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
......@@ -207,28 +207,28 @@ free_dvs_6axis_table(struct ia_css_dvs_6axis_config **dvs_6axis_config)
if ((dvs_6axis_config) && (*dvs_6axis_config)) {
IA_CSS_ENTER_PRIVATE("dvs_6axis_config %p", (*dvs_6axis_config));
if ((*dvs_6axis_config)->xcoords_y) {
sh_css_free((*dvs_6axis_config)->xcoords_y);
kvfree((*dvs_6axis_config)->xcoords_y);
(*dvs_6axis_config)->xcoords_y = NULL;
}
if ((*dvs_6axis_config)->ycoords_y) {
sh_css_free((*dvs_6axis_config)->ycoords_y);
kvfree((*dvs_6axis_config)->ycoords_y);
(*dvs_6axis_config)->ycoords_y = NULL;
}
/* Free up UV buffers */
if ((*dvs_6axis_config)->xcoords_uv) {
sh_css_free((*dvs_6axis_config)->xcoords_uv);
kvfree((*dvs_6axis_config)->xcoords_uv);
(*dvs_6axis_config)->xcoords_uv = NULL;
}
if ((*dvs_6axis_config)->ycoords_uv) {
sh_css_free((*dvs_6axis_config)->ycoords_uv);
kvfree((*dvs_6axis_config)->ycoords_uv);
(*dvs_6axis_config)->ycoords_uv = NULL;
}
IA_CSS_LEAVE_PRIVATE("dvs_6axis_config %p", (*dvs_6axis_config));
sh_css_free(*dvs_6axis_config);
kvfree(*dvs_6axis_config);
*dvs_6axis_config = NULL;
}
}
......
......@@ -360,12 +360,13 @@ ia_css_shading_table_alloc(
me->fraction_bits = 0;
for (i = 0; i < IA_CSS_SC_NUM_COLORS; i++) {
me->data[i] =
sh_css_malloc(width * height * sizeof(*me->data[0]));
kvmalloc(width * height * sizeof(*me->data[0]),
GFP_KERNEL);
if (!me->data[i]) {
unsigned int j;
for (j = 0; j < i; j++) {
sh_css_free(me->data[j]);
kvfree(me->data[j]);
me->data[j] = NULL;
}
kfree(me);
......@@ -392,7 +393,7 @@ ia_css_shading_table_free(struct ia_css_shading_table *table)
for (i = 0; i < IA_CSS_SC_NUM_COLORS; i++) {
if (table->data[i]) {
sh_css_free(table->data[i]);
kvfree(table->data[i]);
table->data[i] = NULL;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment