[SRU][R][PATCH 1/1] drm/amd/display: check GRPH_FLIP status before sending event
Andrei Gherzan
andrei.gherzan at canonical.com
Tue Sep 8 09:51:39 UTC 2026
On 26/09/08 03:57PM, Aaron Ma via kernel-team wrote:
> From: Leo Li <sunpeng.li at amd.com>
>
> BugLink: https://bugs.launchpad.net/bugs/2166730
>
> [Why]
>
> After unifying DCN interrupt sources under VUPDATE_NO_LOCK, we have two
> remaining issues to clean up:
>
> 1. On DCN, flip completion is now delivered from VUPDATE_NO_LOCK
> (dm_crtc_high_irq_handler) instead of GRPH_PFLIP. But VUPDATE_NO_LOCK
> fires every frame, regardless of whether a flip has latched.
>
> 2. There is a window during commit where a flip is armed (pflip_status =
> SUBMITTED) but not yet programmed into HW. If the VUPDATE_NO_LOCK
> fires in that window, its handler would deliver a flip event to
> userspace before HW has latched to it. If userspace then renders to
> what it believes is now the back buffer (but HW is still latched to
> it!), it will cause display corruption. This issue seemed to have
> been introduced by:
> commit 1159898a88db ("drm/amd/display: Handle commit plane with no FB.")
> Enabling replay or psr extended the duration of this window, and
> hence made corruption more likely to be observed.
>
> [How]
>
> * Move acrtc->event/pflip_status arming to after
> update_planes_and_stream_adapter() has programmed the flip into HW.
> This closes the window where pflip_status is SUBMITTED but the flip is
> not yet programmed.
>
> * Add dc_get_flip_pending_on_otg(), which reads the HUBP flip-pending
> status straight from HW for the pipe(s) bound to an OTG instance. It
> is keyed only by otg_inst and does not take or mutate a
> dc_plane_state, so it is safe to call from the OTG interrupt handler
> without racing a concurrent commit that may be modifying plane state.
>
> * Optimistically query for flip-pending after programming, in the event
> that HW latched to the new fb between programming start and arming
> event. If it latched, send the vblank event immediately, rather than
> wait for the next vblank IRQ.
>
> * In the VUPDATE_NO_LOCK handler, only deliver flip completion once
> dc_get_flip_pending_on_otg() reports the flip is no longer pending.
> Otherwise leave the flip armed and retry on the next vupdate.
>
> * For DCE, maintain the existing behavior of arming flips before
> programming, and relying on GRPH_FLIP to fire at HW latch.
>
> v2:
> * Drop flip_programmed completion object, instead move
> event/pflip_status arming after programming.
> * For DCN, optimistically query for flip pending immediately after
> programming, and if it latched, send event right away.
>
> v3:
> * Fix event timestamps on optimistic flip latch detection, where it's
> possible for it to run *before* the vupdate IRQ updates the timestamp.
> * Add more docstrings for DCN vblank handling.
> * Clean up if conditions in dm_arm_vblank_event().
> * Code style cleanup on braces surrounding multi-line statements.
>
> Fixes: 9b47278cec98 ("drm/amd/display: temp w/a for dGPU to enter idle optimizations")
> Link: https://gitlab.freedesktop.org/drm/amd/-/work_items/3787
> Link: https://gitlab.freedesktop.org/drm/amd/-/work_items/4141
> Assisted-by: Copilot:claude-opus-4.8
> Tested-by: Mario Limonciello (AMD) <superm1 at kernel.org>
> Reviewed-by: Mario Limonciello (AMD) <superm1 at kernel.org>
> Signed-off-by: Leo Li <sunpeng.li at amd.com>
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> (cherry picked from commit f64a9be5653689ff43e148cd8a6483077488c8e5)
> Cc: stable at vger.kernel.org # 8382cd234981: drm/amd/display: consolidate DCN vblank/flip handling onto vupdate_no_lock
> Cc: stable at vger.kernel.org
> (backported from commit 48ab86360af117123eb1b15e38f068acf3826400)
Thanks for this.
It looks to me that there is a follow-up commit that fixes backported commit:
8419331e64d9 "Exit idle optimizations before programming"
This should be checked/pulled in unless you have a specific reason to
defer it. In which case we should state that in the cover letter.
Cheers,
--
Andrei Gherzan
gpg: rsa4096/D4D94F67AD0E9640
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20260908/43589ae5/attachment-0001.sig>
More information about the kernel-team
mailing list