drm/msm/dpu: make dpu_format_populate_addrs return void
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Tue, 3 Sep 2024 03:22:54 +0000 (06:22 +0300)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Mon, 21 Oct 2024 11:11:12 +0000 (14:11 +0300)
The function msm_framebuffer_iova() can not fail, it always returns a
valid address. Drop the useless checks (that were already performed at
the time) and make dpu_format_populate_addrs() return void.

Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/612247/
Link: https://lore.kernel.org/r/20240903-dpu-mode-config-width-v6-11-617e1ecc4b7a@linaro.org
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c
drivers/gpu/drm/msm/disp/dpu1/dpu_formats.h
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c

index 894f78cc6f6495bd5a63e3396716a2dc1b83ba48..4c006ec74575b2829265f0eae5c462af8d491621 100644 (file)
@@ -588,11 +588,7 @@ static void dpu_encoder_phys_wb_prepare_wb_job(struct dpu_encoder_phys *phys_enc
                return;
        }
 
-       ret = dpu_format_populate_addrs(aspace, job->fb, &wb_cfg->dest);
-       if (ret) {
-               DPU_DEBUG("failed to populate layout %d\n", ret);
-               return;
-       }
+       dpu_format_populate_addrs(aspace, job->fb, &wb_cfg->dest);
 
        wb_cfg->dest.width = job->fb->width;
        wb_cfg->dest.height = job->fb->height;
index abe3a1c0e409687345a9615df8c7822c0fcbad11..095bb947f1ffccfe4b1b3de40bbb9d3a9697cf6f 100644 (file)
@@ -277,25 +277,15 @@ int dpu_format_populate_plane_sizes(
        return _dpu_format_populate_plane_sizes_linear(fmt, fb, layout);
 }
 
-static int _dpu_format_populate_addrs_ubwc(
-               struct msm_gem_address_space *aspace,
-               struct drm_framebuffer *fb,
-               struct dpu_hw_fmt_layout *layout)
+static void _dpu_format_populate_addrs_ubwc(struct msm_gem_address_space *aspace,
+                                           struct drm_framebuffer *fb,
+                                           struct dpu_hw_fmt_layout *layout)
 {
        const struct msm_format *fmt;
        uint32_t base_addr = 0;
        bool meta;
 
-       if (!fb || !layout) {
-               DRM_ERROR("invalid pointers\n");
-               return -EINVAL;
-       }
-
        base_addr = msm_framebuffer_iova(fb, aspace, 0);
-       if (!base_addr) {
-               DRM_ERROR("failed to retrieve base addr\n");
-               return -EFAULT;
-       }
 
        fmt = msm_framebuffer_format(fb);
        meta = MSM_FORMAT_IS_UBWC(fmt);
@@ -330,7 +320,7 @@ static int _dpu_format_populate_addrs_ubwc(
                        + layout->plane_size[2] + layout->plane_size[3];
 
                if (!meta)
-                       return 0;
+                       return;
 
                /* configure Y metadata plane */
                layout->plane_addr[2] = base_addr;
@@ -361,60 +351,36 @@ static int _dpu_format_populate_addrs_ubwc(
                layout->plane_addr[1] = 0;
 
                if (!meta)
-                       return 0;
+                       return;
 
                layout->plane_addr[2] = base_addr;
                layout->plane_addr[3] = 0;
        }
-       return 0;
 }
 
-static int _dpu_format_populate_addrs_linear(
-               struct msm_gem_address_space *aspace,
-               struct drm_framebuffer *fb,
-               struct dpu_hw_fmt_layout *layout)
+static void _dpu_format_populate_addrs_linear(struct msm_gem_address_space *aspace,
+                                             struct drm_framebuffer *fb,
+                                             struct dpu_hw_fmt_layout *layout)
 {
        unsigned int i;
 
        /* Populate addresses for simple formats here */
-       for (i = 0; i < layout->num_planes; ++i) {
+       for (i = 0; i < layout->num_planes; ++i)
                layout->plane_addr[i] = msm_framebuffer_iova(fb, aspace, i);
-               if (!layout->plane_addr[i]) {
-                       DRM_ERROR("failed to retrieve base addr\n");
-                       return -EFAULT;
-               }
-       }
-
-       return 0;
 }
 
-int dpu_format_populate_addrs(
-               struct msm_gem_address_space *aspace,
-               struct drm_framebuffer *fb,
-               struct dpu_hw_fmt_layout *layout)
+void dpu_format_populate_addrs(struct msm_gem_address_space *aspace,
+                              struct drm_framebuffer *fb,
+                              struct dpu_hw_fmt_layout *layout)
 {
        const struct msm_format *fmt;
-       int ret;
-
-       if (!fb || !layout) {
-               DRM_ERROR("invalid arguments\n");
-               return -EINVAL;
-       }
-
-       if ((fb->width > DPU_MAX_IMG_WIDTH) ||
-                       (fb->height > DPU_MAX_IMG_HEIGHT)) {
-               DRM_ERROR("image dimensions outside max range\n");
-               return -ERANGE;
-       }
 
        fmt = msm_framebuffer_format(fb);
 
        /* Populate the addresses given the fb */
        if (MSM_FORMAT_IS_UBWC(fmt) ||
                        MSM_FORMAT_IS_TILE(fmt))
-               ret = _dpu_format_populate_addrs_ubwc(aspace, fb, layout);
+               _dpu_format_populate_addrs_ubwc(aspace, fb, layout);
        else
-               ret = _dpu_format_populate_addrs_linear(aspace, fb, layout);
-
-       return ret;
+               _dpu_format_populate_addrs_linear(aspace, fb, layout);
 }
index 2f2bff14c0db1f140e11e8dacae5c081f8fd9c22..256ca25c37a0eab9184f3f19edd255a5a8cdc0cb 100644 (file)
@@ -37,14 +37,10 @@ static inline bool dpu_find_format(u32 format, const u32 *supported_formats,
  * @aspace:            address space pointer
  * @fb:                framebuffer pointer
  * @fmtl:              format layout structure to populate
- *
- * Return: error code on failure, -EAGAIN if success but the addresses
- *         are the same as before or 0 if new addresses were populated
  */
-int dpu_format_populate_addrs(
-               struct msm_gem_address_space *aspace,
-               struct drm_framebuffer *fb,
-               struct dpu_hw_fmt_layout *fmtl);
+void dpu_format_populate_addrs(struct msm_gem_address_space *aspace,
+                              struct drm_framebuffer *fb,
+                              struct dpu_hw_fmt_layout *layout);
 
 int dpu_format_populate_plane_sizes(
                struct drm_framebuffer *fb,
index 39ceb7b65318aadfeb6f4c3abb6f8d71c939c950..df95377b98fca33f69a8a2e2548a8cc6483e9618 100644 (file)
@@ -684,17 +684,9 @@ static int dpu_plane_prepare_fb(struct drm_plane *plane,
                return ret;
        }
 
-       /* validate framebuffer layout before commit */
-       ret = dpu_format_populate_addrs(pstate->aspace,
-                                       new_state->fb,
-                                       &pstate->layout);
-       if (ret) {
-               DPU_ERROR_PLANE(pdpu, "failed to get format layout, %d\n", ret);
-               if (pstate->aspace)
-                       msm_framebuffer_cleanup(new_state->fb, pstate->aspace,
-                                               pstate->needs_dirtyfb);
-               return ret;
-       }
+       dpu_format_populate_addrs(pstate->aspace,
+                                 new_state->fb,
+                                 &pstate->layout);
 
        return 0;
 }