drm/i915: Mark FIFO underrun disabled earlier
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 25 Jan 2023 18:52:30 +0000 (20:52 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 23 Feb 2023 14:28:03 +0000 (16:28 +0200)
At least on some platforms (tested on ctg) the way
vgacon does screen blanking seems to flag constant
FIFO underruns, which means we have to be prepared
for them while the driver is loading. Currently
there is a time window between drm_crtc_init() and
intel_sanitize_fifo_underrun_reporting() during
which FIFO underrun reporting is in fact marked as
enabled. Thus we may end up mistakenly detecting
these bogus underruns during driver init.

Close the race by marking FIFO underrun reporting
as disabled prior to even registering the crtc.
intel_sanitize_fifo_underrun_reporting()/etc. will
re-enable it later if needed.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230125185234.21599-2-ville.syrjala@linux.intel.com
Reviewed-by: Vinod Govindapillai <vinod.govindapillai@intel.com>
drivers/gpu/drm/i915/display/intel_crtc.c
drivers/gpu/drm/i915/display/intel_fifo_underrun.c
drivers/gpu/drm/i915/display/intel_fifo_underrun.h
drivers/gpu/drm/i915/display/intel_modeset_setup.c

index 82be0fb..b79a883 100644 (file)
@@ -25,6 +25,7 @@
 #include "intel_display_types.h"
 #include "intel_drrs.h"
 #include "intel_dsi.h"
+#include "intel_fifo_underrun.h"
 #include "intel_pipe_crc.h"
 #include "intel_psr.h"
 #include "intel_sprite.h"
@@ -314,6 +315,8 @@ int intel_crtc_init(struct drm_i915_private *dev_priv, enum pipe pipe)
        }
        crtc->plane_ids_mask |= BIT(primary->id);
 
+       intel_init_fifo_underrun_reporting(dev_priv, crtc, false);
+
        for_each_sprite(dev_priv, pipe, sprite) {
                struct intel_plane *plane;
 
index d636d21..b708a62 100644 (file)
@@ -31,6 +31,7 @@
 #include "intel_display_types.h"
 #include "intel_fbc.h"
 #include "intel_fifo_underrun.h"
+#include "intel_pch_display.h"
 
 /**
  * DOC: fifo underrun handling
@@ -509,3 +510,22 @@ void intel_check_pch_fifo_underruns(struct drm_i915_private *dev_priv)
 
        spin_unlock_irq(&dev_priv->irq_lock);
 }
+
+void intel_init_fifo_underrun_reporting(struct drm_i915_private *i915,
+                                       struct intel_crtc *crtc,
+                                       bool enable)
+{
+       crtc->cpu_fifo_underrun_disabled = !enable;
+
+       /*
+        * We track the PCH trancoder underrun reporting state
+        * within the crtc. With crtc for pipe A housing the underrun
+        * reporting state for PCH transcoder A, crtc for pipe B housing
+        * it for PCH transcoder B, etc. LPT-H has only PCH transcoder A,
+        * and marking underrun reporting as disabled for the non-existing
+        * PCH transcoders B and C would prevent enabling the south
+        * error interrupt (see cpt_can_enable_serr_int()).
+        */
+       if (intel_has_pch_trancoder(i915, crtc->pipe))
+               crtc->pch_fifo_underrun_disabled = !enable;
+}
index 2e47d7d..b00d8ab 100644 (file)
@@ -9,8 +9,11 @@
 #include <linux/types.h>
 
 struct drm_i915_private;
+struct intel_crtc;
 enum pipe;
 
+void intel_init_fifo_underrun_reporting(struct drm_i915_private *i915,
+                                       struct intel_crtc *crtc, bool enable);
 bool intel_set_cpu_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
                                           enum pipe pipe, bool enable);
 bool intel_set_pch_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
index 2d3c42a..60f71e6 100644 (file)
@@ -22,6 +22,7 @@
 #include "intel_display.h"
 #include "intel_display_power.h"
 #include "intel_display_types.h"
+#include "intel_fifo_underrun.h"
 #include "intel_modeset_setup.h"
 #include "intel_pch_display.h"
 #include "intel_pm.h"
@@ -236,12 +237,9 @@ static void intel_sanitize_fifo_underrun_reporting(const struct intel_crtc_state
        struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
        struct drm_i915_private *i915 = to_i915(crtc->base.dev);
 
-       if (!crtc_state->hw.active && !HAS_GMCH(i915))
-               return;
-
        /*
-        * We start out with underrun reporting disabled to avoid races.
-        * For correct bookkeeping mark this on active crtcs.
+        * We start out with underrun reporting disabled on active
+        * pipes to avoid races.
         *
         * Also on gmch platforms we dont have any hardware bits to
         * disable the underrun reporting. Which means we need to start
@@ -252,19 +250,9 @@ static void intel_sanitize_fifo_underrun_reporting(const struct intel_crtc_state
         * No protection against concurrent access is required - at
         * worst a fifo underrun happens which also sets this to false.
         */
-       crtc->cpu_fifo_underrun_disabled = true;
-
-       /*
-        * We track the PCH trancoder underrun reporting state
-        * within the crtc. With crtc for pipe A housing the underrun
-        * reporting state for PCH transcoder A, crtc for pipe B housing
-        * it for PCH transcoder B, etc. LPT-H has only PCH transcoder A,
-        * and marking underrun reporting as disabled for the non-existing
-        * PCH transcoders B and C would prevent enabling the south
-        * error interrupt (see cpt_can_enable_serr_int()).
-        */
-       if (intel_has_pch_trancoder(i915, crtc->pipe))
-               crtc->pch_fifo_underrun_disabled = true;
+       intel_init_fifo_underrun_reporting(i915, crtc,
+                                          !crtc_state->hw.active &&
+                                          !HAS_GMCH(i915));
 }
 
 static void intel_sanitize_crtc(struct intel_crtc *crtc,