All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Roman Ilin" <me@romanilin.is>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3] drm/vblank: Don't arm vblank timer with invalid frame duration
Date: Thu, 02 Jul 2026 18:23:04 +0000	[thread overview]
Message-ID: <20260702182305.04E541F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260702181027.98526-1-me@romanilin.is>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Critical] drm_crtc_vblank_start_timer() deadlocks when synchronously spinning on hrtimer cancellation if the timer callback is concurrently running.
--

commit ea5cbfbf25c3ea02070a1ec1d83634d5505e475b
Author: Roman Ilin <me@romanilin.is>

drm/vblank: Don't arm vblank timer with invalid frame duration

This commit fixes a bug where an extremely small pixel clock results in a
computed frame duration that wraps to a negative value, causing the vblank
hrtimer to fail and stall pending page flips. It updates the calculation to
use u64 and adds overflow checks, returning an error to fall back to
immediate vblank events.

> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> index f90fb2d13e423..629b9fcc7a52d 100644
> --- a/drivers/gpu/drm/drm_vblank.c
> +++ b/drivers/gpu/drm/drm_vblank.c

[ ... ]

> @@ -2221,6 +2239,7 @@ int drm_crtc_vblank_start_timer(struct drm_crtc *crtc)
>  	struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc);
>  	struct drm_vblank_crtc_timer *vtimer = &vblank->vblank_timer;
>  	unsigned long flags;
> +	int ret;
>  
>  	if (!vtimer->crtc) {
>  		/*
> @@ -2239,7 +2258,9 @@ int drm_crtc_vblank_start_timer(struct drm_crtc *crtc)
>  			hrtimer_try_to_cancel(&vtimer->timer);
>  	}

[Severity: Critical]
This isn't a bug introduced by this patch, but does this busy-wait loop
cause a deadlock if the timer callback is running concurrently?

When drm_vblank_enable() is called, it takes dev->vblank_time_lock before
calling down to __enable_vblank(), which eventually calls
drm_crtc_vblank_start_timer().

If the timer fires on another CPU at this exact moment, this loop will spin
indefinitely waiting for the callback to finish. However, the timer callback
executes drm_handle_vblank(), which tries to acquire dev->vblank_time_lock:

drm_vblank_timer_function() -> drm_handle_vblank() {
    ...
    spin_lock(&dev->vblank_time_lock);
}

Could this result in a deadlock between the spinning thread holding
vblank_time_lock and the timer callback trying to acquire it?

> -	drm_calc_timestamping_constants(crtc, &crtc->mode);
> +	ret = drm_calc_timestamping_constants(crtc, &crtc->mode);
> +	if (ret)
> +		return ret;
>  
>  	spin_lock_irqsave(&vtimer->interval_lock, flags);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260702181027.98526-1-me@romanilin.is?part=1

      parent reply	other threads:[~2026-07-02 18:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-13 22:44 [PATCH] drm/vblank: Don't arm vblank timer with invalid frame duration Roman Ilin
2026-06-30 12:06 ` Thorsten Leemhuis
2026-06-30 12:09   ` Thomas Zimmermann
2026-06-30 12:58 ` Thomas Zimmermann
2026-07-02 15:23 ` [PATCH v2] " Roman Ilin
2026-07-02 15:49   ` sashiko-bot
2026-07-02 18:10 ` [PATCH v3] " Roman Ilin
2026-07-02 18:23   ` Roman Ilin
2026-07-03  7:26     ` Thomas Zimmermann
2026-07-02 18:23   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260702182305.04E541F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=me@romanilin.is \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.