dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maarten Lankhorst" <dev@lankhorst.se>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 06/10] drm/i915/display: Remove locking from intel_vblank_evade critical section
Date: Thu, 02 Jul 2026 07:36:23 +0000	[thread overview]
Message-ID: <20260702073624.8C1BE1F01568@smtp.kernel.org> (raw)
In-Reply-To: <20260702072154.171324-7-dev@lankhorst.se>

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

New issues:
- [High] Bypassing `uncore->lock` for scanline reads breaks the hardware serialization workaround for older platforms like Ivy Bridge and Haswell, potentially causing hardware hangs.

Pre-existing issues:
- [High] drm_crtc_vblank_put() is called with local interrupts disabled in intel_pipe_update_start().
--

commit a415cb59c253b3a3fa754a68afc62b743249b0f2
Author: Maarten Lankhorst <dev@lankhorst.se>

drm/i915/display: Remove locking from intel_vblank_evade critical section
    
finish_wait() may take a lock, which means that it can take any amount
of time. On PREEMPT-RT we should not be taking any lock after disabling
preemption, so ensure that the completion is done before disabling
interrupts.

This also has the benefit of making vblank evasion more deterministic,
by performing the final vblank check after all locking is done.

> diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c
> index 34a159f7c9a43..8218938985b41 100644
> --- a/drivers/gpu/drm/i915/display/intel_crtc.c
> +++ b/drivers/gpu/drm/i915/display/intel_crtc.c
> @@ -734,7 +734,7 @@ void intel_pipe_update_end(struct intel_atomic_state *state,
>  	struct intel_crtc_state *new_crtc_state =
>  		intel_atomic_get_new_crtc_state(state, crtc);
>  	enum pipe pipe = crtc->pipe;
> -	int scanline_end = intel_get_crtc_scanline(crtc);
> +	int scanline_end = __intel_get_crtc_scanline(crtc);

[Severity: High]
Does bypassing uncore->lock here break the hardware serialization workaround
for older platforms?

Calling __intel_get_crtc_scanline() without the lock in intel_pipe_update_end()
risks concurrent mmio access with other threads, such as when reading the
PIPEDSL register, which could cause hardware hangs on platforms like Ivy Bridge
and Haswell.

[ ... ]

> diff --git a/drivers/gpu/drm/i915/display/intel_vblank.c b/drivers/gpu/drm/i915/display/intel_vblank.c
> index 28d81199792ef..ca08059e088ea 100644
> --- a/drivers/gpu/drm/i915/display/intel_vblank.c
> +++ b/drivers/gpu/drm/i915/display/intel_vblank.c
> @@ -732,6 +732,16 @@ void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state,
>  		evade->min -= vblank_delay;
>  }
>  
> +static bool scanline_in_safe_range(struct intel_vblank_evade_ctx *evade, int *scanline, bool unlocked)
> +{
> +	if (unlocked)
> +		*scanline = intel_get_crtc_scanline(evade->crtc);
> +	else
> +		*scanline = __intel_get_crtc_scanline(evade->crtc);

[Severity: High]
Could this lockless scanline read cause a hardware hang during evasion?

Similar to the above, calling __intel_get_crtc_scanline() here during
the preempt-disabled evasion loop in scanline_in_safe_range() bypasses the
required hardware serialization lock. Older platforms might experience hangs
due to unsynchronized mmio cacheline access.

> +
> +	return *scanline < evade->min || *scanline > evade->max;
> +}

[ ... ]

[Severity: High]
This is a pre-existing issue, but intel_pipe_update_start() calls
drm_crtc_vblank_put() with local interrupts disabled:

drivers/gpu/drm/i915/display/intel_crtc.c:intel_pipe_update_start() {
    ...
    local_irq_disable();

    crtc->debug.min_vbl = evade.min;
    crtc->debug.max_vbl = evade.max;
    trace_intel_pipe_update_start(crtc);

    scanline = intel_vblank_evade(&evade);

    drm_crtc_vblank_put(&crtc->base);
    ...
}

Could this lead to scheduling while atomic on preempt-rt kernels?

When the reference count drops to zero, drm_crtc_vblank_put() might acquire
dev->vbl_lock, which is a spinlock_t that sleeps on preempt-rt.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260702072154.171324-1-dev@lankhorst.se?part=6

  reply	other threads:[~2026-07-02  7:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  7:21 [PATCH 00/10] drm/intel/display: Changes required to make vblank evasion PREEMPT_RT safe Maarten Lankhorst
2026-07-02  7:21 ` [PATCH 01/10] drm/vblank_work: Add methods to schedule vblank_work in 2 stages Maarten Lankhorst
2026-07-02  7:32   ` sashiko-bot
2026-07-02  7:21 ` [PATCH 02/10] drm/vblank: Add a 2-stage version of drm_crtc_arm_vblank_event Maarten Lankhorst
2026-07-02  7:35   ` sashiko-bot
2026-07-02  7:21 ` [PATCH 03/10] drm/intel/display: Make intel_crtc_arm_vblank_event static Maarten Lankhorst
2026-07-10 14:20   ` Ville Syrjälä
2026-07-02  7:21 ` [PATCH 04/10] drm/intel/display: Convert vblank event handling to 2-stage arming Maarten Lankhorst
2026-07-02  7:37   ` sashiko-bot
2026-07-02  7:21 ` [PATCH 05/10] drm/i915/display: Move vblank put until after critical section Maarten Lankhorst
2026-07-02  7:34   ` sashiko-bot
2026-07-02  7:21 ` [PATCH 06/10] drm/i915/display: Remove locking from intel_vblank_evade " Maarten Lankhorst
2026-07-02  7:36   ` sashiko-bot [this message]
2026-07-02  7:21 ` [PATCH 07/10] drm/i915/display: Handle vlv dsi workaround in scanline_in_safe_range too Maarten Lankhorst
2026-07-02  7:30   ` sashiko-bot
2026-07-02  7:21 ` [PATCH 08/10] drm/i915: Use preempt_disable/enable_rt() where recommended Maarten Lankhorst
2026-07-02  7:36   ` sashiko-bot
2026-07-02  7:21 ` [PATCH 09/10] drm/i915/display: Make get_vblank_counter use intel_de_read_fw() Maarten Lankhorst
2026-07-02  7:43   ` sashiko-bot
2026-07-10 14:34   ` Ville Syrjälä
2026-07-02  7:21 ` [PATCH 10/10] drm/i915/display: Do not take uncore lock in i915_get_vblank_counter Maarten Lankhorst
2026-07-10 14:19   ` Ville Syrjälä
2026-07-10 14:43 ` [PATCH 00/10] drm/intel/display: Changes required to make vblank evasion PREEMPT_RT safe Ville Syrjälä

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=20260702073624.8C1BE1F01568@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dev@lankhorst.se \
    --cc=dri-devel@lists.freedesktop.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox