]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/display: Make intel_crtc_get_vblank_counter safe on PREEMPT_RT
authorMaarten Lankhorst <dev@lankhorst.se>
Fri, 29 Aug 2025 13:17:02 +0000 (15:17 +0200)
committerMaarten Lankhorst <dev@lankhorst.se>
Thu, 9 Oct 2025 14:10:37 +0000 (16:10 +0200)
drm_crtc_accurate_vblank_count takes a spinlock, which we should avoid
in tracepoints and debug functions.

This also prevents taking the spinlock 2x during the critical
section of pipe updates for DSI updates.

Acked-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://lore.kernel.org/r/20250829131701.15607-2-dev@lankhorst.se
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
drivers/gpu/drm/i915/display/intel_crtc.c

index a187db6df2d36ec7dbbba56fe7aa4e9f9b92751c..c0329e132462616b7923c5ed77775bb708469aef 100644 (file)
@@ -84,8 +84,13 @@ u32 intel_crtc_get_vblank_counter(struct intel_crtc *crtc)
        if (!crtc->active)
                return 0;
 
-       if (!vblank->max_vblank_count)
-               return (u32)drm_crtc_accurate_vblank_count(&crtc->base);
+       if (!vblank->max_vblank_count) {
+               /* On preempt-rt we cannot take the vblank spinlock since this function is called from tracepoints */
+               if (IS_ENABLED(CONFIG_PREEMPT_RT))
+                       return (u32)drm_crtc_vblank_count(&crtc->base);
+               else
+                       return (u32)drm_crtc_accurate_vblank_count(&crtc->base);
+       }
 
        return crtc->base.funcs->get_vblank_counter(&crtc->base);
 }