drm/amd/display: complete cursor vblank events immediately
Subsystems (3)
PATCH 1/1 drm/amd/display: complete cursor vblank events immediately
Intermittent flip_done timeouts have been observed on AMD GPUs since kernel 6.12.
Analysis with bpftrace reveals that amdgpu_dm_crtc_handle_vblank() can incorrectly consume events meant for plane flips during cursor-only updates. This happens because cursor commits defer event delivery to the vblank handler, which checks (pflip_status != SUBMITTED). Since AMDGPU_FLIP_NONE also matches this, cursor events can "steal" the event slot for subsequent plane flips, leading to timeouts.
The potential for a race was present since commit 473683a03495 ("drm/amd/display: Create a file dedicated for CRTC"), then commit 58a261bfc967 ("drm/amd/display: use a more lax vblank enable policy for older ASICs") made it happen by reducing vblank off-delay and making disables happen much more frequently between commits.
Fix this by sending cursor-only vblank events immediately in amdgpu_dm_commit_planes(). Since cursor updates are committed to hardware immediately, deferring the event is unnecessary and creates race windows for event stealing or starvation if vblank is disabled before the handler runs.
Tested on DCN 2.1, 3.2, and 3.5.
---
I've been chasing intermittent flip_done timeouts on AMD GPUs (7900 GRE first, 9070 XT now) since kernel 6.12. The hang occurs during normal desktop usage but is much easier to trigger under specific conditions involving cursor movements and plane updates.
Partially tracked in https://gitlab.freedesktop.org/drm/amd/-/issues/3787
Hardware: Ryzen 7 7800X3D, Radeon RX 9070 XT
Dual DP monitors, 2560x1440, 144Hz
Desktop: KDE Plasma Wayland
The hang was initially observed while using Cisco Webex (XDG_SESSION_TYPE=x11 /opt/Webex/bin/CiscoCollabHost %U), start a meeting and screen share a window running Omnissa Horizon client. Then move the cursor around between the two monitors and the shared window.
Under these conditions the hang usually occurs within a few hours.
Enabling drm.debug masks the issue entirely, the overhead
changes timing enough to close the race window.
So i added debug printks to amdgpu_dm.c and used a small bpftrace script to log the pageflip lifecycle with per-thread tracking to debug.
bpftrace script:
config = { missing_probes = "warn" }
BEGIN { printf("=== flip_done tracer started ===\n"); }
kprobe:drm_crtc_vblank_on_config { printf("%lu drm_crtc_vblank_on_config\n", nsecs/1000000); }
kprobe:drm_vblank_disable_and_save { printf("%lu drm_vblank_disable_and_save\n", nsecs/1000000); }
kprobe:dm_pflip_high_irq { printf("%lu dm_pflip_high_irq\n", nsecs/1000000); }
kprobe:drm_crtc_send_vblank_event { printf("%lu drm_crtc_send_vblank_event\n", nsecs/1000000); }
kprobe:drm_vblank_put { printf("%lu drm_vblank_put\n", nsecs/1000000); }
kprobe:drm_atomic_helper_commit_hw_done { printf("%lu drm_atomic_helper_commit_hw_done\n", nsecs/1000000); }
kprobe:manage_dm_interrupts { printf("%lu manage_dm_interrupts\n", nsecs/1000000); }
kprobe:drm_atomic_helper_wait_for_flip_done {
@wait_start[tid] = nsecs;
printf("%lu drm_atomic_helper_wait_for_flip_done ENTER [tid=%d]\n", nsecs/1000000, tid);
}
kretprobe:drm_atomic_helper_wait_for_flip_done {
$start = @wait_start[tid];
$ms = $start > 0 ? (nsecs - $start) / 1000000 : 0;
if ($ms > 100) {
printf("%lu drm_atomic_helper_wait_for_flip_done TIMEOUT waited %lums [tid=%d]\n",
nsecs/1000000, $ms, tid);
} else {
printf("%lu drm_atomic_helper_wait_for_flip_done EXIT %lums [tid=%d]\n",
nsecs/1000000, $ms, tid);
}
delete(@wait_start[tid]);
}
interval:s:60 { printf("%lu HEARTBEAT\n", nsecs/1000000); }
END { printf("=== stopped ===\n"); clear(@wait_start); }The timeout was captured at 17:35:41 CET. The trace timestamps match dmesg exactly (9942110ms = dmesg 9942.110s).
dmesg output from the timeout:
[ 9942.110360] [FLIP_DEBUG] wait_for_flip_done took 10329ms!
[ 9942.110380] [FLIP_DEBUG] crtc:0 pflip_status=0 event=00000000a0636a23
vbl_enabled=1 vbl_refcount=1 vbl_count=1428659
disable_immediate=0 active_planes=1pflip_status=0 (AMDGPU_FLIP_NONE) but event is still non-NULL. The flip was never completed but the status was already reset to NONE. vblank was enabled, refcount was held, so vblank IRQs were firing throughout the wait.
The bpftrace captured the exact sequence leading up to the hang. Here's the critical timeline at ~17:35:31 (9931771), about 10 seconds before the timeout fired:
9931755 drm_atomic_helper_commit_hw_done
9931755 drm_atomic_helper_wait_for_flip_done ENTER [tid=35929]
9931756 dm_pflip_high_irq <- normal plane flip, last good one
9931756 drm_crtc_send_vblank_event
9931756 drm_vblank_put
9931756 drm_atomic_helper_wait_for_flip_done EXIT 1ms [tid=35929]
9931771 drm_vblank_disable_and_save <- vblank timer fires
9931771 drm_crtc_send_vblank_event <- event sent WITHOUT dm_pflip_high_irq
9931771 drm_vblank_put
9931771 drm_atomic_helper_commit_hw_done
9931771 drm_atomic_helper_wait_for_flip_done ENTER [tid=35929]
9931771 drm_atomic_helper_wait_for_flip_done EXIT 0ms [tid=35929] <- instant, already done 9931773 drm_atomic_helper_commit_hw_done
9931773 drm_atomic_helper_wait_for_flip_done ENTER [tid=36929] <- new commit
9931777 dm_pflip_high_irq <- pflip fires, completes the wrong one
9931777 drm_crtc_send_vblank_event
9931777 drm_vblank_put
9931777 drm_atomic_helper_wait_for_flip_done EXIT 3ms [tid=36929]
9931781 drm_atomic_helper_commit_hw_done
9931781 drm_atomic_helper_wait_for_flip_done ENTER [tid=36929] <- THIS ONE HANGS
... 10328ms of silence ...
9942110 drm_atomic_helper_wait_for_flip_done TIMEOUT waited 10328ms [tid=36929]
The drm_crtc_send_vblank_event at 9931771 fires without dm_pflip_high_irq. This is amdgpu_dm_crtc_handle_vblank() sending a cursor-only event. The problem is that the cursor-only commit path in amdgpu_dm_commit_planes() stores the event in acrtc->event and defers delivery to the vblank handler. This creates two race conditions:
- The vblank handler checks (pflip_status != SUBMITTED) which also matches NONE, so it can consume events meant for plane flips. The subsequent dm_pflip_high_irq finds no event, and the next commit hangs.
- If vblank is disabled by the off-delay timer before the handler runs, the PENDING cursor event is never delivered and the commit hangs.
The fix is to send cursor-only events immediately via drm_crtc_send_vblank_event() in amdgpu_dm_commit_planes() instead of deferring to the vblank handler. The cursor update is already committed to hardware at this point, so immediate delivery is correct. This eliminates both race conditions by removing cursor events from the deferred delivery path entirely:
- Plane flips: SUBMITTED -> dm_pflip_high_irq delivers (unchanged)
- Cursor updates: sent immediately in commit_planes (no deferral, no races)
From git history the check in amdgpu_dm_crtc_handle_vblank() has been like this since 473683a03495 ("drm/amd/display: Create a file dedicated for CRTC", 2022)
which moved this code from amdgpu_dm.c, but it was practically impossible to trigger because the default drm_vblank_offdelay was 5000ms.
Commit 58a261bfc967("drm/amd/display: use a more lax vblank enable policy for older ASICs") in 6.12 changed all ASICs to use drm_crtc_vblank_on_config() with a computed off-delay
of roughly 2 frames (~14ms at 144Hz).
This made drm_vblank_disable_and_save fire hundreds of times more often, turning
a theoretical race into reality. The bpftrace log is full of drm_vblank_disable_and_save events interleaved with the commit sequence.
This fix was tested on DCN 2.1 (4700U), DCN 3.2 (7600M XT), and DCN 3.5 (9070 XT). Under high-frequency glxgears + cursor jiggling test the patch successfully intercepted the race thousands of times without a single timeout.
Also running this on the main system without issues.
This instead https://lists.freedesktop.org/archives/amd-gfx/2026-February/138636.html was my previously rushed attempt to do something about this that is no longer needed.
Patch applies cleanly on top of tag v6.19.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -2
@@ -10168,8 +10168,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, }else if (cursor_update && acrtc_state->active_planes >0 ) {spin_lock_irqsave (&pcrtc->dev->event_lock, flags);if (acrtc_attach->base.state->event) { -drm_crtc_vblank_get (pcrtc); - acrtc_attach->event = acrtc_attach->base.state->event; +drm_crtc_send_vblank_event (pcrtc, acrtc_attach->base.state->event); acrtc_attach->base.state->event =NULL ; }spin_unlock_irqrestore (&pcrtc->dev->event_lock, flags);
Signature · 1 line
2.53.0
Quoted 156 lines · Michele Palazzi
Intermittent
flip_donetimeouts have been observed on AMD GPUs since kernel 6.12.Analysis with bpftrace reveals that
amdgpu_dm_crtc_handle_vblank()can incorrectly consume events meant for plane flips during cursor-only updates. This happens because cursor commits defer event delivery to the vblank handler, which checks (pflip_status!= SUBMITTED). SinceAMDGPU_FLIP_NONEalso matches this, cursor events can "steal" the event slot for subsequent plane flips, leading to timeouts.The potential for a race was present since commit
473683a03495("drm/amd/display: Create a file dedicated for CRTC"), then commit58a261bfc967("drm/amd/display: use a more lax vblank enable policy for older ASICs") made it happen by reducing vblank off-delay and making disables happen much more frequently between commits.Fix this by sending cursor-only vblank events immediately in
amdgpu_dm_commit_planes(). Since cursor updates are committed to hardware immediately, deferring the event is unnecessary and creates race windows for event stealing or starvation if vblank is disabled before the handler runs.Tested on DCN 2.1, 3.2, and 3.5.
Fixes 58a261bfc967 ("drm/amd/display: use a more lax vblank enable policy for older ASICs")Signed-off-by Michele Palazzi <[email protected]>---
I've been chasing intermittentflip_donetimeouts on AMD GPUs (7900 GRE first, 9070 XT now) since kernel 6.12. The hang occurs during normal desktop usage but is much easier to trigger under specific conditions involving cursor movements and plane updates.Partially tracked in https://gitlab.freedesktop.org/drm/amd/-/issues/3787
Hardware: Ryzen 7 7800X3D, Radeon RX 9070 XT
Dual DP monitors, 2560x1440, 144Hz
Desktop: KDE Plasma WaylandThe hang was initially observed while using Cisco Webex (XDG_SESSION_TYPE=x11
/opt/Webex/bin/CiscoCollabHost%U), start a meeting and screen share a window running Omnissa Horizon client. Then move the cursor around between the two monitors and the shared window.
Under these conditions the hang usually occurs within a few hours.Enabling drm.debug masks the issue entirely, the overhead
changes timing enough to close the race window.
So i added debug printks toamdgpu_dm.cand used a small bpftrace script to log the pageflip lifecycle with per-thread tracking to debug.bpftrace script:
config = { missing_probes = "warn" } BEGIN { printf("=== flip_done tracer started ===\n"); } kprobe:drm_crtc_vblank_on_config { printf("%lu drm_crtc_vblank_on_config\n", nsecs/1000000); } kprobe:drm_vblank_disable_and_save { printf("%lu drm_vblank_disable_and_save\n", nsecs/1000000); } kprobe:dm_pflip_high_irq { printf("%lu dm_pflip_high_irq\n", nsecs/1000000); } kprobe:drm_crtc_send_vblank_event { printf("%lu drm_crtc_send_vblank_event\n", nsecs/1000000); } kprobe:drm_vblank_put { printf("%lu drm_vblank_put\n", nsecs/1000000); } kprobe:drm_atomic_helper_commit_hw_done { printf("%lu drm_atomic_helper_commit_hw_done\n", nsecs/1000000); } kprobe:manage_dm_interrupts { printf("%lu manage_dm_interrupts\n", nsecs/1000000); } kprobe:drm_atomic_helper_wait_for_flip_done { @wait_start[tid] = nsecs; printf("%lu drm_atomic_helper_wait_for_flip_done ENTER [tid=%d]\n", nsecs/1000000, tid); } kretprobe:drm_atomic_helper_wait_for_flip_done { $start = @wait_start[tid]; $ms = $start > 0 ? (nsecs - $start) / 1000000 : 0; if ($ms > 100) { printf("%lu drm_atomic_helper_wait_for_flip_done TIMEOUT waited %lums [tid=%d]\n", nsecs/1000000, $ms, tid); } else { printf("%lu drm_atomic_helper_wait_for_flip_done EXIT %lums [tid=%d]\n", nsecs/1000000, $ms, tid); } delete(@wait_start[tid]); } interval:s:60 { printf("%lu HEARTBEAT\n", nsecs/1000000); } END { printf("=== stopped ===\n"); clear(@wait_start); }The timeout was captured at 17:35:41 CET. The trace timestamps match dmesg exactly (9942110ms = dmesg 9942.110s).
dmesg output from the timeout:
[ 9942.110360] [FLIP_DEBUG] wait_for_flip_done took 10329ms! [ 9942.110380] [FLIP_DEBUG] crtc:0 pflip_status=0 event=00000000a0636a23 vbl_enabled=1 vbl_refcount=1 vbl_count=1428659 disable_immediate=0 active_planes=1pflip_status=0 (
AMDGPU_FLIP_NONE) but event is still non-NULL. The flip was never completed but the status was already reset to NONE. vblank was enabled, refcount was held, so vblank IRQs were firing throughout the wait.The bpftrace captured the exact sequence leading up to the hang. Here's the critical timeline at ~17:35:31 (9931771), about 10 seconds before the timeout fired:
9931755
drm_atomic_helper_commit_hw_done
9931755drm_atomic_helper_wait_for_flip_doneENTER [tid=35929]
9931756dm_pflip_high_irq<- normal plane flip, last good one
9931756drm_crtc_send_vblank_event
9931756drm_vblank_put
9931756drm_atomic_helper_wait_for_flip_doneEXIT 1ms [tid=35929]
9931771drm_vblank_disable_and_save<- vblank timer fires
9931771drm_crtc_send_vblank_event<- event sent WITHOUTdm_pflip_high_irq
9931771drm_vblank_put
9931771drm_atomic_helper_commit_hw_done
9931771drm_atomic_helper_wait_for_flip_doneENTER [tid=35929]
9931771drm_atomic_helper_wait_for_flip_doneEXIT 0ms [tid=35929] <- instant, already done 9931773drm_atomic_helper_commit_hw_done
9931773drm_atomic_helper_wait_for_flip_doneENTER [tid=36929] <- new commit
9931777dm_pflip_high_irq<- pflip fires, completes the wrong one
9931777drm_crtc_send_vblank_event
9931777drm_vblank_put
9931777drm_atomic_helper_wait_for_flip_doneEXIT 3ms [tid=36929]
9931781drm_atomic_helper_commit_hw_done
9931781drm_atomic_helper_wait_for_flip_doneENTER [tid=36929] <- THIS ONE HANGS
... 10328ms of silence ...
9942110drm_atomic_helper_wait_for_flip_doneTIMEOUT waited 10328ms [tid=36929]The
drm_crtc_send_vblank_eventat 9931771 fires withoutdm_pflip_high_irq. This isamdgpu_dm_crtc_handle_vblank()sending a cursor-only event. The problem is that the cursor-only commit path inamdgpu_dm_commit_planes()stores the event inacrtc->eventand defers delivery to the vblank handler. This creates two race conditions:- The vblank handler checks (
pflip_status!= SUBMITTED) which also matches NONE, so it can consume events meant for plane flips. The subsequentdm_pflip_high_irqfinds no event, and the next commit hangs.- If vblank is disabled by the off-delay timer before the handler runs, the PENDING cursor event is never delivered and the commit hangs.
The fix is to send cursor-only events immediately via
drm_crtc_send_vblank_event()inamdgpu_dm_commit_planes()instead of deferring to the vblank handler. The cursor update is already committed to hardware at this point, so immediate delivery is correct. This eliminates both race conditions by removing cursor events from the deferred delivery path entirely:- Plane flips: SUBMITTED ->
dm_pflip_high_irqdelivers (unchanged)
- Cursor updates: sent immediately incommit_planes(no deferral, no races)From git history the check in
amdgpu_dm_crtc_handle_vblank()has been like this since473683a03495("drm/amd/display: Create a file dedicated for CRTC", 2022)
which moved this code fromamdgpu_dm.c, but it was practically impossible to trigger because the defaultdrm_vblank_offdelaywas 5000ms.
Commit 58a261bfc967("drm/amd/display: use a more lax vblank enable policy for older ASICs") in 6.12 changed all ASICs to usedrm_crtc_vblank_on_config()with a computed off-delay
of roughly 2 frames (~14ms at 144Hz).
This madedrm_vblank_disable_and_savefire hundreds of times more often, turning
a theoretical race into reality. The bpftrace log is full ofdrm_vblank_disable_and_saveevents interleaved with the commit sequence.This fix was tested on DCN 2.1 (4700U), DCN 3.2 (7600M XT), and DCN 3.5 (9070 XT). Under high-frequency glxgears + cursor jiggling test the patch successfully intercepted the race thousands of times without a single timeout.
Also running this on the main system without issues.
Quoted 4 lines
This instead https://lists.freedesktop.org/archives/amd-gfx/2026-February/138636.html was my previously rushed attempt to do something about this that is no longer needed.
Patch applies cleanly on top of tag v6.19.
Really nice debuging work, thanks for catching this!
Ideally, the cursor event should be delivered when hardware latches onto the new cursor info and starts scanning it out. The latching event fires an interrupt that should be handled by dm_crtc_high_irq().
dm_pflip_high_irq() handles an interrupt specifically for when hardware latches onto a new fb address; I don't think it actually fires when there's a cursor-only update. I think if we really want to do it right, we can have another "acrtc_attach->cursor_event" just for cusror-only updates, and deliver the event in crtc_high_irq().
In any case, I don't foresee any major issues with delivering the event early. And since it fixes an ongoing issue:
Thanks!
Leo
Quoted 18 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-2@@ -10168,8 +10168,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, }else if (cursor_update && acrtc_state->active_planes >0 ) {spin_lock_irqsave (&pcrtc->dev->event_lock, flags);if (acrtc_attach->base.state->event) { -drm_crtc_vblank_get (pcrtc); - acrtc_attach->event = acrtc_attach->base.state->event; +drm_crtc_send_vblank_event (pcrtc, acrtc_attach->base.state->event); acrtc_attach->base.state->event =NULL ; }spin_unlock_irqrestore (&pcrtc->dev->event_lock, flags);
Quoted 13 lines · Leo Li
Really nice debuging work, thanks for catching this!
Ideally, the cursor event should be delivered when hardware latches onto the new cursor info and starts scanning it out. The latching event fires an interrupt that should be handled by
dm_crtc_high_irq().
dm_pflip_high_irq()handles an interrupt specifically for when hardware latches onto a new fb address; I don't think it actually fires when there's a cursor-only update. I think if we really want to do it right, we can have another "acrtc_attach->cursor_event" just for cusror-only updates, and deliver the event incrtc_high_irq().
Quoted 7 lines
In any case, I don't foresee any major issues with delivering the event early. And since it fixes an ongoing issue:
Reviewed-by Leo Li <[email protected]>Thanks!
Leo
Thanks for the review. Further testing confirms that both this patch and increasing the dGPU vblank offdelay (from 2 frames to ~50 frames) independently eliminate the flip timeouts in my testing. Both work by reducing the frequency of vblank disable/re-enable cycles, basically either could be an interim fix.
Your deferred vblank enable/disable series https://lore.kernel.org/amd-gfx/[email protected]/T/#t looks like it could be the proper solution going forward instead (haven't tested it).
Quoted 17 lines · Michele Palazzi
Quoted 16 lines · Leo Li
Really nice debuging work, thanks for catching this!
Ideally, the cursor event should be delivered when hardware latches onto the new cursor info and starts scanning it out. The latching event fires an interrupt that should be handled by
dm_crtc_high_irq().
dm_pflip_high_irq()handles an interrupt specifically for when hardware latches onto a new fb address; I don't think it actually fires when there's a cursor-only update. I think if we really want to do it right, we can have another "acrtc_attach->cursor_event" just for cusror-only updates, and deliver the event incrtc_high_irq().In any case, I don't foresee any major issues with delivering the event early. And since it fixes an ongoing issue:
Quoted 9 lines
Quoted 4 lines
Reviewed-by Leo Li <[email protected]>Thanks!
LeoThanks for the review. Further testing confirms that both this patch and increasing the dGPU vblank offdelay (from 2 frames to ~50 frames) independently eliminate the flip timeouts in my testing. Both work by reducing the frequency of vblank disable/re-enable cycles, basically either could be an interim fix.
Your deferred vblank enable/disable series https://lore.kernel.org/amd- gfx/[email protected]/T/#t looks like it could be the proper solution going forward instead (haven't tested it).
fixed [email protected] cc
Quoted 177 lines · Leo Li
Quoted 156 lines · Michele Palazzi
Intermittent
flip_donetimeouts have been observed on AMD GPUs since kernel 6.12.Analysis with bpftrace reveals that
amdgpu_dm_crtc_handle_vblank()can incorrectly consume events meant for plane flips during cursor-only updates. This happens because cursor commits defer event delivery to the vblank handler, which checks (pflip_status!= SUBMITTED). SinceAMDGPU_FLIP_NONEalso matches this, cursor events can "steal" the event slot for subsequent plane flips, leading to timeouts.The potential for a race was present since commit
473683a03495("drm/amd/display: Create a file dedicated for CRTC"), then commit58a261bfc967("drm/amd/display: use a more lax vblank enable policy for older ASICs") made it happen by reducing vblank off-delay and making disables happen much more frequently between commits.Fix this by sending cursor-only vblank events immediately in
amdgpu_dm_commit_planes(). Since cursor updates are committed to hardware immediately, deferring the event is unnecessary and creates race windows for event stealing or starvation if vblank is disabled before the handler runs.Tested on DCN 2.1, 3.2, and 3.5.
Fixes 58a261bfc967 ("drm/amd/display: use a more lax vblank enable policy for older ASICs")Signed-off-by Michele Palazzi <[email protected]>---
I've been chasing intermittentflip_donetimeouts on AMD GPUs (7900 GRE first, 9070 XT now) since kernel 6.12. The hang occurs during normal desktop usage but is much easier to trigger under specific conditions involving cursor movements and plane updates.Partially tracked in https://gitlab.freedesktop.org/drm/amd/-/issues/3787
Hardware: Ryzen 7 7800X3D, Radeon RX 9070 XT
Dual DP monitors, 2560x1440, 144Hz
Desktop: KDE Plasma WaylandThe hang was initially observed while using Cisco Webex (XDG_SESSION_TYPE=x11
/opt/Webex/bin/CiscoCollabHost%U), start a meeting and screen share a window running Omnissa Horizon client. Then move the cursor around between the two monitors and the shared window.
Under these conditions the hang usually occurs within a few hours.Enabling drm.debug masks the issue entirely, the overhead
changes timing enough to close the race window.
So i added debug printks toamdgpu_dm.cand used a small bpftrace script to log the pageflip lifecycle with per-thread tracking to debug.bpftrace script:
config = { missing_probes = "warn" } BEGIN { printf("=== flip_done tracer started ===\n"); } kprobe:drm_crtc_vblank_on_config { printf("%lu drm_crtc_vblank_on_config\n", nsecs/1000000); } kprobe:drm_vblank_disable_and_save { printf("%lu drm_vblank_disable_and_save\n", nsecs/1000000); } kprobe:dm_pflip_high_irq { printf("%lu dm_pflip_high_irq\n", nsecs/1000000); } kprobe:drm_crtc_send_vblank_event { printf("%lu drm_crtc_send_vblank_event\n", nsecs/1000000); } kprobe:drm_vblank_put { printf("%lu drm_vblank_put\n", nsecs/1000000); } kprobe:drm_atomic_helper_commit_hw_done { printf("%lu drm_atomic_helper_commit_hw_done\n", nsecs/1000000); } kprobe:manage_dm_interrupts { printf("%lu manage_dm_interrupts\n", nsecs/1000000); } kprobe:drm_atomic_helper_wait_for_flip_done { @wait_start[tid] = nsecs; printf("%lu drm_atomic_helper_wait_for_flip_done ENTER [tid=%d]\n", nsecs/1000000, tid); } kretprobe:drm_atomic_helper_wait_for_flip_done { $start = @wait_start[tid]; $ms = $start > 0 ? (nsecs - $start) / 1000000 : 0; if ($ms > 100) { printf("%lu drm_atomic_helper_wait_for_flip_done TIMEOUT waited %lums [tid=%d]\n", nsecs/1000000, $ms, tid); } else { printf("%lu drm_atomic_helper_wait_for_flip_done EXIT %lums [tid=%d]\n", nsecs/1000000, $ms, tid); } delete(@wait_start[tid]); } interval:s:60 { printf("%lu HEARTBEAT\n", nsecs/1000000); } END { printf("=== stopped ===\n"); clear(@wait_start); }The timeout was captured at 17:35:41 CET. The trace timestamps match dmesg exactly (9942110ms = dmesg 9942.110s).
dmesg output from the timeout:
[ 9942.110360] [FLIP_DEBUG] wait_for_flip_done took 10329ms! [ 9942.110380] [FLIP_DEBUG] crtc:0 pflip_status=0 event=00000000a0636a23 vbl_enabled=1 vbl_refcount=1 vbl_count=1428659 disable_immediate=0 active_planes=1pflip_status=0 (
AMDGPU_FLIP_NONE) but event is still non-NULL. The flip was never completed but the status was already reset to NONE. vblank was enabled, refcount was held, so vblank IRQs were firing throughout the wait.The bpftrace captured the exact sequence leading up to the hang. Here's the critical timeline at ~17:35:31 (9931771), about 10 seconds before the timeout fired:
9931755
drm_atomic_helper_commit_hw_done
9931755drm_atomic_helper_wait_for_flip_doneENTER [tid=35929]
9931756dm_pflip_high_irq<- normal plane flip, last good one
9931756drm_crtc_send_vblank_event
9931756drm_vblank_put
9931756drm_atomic_helper_wait_for_flip_doneEXIT 1ms [tid=35929]
9931771drm_vblank_disable_and_save<- vblank timer fires
9931771drm_crtc_send_vblank_event<- event sent WITHOUTdm_pflip_high_irq
9931771drm_vblank_put
9931771drm_atomic_helper_commit_hw_done
9931771drm_atomic_helper_wait_for_flip_doneENTER [tid=35929]
9931771drm_atomic_helper_wait_for_flip_doneEXIT 0ms [tid=35929] <- instant, already done 9931773drm_atomic_helper_commit_hw_done
9931773drm_atomic_helper_wait_for_flip_doneENTER [tid=36929] <- new commit
9931777dm_pflip_high_irq<- pflip fires, completes the wrong one
9931777drm_crtc_send_vblank_event
9931777drm_vblank_put
9931777drm_atomic_helper_wait_for_flip_doneEXIT 3ms [tid=36929]
9931781drm_atomic_helper_commit_hw_done
9931781drm_atomic_helper_wait_for_flip_doneENTER [tid=36929] <- THIS ONE HANGS
... 10328ms of silence ...
9942110drm_atomic_helper_wait_for_flip_doneTIMEOUT waited 10328ms [tid=36929]The
drm_crtc_send_vblank_eventat 9931771 fires withoutdm_pflip_high_irq. This isamdgpu_dm_crtc_handle_vblank()sending a cursor-only event. The problem is that the cursor-only commit path inamdgpu_dm_commit_planes()stores the event inacrtc->eventand defers delivery to the vblank handler. This creates two race conditions:- The vblank handler checks (
pflip_status!= SUBMITTED) which also matches NONE, so it can consume events meant for plane flips. The subsequentdm_pflip_high_irqfinds no event, and the next commit hangs.- If vblank is disabled by the off-delay timer before the handler runs, the PENDING cursor event is never delivered and the commit hangs.
The fix is to send cursor-only events immediately via
drm_crtc_send_vblank_event()inamdgpu_dm_commit_planes()instead of deferring to the vblank handler. The cursor update is already committed to hardware at this point, so immediate delivery is correct. This eliminates both race conditions by removing cursor events from the deferred delivery path entirely:- Plane flips: SUBMITTED ->
dm_pflip_high_irqdelivers (unchanged)
- Cursor updates: sent immediately incommit_planes(no deferral, no races)From git history the check in
amdgpu_dm_crtc_handle_vblank()has been like this since473683a03495("drm/amd/display: Create a file dedicated for CRTC", 2022)
which moved this code fromamdgpu_dm.c, but it was practically impossible to trigger because the defaultdrm_vblank_offdelaywas 5000ms.
Commit 58a261bfc967("drm/amd/display: use a more lax vblank enable policy for older ASICs") in 6.12 changed all ASICs to usedrm_crtc_vblank_on_config()with a computed off-delay
of roughly 2 frames (~14ms at 144Hz).
This madedrm_vblank_disable_and_savefire hundreds of times more often, turning
a theoretical race into reality. The bpftrace log is full ofdrm_vblank_disable_and_saveevents interleaved with the commit sequence.This fix was tested on DCN 2.1 (4700U), DCN 3.2 (7600M XT), and DCN 3.5 (9070 XT). Under high-frequency glxgears + cursor jiggling test the patch successfully intercepted the race thousands of times without a single timeout.
Also running this on the main system without issues.Quoted 4 lines
This instead https://lists.freedesktop.org/archives/amd-gfx/2026-February/138636.html was my previously rushed attempt to do something about this that is no longer needed.
Patch applies cleanly on top of tag v6.19.
Really nice debuging work, thanks for catching this!
Ideally, the cursor event should be delivered when hardware latches onto the new cursor info and starts scanning it out. The latching event fires an interrupt that should be handled by
dm_crtc_high_irq().
dm_pflip_high_irq()handles an interrupt specifically for when hardware latches onto a new fb address; I don't think it actually fires when there's a cursor-only update. I think if we really want to do it right, we can have another "acrtc_attach->cursor_event" just for cusror-only updates, and deliver the event incrtc_high_irq().
Quoted 4 lines
In any case, I don't foresee any major issues with delivering the event early. And since it fixes an ongoing issue:
Reviewed-by Leo Li <[email protected]>
Leo, I assume you are planning to push this?
Alex
Quoted 23 lines
Thanks!
LeoQuoted 18 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-2@@ -10168,8 +10168,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, }else if (cursor_update && acrtc_state->active_planes >0 ) {spin_lock_irqsave (&pcrtc->dev->event_lock, flags);if (acrtc_attach->base.state->event) { -drm_crtc_vblank_get (pcrtc); - acrtc_attach->event = acrtc_attach->base.state->event; +drm_crtc_send_vblank_event (pcrtc, acrtc_attach->base.state->event); acrtc_attach->base.state->event =NULL ; }spin_unlock_irqrestore (&pcrtc->dev->event_lock, flags);
Quoted 5 lines · Leo Li
Ideally, the cursor event should be delivered when hardware latches onto the new cursor info and starts scanning it out. The latching event fires an interrupt that should be handled by
dm_crtc_high_irq().
Quoted 7 lines
dm_pflip_high_irq()handles an interrupt specifically for when hardware latches onto a new fb address; I don't think it actually fires when there's a cursor-only update. I think if we really want to do it right, we can have another "acrtc_attach->cursor_event" just for cusror-only updates, and deliver the event incrtc_high_irq().In any case, I don't foresee any major issues with delivering the event early.
If the event having wrong sequence & timestamp values isn't considered a "major issue", we might as well not bother and just put random values in there. ;)
Compositors actually make use of the timestamp for frame scheduling.
Signature · 2 lines
Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer https://redhat.com \ Libre software enthusiast
Leo Li
maintainerQuoted 20 lines · Michele Palazzi
Quoted 19 lines · Michele Palazzi
Quoted 18 lines · Leo Li
Really nice debuging work, thanks for catching this!
Ideally, the cursor event should be delivered when hardware latches onto the new cursor info and starts scanning it out. The latching event fires an interrupt that should be handled by
dm_crtc_high_irq().
dm_pflip_high_irq()handles an interrupt specifically for when hardware latches onto a new fb address; I don't think it actually fires when there's a cursor-only update. I think if we really want to do it right, we can have another "acrtc_attach->cursor_event" just for cusror-only updates, and deliver the event incrtc_high_irq().In any case, I don't foresee any major issues with delivering the event early. And since it fixes an ongoing issue:
Reviewed-by Leo Li <[email protected]>
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Thanks!
LeoThanks for the review. Further testing confirms that both this patch and increasing the dGPU vblank offdelay (from 2 frames to ~50 frames) independently eliminate the flip timeouts in my testing. Both work by reducing the frequency of vblank disable/re-enable cycles, basically either could be an interim fix.
Your deferred vblank enable/disable series https://lore.kernel.org/amd- gfx/[email protected]/T/#t looks like it could be the proper solution going forward instead (haven't tested it).
Looking at this a bit more, I'm not sure if we're understanding the trace correctly.
Let's first assume the cursor update is not an legacy_cursor_update: In both non-blocking and blocking atomic commits, there should be mechanisms in place that limits the number of in-flight atomic_commit_tail()s per crtc to 1 (see drm_atomic_helper_wait_for_dependencies()). IOW, After each independent cursor **or** fb update, there should be one flip_done completion from drm_crtc_send_vblank_event(), before the next update is allowed to continue. Since the event is "armed" as part of atomic_commit_tail(), and "completed" in either pflip_high_irq or crtc_high_irq, racing "arms" of acrtc->event should not be possible.
A combined cursor **and** flip update should use a single event and flip_done completion, since it's one atomic_commit_tail to update both.
Now if it is a legacy_cursor_update, DRM core first checks if the driver can commit it asynchronously, and set state->async_update=true if it can. If async_update==true, drm_atomic_helper_commit() skips setting up the event entirely. Otherwise, drm_atomic_helper_setup_commit() will check if legacy_cursor_update==true. If it is, it completes flip_done early *and* skips setting up the event. So either way, there's no event to send, nor flip_done to wait on.
But evidently in the trace, something awry is going on. Though I'm not sure if it's because of the race condition as described. It would be interesting to trace the events at the point that they're created, armed, then completed, and see if there's some mismatch going on.
Here's a patch that inserts a few trace events.
https://pastebin.com/dpLnVSbu
Could you try to reproduce the hang again while recording these trace events? Using trace-cmd (with stack trace enabled '-T'):
trace-cmd record -e amdgpu_dm_event_arm -e drm_vblank_dbg* -T trace-cmd report trace.dat
The timeout can be found by searching 'remaining_wait_ms=0'.
Regarding the deferred vblank patchset, if the issue is indeed racing writes of amdgpu_crtc->event, then I don't imagine that patchset would help. It's intended to solve a different race.
Thanks,
Leo
Quoted 2 lines
fixed [email protected] cc
Leo Li
maintainerQuoted 12 lines · Michel Dänzer
Quoted 11 lines · Leo Li
Ideally, the cursor event should be delivered when hardware latches onto the new cursor info and starts scanning it out. The latching event fires an interrupt that should be handled by
dm_crtc_high_irq().
dm_pflip_high_irq()handles an interrupt specifically for when hardware latches onto a new fb address; I don't think it actually fires when there's a cursor-only update. I think if we really want to do it right, we can have another "acrtc_attach->cursor_event" just for cusror-only updates, and deliver the event incrtc_high_irq().
Quoted 5 lines
Quoted 1 line
In any case, I don't foresee any major issues with delivering the event early.
If the event having wrong sequence & timestamp values isn't considered a "major issue", we might as well not bother and just put random values in there. ;)
Compositors actually make use of the timestamp for frame scheduling.
Yeah, point taken, I read the other thread too late :)
- Leo
Quoted 2 lines
Quoted 5 lines
Here's a patch that inserts a few trace events.
https://pastebin.com/dpLnVSbuCould you try to reproduce the hang again while recording these trace events? Using trace-cmd (with stack trace enabled '-T'):
I think Michele said that the timeout issue would be masked by drm.debug due to overhead?
Quoted 17 lines
trace-cmd record -e
amdgpu_dm_event_arm-e drm_vblank_dbg* -T trace-cmd report trace.datThe timeout can be found by searching 'remaining_wait_ms=0'.
Regarding the deferred vblank patchset, if the issue is indeed racing writes of
amdgpu_crtc->event, then I don't imagine that patchset would help. It's intended to solve a different race.Thanks,
LeoQuoted 2 lines
fixed [email protected] cc
Leo Li
maintainerQuoted 7 lines · Shengyu Qu
Quoted 5 lines
Here's a patch that inserts a few trace events.
https://pastebin.com/dpLnVSbuCould you try to reproduce the hang again while recording these trace events? Using trace-cmd (with stack trace enabled '-T'):
I think Michele said that the timeout issue would be masked by drm.debug due to overhead?
I'm hoping that enabling a few tracepoints would have much less overhead than enabling drm.debug. Depending on which debug flag, there can be a lot of dmesg output.
If tracepoints ends up masking the race condition, I wonder if there's a way for bpftrace to probe the lines where the tracepoints are inserted, and print out the event's pointer address. If so, that's a viable alternative.
- Leo
Quoted 19 lines
Quoted 18 lines
trace-cmd record -e
amdgpu_dm_event_arm-e drm_vblank_dbg* -T trace-cmd report trace.datThe timeout can be found by searching 'remaining_wait_ms=0'.
Regarding the deferred vblank patchset, if the issue is indeed racing writes of
amdgpu_crtc->event, then I don't imagine that patchset would help. It's intended to solve a different race.Thanks,
LeoQuoted 2 lines
fixed [email protected] cc
Quoted 15 lines · Leo Li
Quoted 7 lines · Shengyu Qu
Quoted 5 lines
Here's a patch that inserts a few trace events.
https://pastebin.com/dpLnVSbuCould you try to reproduce the hang again while recording these trace events? Using trace-cmd (with stack trace enabled '-T'):
I think Michele said that the timeout issue would be masked by drm.debug due to overhead?
I'm hoping that enabling a few tracepoints would have much less overhead than enabling drm.debug. Depending on which debug flag, there can be a lot of dmesg output.
Quoted 5 lines
If tracepoints ends up masking the race condition, I wonder if there's a way for bpftrace to probe the lines where the tracepoints are inserted, and print out the event's pointer address. If so, that's a viable alternative.
- Leo
So far i could not reproduce with your tracing patch applied, i could try to use bpftrace instead but it will take some time, i am quite busy these days.
Leo Li
maintainerQuoted 16 lines · Michele Palazzi
Quoted 15 lines · Leo Li
Quoted 7 lines · Shengyu Qu
Quoted 5 lines
Here's a patch that inserts a few trace events.
https://pastebin.com/dpLnVSbuCould you try to reproduce the hang again while recording these trace events? Using trace-cmd (with stack trace enabled '-T'):
I think Michele said that the timeout issue would be masked by drm.debug due to overhead?
I'm hoping that enabling a few tracepoints would have much less overhead than enabling drm.debug. Depending on which debug flag, there can be a lot of dmesg output.
Quoted 6 lines
Quoted 5 lines
If tracepoints ends up masking the race condition, I wonder if there's a way for bpftrace to probe the lines where the tracepoints are inserted, and print out the event's pointer address. If so, that's a viable alternative.
- Leo
So far i could not reproduce with your tracing patch applied, i could try to use bpftrace instead but it will take some time, i am quite busy these days.
Understood. If you haven't tried already, maybe dropping the stack trace (-T) flag is worth a shot.
- Leo
Leo Li
maintainerQuoted 3 lines · Leo Li
Quoted 1 line
So far i could not reproduce with your tracing patch applied, i could try to use bpftrace instead but it will take some time, i am quite busy these days.
Understood. If you haven't tried already, maybe dropping the stack trace (-T) flag is worth a shot.
- Leo
Hi Michele,
Since this issue is fairly widespread, and we're heading towards *a* fix, I sent a reworked version of this where we save cursor-only vblank events in a separate member in struct amdgpu_crtc, and deliver it in amdgpu_dm_crtc_handle_vblank():
https://lore.kernel.org/amd-gfx/[email protected]/
Let me know if you get a chance to try it out! I'll also add your Co-developed-by when merging -- I forgot to add it when sending it out.
- Leo
Quoted 14 lines · Leo Li
Quoted 3 lines · Leo Li
Quoted 1 line
So far i could not reproduce with your tracing patch applied, i could try to use bpftrace instead but it will take some time, i am quite busy these days.
Understood. If you haven't tried already, maybe dropping the stack trace (-T) flag is worth a shot.
- LeoHi Michele,
Since this issue is fairly widespread, and we're heading towards *a* fix, I sent a reworked version of this where we save cursor-only vblank events in a separate member in struct
amdgpu_crtc, and deliver it inamdgpu_dm_crtc_handle_vblank():
Quoted 6 lines
https://lore.kernel.org/amd-gfx/[email protected]/
Let me know if you get a chance to try it out! I'll also add your Co-developed-by when merging -- I forgot to add it when sending it out.
- Leo
Reproduced today with a minimal bpftrace active but prepare_flip_isr is inlined by the compiler so was unable to track the event ARM side (stil have to try the offset approach)
Trace around the timeout:
142642747 commit_hw_done [tid=778834] 142642747 WAIT_FLIP ENTER [tid=778834]
10279ms silence for tid=778834 on CRTC 0
CRTC 1 continues normally throughout
142653026 WAIT_FLIP TIMEOUT waited 10278ms [tid=778834]
No dm_pflip_high_irq or DELIVER for that specific commit. CRTC 1 kept flowing normally the entire time.
Your new patch is an approach i already tried, and in my previous testing i still had flip timeouts, so while i think separating the cursor events makes sense and is correct, the root cause could be different from what i initially assumed and sending the cursor events immediately was masking it by relieving pressure.
Quoted 2 lines · Michele Palazzi
Your new patch is an approach i already tried, and in my previous testing i still had flip timeouts, so while i think separating the cursor events makes sense and is correct, the root cause could be different from what i initially assumed and sending the cursor events immediately was masking it by relieving pressure.
Leo i finally reproduced with a bpftrace that tracks event ARM (flip vs cursor) and DELIVER using kprobe offsets into the inlined prepare_flip_isr.
The hung commit is a cursor-only update on CRTC 0:
31088420 dm_pflip_high_irq [tid=0]
31088420 DELIVER event=ffff8b519225c580 crtc=0 [tid=0]
31088420 WAIT_FLIP EXIT 2ms [tid=203071]
31088421 ARM flip event=ffff8b4f26184c00 acrtc=ffff8b4ed1ddd000 [tid=203071]
31088421 commit_hw_done [tid=203071]
31088421 WAIT_FLIP ENTER [tid=203071]
31088422 dm_pflip_high_irq [tid=0]
31088422 DELIVER event=ffff8b4f26184c00 crtc=1 [tid=0]
31088422 WAIT_FLIP EXIT 1ms [tid=203071]
31088425 ARM cursor event=ffff8b519225ce00 acrtc=ffff8b4ed1dde000 [tid=203071]
31088425 commit_hw_done [tid=203071]
31088425 WAIT_FLIP ENTER [tid=203071]
31088428 ARM flip event=ffff8b4f26184480 acrtc=ffff8b4ed1ddd000 [tid=208580]
31088428 commit_hw_done [tid=208580]
31088428 WAIT_FLIP ENTER [tid=208580]
31088429 dm_pflip_high_irq [tid=0]
31088429 DELIVER event=ffff8b4f26184480 crtc=1 [tid=0]
31088429 WAIT_FLIP EXIT 1ms [tid=208580]
...
10036ms silence for tid=203071
no dm_pflip_high_irq, no DELIVER, no drm_vblank_disable_and_save on CRTC 0
CRTC 1 continues normally throughout
...
31098462 WAIT_FLIP !!!TIMEOUT!!! waited 10036ms [tid=203071]
acrtc ffff8b4ed1dde000 = CRTC 0 (confirmed from ARM+DELIVER correlation) acrtc ffff8b4ed1ddd000 = CRTC 1
Event ffff8b519225ce00 was armed as cursor on CRTC 0 and never delivered. No dm_pflip_high_irq fired for CRTC 0 during the entire 10s wait, and vblank was not disabled (no drm_vblank_disable_and_save in that window). CRTC 1 kept flowing normally throughout.
The complete bpftrace is here https://pastebin.com/Xiju44Cy
Note that i did this on tag v6.19
Leo Li
maintainerQuoted 34 lines · Michele Palazzi
Quoted 2 lines · Michele Palazzi
Your new patch is an approach i already tried, and in my previous testing i still had flip timeouts, so while i think separating the cursor events makes sense and is correct, the root cause could be different from what i initially assumed and sending the cursor events immediately was masking it by relieving pressure.
Leo i finally reproduced with a bpftrace that tracks event ARM (flip vs cursor) and DELIVER using kprobe offsets into the inlined
prepare_flip_isr.The hung commit is a cursor-only update on CRTC 0:
31088420
dm_pflip_high_irq[tid=0]
31088420 DELIVER event=ffff8b519225c580 crtc=0 [tid=0]
31088420WAIT_FLIPEXIT 2ms [tid=203071]
31088421 ARM flip event=ffff8b4f26184c00 acrtc=ffff8b4ed1ddd000 [tid=203071]
31088421commit_hw_done[tid=203071]
31088421WAIT_FLIPENTER [tid=203071]
31088422dm_pflip_high_irq[tid=0]
31088422 DELIVER event=ffff8b4f26184c00 crtc=1 [tid=0]
31088422WAIT_FLIPEXIT 1ms [tid=203071]
31088425 ARM cursor event=ffff8b519225ce00 acrtc=ffff8b4ed1dde000 [tid=203071] 31088425commit_hw_done[tid=203071]
31088425WAIT_FLIPENTER [tid=203071]
31088428 ARM flip event=ffff8b4f26184480 acrtc=ffff8b4ed1ddd000 [tid=208580]
31088428commit_hw_done[tid=208580]
31088428WAIT_FLIPENTER [tid=208580]
31088429dm_pflip_high_irq[tid=0]
31088429 DELIVER event=ffff8b4f26184480 crtc=1 [tid=0]
31088429WAIT_FLIPEXIT 1ms [tid=208580]
...
10036ms silence for tid=203071
nodm_pflip_high_irq, no DELIVER, nodrm_vblank_disable_and_saveon CRTC 0 CRTC 1 continues normally throughout
...
31098462WAIT_FLIP!!!TIMEOUT!!! waited 10036ms [tid=203071]
acrtcffff8b4ed1dde000= CRTC 0 (confirmed from ARM+DELIVER correlation) acrtcffff8b4ed1ddd000= CRTC 1
Quoted 1 line
Event
ffff8b519225ce00was armed as cursor on CRTC 0 and never delivered. Nodm_pflip_high_irqfired for CRTC 0 during the entire 10s wait, and vblank was not disabled (nodrm_vblank_disable_and_savein that window). CRTC 1 kept flowing normally throughout.
Hi Michele, no dm_pflip_high_irq firing makes sense, since there's no new fb addresses being programmed on CRTC 0 due to the timeout.
Did you see any dm_crtc_high_irq() or dm_vupdate_high_irq() on crtc0 after the timeout? An easy way to check would be to enable DRM vblank debug once you hit the flip_done timeout. The drm_dbg_vbl prints will start outputting to dmesg:
echo 0x20 > /sys/module/drm/parameters/debug
I'm also curious what the acrtc->event and ->pflip_status end up being when the timeout is hit. This debug diff should dump that without masking the issue:
https://pastebin.com/u7hGR7L4
Thanks,
Leo
Quoted 5 lines
The complete bpftrace is here https://pastebin.com/Xiju44Cy
Note that i did this on tag v6.19
Quoted 8 lines · Leo Li
Hi Michele, no
dm_pflip_high_irqfiring makes sense, since there's no new fb addresses being programmed on CRTC 0 due to the timeout.Did you see any
dm_crtc_high_irq()ordm_vupdate_high_irq()on crtc0 after the timeout? An easy way to check would be to enable DRM vblank debug once you hit theflip_donetimeout. Thedrm_dbg_vblprints will start outputting to dmesg:
Quoted 8 lines
echo 0x20 > /sys/module/drm/parameters/debugI'm also curious what the
acrtc->eventand ->pflip_status end up being when the timeout is hit. This debug diff should dump that without masking the issue:
https://pastebin.com/u7hGR7L4Thanks,
Leo
Applied your debug diff on clean v6.19, reproduced with bpftrace running (dm_crtc_high_irq and dm_vupdate_high_irq probes added).
dmesg:
[drm] *ERROR* [CRTC:283:crtc-0] flip_done timed out [flip_done timeout] crtc-0 event 00000000baf6917e status 0 [flip_done timeout] crtc-1 event 0000000000000000 status 0 [flip_done timeout] crtc-2 event 0000000000000000 status 0 [flip_done timeout] crtc-3 event 0000000000000000 status 0
crtc-0 has a non-NULL event with pflip_status=0 (AMDGPU_FLIP_NONE).
Note: %p hashes the pointer so can't directly correlate with the bpftrace output.
bpftrace:
8301644 dm_pflip_high_irq [tid=0]
8301644 DELIVER event=ffff8b87186d5a80 crtc=0 [tid=0]
8301644 WAIT_FLIP EXIT 1ms [tid=36993]
8301649 ARM cursor event=ffff8b87186d5480 acrtc=ffff8b84958f7000 [tid=176]
8301649 commit_hw_done [tid=176]
8301649 WAIT_FLIP ENTER [tid=176]
...
10252ms, CRTC 1 continues normally
...8311902 WAIT_FLIP !!!TIMEOUT!!! waited 10252ms [tid=176] Between the ARM cursor at 8301649 and the TIMEOUT at 8311902:
692 dm_crtc_high_irq fired, all on CRTC 1 (zero DELIVER with crtc=0 in the window) 0 DELIVER for event ffff8b87186d5480
0 ARM or DELIVER referencing acrtc ffff8b84958f7000 (CRTC 0) drm_vblank_disable_and_save continued firing (on CRTC 1)
no dm_vupdate_high_irq fired at all during the entire trace
acrtc ffff8b84958f7000 = CRTC 0
If this is not enough i can retry to have the proper correlation using %px
Some test report: https://gitlab.freedesktop.org/drm/amd/-/issues/2950#note_3366575
Quoted 62 lines · Leo Li
Quoted 34 lines · Michele Palazzi
Quoted 2 lines · Michele Palazzi
Your new patch is an approach i already tried, and in my previous testing i still had flip timeouts, so while i think separating the cursor events makes sense and is correct, the root cause could be different from what i initially assumed and sending the cursor events immediately was masking it by relieving pressure.
Leo i finally reproduced with a bpftrace that tracks event ARM (flip vs cursor) and DELIVER using kprobe offsets into the inlined
prepare_flip_isr.The hung commit is a cursor-only update on CRTC 0:
31088420
dm_pflip_high_irq[tid=0]
31088420 DELIVER event=ffff8b519225c580 crtc=0 [tid=0]
31088420WAIT_FLIPEXIT 2ms [tid=203071]
31088421 ARM flip event=ffff8b4f26184c00 acrtc=ffff8b4ed1ddd000 [tid=203071]
31088421commit_hw_done[tid=203071]
31088421WAIT_FLIPENTER [tid=203071]
31088422dm_pflip_high_irq[tid=0]
31088422 DELIVER event=ffff8b4f26184c00 crtc=1 [tid=0]
31088422WAIT_FLIPEXIT 1ms [tid=203071]
31088425 ARM cursor event=ffff8b519225ce00 acrtc=ffff8b4ed1dde000 [tid=203071] 31088425commit_hw_done[tid=203071]
31088425WAIT_FLIPENTER [tid=203071]
31088428 ARM flip event=ffff8b4f26184480 acrtc=ffff8b4ed1ddd000 [tid=208580]
31088428commit_hw_done[tid=208580]
31088428WAIT_FLIPENTER [tid=208580]
31088429dm_pflip_high_irq[tid=0]
31088429 DELIVER event=ffff8b4f26184480 crtc=1 [tid=0]
31088429WAIT_FLIPEXIT 1ms [tid=208580]
...
10036ms silence for tid=203071
nodm_pflip_high_irq, no DELIVER, nodrm_vblank_disable_and_saveon CRTC 0 CRTC 1 continues normally throughout
...
31098462WAIT_FLIP!!!TIMEOUT!!! waited 10036ms [tid=203071]
acrtcffff8b4ed1dde000= CRTC 0 (confirmed from ARM+DELIVER correlation) acrtcffff8b4ed1ddd000= CRTC 1Quoted 1 line
Event
ffff8b519225ce00was armed as cursor on CRTC 0 and never delivered. Nodm_pflip_high_irqfired for CRTC 0 during the entire 10s wait, and vblank was not disabled (nodrm_vblank_disable_and_savein that window). CRTC 1 kept flowing normally throughout.Hi Michele, no
dm_pflip_high_irqfiring makes sense, since there's no new fb addresses being programmed on CRTC 0 due to the timeout.Did you see any
dm_crtc_high_irq()ordm_vupdate_high_irq()on crtc0 after the timeout? An easy way to check would be to enable DRM vblank debug once you hit theflip_donetimeout. Thedrm_dbg_vblprints will start outputting to dmesg:echo 0x20 > /sys/module/drm/parameters/debugI'm also curious what the
acrtc->eventand ->pflip_status end up being when the timeout is hit. This debug diff should dump that without masking the issue:
https://pastebin.com/u7hGR7L4Thanks,
LeoQuoted 5 lines
The complete bpftrace is here https://pastebin.com/Xiju44Cy
Note that i did this on tag v6.19
Leo Li
maintainerQuoted 27 lines · Michele Palazzi
Applied your debug diff on clean v6.19, reproduced with bpftrace running (dm_crtc_high_irq and dm_vupdate_high_irq probes added).
dmesg:
[drm] *ERROR* [CRTC:283:crtc-0] flip_done timed out [flip_done timeout] crtc-0 event 00000000baf6917e status 0 [flip_done timeout] crtc-1 event 0000000000000000 status 0 [flip_done timeout] crtc-2 event 0000000000000000 status 0 [flip_done timeout] crtc-3 event 0000000000000000 status 0
crtc-0 has a non-NULL event with pflip_status=0 (AMDGPU_FLIP_NONE).
Note: %p hashes the pointer so can't directly correlate with the bpftrace output.bpftrace:
8301644 dm_pflip_high_irq [tid=0]
8301644 DELIVER event=ffff8b87186d5a80 crtc=0 [tid=0]
8301644 WAIT_FLIP EXIT 1ms [tid=36993]
8301649 ARM cursor event=ffff8b87186d5480 acrtc=ffff8b84958f7000 [tid=176] 8301649 commit_hw_done [tid=176]
8301649 WAIT_FLIP ENTER [tid=176]
...
10252ms, CRTC 1 continues normally
...
8311902 WAIT_FLIP !!!TIMEOUT!!! waited 10252ms [tid=176] Between the ARM cursor at 8301649 and the TIMEOUT at 8311902:
Quoted 8 lines
692
dm_crtc_high_irqfired, all on CRTC 1 (zero DELIVER with crtc=0 in the window) 0 DELIVER for event ffff8b87186d5480
0 ARM or DELIVER referencing acrtc ffff8b84958f7000 (CRTC 0) drm_vblank_disable_and_save continued firing (on CRTC 1)
no dm_vupdate_high_irq fired at all during the entire trace
acrtc ffff8b84958f7000 = CRTC 0If this is not enough i can retry to have the proper correlation using %px
dm_crtc_high_irq() not firing on CRTC 0 is quite strange. It suggests either the interrupts were disabled (even though drm_vblank_disable_and_save() was not called), or the timing generator in HW hanged.
Could you dump the interrupt state registers once the timeout is hit? Using UMR:
# get the GPU instance for your 9070XT, it should be the one with "dcn401" under # "IP Blocks:" sudo umr -e
# Dump interrupt state, replacing --instance # with your 9070XT instance:
sudo umr --instance 1 -r '*.*.OTG_GLOBAL_SYNC_STATUS' -O bits
UMR is available on aur, building it is also straightforward:
https://aur.archlinux.org/packages/umr
https://gitlab.freedesktop.org/tomstdenis/umr
----
Another suspicion is that DGPU idle optimizations might hang the TG. If force- disabling it fixes the issue, then it would support that suspicion:
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -0
@@ -2096,6 +2096,10 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)/* Display Core create. */ adev->dm.dc =dc_create (&init_data); + adev->dm.dc->debug.disable_idle_power_optimizations = true; + adev->dm.dc->debug.force_disable_subvp = true; + adev->dm.dc->debug.fams2_config.bits.enable = false; +if (adev->dm.dc) {drm_info (adev_to_drm (adev),"Display Core v%s initialized on %s\n" ,DC_VER ,dce_version_to_string (adev->dm.dc->ctx->dce_version));
Thanks,
Leo
Quoted 11 lines · Leo Li
dm_crtc_high_irq()not firing on CRTC 0 is quite strange. It suggests either the interrupts were disabled (even thoughdrm_vblank_disable_and_save()was not called), or the timing generator in HW hanged.Could you dump the interrupt state registers once the timeout is hit? Using UMR:
# get the GPU instance for your 9070XT, it should be the one with "dcn401" under # "IP Blocks:" sudo umr -e
Quoted 7 lines
# Dump interrupt state, replacing --instance # with your 9070XT instance:
sudo umr --instance 1 -r '*.*.OTG_GLOBAL_SYNC_STATUS' -O bitsUMR is available on aur, building it is also straightforward:
https://aur.archlinux.org/packages/umr
https://gitlab.freedesktop.org/tomstdenis/umr
took me a while to get the umr output after the timeout (taken within 1 second from the flip timeout)
Quoted 21 lines · Michele Palazzi
Quoted 11 lines · Leo Li
dm_crtc_high_irq()not firing on CRTC 0 is quite strange. It suggests either the interrupts were disabled (even thoughdrm_vblank_disable_and_save()was not called), or the timing generator in HW hanged.Could you dump the interrupt state registers once the timeout is hit? Using UMR:
# get the GPU instance for your 9070XT, it should be the one with "dcn401" under # "IP Blocks:" sudo umr -eQuoted 7 lines
# Dump interrupt state, replacing --instance # with your 9070XT instance:
sudo umr --instance 1 -r '*.*.OTG_GLOBAL_SYNC_STATUS' -O bitsUMR is available on aur, building it is also straightforward:
https://aur.archlinux.org/packages/umr
https://gitlab.freedesktop.org/tomstdenis/umr
Quoted 5 lines
took me a while to get the umr output after the timeout (taken within 1 second from the flip timeout)
actually there were 3 dumps in rapid succession, here you have all 3 for completeness
16 mar 15.33 umr_dump_20260316_153356.txt https://pastebin.com/LvYrjw5y
16 mar 15.35 umr_dump_20260316_153540.txt https://pastebin.com/SmSvCXva
16 mar 15.35 umr_dump_20260316_153550.txt https://pastebin.com/BbsWbbTN
Leo Li
maintainerQuoted 11 lines · Michele Palazzi
Quoted 5 lines
took me a while to get the umr output after the timeout (taken within 1 second from the flip timeout)
actually there were 3 dumps in rapid succession, here you have all 3 for completeness
16 mar 15.33 umr_dump_20260316_153356.txt https://pastebin.com/LvYrjw5y
16 mar 15.35 umr_dump_20260316_153540.txt https://pastebin.com/SmSvCXva
16 mar 15.35 umr_dump_20260316_153550.txt https://pastebin.com/BbsWbbTN
Thanks for the dumps, looks like interrupts were disabled, which is surprising given drm_vblank_disable_and_save() was not called. OTG0 seems to be active as the FRAME_COUNT is incrementing.
Does force-enabling the VSTARTUP interrupt on OTG0 revive the hanging display once the timeout happens?
sudo umr --instance 1 -wb '*.dcn410.regOTG0_OTG_GLOBAL_SYNC_STATUS.VSTARTUP_INT_EN' 1
- Leo
Leo Li
maintainerQuoted 15 lines · Leo Li
Quoted 11 lines · Michele Palazzi
Quoted 5 lines
took me a while to get the umr output after the timeout (taken within 1 second from the flip timeout)
actually there were 3 dumps in rapid succession, here you have all 3 for completeness
16 mar 15.33 umr_dump_20260316_153356.txt https://pastebin.com/LvYrjw5y
16 mar 15.35 umr_dump_20260316_153540.txt https://pastebin.com/SmSvCXva
16 mar 15.35 umr_dump_20260316_153550.txt https://pastebin.com/BbsWbbTN
Quoted 6 lines
Thanks for the dumps, looks like interrupts were disabled, which is surprising given
drm_vblank_disable_and_save()was not called. OTG0 seems to be active as theFRAME_COUNTis incrementing.Does force-enabling the VSTARTUP interrupt on OTG0 revive the hanging display once the timeout happens?
Actually, if you manage to catch it and send the below umr command *before* the 10s timeout expires, that'd be even more telling.
- Leo
Quoted 4 lines
sudo umr --instance 1 -wb '*.dcn410.regOTG0_OTG_GLOBAL_SYNC_STATUS.VSTARTUP_INT_EN' 1
- Leo
Quoted 5 lines · Leo Li
Quoted 5 lines
Thanks for the dumps, looks like interrupts were disabled, which is surprising given
drm_vblank_disable_and_save()was not called. OTG0 seems to be active as theFRAME_COUNTis incrementing.
Quoted 12 lines
Quoted 2 lines
Does force-enabling the VSTARTUP interrupt on OTG0 revive the hanging display once the timeout happens?
Actually, if you manage to catch it and send the below umr command *before* the 10s timeout expires, that'd be even more telling.
- LeoQuoted 4 lines
sudo umr --instance 1 -wb '*.dcn410.regOTG0_OTG_GLOBAL_SYNC_STATUS.VSTARTUP_INT_EN' 1
- Leo
Ok i managed to do exactly that, before the timeout sent your umr command, frozen display did not recover (recovered only after unplugging/replugging the DP cable as always)
UMR output before/after force enable
https://pastebin.com/hhapxBev
Leo Li
maintainerQuoted 4 lines · Michele Palazzi
Ok i managed to do exactly that, before the timeout sent your umr command, frozen display did not recover (recovered only after unplugging/replugging the DP cable as always)
UMR output before/after force enable
https://pastebin.com/hhapxBev
Hmm, is the "before" captured after the display hangs, but before the flip_done timeout error in dmesg? And the "after" is captured after writing VSTARTUP_INT_EN=1, but also before flip_done timeout error in dmesg?
If so, it seems my previous idea that interrupts got disabled is wrong, since OTG0 has VSTARTUP enabled in "before".
Did you happen to try disabling some idle optimization features mentioned in a previous reply?
https://lore.kernel.org/amd-gfx/[email protected]/
Thanks,
Leo
Quoted 2 lines · Leo Li
Hmm, is the "before" captured after the display hangs, but before the
flip_donetimeout error in dmesg?
yes
Quoted 1 line
And the "after" is captured after writing VSTARTUP_INT_EN=1, but also before
flip_donetimeout error in dmesg?
also yes
basically i detected the timeout with bpftrace and got umr dump before/after setting VSTARTUP_INT_EN=1
Quoted 2 lines
Did you happen to try disabling some idle optimization features mentioned in a previous reply?
https://lore.kernel.org/amd-gfx/[email protected]/
only for a bit, need more time on it to properly assess
Quoted 5 lines · Leo Li
Quoted 3 lines
Did you happen to try disabling some idle optimization features mentioned in a previous reply?
https://lore.kernel.org/amd-gfx/1356e93b-af76-47f3- [email protected]/
Sorry for the delay i have been away due to business travel, anyway since resuming testing i can't seem to reproduce the timeout with idle optimization features disabled.
Hi Leo,
Could you merge this patch first and do more discovery into this bug later? Since this solve some problems for users.
Best regards,
Shengyu
Quoted 18 lines · Leo Li
Quoted 4 lines · Michele Palazzi
Ok i managed to do exactly that, before the timeout sent your umr command, frozen display did not recover (recovered only after unplugging/replugging the DP cable as always)
UMR output before/after force enable
https://pastebin.com/hhapxBevHmm, is the "before" captured after the display hangs, but before the
flip_donetimeout error in dmesg? And the "after" is captured after writing VSTARTUP_INT_EN=1, but also beforeflip_donetimeout error in dmesg?If so, it seems my previous idea that interrupts got disabled is wrong, since OTG0 has VSTARTUP enabled in "before".
Did you happen to try disabling some idle optimization features mentioned in a previous reply?
https://lore.kernel.org/amd-gfx/[email protected]/Thanks,
Leo
Leo Li
maintainerQuoted 7 lines · Shengyu Qu
Hi Leo,
Could you merge this patch first and do more discovery into this bug later? Since this solve some problems for users.
Best regards,
Shengyu
Hi Shengyu, Michele
I vaguely recall that restoring the old 5s vblank off delay helped alleviate this by allowing idle less frequently. That may be a better bandaid for now.
Let me know if the below patch helps, we'll merge it if it does.
Thanks,
Leo
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +15 -3
@@ -9511,9 +9511,21 @@ static void manage_dm_interrupts(struct amdgpu_device *adev,if (acrtc_state) { timing = &acrtc_state->stream->timing; -if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) < -IP_VERSION (3 ,5 ,0 ) || - !(adev->flags &AMD_IS_APU )) { +if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) >= +IP_VERSION (3 ,2 ,0 ) && + !(adev->flags &AMD_IS_APU )) { +/* +* DGPUs NV3x and newer that support idle optimizations +* experience intermittent flip-done timeouts on cursor +* updates. Restore 5s offdelay behavior for now. +* +* Discussion on the issue: +* https://lore.kernel.org/amd-gfx/[email protected]/ +*/ + config.offdelay_ms =5000 ; + config.disable_immediate = false; + }else if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) < +IP_VERSION (3 ,5 ,0 )) {/* * Older HW and DGPU have issues with instant off; * use a 2 frame offdelay.
Signature · 1 line
2.53.0
Michele Palazzi
Tested-byQuoted 29 lines · Leo Li
Hi Shengyu, Michele
I vaguely recall that restoring the old 5s vblank off delay helped alleviate this by allowing idle less frequently. That may be a better bandaid for now.
Let me know if the below patch helps, we'll merge it if it does.
Thanks,
Leo
---drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8
-3@@ -9511,9 +9511,21 @@ static void manage_dm_interrupts(struct amdgpu_device *adev,if (acrtc_state) { timing = &acrtc_state->stream->timing; -if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) < -IP_VERSION (3 ,5 ,0 ) || - !(adev->flags &AMD_IS_APU )) { +if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) >= +IP_VERSION (3 ,2 ,0 ) && + !(adev->flags &AMD_IS_APU )) { +/* +* DGPUs NV3x and newer that support idle optimizations +* experience intermittent flip-done timeouts on cursor +* updates. Restore 5s offdelay behavior for now. +*
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void manage_dm_interrupts(struct amdgpu_device *adev, · line 9531
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7
-0+* Discussion on the issue: +* https://lore.kernel.org/amd-gfx/[email protected]/ +*/ + config.offdelay_ms =5000 ; + config.disable_immediate = false; + }else if (amdgpu_ip_version (adev,DCE_HWIP ,0 ) < +IP_VERSION (3 ,5 ,0 )) {/* * Older HW and DGPU have issues with instant off; * use a 2 frame offdelay.
Hi Leo, Shengyu
Yes, this is effectively one of the possible workarounds I've already validated and tested earlier without incurring in any flip timeout.
You can safely add Tested-by if you want.
Leo Li
maintainerQuoted 8 lines · Michele Palazzi
Quoted 5 lines · Leo Li
Quoted 3 lines
Did you happen to try disabling some idle optimization features mentioned in a previous reply?
https://lore.kernel.org/amd-gfx/1356e93b-af76-47f3- [email protected]/Sorry for the delay i have been away due to business travel, anyway since resuming testing i can't seem to reproduce the timeout with idle optimization features disabled.
Hi Michel, Shengyu,
I sent out a potential fix here: https://lore.kernel.org/amd-gfx/[email protected]/T/#u
If you get a chance, can you give it a spin and let me know the results(*)? The issue remains elusive on my end.
(*) Of course, make sure the Restore 5s vbl offdelay change is not applied, and that no other debug patch/kernel cmdline are applied.
Thanks,
Leo
Quoted 11 lines · Leo Li
Hi Michel, Shengyu,
I sent out a potential fix here: https://lore.kernel.org/amd-gfx/[email protected]/T/#u
If you get a chance, can you give it a spin and let me know theresults(*)? The issue remains elusive on my end.(*) Of course, make sure the Restore 5s vbl offdelay change is not applied, and that no other debug patch/kernel cmdline are applied.
Thanks,
Leo
Hi Leo,
building it right now, will let you know how it goes.
Michele
Hi Leo,
Personally I can't reproduce this issue on my 7800XT PC. But I've reposted the new patch to some flip done timeout issues for other users to test. Will report if there's any result.
Best regards,
Shengyu
Quoted 22 lines · Leo Li
Quoted 8 lines · Michele Palazzi
Quoted 5 lines · Leo Li
Quoted 3 lines
Did you happen to try disabling some idle optimization features mentioned in a previous reply?
https://lore.kernel.org/amd-gfx/1356e93b-af76-47f3- [email protected]/Sorry for the delay i have been away due to business travel, anyway since resuming testing i can't seem to reproduce the timeout with idle optimization features disabled.
Hi Michel, Shengyu,
I sent out a potential fix here: https://lore.kernel.org/amd-gfx/[email protected]/T/#u
If you get a chance, can you give it a spin and let me know theresults(*)? The issue remains elusive on my end.(*) Of course, make sure the Restore 5s vbl offdelay change is not applied, and that no other debug patch/kernel cmdline are applied.
Thanks,
Leo
Leo Li
maintainerQuoted 9 lines · Michele Palazzi
Quoted 8 lines · Leo Li
Hi Michel, Shengyu,
I sent out a potential fix here: https://lore.kernel.org/amd-gfx/[email protected]/T/#u
If you get a chance, can you give it a spin and let me know theresults(*)? The issue remains elusive on my end.(*) Of course, make sure the Restore 5s vbl offdelay change is not applied, and that no other debug patch/kernel cmdline are applied.
Quoted 8 lines
Quoted 3 lines
Thanks,
LeoHi Leo,
building it right now, will let you know how it goes.Michele
In the event that you do hit the timeout again, would you give this branch a spin?
https://gitlab.freedesktop.org/leoli/linux-asdn/-/commits/lileo/flip_done_timeout
It contains this patch, plus some additional debug dumps on timeouts/dmub hangs. In the event you hit the timeout with this branch, please post the full dmesg.
Thanks,
Leo
Quoted 10 lines · Leo Li
In the event that you do hit the timeout again, would you give this branch a spin?
https://gitlab.freedesktop.org/leoli/linux-asdn/-/commits/lileo/flip_done_timeoutIt contains this patch, plus some additional debug dumps on timeouts/dmub hangs. In the event you hit the timeout with this branch, please post the full dmesg.
Thanks,
Leo
ok will do.
fwiw, running v7.0.3 + your vline2 patch alone (no 5s offdelay restore on top) since building it and no flip-done timeouts so far, but from past experience it's too early to call.
Michele