Commit 4cc20c9c authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

media: atomisp: Simplify hmm_alloc() calls

Make hmm_alloc() only take size as a parameter and remove other parameters.
since all callers always pass the same flags.

Link: https://lore.kernel.org/linux-media/20220615205037.16549-30-hdegoede@redhat.comReviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent ceff4bdb
...@@ -36,9 +36,7 @@ ...@@ -36,9 +36,7 @@
int hmm_init(void); int hmm_init(void);
void hmm_cleanup(void); void hmm_cleanup(void);
ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, ia_css_ptr hmm_alloc(size_t bytes);
int from_highmem, const void __user *userptr,
const uint16_t attrs);
ia_css_ptr hmm_create_from_userdata(size_t bytes, const void __user *userptr); ia_css_ptr hmm_create_from_userdata(size_t bytes, const void __user *userptr);
void hmm_free(ia_css_ptr ptr); void hmm_free(ia_css_ptr ptr);
int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes); int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes);
......
...@@ -141,7 +141,7 @@ int hmm_init(void) ...@@ -141,7 +141,7 @@ int hmm_init(void)
* at the beginning, to avoid hmm_alloc return 0 in the * at the beginning, to avoid hmm_alloc return 0 in the
* further allocation. * further allocation.
*/ */
dummy_ptr = hmm_alloc(1, HMM_BO_PRIVATE, 0, NULL, 0); dummy_ptr = hmm_alloc(1);
if (!ret) { if (!ret) {
ret = sysfs_create_group(&atomisp_dev->kobj, ret = sysfs_create_group(&atomisp_dev->kobj,
...@@ -168,9 +168,7 @@ void hmm_cleanup(void) ...@@ -168,9 +168,7 @@ void hmm_cleanup(void)
hmm_initialized = false; hmm_initialized = false;
} }
ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type, const void __user *userptr)
int from_highmem, const void __user *userptr,
const uint16_t attrs)
{ {
unsigned int pgnr; unsigned int pgnr;
struct hmm_buffer_object *bo; struct hmm_buffer_object *bo;
...@@ -194,7 +192,7 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, ...@@ -194,7 +192,7 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
} }
/* Allocate pages for memory */ /* Allocate pages for memory */
ret = hmm_bo_alloc_pages(bo, type, from_highmem, userptr); ret = hmm_bo_alloc_pages(bo, type, false, userptr);
if (ret) { if (ret) {
dev_err(atomisp_dev, "hmm_bo_alloc_pages failed.\n"); dev_err(atomisp_dev, "hmm_bo_alloc_pages failed.\n");
goto alloc_page_err; goto alloc_page_err;
...@@ -208,8 +206,8 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, ...@@ -208,8 +206,8 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
} }
dev_dbg(atomisp_dev, dev_dbg(atomisp_dev,
"%s: pages: 0x%08x (%zu bytes), type: %d from highmem %d, user ptr %p\n", "%s: pages: 0x%08x (%zu bytes), type: %d, user ptr %p\n",
__func__, bo->start, bytes, type, from_highmem, userptr); __func__, bo->start, bytes, type, userptr);
return bo->start; return bo->start;
...@@ -221,9 +219,14 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, ...@@ -221,9 +219,14 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
return 0; return 0;
} }
ia_css_ptr hmm_alloc(size_t bytes)
{
return __hmm_alloc(bytes, HMM_BO_PRIVATE, NULL);
}
ia_css_ptr hmm_create_from_userdata(size_t bytes, const void __user *userptr) ia_css_ptr hmm_create_from_userdata(size_t bytes, const void __user *userptr)
{ {
return hmm_alloc(bytes, HMM_BO_USER, 0, userptr, 0); return __hmm_alloc(bytes, HMM_BO_USER, userptr);
} }
void hmm_free(ia_css_ptr virt) void hmm_free(ia_css_ptr virt)
......
...@@ -331,7 +331,7 @@ ia_css_isp_dvs_statistics_allocate( ...@@ -331,7 +331,7 @@ ia_css_isp_dvs_statistics_allocate(
HIVE_ISP_DDR_WORD_BYTES); HIVE_ISP_DDR_WORD_BYTES);
me->size = hor_size + ver_size; me->size = hor_size + ver_size;
me->data_ptr = hmm_alloc(me->size, HMM_BO_PRIVATE, 0, NULL, 0); me->data_ptr = hmm_alloc(me->size);
if (me->data_ptr == mmgr_NULL) if (me->data_ptr == mmgr_NULL)
goto err; goto err;
me->hor_size = hor_size; me->hor_size = hor_size;
......
...@@ -294,7 +294,7 @@ ia_css_isp_dvs2_statistics_allocate( ...@@ -294,7 +294,7 @@ ia_css_isp_dvs2_statistics_allocate(
* grid->aligned_height * IA_CSS_DVS2_NUM_COEF_TYPES; * grid->aligned_height * IA_CSS_DVS2_NUM_COEF_TYPES;
me->size = 2 * size; me->size = 2 * size;
me->data_ptr = hmm_alloc(me->size, HMM_BO_PRIVATE, 0, NULL, 0); me->data_ptr = hmm_alloc(me->size);
if (me->data_ptr == mmgr_NULL) if (me->data_ptr == mmgr_NULL)
goto err; goto err;
me->hor_proj = me->data_ptr; me->hor_proj = me->data_ptr;
......
...@@ -728,8 +728,7 @@ static int frame_allocate_buffer_data(struct ia_css_frame *frame) ...@@ -728,8 +728,7 @@ static int frame_allocate_buffer_data(struct ia_css_frame *frame)
#ifdef ISP2401 #ifdef ISP2401
IA_CSS_ENTER_LEAVE_PRIVATE("frame->data_bytes=%d\n", frame->data_bytes); IA_CSS_ENTER_LEAVE_PRIVATE("frame->data_bytes=%d\n", frame->data_bytes);
#endif #endif
frame->data = hmm_alloc(frame->data_bytes, frame->data = hmm_alloc(frame->data_bytes);
HMM_BO_PRIVATE, 0, NULL, 0);
if (frame->data == mmgr_NULL) if (frame->data == mmgr_NULL)
return -ENOMEM; return -ENOMEM;
return 0; return 0;
......
...@@ -131,7 +131,7 @@ ia_css_isp_param_allocate_isp_parameters( ...@@ -131,7 +131,7 @@ ia_css_isp_param_allocate_isp_parameters(
goto cleanup; goto cleanup;
} }
if (pclass != IA_CSS_PARAM_CLASS_PARAM) { if (pclass != IA_CSS_PARAM_CLASS_PARAM) {
css_params->params[pclass][mem].address = hmm_alloc(size, HMM_BO_PRIVATE, 0, NULL, 0); css_params->params[pclass][mem].address = hmm_alloc(size);
if (!css_params->params[pclass][mem].address) { if (!css_params->params[pclass][mem].address) {
err = -ENOMEM; err = -ENOMEM;
goto cleanup; goto cleanup;
......
...@@ -282,8 +282,7 @@ void ia_css_rmgr_acq_vbuf(struct ia_css_rmgr_vbuf_pool *pool, ...@@ -282,8 +282,7 @@ void ia_css_rmgr_acq_vbuf(struct ia_css_rmgr_vbuf_pool *pool,
} }
if ((*handle)->vptr == 0x0) { if ((*handle)->vptr == 0x0) {
/* we need to allocate */ /* we need to allocate */
(*handle)->vptr = hmm_alloc((*handle)->size, (*handle)->vptr = hmm_alloc((*handle)->size);
HMM_BO_PRIVATE, 0, NULL, 0);
} else { } else {
/* we popped a buffer */ /* we popped a buffer */
return; return;
......
...@@ -64,7 +64,7 @@ int ia_css_spctrl_load_fw(sp_ID_t sp_id, ia_css_spctrl_cfg *spctrl_cfg) ...@@ -64,7 +64,7 @@ int ia_css_spctrl_load_fw(sp_ID_t sp_id, ia_css_spctrl_cfg *spctrl_cfg)
* Data used to be stored separately, because of access alignment constraints, * Data used to be stored separately, because of access alignment constraints,
* fix the FW generation instead * fix the FW generation instead
*/ */
code_addr = hmm_alloc(spctrl_cfg->code_size, HMM_BO_PRIVATE, 0, NULL, 0); code_addr = hmm_alloc(spctrl_cfg->code_size);
if (code_addr == mmgr_NULL) if (code_addr == mmgr_NULL)
return -ENOMEM; return -ENOMEM;
hmm_store(code_addr, spctrl_cfg->code, spctrl_cfg->code_size); hmm_store(code_addr, spctrl_cfg->code, spctrl_cfg->code_size);
......
...@@ -369,7 +369,7 @@ void sh_css_unload_firmware(void) ...@@ -369,7 +369,7 @@ void sh_css_unload_firmware(void)
ia_css_ptr ia_css_ptr
sh_css_load_blob(const unsigned char *blob, unsigned int size) sh_css_load_blob(const unsigned char *blob, unsigned int size)
{ {
ia_css_ptr target_addr = hmm_alloc(size, HMM_BO_PRIVATE, 0, NULL, 0); ia_css_ptr target_addr = hmm_alloc(size);
/* /*
* this will allocate memory aligned to a DDR word boundary which * this will allocate memory aligned to a DDR word boundary which
* is required for the CSS DMA to read the instructions. * is required for the CSS DMA to read the instructions.
......
...@@ -2072,8 +2072,7 @@ static bool realloc_isp_css_mm_buf( ...@@ -2072,8 +2072,7 @@ static bool realloc_isp_css_mm_buf(
size_t *curr_size, size_t *curr_size,
size_t needed_size, size_t needed_size,
bool force, bool force,
int *err, int *err)
uint16_t mmgr_attribute)
{ {
s32 id; s32 id;
...@@ -2095,11 +2094,7 @@ static bool realloc_isp_css_mm_buf( ...@@ -2095,11 +2094,7 @@ static bool realloc_isp_css_mm_buf(
id = IA_CSS_REFCOUNT_PARAM_BUFFER; id = IA_CSS_REFCOUNT_PARAM_BUFFER;
ia_css_refcount_decrement(id, *curr_buf); ia_css_refcount_decrement(id, *curr_buf);
*curr_buf = ia_css_refcount_increment(id, hmm_alloc(needed_size, *curr_buf = ia_css_refcount_increment(id, hmm_alloc(needed_size));
HMM_BO_PRIVATE, 0,
NULL,
mmgr_attribute));
if (!*curr_buf) { if (!*curr_buf) {
*err = -ENOMEM; *err = -ENOMEM;
*curr_size = 0; *curr_size = 0;
...@@ -2122,7 +2117,7 @@ static bool reallocate_buffer( ...@@ -2122,7 +2117,7 @@ static bool reallocate_buffer(
IA_CSS_ENTER_PRIVATE("void"); IA_CSS_ENTER_PRIVATE("void");
ret = realloc_isp_css_mm_buf(curr_buf, ret = realloc_isp_css_mm_buf(curr_buf,
curr_size, needed_size, force, err, 0); curr_size, needed_size, force, err);
IA_CSS_LEAVE_PRIVATE("ret=%d", ret); IA_CSS_LEAVE_PRIVATE("ret=%d", ret);
return ret; return ret;
...@@ -2161,7 +2156,7 @@ ia_css_isp_3a_statistics_allocate(const struct ia_css_3a_grid_info *grid) ...@@ -2161,7 +2156,7 @@ ia_css_isp_3a_statistics_allocate(const struct ia_css_3a_grid_info *grid)
me->hmem_size = CEIL_MUL(me->hmem_size, HIVE_ISP_DDR_WORD_BYTES); me->hmem_size = CEIL_MUL(me->hmem_size, HIVE_ISP_DDR_WORD_BYTES);
me->size = me->dmem_size + me->vmem_size * 2 + me->hmem_size; me->size = me->dmem_size + me->vmem_size * 2 + me->hmem_size;
me->data_ptr = hmm_alloc(me->size, HMM_BO_PRIVATE, 0, NULL, 0); me->data_ptr = hmm_alloc(me->size);
if (me->data_ptr == mmgr_NULL) { if (me->data_ptr == mmgr_NULL) {
kvfree(me); kvfree(me);
me = NULL; me = NULL;
...@@ -2211,7 +2206,7 @@ ia_css_metadata_allocate(const struct ia_css_metadata_info *metadata_info) ...@@ -2211,7 +2206,7 @@ ia_css_metadata_allocate(const struct ia_css_metadata_info *metadata_info)
md->info = *metadata_info; md->info = *metadata_info;
md->exp_id = 0; md->exp_id = 0;
md->address = hmm_alloc(metadata_info->size, HMM_BO_PRIVATE, 0, NULL, 0); md->address = hmm_alloc(metadata_info->size);
if (md->address == mmgr_NULL) if (md->address == mmgr_NULL)
goto error; goto error;
...@@ -2364,13 +2359,13 @@ sh_css_create_isp_params(struct ia_css_stream *stream, ...@@ -2364,13 +2359,13 @@ sh_css_create_isp_params(struct ia_css_stream *stream,
ddr_ptrs_size->isp_param = params_size; ddr_ptrs_size->isp_param = params_size;
ddr_ptrs->isp_param = ddr_ptrs->isp_param =
ia_css_refcount_increment(IA_CSS_REFCOUNT_PARAM_BUFFER, ia_css_refcount_increment(IA_CSS_REFCOUNT_PARAM_BUFFER,
hmm_alloc(params_size, HMM_BO_PRIVATE, 0, NULL, 0)); hmm_alloc(params_size));
succ &= (ddr_ptrs->isp_param != mmgr_NULL); succ &= (ddr_ptrs->isp_param != mmgr_NULL);
ddr_ptrs_size->macc_tbl = sizeof(struct ia_css_macc_table); ddr_ptrs_size->macc_tbl = sizeof(struct ia_css_macc_table);
ddr_ptrs->macc_tbl = ddr_ptrs->macc_tbl =
ia_css_refcount_increment(IA_CSS_REFCOUNT_PARAM_BUFFER, ia_css_refcount_increment(IA_CSS_REFCOUNT_PARAM_BUFFER,
hmm_alloc(sizeof(struct ia_css_macc_table), HMM_BO_PRIVATE, 0, NULL, 0)); hmm_alloc(sizeof(struct ia_css_macc_table)));
succ &= (ddr_ptrs->macc_tbl != mmgr_NULL); succ &= (ddr_ptrs->macc_tbl != mmgr_NULL);
*isp_params_out = params; *isp_params_out = params;
...@@ -2584,12 +2579,10 @@ sh_css_params_init(void) ...@@ -2584,12 +2579,10 @@ sh_css_params_init(void)
for (i = 0; i < SH_CSS_MAX_STAGES; i++) { for (i = 0; i < SH_CSS_MAX_STAGES; i++) {
xmem_sp_stage_ptrs[p][i] = xmem_sp_stage_ptrs[p][i] =
ia_css_refcount_increment(-1, ia_css_refcount_increment(-1,
hmm_alloc(sizeof(struct sh_css_sp_stage), hmm_alloc(sizeof(struct sh_css_sp_stage)));
HMM_BO_PRIVATE, 0, NULL, 0));
xmem_isp_stage_ptrs[p][i] = xmem_isp_stage_ptrs[p][i] =
ia_css_refcount_increment(-1, ia_css_refcount_increment(-1,
hmm_alloc(sizeof(struct sh_css_sp_stage), hmm_alloc(sizeof(struct sh_css_sp_stage)));
HMM_BO_PRIVATE, 0, NULL, 0));
if ((xmem_sp_stage_ptrs[p][i] == mmgr_NULL) || if ((xmem_sp_stage_ptrs[p][i] == mmgr_NULL) ||
(xmem_isp_stage_ptrs[p][i] == mmgr_NULL)) { (xmem_isp_stage_ptrs[p][i] == mmgr_NULL)) {
...@@ -2610,11 +2603,9 @@ sh_css_params_init(void) ...@@ -2610,11 +2603,9 @@ sh_css_params_init(void)
sp_ddr_ptrs = ia_css_refcount_increment(-1, sp_ddr_ptrs = ia_css_refcount_increment(-1,
hmm_alloc(CEIL_MUL(sizeof(struct sh_css_ddr_address_map), hmm_alloc(CEIL_MUL(sizeof(struct sh_css_ddr_address_map),
HIVE_ISP_DDR_WORD_BYTES), HIVE_ISP_DDR_WORD_BYTES)));
HMM_BO_PRIVATE, 0, NULL, 0));
xmem_sp_group_ptrs = ia_css_refcount_increment(-1, xmem_sp_group_ptrs = ia_css_refcount_increment(-1,
hmm_alloc(sizeof(struct sh_css_sp_group), hmm_alloc(sizeof(struct sh_css_sp_group)));
HMM_BO_PRIVATE, 0, NULL, 0));
if ((sp_ddr_ptrs == mmgr_NULL) || if ((sp_ddr_ptrs == mmgr_NULL) ||
(xmem_sp_group_ptrs == mmgr_NULL)) { (xmem_sp_group_ptrs == mmgr_NULL)) {
...@@ -2669,7 +2660,7 @@ int ia_css_pipe_set_bci_scaler_lut(struct ia_css_pipe *pipe, ...@@ -2669,7 +2660,7 @@ int ia_css_pipe_set_bci_scaler_lut(struct ia_css_pipe *pipe,
} }
if (!stream_started) { if (!stream_started) {
pipe->scaler_pp_lut = hmm_alloc(sizeof(zoom_table), HMM_BO_PRIVATE, 0, NULL, 0); pipe->scaler_pp_lut = hmm_alloc(sizeof(zoom_table));
if (pipe->scaler_pp_lut == mmgr_NULL) { if (pipe->scaler_pp_lut == mmgr_NULL) {
ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR, ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
...@@ -2711,7 +2702,7 @@ int sh_css_params_map_and_store_default_gdc_lut(void) ...@@ -2711,7 +2702,7 @@ int sh_css_params_map_and_store_default_gdc_lut(void)
host_lut_store((void *)zoom_table); host_lut_store((void *)zoom_table);
default_gdc_lut = hmm_alloc(sizeof(zoom_table), HMM_BO_PRIVATE, 0, NULL, 0); default_gdc_lut = hmm_alloc(sizeof(zoom_table));
if (default_gdc_lut == mmgr_NULL) if (default_gdc_lut == mmgr_NULL)
return -ENOMEM; return -ENOMEM;
...@@ -3804,7 +3795,7 @@ static int write_ia_css_isp_parameter_set_info_to_ddr( ...@@ -3804,7 +3795,7 @@ static int write_ia_css_isp_parameter_set_info_to_ddr(
assert(out); assert(out);
*out = ia_css_refcount_increment(IA_CSS_REFCOUNT_PARAM_SET_POOL, *out = ia_css_refcount_increment(IA_CSS_REFCOUNT_PARAM_SET_POOL,
hmm_alloc(sizeof(struct ia_css_isp_parameter_set_info), HMM_BO_PRIVATE, 0, NULL, 0)); hmm_alloc(sizeof(struct ia_css_isp_parameter_set_info)));
succ = (*out != mmgr_NULL); succ = (*out != mmgr_NULL);
if (succ) if (succ)
hmm_store(*out, hmm_store(*out,
......
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