Re: [PATCH v2 7/9] drm/msm/dpu: check for overflow in _dpu_crtc_setup_lm_bounds()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 6/3/2024 2:16 PM, Dmitry Baryshkov wrote:
On Mon, 3 Jun 2024 at 23:57, Abhinav Kumar <quic_abhinavk@xxxxxxxxxxx> wrote:



On 6/2/2024 2:39 PM, Dmitry Baryshkov wrote:
Check in _dpu_crtc_setup_lm_bounds() that CRTC width is not overflowing
LM requirements.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx>
---
   drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 15 ++++++++++++---
   1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index e3b1e5f55a92..c5e874a3656a 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -711,12 +711,13 @@ void dpu_crtc_complete_commit(struct drm_crtc *crtc)
       _dpu_crtc_complete_flip(crtc);
   }

-static void _dpu_crtc_setup_lm_bounds(struct drm_crtc *crtc,
+static int _dpu_crtc_setup_lm_bounds(struct drm_crtc *crtc,
               struct drm_crtc_state *state)

Perhaps now we need to rename this to _dpu_crtc_setup_and_check_lm_bounds()?

Ack, I'll rename it.


Also, prior to this change, we never had a bounds check for each LM
which we should have had . Does this qualify for a Fixes tag?

Probably no. We currently have a limit in the drm_mode_config, which
ensures that the CRTC isn't too wide.


The limit in drm_mode_config is to ensure we will not go beyond 2*max_mixer_width for the mode as we support only upto 2 LMs.

This check is making sure that even for the single LM, we do not go beyond the max_mixer_width which is valid imo.


With those two questions addressed,

Reviewed-by: Abhinav Kumar <quic_abhinavk@xxxxxxxxxxx>

   {
       struct dpu_crtc_state *cstate = to_dpu_crtc_state(state);
       struct drm_display_mode *adj_mode = &state->adjusted_mode;
       u32 crtc_split_width = adj_mode->hdisplay / cstate->num_mixers;
+     struct dpu_kms *dpu_kms = _dpu_crtc_get_kms(crtc);
       int i;

       for (i = 0; i < cstate->num_mixers; i++) {
@@ -727,7 +728,12 @@ static void _dpu_crtc_setup_lm_bounds(struct drm_crtc *crtc,
               r->y2 = adj_mode->vdisplay;

               trace_dpu_crtc_setup_lm_bounds(DRMID(crtc), i, r);
+
+             if (drm_rect_width(r) > dpu_kms->catalog->caps->max_mixer_width)
+                     return -E2BIG;
       }

+
+     return 0;
   }

   static void _dpu_crtc_get_pcc_coeff(struct drm_crtc_state *state,
@@ -1195,8 +1201,11 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
       if (crtc_state->active_changed)
               crtc_state->mode_changed = true;

-     if (cstate->num_mixers)
-             _dpu_crtc_setup_lm_bounds(crtc, crtc_state);
+     if (cstate->num_mixers) {
+             rc = _dpu_crtc_setup_lm_bounds(crtc, crtc_state);
+             if (rc)
+                     return rc;
+     }

       /* FIXME: move this to dpu_plane_atomic_check? */
       drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {








[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux