On Tue, Nov 10, 2026 at 3:47 AM Thomas Zimmermann <[email protected]> wrote: > > Busy-waiting in drm_crtc_vblank_start_timer() until a previous vblank > timer has completed can deadlock. Rework how the vblank timer's start > and cancel helpers interact with the timer function. > > Patch 1 fixes the possible deadlock by removing the busy-wait loop from > drm_crtc_vblank_start_timer(). To avoid possible interference between > _start_timer()'s hrtimer_start() and hrtimer_forward_now() in the timer > function, extend the interval_lock around both. Both, _start_timer() and > the timer function, can still overlap, but hrtimer initialization should > work reliably. At most, the first vblank event after changing the interval > might be off. > > Fix the possible overlap by canceling the vblank timer's internal hrtimer. > Do this outside of the vblank code's critical section after switching > the vblank timer off. With the hrtimer being canceled, the next vblank > event will be sent at the correct time. > > Tested with bochs on qemu. > > Additional notes: there have been reports about vblank timers not happening > in time, such as [1]. We suspected that might happen due to guest systems > running under high CPU load. But the problem could also be caused by the > deadlock fixed in patch 1. > > v2: > - handle uninitialized timer in drm_crtc_vblank_cancel_timer() > > [1] > https://lore.kernel.org/dri-devel/[email protected]/ > > Thomas Zimmermann (2): > drm/vblank: timer: Do not block within critical section > drm/vblank: Cancel vblank timer outside of critical section > > drivers/gpu/drm/drm_vblank.c | 90 ++++++++++++++++++---------- > drivers/gpu/drm/drm_vblank_helper.c | 16 +++++ > drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 3 +- > drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 2 + > drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 2 + > drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c | 2 +- > include/drm/drm_crtc.h | 9 +++ > include/drm/drm_vblank.h | 16 +++++ > include/drm/drm_vblank_helper.h | 2 + > 9 files changed, 108 insertions(+), 34 deletions(-) > > > base-commit: 7d502136b31169f6b5575f7f89c3da60cdf7891d > -- > 2.56.0 >
Thanks for doing this. Looks great. For the series: Reviewed-by: Zack Rusin <[email protected]> z
smime.p7s
Description: S/MIME Cryptographic Signature
