media: atomisp: return errors from ia_css_dma_configure_from_info()
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 5 Nov 2021 16:30:48 +0000 (16:30 +0000)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 15 Nov 2021 08:11:52 +0000 (08:11 +0000)
Now that the pipeline config functions can return errors, change
ia_css_dma_configure_from_info() and callers in order for them
to return errors at pipelines instead of using assert().

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/atomisp/pci/isp/kernels/crop/crop_1.0/ia_css_crop.host.c
drivers/staging/media/atomisp/pci/isp/kernels/fpn/fpn_1.0/ia_css_fpn.host.c
drivers/staging/media/atomisp/pci/isp/kernels/ipu2_io_ls/bayer_io_ls/ia_css_bayer_io.host.c
drivers/staging/media/atomisp/pci/isp/kernels/ipu2_io_ls/yuv444_io_ls/ia_css_yuv444_io.host.c
drivers/staging/media/atomisp/pci/isp/kernels/output/output_1.0/ia_css_output.host.c
drivers/staging/media/atomisp/pci/isp/kernels/qplane/qplane_2/ia_css_qplane.host.c
drivers/staging/media/atomisp/pci/isp/kernels/raw/raw_1.0/ia_css_raw.host.c
drivers/staging/media/atomisp/pci/isp/kernels/ref/ref_1.0/ia_css_ref.host.c
drivers/staging/media/atomisp/pci/isp/kernels/tnr/tnr_1.0/ia_css_tnr.host.c
drivers/staging/media/atomisp/pci/isp/kernels/vf/vf_1.0/ia_css_vf.host.c
drivers/staging/media/atomisp/pci/runtime/frame/src/frame.c

index 69b1c49..8c1d50f 100644 (file)
@@ -41,13 +41,18 @@ int ia_css_crop_config(struct sh_css_isp_crop_isp_config *to,
                       unsigned int size)
 {
        unsigned int elems_a = ISP_VEC_NELEMS;
+       int ret;
+
+       ret = ia_css_dma_configure_from_info(&to->port_b, from->info);
+       if (ret)
+               return ret;
 
-       (void)size;
-       ia_css_dma_configure_from_info(&to->port_b, from->info);
        to->width_a_over_b = elems_a / to->port_b.elems;
 
        /* Assume divisiblity here, may need to generalize to fixed point. */
-       assert(elems_a % to->port_b.elems == 0);
+       if (elems_a % to->port_b.elems != 0)
+               return -EINVAL;
+
        return 0;
 }
 
index be68192..57b5e11 100644 (file)
@@ -56,13 +56,18 @@ int ia_css_fpn_config(struct sh_css_isp_fpn_isp_config *to,
                      unsigned int size)
 {
        unsigned int elems_a = ISP_VEC_NELEMS;
+       int ret;
+
+       ret = ia_css_dma_configure_from_info(&to->port_b, from->info);
+       if (ret)
+               return ret;
 
-       (void)size;
-       ia_css_dma_configure_from_info(&to->port_b, from->info);
        to->width_a_over_b = elems_a / to->port_b.elems;
 
        /* Assume divisiblity here, may need to generalize to fixed point. */
-       assert(elems_a % to->port_b.elems == 0);
+       if (elems_a % to->port_b.elems != 0)
+               return -EINVAL;
+
        return 0;
 }
 
index 5e2755b..c7d8855 100644 (file)
@@ -36,6 +36,7 @@ int ia_css_bayer_io_config(const struct ia_css_binary      *binary,
                                                ddr_bits_per_element);
        unsigned int size_get = 0, size_put = 0;
        unsigned int offset = 0;
+       int ret;
 
        if (binary->info->mem_offsets.offsets.param) {
                size_get = binary->info->mem_offsets.offsets.param->dmem.get.size;
@@ -51,7 +52,9 @@ int ia_css_bayer_io_config(const struct ia_css_binary      *binary,
                                    "ia_css_bayer_io_config() get part enter:\n");
 #endif
 
-               ia_css_dma_configure_from_info(&config, in_frame_info);
+               ret = ia_css_dma_configure_from_info(&config, in_frame_info);
+               if (ret)
+                       return ret;
                // The base_address of the input frame will be set in the ISP
                to->width = in_frame_info->res.width;
                to->height = in_frame_info->res.height;
@@ -77,7 +80,9 @@ int ia_css_bayer_io_config(const struct ia_css_binary      *binary,
                                    "ia_css_bayer_io_config() put part enter:\n");
 #endif
 
-               ia_css_dma_configure_from_info(&config, &out_frames[0]->info);
+               ret = ia_css_dma_configure_from_info(&config, &out_frames[0]->info);
+               if (ret)
+                       return ret;
                to->base_address = out_frames[0]->data;
                to->width = out_frames[0]->info.res.width;
                to->height = out_frames[0]->info.res.height;
index 46fa1f7..7d2ef6e 100644 (file)
@@ -36,6 +36,7 @@ int ia_css_yuv444_io_config(const struct ia_css_binary      *binary,
                                                ddr_bits_per_element);
        unsigned int size_get = 0, size_put = 0;
        unsigned int offset = 0;
+       int ret;
 
        if (binary->info->mem_offsets.offsets.param) {
                size_get = binary->info->mem_offsets.offsets.param->dmem.get.size;
@@ -51,7 +52,10 @@ int ia_css_yuv444_io_config(const struct ia_css_binary      *binary,
                                    "ia_css_yuv444_io_config() get part enter:\n");
 #endif
 
-               ia_css_dma_configure_from_info(&config, in_frame_info);
+               ret = ia_css_dma_configure_from_info(&config, in_frame_info);
+               if (ret)
+                       return ret;
+
                // The base_address of the input frame will be set in the ISP
                to->width = in_frame_info->res.width;
                to->height = in_frame_info->res.height;
@@ -77,7 +81,10 @@ int ia_css_yuv444_io_config(const struct ia_css_binary      *binary,
                                    "ia_css_yuv444_io_config() put part enter:\n");
 #endif
 
-               ia_css_dma_configure_from_info(&config, &out_frames[0]->info);
+               ret = ia_css_dma_configure_from_info(&config, &out_frames[0]->info);
+               if (ret)
+                       return ret;
+
                to->base_address = out_frames[0]->data;
                to->width = out_frames[0]->info.res.width;
                to->height = out_frames[0]->info.res.height;
index 137e5b2..be9e4ef 100644 (file)
@@ -57,16 +57,21 @@ int ia_css_output_config(struct sh_css_isp_output_isp_config *to,
                         unsigned int size)
 {
        unsigned int elems_a = ISP_VEC_NELEMS;
+       int ret;
+
+       ret = ia_css_dma_configure_from_info(&to->port_b, from->info);
+       if (ret)
+               return ret;
 
-       (void)size;
-       ia_css_dma_configure_from_info(&to->port_b, from->info);
        to->width_a_over_b = elems_a / to->port_b.elems;
        to->height = from->info ? from->info->res.height : 0;
        to->enable = from->info != NULL;
        ia_css_frame_info_to_frame_sp_info(&to->info, from->info);
 
        /* Assume divisiblity here, may need to generalize to fixed point. */
-       assert(elems_a % to->port_b.elems == 0);
+       if (elems_a % to->port_b.elems != 0)
+               return -EINVAL;
+
        return 0;
 }
 
index 38ad6e5..9fd4435 100644 (file)
@@ -33,16 +33,21 @@ int ia_css_qplane_config(struct sh_css_isp_qplane_isp_config *to,
                         unsigned int size)
 {
        unsigned int elems_a = ISP_VEC_NELEMS;
+       int ret;
+
+       ret = ia_css_dma_configure_from_info(&to->port_b, from->info);
+       if (ret)
+               return ret;
 
-       (void)size;
-       ia_css_dma_configure_from_info(&to->port_b, from->info);
        to->width_a_over_b = elems_a / to->port_b.elems;
 
        /* Assume divisiblity here, may need to generalize to fixed point. */
-       assert(elems_a % to->port_b.elems == 0);
+       if (elems_a % to->port_b.elems != 0)
+               return -EINVAL;
 
        to->inout_port_config = from->pipe->inout_port_config;
        to->format = from->info->format;
+
        return 0;
 }
 
index aba0409..646d6e3 100644 (file)
@@ -71,8 +71,8 @@ int ia_css_raw_config(struct sh_css_isp_raw_isp_config *to,
        unsigned int elems_a = ISP_VEC_NELEMS;
        const struct ia_css_frame_info *in_info = from->in_info;
        const struct ia_css_frame_info *internal_info = from->internal_info;
+       int ret;
 
-       (void)size;
 #if !defined(ISP2401)
        /* 2401 input system uses input width width */
        in_info = internal_info;
@@ -84,7 +84,9 @@ int ia_css_raw_config(struct sh_css_isp_raw_isp_config *to,
                in_info = internal_info;
 
 #endif
-       ia_css_dma_configure_from_info(&to->port_b, in_info);
+       ret = ia_css_dma_configure_from_info(&to->port_b, in_info);
+       if (ret)
+               return ret;
 
        /* Assume divisiblity here, may need to generalize to fixed point. */
        assert((in_info->format == IA_CSS_FRAME_FORMAT_RAW_PACKED) ||
index 663dbb7..08ed916 100644 (file)
@@ -27,9 +27,12 @@ int ia_css_ref_config(struct sh_css_isp_ref_isp_config *to,
                      unsigned int size)
 {
        unsigned int elems_a = ISP_VEC_NELEMS, i;
+       int ret;
 
        if (from->ref_frames[0]) {
-               ia_css_dma_configure_from_info(&to->port_b, &from->ref_frames[0]->info);
+               ret = ia_css_dma_configure_from_info(&to->port_b, &from->ref_frames[0]->info);
+               if (ret)
+                       return ret;
                to->width_a_over_b = elems_a / to->port_b.elems;
                to->dvs_frame_delay = from->dvs_frame_delay;
        } else {
@@ -50,7 +53,9 @@ int ia_css_ref_config(struct sh_css_isp_ref_isp_config *to,
        }
 
        /* Assume divisiblity here, may need to generalize to fixed point. */
-       assert(elems_a % to->port_b.elems == 0);
+       if (elems_a % to->port_b.elems != 0)
+               return -EINVAL;
+
        return 0;
 }
 
index 3a5bea2..7177cf2 100644 (file)
@@ -77,9 +77,11 @@ int ia_css_tnr_config(struct sh_css_isp_tnr_isp_config *to,
 {
        unsigned int elems_a = ISP_VEC_NELEMS;
        unsigned int i;
+       int ret;
 
-       (void)size;
-       ia_css_dma_configure_from_info(&to->port_b, &from->tnr_frames[0]->info);
+       ret = ia_css_dma_configure_from_info(&to->port_b, &from->tnr_frames[0]->info);
+       if (ret)
+               return ret;
        to->width_a_over_b = elems_a / to->port_b.elems;
        to->frame_height = from->tnr_frames[0]->info.res.height;
        for (i = 0; i < NUM_TNR_FRAMES; i++) {
@@ -88,7 +90,9 @@ int ia_css_tnr_config(struct sh_css_isp_tnr_isp_config *to,
        }
 
        /* Assume divisiblity here, may need to generalize to fixed point. */
-       assert(elems_a % to->port_b.elems == 0);
+       if (elems_a % to->port_b.elems != 0)
+               return -EINVAL;
+
        return 0;
 }
 
index 1ace34f..aecdcbe 100644 (file)
@@ -31,18 +31,21 @@ int ia_css_vf_config(struct sh_css_isp_vf_isp_config      *to,
                    unsigned int size)
 {
        unsigned int elems_a = ISP_VEC_NELEMS;
+       int ret;
 
-       (void)size;
        to->vf_downscale_bits = from->vf_downscale_bits;
        to->enable = from->info != NULL;
 
        if (from->info) {
                ia_css_frame_info_to_frame_sp_info(&to->info, from->info);
-               ia_css_dma_configure_from_info(&to->dma.port_b, from->info);
+               ret = ia_css_dma_configure_from_info(&to->dma.port_b, from->info);
+               if (ret)
+                       return ret;
                to->dma.width_a_over_b = elems_a / to->dma.port_b.elems;
 
                /* Assume divisiblity here, may need to generalize to fixed point. */
-               assert(elems_a % to->dma.port_b.elems == 0);
+               if (elems_a % to->dma.port_b.elems != 0)
+                       return -EINVAL;
        }
        return 0;
 }
index 647383e..3c9dd5c 100644 (file)
@@ -608,7 +608,12 @@ int ia_css_dma_configure_from_info(struct dma_port_config *config,
        config->elems  = (uint8_t)elems_b;
        config->width  = (uint16_t)info->res.width;
        config->crop   = 0;
-       assert(config->width <= info->padded_width);
+
+       if (config->width > info->padded_width) {
+               dev_err(atomisp_dev, "internal error: padded_width is too small!\n");
+               return -EINVAL;
+       }
+
        return 0;
 }