media: atomisp: Simplify hmm_alloc() calls
authorHans de Goede <hdegoede@redhat.com>
Wed, 15 Jun 2022 20:50:26 +0000 (21:50 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 8 Jul 2022 15:33:19 +0000 (16:33 +0100)
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.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/staging/media/atomisp/include/hmm/hmm.h
drivers/staging/media/atomisp/pci/hmm/hmm.c
drivers/staging/media/atomisp/pci/isp/kernels/sdis/sdis_1.0/ia_css_sdis.host.c
drivers/staging/media/atomisp/pci/isp/kernels/sdis/sdis_2/ia_css_sdis2.host.c
drivers/staging/media/atomisp/pci/runtime/frame/src/frame.c
drivers/staging/media/atomisp/pci/runtime/isp_param/src/isp_param.c
drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c
drivers/staging/media/atomisp/pci/runtime/spctrl/src/spctrl.c
drivers/staging/media/atomisp/pci/sh_css_firmware.c
drivers/staging/media/atomisp/pci/sh_css_params.c

index 615805d0dd9153fdf1c91f559aa22036d1455cbb..c0384bb0a76245ad0ab7d61d0f953369f90de84a 100644 (file)
@@ -36,9 +36,7 @@
 int hmm_init(void);
 void hmm_cleanup(void);
 
-ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
-                    int from_highmem, const void __user *userptr,
-                    const uint16_t attrs);
+ia_css_ptr hmm_alloc(size_t bytes);
 ia_css_ptr hmm_create_from_userdata(size_t bytes, const void __user *userptr);
 void hmm_free(ia_css_ptr ptr);
 int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes);
index a71db7969e1d8c83e657fe1a91771f17dfb2faf6..a5d725908052da742b36ebc6b58c82758c61202a 100644 (file)
@@ -141,7 +141,7 @@ int hmm_init(void)
         * at the beginning, to avoid hmm_alloc return 0 in the
         * further allocation.
         */
-       dummy_ptr = hmm_alloc(1, HMM_BO_PRIVATE, 0, NULL, 0);
+       dummy_ptr = hmm_alloc(1);
 
        if (!ret) {
                ret = sysfs_create_group(&atomisp_dev->kobj,
@@ -168,9 +168,7 @@ void hmm_cleanup(void)
        hmm_initialized = false;
 }
 
-ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
-                    int from_highmem, const void __user *userptr,
-                    const uint16_t attrs)
+static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type, const void __user *userptr)
 {
        unsigned int pgnr;
        struct hmm_buffer_object *bo;
@@ -194,7 +192,7 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
        }
 
        /* 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) {
                dev_err(atomisp_dev, "hmm_bo_alloc_pages failed.\n");
                goto alloc_page_err;
@@ -208,8 +206,8 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
        }
 
        dev_dbg(atomisp_dev,
-               "%s: pages: 0x%08x (%zu bytes), type: %d from highmem %d, user ptr %p\n",
-               __func__, bo->start, bytes, type, from_highmem, userptr);
+               "%s: pages: 0x%08x (%zu bytes), type: %d, user ptr %p\n",
+               __func__, bo->start, bytes, type, userptr);
 
        return bo->start;
 
@@ -221,9 +219,14 @@ create_bo_err:
        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)
 {
-       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)
index 13caa55fd51a6285d093b8f47afb08315aa22ca1..bf0a768f8fe18c7c9c653c618d5436f41463b9d2 100644 (file)
@@ -331,7 +331,7 @@ ia_css_isp_dvs_statistics_allocate(
                            HIVE_ISP_DDR_WORD_BYTES);
 
        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)
                goto err;
        me->hor_size = hor_size;
index f608740e8340dc21a2628da29acb18074f5928e7..c13de289a3dbe9bd03c101e686ac584e7f754462 100644 (file)
@@ -294,7 +294,7 @@ ia_css_isp_dvs2_statistics_allocate(
               * grid->aligned_height * IA_CSS_DVS2_NUM_COEF_TYPES;
 
        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)
                goto err;
        me->hor_proj = me->data_ptr;
index b0ce288b76be3f1c45f6924e54db0b951478e6d9..bd0eb864126574a0f644d136e9f10120662e89af 100644 (file)
@@ -728,8 +728,7 @@ static int frame_allocate_buffer_data(struct ia_css_frame *frame)
 #ifdef ISP2401
        IA_CSS_ENTER_LEAVE_PRIVATE("frame->data_bytes=%d\n", frame->data_bytes);
 #endif
-       frame->data = hmm_alloc(frame->data_bytes,
-                               HMM_BO_PRIVATE, 0, NULL, 0);
+       frame->data = hmm_alloc(frame->data_bytes);
        if (frame->data == mmgr_NULL)
                return -ENOMEM;
        return 0;
index 823ec54b6281f84ee02c9e88d1994ec92989b655..99c2f3a533abaae8a6b3c73ced0391832340ab0e 100644 (file)
@@ -131,7 +131,7 @@ ia_css_isp_param_allocate_isp_parameters(
                                        goto cleanup;
                                }
                                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) {
                                                err = -ENOMEM;
                                                goto cleanup;
index 39604752785bd657eea4ed3f5fbe6b14357672ba..2443406887d79a10b9903e124b6d3032fc256c28 100644 (file)
@@ -282,8 +282,7 @@ void ia_css_rmgr_acq_vbuf(struct ia_css_rmgr_vbuf_pool *pool,
                        }
                        if ((*handle)->vptr == 0x0) {
                                /* we need to allocate */
-                               (*handle)->vptr = hmm_alloc((*handle)->size,
-                                                            HMM_BO_PRIVATE, 0, NULL, 0);
+                               (*handle)->vptr = hmm_alloc((*handle)->size);
                        } else {
                                /* we popped a buffer */
                                return;
index 7f4592565af67f0b1aa1acaa18f5c9eecfb6c479..c34bfc5f970d0a145684e45150919af46516406c 100644 (file)
@@ -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,
         * 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)
                return -ENOMEM;
        hmm_store(code_addr, spctrl_cfg->code, spctrl_cfg->code_size);
index dd688f8ab649d3ce32af1bd2fc2b6df57291ab3f..e7ef578db8ab1fdfc0cf0e4aaef4034104354a60 100644 (file)
@@ -369,7 +369,7 @@ void sh_css_unload_firmware(void)
 ia_css_ptr
 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
         * is required for the CSS DMA to read the instructions.
index b5a10725d26337ab4183c424b68830f19e30336d..0e7c38b2bfe329f9f3f79c565232c1bc657d986a 100644 (file)
@@ -2072,8 +2072,7 @@ static bool realloc_isp_css_mm_buf(
     size_t *curr_size,
     size_t needed_size,
     bool force,
-    int *err,
-    uint16_t mmgr_attribute)
+    int *err)
 {
        s32 id;
 
@@ -2095,11 +2094,7 @@ static bool realloc_isp_css_mm_buf(
 
        id = IA_CSS_REFCOUNT_PARAM_BUFFER;
        ia_css_refcount_decrement(id, *curr_buf);
-       *curr_buf = ia_css_refcount_increment(id, hmm_alloc(needed_size,
-                                                           HMM_BO_PRIVATE, 0,
-                                                           NULL,
-                                                           mmgr_attribute));
-
+       *curr_buf = ia_css_refcount_increment(id, hmm_alloc(needed_size));
        if (!*curr_buf) {
                *err = -ENOMEM;
                *curr_size = 0;
@@ -2122,7 +2117,7 @@ static bool reallocate_buffer(
        IA_CSS_ENTER_PRIVATE("void");
 
        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);
        return ret;
@@ -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->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) {
                kvfree(me);
                me = NULL;
@@ -2211,7 +2206,7 @@ ia_css_metadata_allocate(const struct ia_css_metadata_info *metadata_info)
 
        md->info = *metadata_info;
        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)
                goto error;
 
@@ -2364,13 +2359,13 @@ sh_css_create_isp_params(struct ia_css_stream *stream,
        ddr_ptrs_size->isp_param = params_size;
        ddr_ptrs->isp_param =
        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);
 
        ddr_ptrs_size->macc_tbl = sizeof(struct ia_css_macc_table);
        ddr_ptrs->macc_tbl =
        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);
 
        *isp_params_out = params;
@@ -2584,12 +2579,10 @@ sh_css_params_init(void)
                for (i = 0; i < SH_CSS_MAX_STAGES; i++) {
                        xmem_sp_stage_ptrs[p][i] =
                        ia_css_refcount_increment(-1,
-                                                 hmm_alloc(sizeof(struct sh_css_sp_stage),
-                                                           HMM_BO_PRIVATE, 0, NULL, 0));
+                                                 hmm_alloc(sizeof(struct sh_css_sp_stage)));
                        xmem_isp_stage_ptrs[p][i] =
                        ia_css_refcount_increment(-1,
-                                                 hmm_alloc(sizeof(struct sh_css_sp_stage),
-                                                           HMM_BO_PRIVATE, 0, NULL, 0));
+                                                 hmm_alloc(sizeof(struct sh_css_sp_stage)));
 
                        if ((xmem_sp_stage_ptrs[p][i] == mmgr_NULL) ||
                            (xmem_isp_stage_ptrs[p][i] == mmgr_NULL)) {
@@ -2610,11 +2603,9 @@ sh_css_params_init(void)
 
        sp_ddr_ptrs = ia_css_refcount_increment(-1,
                                                hmm_alloc(CEIL_MUL(sizeof(struct sh_css_ddr_address_map),
-                                                                  HIVE_ISP_DDR_WORD_BYTES),
-                                                         HMM_BO_PRIVATE, 0, NULL, 0));
+                                                                  HIVE_ISP_DDR_WORD_BYTES)));
        xmem_sp_group_ptrs = ia_css_refcount_increment(-1,
-                                                      hmm_alloc(sizeof(struct sh_css_sp_group),
-                                                                HMM_BO_PRIVATE, 0, NULL, 0));
+                                                      hmm_alloc(sizeof(struct sh_css_sp_group)));
 
        if ((sp_ddr_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,
        }
 
        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) {
                        ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
@@ -2711,7 +2702,7 @@ int sh_css_params_map_and_store_default_gdc_lut(void)
 
        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)
                return -ENOMEM;
@@ -3804,7 +3795,7 @@ static int write_ia_css_isp_parameter_set_info_to_ddr(
        assert(out);
 
        *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);
        if (succ)
                hmm_store(*out,