drm/i915: WARN when trying to enabled an unused crtc
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 2 Jul 2012 09:43:47 +0000 (11:43 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 6 Sep 2012 05:57:45 +0000 (07:57 +0200)
This is the first tiny step towards cross-checking the entire modeset
state machine with WARNs. A crtc can only be enabled when it's
actually in use, i.e. crtc->active imlies crtc->enabled.

Unfortunately we can't (yet) check this when disabling the crtc,
because the crtc helpers are a bit slopy with updating state and
unconditionally update crtc->enabled before changing the hw state.

Fixing that requires quite some more work.

Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_drv.h

index ca1701081c56c00652c916c75bd98848bbf68e0e..5ab86949014f94d84983a2605960970667b2fb05 100644 (file)
@@ -3215,6 +3215,8 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
        u32 temp;
        bool is_pch_port;
 
+       WARN_ON(!crtc->enabled);
+
        /* XXX: For compatability with the crtc helper code, call the encoder's
         * enable function unconditionally for now. */
        if (intel_crtc->active)
@@ -3391,6 +3393,8 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc)
        int pipe = intel_crtc->pipe;
        int plane = intel_crtc->plane;
 
+       WARN_ON(!crtc->enabled);
+
        /* XXX: For compatability with the crtc helper code, call the encoder's
         * enable function unconditionally for now. */
        if (intel_crtc->active)
index 673e8d484bfa3b701013b95114507721d5cf9b68..36991dee2d403e46b0fd622dd903e081cd0413e7 100644 (file)
@@ -158,7 +158,15 @@ struct intel_crtc {
        enum plane plane;
        u8 lut_r[256], lut_g[256], lut_b[256];
        int dpms_mode;
-       bool active; /* is the crtc on? independent of the dpms mode */
+       /*
+        * Whether the crtc and the connected output pipeline is active. Implies
+        * that crtc->enabled is set, i.e. the current mode configuration has
+        * some outputs connected to this crtc.
+        *
+        * Atm crtc->enabled is unconditionally updated _before_ the hw state is
+        * changed, hence we can only check this when enabling the crtc.
+        */
+       bool active;
        bool primary_disabled; /* is the crtc obscured by a plane? */
        bool lowfreq_avail;
        struct intel_overlay *overlay;