[PATCH] drm/vblank: downgrade vblank wait timeout from WARN to debug

Chintan Patel posted 1 patch 16 hours ago
drivers/gpu/drm/drm_vblank.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
[PATCH] drm/vblank: downgrade vblank wait timeout from WARN to debug
Posted by Chintan Patel 16 hours ago
When wait_event_timeout() in drm_wait_one_vblank() times out, the
current WARN can cause unnecessary kernel panics in environments
with panic_on_warn set (e.g. CI, fuzzing). These timeouts can happen
under scheduler pressure or from invalid userspace calls, so they are
not always a kernel bug.

Replace the WARN with drm_dbg_kms() messages that provide useful
context (last and current vblank counters) without crashing the
system. Developers can still enable drm.debug to diagnose genuine
problems.

Reported-by: syzbot+147ba789658184f0ce04@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=147ba789658184f0ce04
Tested-by: syzbot+147ba789658184f0ce04@syzkaller.appspotmail.com

Signed-off-by: Chintan Patel <chintanlike@gmail.com>
---
 drivers/gpu/drm/drm_vblank.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 46f59883183d..c8dd9d4be26c 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -1289,7 +1289,7 @@ void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe)
 {
 	struct drm_vblank_crtc *vblank = drm_vblank_crtc(dev, pipe);
 	int ret;
-	u64 last;
+	u64 last, curr;
 
 	if (drm_WARN_ON(dev, pipe >= dev->num_crtcs))
 		return;
@@ -1305,7 +1305,20 @@ void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe)
 				 last != drm_vblank_count(dev, pipe),
 				 msecs_to_jiffies(100));
 
-	drm_WARN(dev, ret == 0, "vblank wait timed out on crtc %i\n", pipe);
+	curr = drm_vblank_count(dev, pipe);
+
+	if (ret == 0) {
+		/*
+		 * Avoid spamming WARNs for timeouts which can be caused by
+		 * heavy scheduling pressure or invalid userspace calls (fuzzing).
+		 * Use debug message instead.
+		 */
+		drm_dbg_kms(dev, "WAIT_VBLANK: timeout crtc=%d, last=%llu, curr=%llu\n",
+			pipe, last, curr);
+	} else {
+		drm_dbg_kms(dev, "WAIT_VBLANK: completed crtc=%d, last=%llu, curr=%llu\n",
+			pipe, last, curr);
+		}
 
 	drm_vblank_put(dev, pipe);
 }
-- 
2.43.0
Re: [PATCH] drm/vblank: downgrade vblank wait timeout from WARN to debug
Posted by Thomas Zimmermann 13 hours ago
Hi

Am 01.10.25 um 05:32 schrieb Chintan Patel:
> When wait_event_timeout() in drm_wait_one_vblank() times out, the
> current WARN can cause unnecessary kernel panics in environments
> with panic_on_warn set (e.g. CI, fuzzing). These timeouts can happen
> under scheduler pressure or from invalid userspace calls, so they are
> not always a kernel bug.
>
> Replace the WARN with drm_dbg_kms() messages that provide useful
> context (last and current vblank counters) without crashing the
> system. Developers can still enable drm.debug to diagnose genuine
> problems.
>
> Reported-by: syzbot+147ba789658184f0ce04@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=147ba789658184f0ce04
> Tested-by: syzbot+147ba789658184f0ce04@syzkaller.appspotmail.com
>
> Signed-off-by: Chintan Patel <chintanlike@gmail.com>
> ---
>   drivers/gpu/drm/drm_vblank.c | 17 +++++++++++++++--
>   1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> index 46f59883183d..c8dd9d4be26c 100644
> --- a/drivers/gpu/drm/drm_vblank.c
> +++ b/drivers/gpu/drm/drm_vblank.c
> @@ -1289,7 +1289,7 @@ void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe)
>   {
>   	struct drm_vblank_crtc *vblank = drm_vblank_crtc(dev, pipe);
>   	int ret;
> -	u64 last;
> +	u64 last, curr;
>   
>   	if (drm_WARN_ON(dev, pipe >= dev->num_crtcs))
>   		return;
> @@ -1305,7 +1305,20 @@ void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe)
>   				 last != drm_vblank_count(dev, pipe),
>   				 msecs_to_jiffies(100));
>   
> -	drm_WARN(dev, ret == 0, "vblank wait timed out on crtc %i\n", pipe);
> +	curr = drm_vblank_count(dev, pipe);
> +
> +	if (ret == 0) {

if (!ret)

> +		/*
> +		 * Avoid spamming WARNs for timeouts which can be caused by
> +		 * heavy scheduling pressure or invalid userspace calls (fuzzing).
> +		 * Use debug message instead.
> +		 */

The comment is not necessary. The commit description gives a good rational.

> +		drm_dbg_kms(dev, "WAIT_VBLANK: timeout crtc=%d, last=%llu, curr=%llu\n",
> +			pipe, last, curr);
> +	} else {
> +		drm_dbg_kms(dev, "WAIT_VBLANK: completed crtc=%d, last=%llu, curr=%llu\n",
> +			pipe, last, curr);
> +		}

Rather drop the else branch.

Best regards
Thomas


>   
>   	drm_vblank_put(dev, pipe);
>   }

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)