[PATCH v3 5/6] drm/rockchip: Fix leaked vblank event in vop_crtc_atomic_disable()

Jiaqi shijiaqi_develop at 163.com
Sat May 9 01:33:58 PDT 2026


In vop_crtc_atomic_disable(), there is a WARN_ON(vop->event) that warns
when an event is pending, but the event is never actually handled.

When vop_crtc_atomic_flush() has been called, it moves crtc->state->event
to vop->event and calls drm_crtc_vblank_get(). If atomic_disable() is
called before the vblank IRQ fires (e.g., due to a modeset or CRTC
disable), vop->event remains set but is never sent to userspace. This
means:

1. Userspace waits forever for the flip completion event, causing a hang.
2. The vblank reference acquired in atomic_flush() is never released,
   leaking the vblank reference count.

Fix by sending the pending event and releasing the vblank reference when
atomic_disable() detects a pending vop->event, matching the behavior
in vop_handle_vblank().

Signed-off-by: Jiaqi <shijiaqi_develop at 163.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 8afabe2118a9..1234567890ab 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -700,7 +700,16 @@ static void vop_crtc_atomic_disable(struct drm_crtc *crtc,
 {
 	struct vop *vop = to_vop(crtc);

-	WARN_ON(vop->event);
+	if (vop->event) {
+		WARN_ON(1);
+		spin_lock_irq(&crtc->dev->event_lock);
+		drm_crtc_send_vblank_event(crtc, vop->event);
+		spin_unlock_irq(&crtc->dev->event_lock);
+		drm_crtc_vblank_put(crtc);
+		vop->event = NULL;
+	}

 	if (crtc->state->self_refresh_active)
 		rockchip_drm_set_win_enabled(crtc, false);
-- 
2.40.0




More information about the Linux-rockchip mailing list