Hey, On 7/10/26 16:43, Ville Syrjälä wrote: > On Thu, Jul 02, 2026 at 09:21:43AM +0200, Maarten Lankhorst wrote: >> CONFIG_PREEMPT_RT requires code to be as deterministic as possible, >> and codes with interrupts disabled cannot use spinlocks. >> >> In order to handle this correctly, we ensure any locking requirements >> are handled before disabling interrupts, and only start locking again >> after interrupts are re-enabled and timing sensitive path completed. >> >> This also has the benefit of making the vblank evasion code more >> deterministic; without locking there's much less jitter. >> >> Previously, we scheduled vblank work on completion. >> This is now handled by scheduling the vblank in advance, only arming >> it upon completion without locks. > > Sashiko found a bunch of stuff that I was also thinking would be > a problem. Don't think I'll need to repeat it here. > > I'm still thinking the easy way out would be to just convert > everything to raw spinlocks. The uncore lock I think should become > easier to deal with once I manage to move all of it into the > display code. I admit that the vblank locking is kinda annoying > and potentially inefficient. I've been pondering about making the > vblank locks to per-crtc to at least avoid some unnecessary contention, > but the fact that a lot of the drivers poke at the vblank internals > directly makes it a lot more work than it should be :/
I'll do the full wmb instead of the smp wmb, should hopefully fix it. In general, the approach I'm taking was ensuring that no raw spinlocks are ever needed. Every lock is taken before disabling interrupts, and then we run the time sensitive code only after checking there's enough time left. This means that even on PROVE_LOCKING, there is no contention of locks, and the VBLANK_EVASION_TIME_US could be set to 100 µs even with PROVE_LOCKING set. You can take the uncore lock in advance just like any other lock if required, but no contention should happen and it can be taken as normal not raw spinlock. > >> >> Maarten Lankhorst (9): >> drm/vblank_work: Add methods to schedule vblank_work in 2 stages >> drm/vblank: Add a 2-stage version of drm_crtc_arm_vblank_event >> drm/intel/display: Make intel_crtc_arm_vblank_event static >> drm/intel/display: Convert vblank event handling to 2-stage arming >> drm/i915/display: Move vblank put until after critical section >> drm/i915/display: Remove locking from intel_vblank_evade critical >> section >> drm/i915/display: Handle vlv dsi workaround in scanline_in_safe_range >> too >> drm/i915/display: Make get_vblank_counter use intel_de_read_fw() >> drm/i915/display: Do not take uncore lock in i915_get_vblank_counter >> >> Mike Galbraith (1): >> drm/i915: Use preempt_disable/enable_rt() where recommended >> >> drivers/gpu/drm/drm_vblank.c | 64 +++++++++- >> drivers/gpu/drm/drm_vblank_work.c | 110 +++++++++++++---- >> drivers/gpu/drm/i915/display/intel_crtc.c | 86 ++++++------- >> drivers/gpu/drm/i915/display/intel_crtc.h | 1 - >> drivers/gpu/drm/i915/display/intel_cursor.c | 8 +- >> drivers/gpu/drm/i915/display/intel_de.h | 8 ++ >> drivers/gpu/drm/i915/display/intel_vblank.c | 115 ++++++++++-------- >> drivers/gpu/drm/i915/display/intel_vblank.h | 1 + >> drivers/gpu/drm/i915/intel_uncore.h | 26 ++-- >> .../drm/xe/compat-i915-headers/intel_uncore.h | 7 ++ >> include/drm/drm_vblank.h | 14 ++- >> include/drm/drm_vblank_work.h | 12 ++ >> 12 files changed, 324 insertions(+), 128 deletions(-) >> >> -- >> 2.53.0 > Kind regards, ~Maarten
