Currently we are aligning Selective Update area to cover cursor fully if
needed only once. It may happen that cursor is in Selective Update area
after pipe alignment and after that covering cursor plane only
partially. Fix this by looping alignment as long as alignment isn't needed
anymore.

Fixes: 1bff93b8bc27 ("drm/i915/psr: Extend SU area to cover cursor fully if 
needed")
Cc: <[email protected]> # v6.9+
Signed-off-by: Jouni Högander <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_psr.c | 32 ++++++++++++++++--------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_psr.c 
b/drivers/gpu/drm/i915/display/intel_psr.c
index 5bea2eda744b..331645a2c9f6 100644
--- a/drivers/gpu/drm/i915/display/intel_psr.c
+++ b/drivers/gpu/drm/i915/display/intel_psr.c
@@ -2688,11 +2688,12 @@ static void clip_area_update(struct drm_rect 
*overlap_damage_area,
                overlap_damage_area->y2 = damage_area->y2;
 }
 
-static void intel_psr2_sel_fetch_pipe_alignment(struct intel_crtc_state 
*crtc_state)
+static bool intel_psr2_sel_fetch_pipe_alignment(struct intel_crtc_state 
*crtc_state)
 {
        struct intel_display *display = to_intel_display(crtc_state);
        const struct drm_dsc_config *vdsc_cfg = &crtc_state->dsc.config;
        u16 y_alignment;
+       bool aligned = false;
 
        /* ADLP aligns the SU region to vdsc slice height in case dsc is 
enabled */
        if (crtc_state->dsc.compression_enable &&
@@ -2701,10 +2702,18 @@ static void intel_psr2_sel_fetch_pipe_alignment(struct 
intel_crtc_state *crtc_st
        else
                y_alignment = crtc_state->su_y_granularity;
 
-       crtc_state->psr2_su_area.y1 -= crtc_state->psr2_su_area.y1 % 
y_alignment;
-       if (crtc_state->psr2_su_area.y2 % y_alignment)
+       if (crtc_state->psr2_su_area.y1 % y_alignment) {
+               crtc_state->psr2_su_area.y1 -= crtc_state->psr2_su_area.y1 % 
y_alignment;
+               aligned = true;
+       }
+
+       if (crtc_state->psr2_su_area.y2 % y_alignment) {
                crtc_state->psr2_su_area.y2 = ((crtc_state->psr2_su_area.y2 /
                                                y_alignment) + 1) * y_alignment;
+               aligned = true;
+       }
+
+       return aligned;
 }
 
 /*
@@ -2945,15 +2954,16 @@ int intel_psr2_sel_fetch_update(struct 
intel_atomic_state *state,
        if (ret)
                return ret;
 
-       /*
-        * Adjust su area to cover cursor fully as necessary (early
-        * transport). This needs to be done after
-        * drm_atomic_add_affected_planes to ensure visible cursor is added into
-        * affected planes even when cursor is not updated by itself.
-        */
-       intel_psr2_sel_fetch_et_alignment(state, crtc, &cursor_in_su_area);
+       do {
+               /*
+                * Adjust su area to cover cursor fully as necessary (early
+                * transport). This needs to be done after
+                * drm_atomic_add_affected_planes to ensure visible cursor is 
added into
+                * affected planes even when cursor is not updated by itself.
+                */
+               intel_psr2_sel_fetch_et_alignment(state, crtc, 
&cursor_in_su_area);
 
-       intel_psr2_sel_fetch_pipe_alignment(crtc_state);
+       } while (intel_psr2_sel_fetch_pipe_alignment(crtc_state));
 
        /*
         * Now that we have the pipe damaged area check if it intersect with
-- 
2.43.0

Reply via email to