From: Maarten Lankhorst <dev@lankhorst.se>
To: intel-xe@lists.freedesktop.org
Subject: [FOR CI 4/5] drm/xe/display: Disable preemption in the most critical section
Date: Thu, 23 Oct 2025 17:34:05 +0200 [thread overview]
Message-ID: <20251023153407.7547-5-dev@lankhorst.se> (raw)
In-Reply-To: <20251023153407.7547-1-dev@lankhorst.se>
Lets see what happens if we only disable preemption in the critical
section to ensure we do run as fast as possible without disabling
too much.
Second attempt: Disable preemption, but keep interrupts enabled.
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
drivers/gpu/drm/i915/display/intel_crtc.c | 14 ++++++
drivers/gpu/drm/i915/display/intel_cursor.c | 18 +++++++-
drivers/gpu/drm/i915/display/intel_vblank.c | 47 ++++++++++++---------
3 files changed, 58 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c
index f34745b5ea497..939ef48859f16 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -569,6 +569,10 @@ void intel_pipe_update_start(struct intel_atomic_state *state,
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
local_irq_disable();
+#ifndef I915
+ else
+ preempt_disable();
+#endif
crtc->debug.min_vbl = evade.min;
crtc->debug.max_vbl = evade.max;
@@ -588,6 +592,11 @@ void intel_pipe_update_start(struct intel_atomic_state *state,
irq_disable:
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
local_irq_disable();
+#ifndef I915
+ else
+ preempt_disable();
+#endif
+
}
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_VBLANK_EVADE)
@@ -686,6 +695,10 @@ void intel_pipe_update_end(struct intel_atomic_state *state,
intel_crtc_has_type(new_crtc_state, INTEL_OUTPUT_DSI))
icl_dsi_frame_update(new_crtc_state);
+#if !defined(I915) && IS_ENABLED(CONFIG_PREEMPT_RT)
+ preempt_enable();
+#endif
+
/* We're still in the vblank-evade critical section, this can't race.
* Would be slightly nice to just grab the vblank count and arm the
* event outside of the critical section - the spinlock might spin for a
@@ -733,6 +746,7 @@ void intel_pipe_update_end(struct intel_atomic_state *state,
if (!state->base.legacy_cursor_update)
intel_vrr_send_push(NULL, new_crtc_state);
+ /* Re-enable irqs here for !RT */
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
local_irq_enable();
diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c b/drivers/gpu/drm/i915/display/intel_cursor.c
index 780fcae77a984..50ca39eb09145 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -912,6 +912,7 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
intel_psr_lock(crtc_state);
+ bool vblanked = false;
if (!drm_WARN_ON(display->drm, drm_crtc_vblank_get(&crtc->base))) {
/*
* TODO: maybe check if we're still in PSR
@@ -921,13 +922,21 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
local_irq_disable();
+#ifndef I915
+ else
+ preempt_disable();
+#endif
intel_vblank_evade(&evade);
- drm_crtc_vblank_put(&crtc->base);
+ vblanked = true;
} else {
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
local_irq_disable();
+#ifndef I915
+ else
+ preempt_disable();
+#endif
}
if (new_plane_state->uapi.visible) {
@@ -939,6 +948,10 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
local_irq_enable();
+#ifndef I915
+ else
+ preempt_enable();
+#endif
intel_psr_unlock(crtc_state);
@@ -955,6 +968,9 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
intel_plane_unpin_fb(old_plane_state);
}
+ if (vblanked)
+ drm_crtc_vblank_put(&crtc->base);
+
out_free:
if (new_crtc_state)
intel_crtc_destroy_state(&crtc->base, &new_crtc_state->uapi);
diff --git a/drivers/gpu/drm/i915/display/intel_vblank.c b/drivers/gpu/drm/i915/display/intel_vblank.c
index 7826f29619a14..448ae8e5b6e90 100644
--- a/drivers/gpu/drm/i915/display/intel_vblank.c
+++ b/drivers/gpu/drm/i915/display/intel_vblank.c
@@ -729,6 +729,13 @@ void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state,
evade->min -= vblank_delay;
}
+static inline int vblank_evadable(struct intel_vblank_evade_ctx *evade, int *scanline)
+{
+ *scanline = intel_get_crtc_scanline(evade->crtc);
+
+ return *scanline < evade->min || *scanline > evade->max;
+}
+
/* must be called with vblank interrupt already enabled! */
int intel_vblank_evade(struct intel_vblank_evade_ctx *evade)
{
@@ -736,23 +743,33 @@ int intel_vblank_evade(struct intel_vblank_evade_ctx *evade)
struct intel_display *display = to_intel_display(crtc);
long timeout = msecs_to_jiffies_timeout(1);
wait_queue_head_t *wq = drm_crtc_vblank_waitqueue(&crtc->base);
- DEFINE_WAIT(wait);
int scanline;
if (evade->min <= 0 || evade->max <= 0)
return 0;
- for (;;) {
- /*
- * prepare_to_wait() has a memory barrier, which guarantees
- * other CPUs can see the task state update by the time we
- * read the scanline.
- */
+ while (!vblank_evadable(evade, &scanline)) {
+ DEFINE_WAIT(wait);
+
+ if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+ local_irq_enable();
+#ifndef I915
+ else
+ preempt_enable();
+#endif
+
prepare_to_wait(wq, &wait, TASK_UNINTERRUPTIBLE);
+ if (!vblank_evadable(evade, &scanline))
+ timeout = schedule_timeout(timeout);
- scanline = intel_get_crtc_scanline(crtc);
- if (scanline < evade->min || scanline > evade->max)
- break;
+ finish_wait(wq, &wait);
+
+ if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+ local_irq_disable();
+#ifndef I915
+ else
+ preempt_disable();
+#endif
if (!timeout) {
drm_dbg_kms(display->drm,
@@ -760,18 +777,8 @@ int intel_vblank_evade(struct intel_vblank_evade_ctx *evade)
pipe_name(crtc->pipe));
break;
}
-
- if (!IS_ENABLED(CONFIG_PREEMPT_RT))
- local_irq_enable();
-
- timeout = schedule_timeout(timeout);
-
- if (!IS_ENABLED(CONFIG_PREEMPT_RT))
- local_irq_disable();
}
- finish_wait(wq, &wait);
-
/*
* On VLV/CHV DSI the scanline counter would appear to
* increment approx. 1/3 of a scanline before start of vblank.
--
2.51.0
next prev parent reply other threads:[~2025-10-23 15:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 15:34 [FOR CI 0/5] drm/xe/display: Test series with PREEMPT_RT and preemption disable Maarten Lankhorst
2025-10-23 15:34 ` [FOR CI 1/5] drm/xe: Bump xe_device_l2_flush even higher Maarten Lankhorst
2025-10-23 15:34 ` [FOR CI 2/5] drm/i915: Use preempt_disable/enable_rt() where recommended Maarten Lankhorst
2025-10-23 15:34 ` [FOR CI 3/5] drm/i915: Don't disable interrupts on PREEMPT_RT during atomic updates Maarten Lankhorst
2025-10-23 15:34 ` Maarten Lankhorst [this message]
2025-10-23 15:34 ` [FOR CI 5/5] PREEMPT_RT injection Maarten Lankhorst
2025-10-23 18:23 ` ✗ CI.checkpatch: warning for drm/xe/display: Test series with PREEMPT_RT and preemption disable. (rev2) Patchwork
2025-10-23 18:24 ` ✓ CI.KUnit: success " Patchwork
2025-10-23 18:38 ` ✗ CI.checksparse: warning " Patchwork
2025-10-23 19:16 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-10-24 7:42 ` ✗ Xe.CI.Full: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2025-10-29 9:59 [FOR CI 0/5] Testing PREEMPT_RT with disabling preemption in the most critical section Maarten Lankhorst
2025-10-29 9:59 ` [FOR CI 4/5] drm/xe/display: Disable " Maarten Lankhorst
2025-10-23 8:55 [FOR CI 0/5] Testing PREEMPT_RT with disabling interrupts " Maarten Lankhorst
2025-10-23 8:56 ` [FOR CI 4/5] drm/xe/display: Disable preemption " Maarten Lankhorst
2025-10-22 12:13 [FOR CI 0/5] drm/xe/display: Test series with PREEMPT_RT and preemption disable Maarten Lankhorst
2025-10-22 12:13 ` [FOR CI 4/5] drm/xe/display: Disable preemption in the most critical section Maarten Lankhorst
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=20251023153407.7547-5-dev@lankhorst.se \
--to=dev@lankhorst.se \
--cc=intel-xe@lists.freedesktop.org \
/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