drm/i915: WARN if PLL ref/unref got messed up
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 21 Sep 2022 21:15:25 +0000 (00:15 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 26 Sep 2022 17:17:26 +0000 (20:17 +0300)
Spew a WARN if we try to ref/unref the same DPLL multiple
times for the same pipe.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220921211525.10675-5-ville.syrjala@linux.intel.com
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/display/intel_dpll_mgr.c

index cc5efac..00e97bd 100644 (file)
@@ -384,6 +384,8 @@ intel_reference_shared_dpll(struct intel_atomic_state *state,
        if (shared_dpll[id].pipe_mask == 0)
                shared_dpll[id].hw_state = *pll_state;
 
+       drm_WARN_ON(&i915->drm, (shared_dpll[id].pipe_mask & BIT(crtc->pipe)) != 0);
+
        shared_dpll[id].pipe_mask |= BIT(crtc->pipe);
 
        drm_dbg_kms(&i915->drm, "[CRTC:%d:%s] reserving %s\n",
@@ -396,10 +398,13 @@ static void intel_unreference_shared_dpll(struct intel_atomic_state *state,
 {
        struct drm_i915_private *i915 = to_i915(state->base.dev);
        struct intel_shared_dpll_state *shared_dpll;
+       const enum intel_dpll_id id = pll->info->id;
 
        shared_dpll = intel_atomic_get_shared_dpll_state(&state->base);
 
-       shared_dpll[pll->info->id].pipe_mask &= ~BIT(crtc->pipe);
+       drm_WARN_ON(&i915->drm, (shared_dpll[id].pipe_mask & BIT(crtc->pipe)) == 0);
+
+       shared_dpll[id].pipe_mask &= ~BIT(crtc->pipe);
 
        drm_dbg_kms(&i915->drm, "[CRTC:%d:%s] releasing %s\n",
                    crtc->base.base.id, crtc->base.name, pll->info->name);