From a991f3bbb7518d2a0d920eff685ae0d7036709cb Mon Sep 17 00:00:00 2001 From: Nemesa Garg Date: Tue, 1 Sep 2026 12:58:12 +0530 Subject: [PATCH] drm/i915/cursor: Program secondary cursor planes Iterate over all joined pipes when arming/disabling the cursor plane so secondary pipes are updated together with the primary. The pin, check and state duplication for secondary pipes was already prepared in the previous commit; this converts the update_arm pass to a loop over the joined_pipe_state[] array. Because the whole loop runs inside a single primary vblank-evade, sample intel_crtc_get_vblank_counter() per pipe around each arm and emit a drm_err() if the counter ticks during that pipe's own programming. v2: Check primary and secondary pipe together. [Ville] v3: Use struct intel_cursor_joiner_state. [Ville] v4: Add per-pipe vblank straddle detection around the arm loop. [Chaitanya] v5: Move straddle check outside the loop to cover all pipes together. Sample vblank counter from primary pipe only. Move drm_err() after local_irq_enable(). [Chaitanya] Assisted-by: Claude:claude-sonnet-4.6 Signed-off-by: Nemesa Garg Reviewed-by: Chaitanya Kumar Borah Signed-off-by: Suraj Kandpal Link: https://patch.msgid.link/20260901072813.2596383-5-nemesa.garg@intel.com --- drivers/gpu/drm/i915/display/intel_cursor.c | 36 +++++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c b/drivers/gpu/drm/i915/display/intel_cursor.c index b4f0f70eaa1a..894bd1df5f42 100644 --- a/drivers/gpu/drm/i915/display/intel_cursor.c +++ b/drivers/gpu/drm/i915/display/intel_cursor.c @@ -13,6 +13,7 @@ #include #include "intel_atomic.h" +#include "intel_crtc.h" #include "intel_cursor.h" #include "intel_cursor_regs.h" #include "intel_de.h" @@ -904,6 +905,7 @@ intel_legacy_cursor_update(struct drm_plane *_plane, struct intel_cursor_joiner_state joined_pipe_state[I915_MAX_PIPES] = {}; struct intel_crtc *pipe_crtc; int num_pipes = 0; + u32 start_vbl_count, end_vbl_count; int ret; /* @@ -1049,17 +1051,37 @@ intel_legacy_cursor_update(struct drm_plane *_plane, local_irq_disable(); } - if (joined_pipe_state[0].new_plane_state->uapi.visible) { - intel_plane_update_noarm(NULL, plane, crtc_state, - joined_pipe_state[0].new_plane_state); - intel_plane_update_arm(NULL, plane, crtc_state, - joined_pipe_state[0].new_plane_state); - } else { - intel_plane_disable_arm(NULL, plane, crtc_state); + /* + * Joiner pipes are vblank-synchronized, so sampling only the primary + * pipe is sufficient to detect a straddle across all joined pipes. + * The vblank evasion above also operates on the primary pipe only. + */ + start_vbl_count = intel_crtc_get_vblank_counter(joined_pipe_state[0].crtc); + + for (int i = 0; i < num_pipes; i++) { + if (joined_pipe_state[i].new_plane_state->uapi.visible) { + intel_plane_update_noarm(NULL, joined_pipe_state[i].plane, + joined_pipe_state[i].crtc_state, + joined_pipe_state[i].new_plane_state); + intel_plane_update_arm(NULL, joined_pipe_state[i].plane, + joined_pipe_state[i].crtc_state, + joined_pipe_state[i].new_plane_state); + } else { + intel_plane_disable_arm(NULL, joined_pipe_state[i].plane, + joined_pipe_state[i].crtc_state); + } } + end_vbl_count = intel_crtc_get_vblank_counter(joined_pipe_state[0].crtc); + local_irq_enable(); + if (start_vbl_count != end_vbl_count) + drm_err(display->drm, + "Atomic update failure on pipe %c (start=%u end=%u)\n", + pipe_name(joined_pipe_state[0].crtc->pipe), + start_vbl_count, end_vbl_count); + intel_psr_unlock(crtc_state); /*