linux/drivers/gpu/drm/amd/display/dc
Leo Li 48ab86360a drm/amd/display: check GRPH_FLIP status before sending event
[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 1159898a88 ("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: 9b47278cec ("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@kernel.org>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Leo Li <sunpeng.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit f64a9be565)
Cc: stable@vger.kernel.org # 8382cd234981: drm/amd/display: consolidate DCN vblank/flip handling onto vupdate_no_lock
Cc: stable@vger.kernel.org
2026-07-17 17:42:18 -04:00
..
basics drm/amd/display: Use krealloc_array() in dal_vector_reserve() 2026-06-03 13:35:57 -04:00
bios drm/amd/display: Add support for FRL to DC core 2026-06-03 13:44:46 -04:00
clk_mgr drm/amd/display: Restore periodic detection for DCN35 2026-06-17 18:10:31 -04:00
core drm/amd/display: check GRPH_FLIP status before sending event 2026-07-17 17:42:18 -04:00
dccg drm/amd/display: Remove DCCG registers not needed in DCN42 2026-07-01 12:58:41 -04:00
dce drm/amd/display: fix __udivdi3 link error 2026-07-17 17:39:36 -04:00
dce60 drm/amd/display/dc: reclassify DCE6 resources and hw sequencer 2025-04-08 16:48:14 -04:00
dce80 drm/amd/display: Fix implicit narrowing conversion warnings 2026-04-17 15:41:15 -04:00
dce110 drm/amd/display: add missing CSC entries for BT.2020 for DCE IPs 2026-06-03 13:31:32 -04:00
dce112 drm/amd/display: Fixed Silence complier warnings in dc 2026-03-30 15:12:15 -04:00
dce120 drm/amd/display: Fixed Silence complier warnings in dc 2026-03-30 15:12:15 -04:00
dcn10 drm/amd/display: Fix type mismatches using guards and explicit casts 2026-05-05 09:56:52 -04:00
dcn20 drm/amd/display: Fix type mismatches using guards and explicit casts 2026-05-05 09:56:52 -04:00
dcn21 drm/amd/display: Fix warnings 2026-05-11 16:10:34 -04:00
dcn30 drm/amd/display: Fix type mismatches using guards and explicit casts 2026-05-05 09:56:52 -04:00
dcn31 drm/amd/display: Add DCN42B code to DC 2026-06-03 13:44:02 -04:00
dcn201 drm/amd/display: refactor HPD to increase flexibility 2025-12-08 13:56:40 -05:00
dcn301 drm/amd/display: Refactor for dio 2024-07-27 17:31:26 -04:00
dio drm/amd/display: Add DCCG DIO, HPO, OPP, and OPTC support for FRL 2026-06-03 13:44:31 -04:00
dml drm/amd/display: use unsigned types for local pipe and REG_GET counters 2026-06-04 15:24:45 -04:00
dml2_0 drm/amd/display: Add DCN42B to dml21_translation_helper 2026-06-04 15:24:17 -04:00
dpp drm/amd/display: Check for sharpening case when calculating max vtaps for scaler 2026-06-03 13:32:02 -04:00
dsc drm/amd/display: add HDMI 2.1 DSC over FRL support 2026-06-03 13:44:59 -04:00
dwb drm/amd/display: Fixed Silence complier warnings in dc 2026-03-30 15:12:15 -04:00
gpio drm/amd/display: Add DCN42B code to DC 2026-06-03 13:44:02 -04:00
hdcp drm/amd/display: Add FRL support to clk_mgr, dsc, hdcp 2026-06-03 13:44:35 -04:00
hpo drm/amd/display: use unsigned types for local pipe and REG_GET counters 2026-06-04 15:24:45 -04:00
hubbub drm/amd/display: Add DCN42B code to DC 2026-06-03 13:44:02 -04:00
hubp drm/amd/display: Add DCN42B code to DC 2026-06-03 13:44:02 -04:00
hwss drm/amd/display: add HDMI 2.1 DSC over FRL support 2026-06-03 13:44:59 -04:00
inc drm/amd/display: add HDMI 2.1 DSC over FRL support 2026-06-03 13:44:59 -04:00
irq drm/amd/display: Fix narrowing boundaries and eDP parser assignment 2026-04-17 15:41:16 -04:00
link drm/amd/display: Add dp_skip_rbr flag for NUTMEG 2026-07-17 17:37:28 -04:00
mmhubbub drm/amd/display: Fix implicit narrowing conversion warnings 2026-04-17 15:41:15 -04:00
mpc drm/amd/display: Fix warnings 2026-05-11 16:10:34 -04:00
opp drm/amd/display: Add DCCG DIO, HPO, OPP, and OPTC support for FRL 2026-06-03 13:44:31 -04:00
optc drm/amd/display: add HDMI 2.1 DSC over FRL support 2026-06-03 13:44:59 -04:00
pg drm/amd/display: Add DCN42B code to DC 2026-06-03 13:44:02 -04:00
resource drm/amd/display: wire DCN42B mcache programming callback 2026-07-17 17:41:33 -04:00
soc_and_ip_translator drm/amd/display: Add DCN42B code to DC 2026-06-03 13:44:02 -04:00
sspl drm/amd/display: Add static keyword for sharpness tables 2026-02-18 10:42:30 -05:00
dc_bios_types.h drm/amd/display: Add no_native_i2c codepath 2026-06-03 13:43:29 -04:00
dc_ddc_types.h
dc_dmub_srv.c drm/amd/display: Fix multiple compiler warnings 2026-05-11 16:10:30 -04:00
dc_dmub_srv.h drm/amd/display: Update tmz field for LSDMA 2026-05-05 09:56:53 -04:00
dc_dp_types.h drm/amd/display: Fix out-of-bounds read in dp_get_eq_aux_rd_interval() 2026-06-03 13:32:08 -04:00
dc_dsc.h drm/amd/display: add HDMI 2.1 DSC over FRL support 2026-06-03 13:44:59 -04:00
dc_edid_parser.c
dc_edid_parser.h
dc_fused_io.c drm/amd/display: Add no_native_i2c codepath 2026-06-03 13:43:29 -04:00
dc_fused_io.h drm/amd/display: HDCP Locality check using DMUB Fused IO 2025-04-07 18:01:07 -04:00
dc_hdmi_types.h drm/amd/display: widen dc_hdmi_frl_flags.force_frl_rate to unsigned int 2026-06-04 15:24:42 -04:00
dc_helper.c drm/amd/display: Add DCN42B code to DC 2026-06-03 13:44:02 -04:00
dc_hw_types.h drm/amd/display: Add HDMI FRL definitions to includes 2026-06-03 13:44:21 -04:00
dc_plane_priv.h drm/amd/display: Add driver support for future FAMS versions 2024-04-09 22:15:26 -04:00
dc_plane.h drm/amd/display: Sync dcn42 with DC 3.2.373 2026-03-11 13:58:07 -04:00
dc_spl_translate.c drm/amd/display: Add DCN42B code to DC 2026-06-03 13:44:02 -04:00
dc_spl_translate.h drm/amd/display: add back quality EASF and ISHARP and dc dependency changes 2024-08-27 17:53:58 -04:00
dc_stat.h
dc_state_priv.h drm/amd/display: Refactor SubVP cursor limiting logic 2025-05-05 12:58:49 -04:00
dc_state.h drm/amd/display: Eliminate recursive header inclusion 2024-10-01 17:37:50 -04:00
dc_stream_priv.h drm/amd/display: Find max flickerless instant vtotal delta 2024-05-13 15:47:53 -04:00
dc_stream.h drm/amd/display: Revert "Unify fast update classification paths" 2026-05-11 16:11:32 -04:00
dc_trace.h drm/amd/display: Clean up unused code 2026-03-11 13:58:06 -04:00
dc_types.h drm/amd/display: Add HDMI FRL definitions to includes 2026-06-03 13:44:21 -04:00
dc.h drm/amd/display: check GRPH_FLIP status before sending event 2026-07-17 17:42:18 -04:00
dm_cp_psp.h drm/amd/display: Add HDMI FRL definitions to includes 2026-06-03 13:44:21 -04:00
dm_event_log.h
dm_helpers.h drm/amd/display: Fix enum decl warnings 2026-05-11 16:11:03 -04:00
dm_pp_smu.h drm/amd/display: Add missing SMU version 2024-04-30 09:52:08 -04:00
dm_services_types.h drm/amd/display: Add HDMI FRL definitions to includes 2026-06-03 13:44:21 -04:00
dm_services.h drm/amd/display: Remove min/max clock levels from clk_mgr (v2) 2026-05-27 10:40:53 -04:00
irq_types.h drm/amd/display: Implement HDMI Read Request 2025-04-21 11:27:25 -04:00
Makefile drm/amd/display: Refactor virtual directory reorganize encoder and hwss files. 2026-02-12 15:08:49 -05:00
os_types.h drm/amd/display: Permit DC_FP_START/END only in non-FP compilation units 2025-12-08 13:56:37 -05:00