diff mbox

[1/2] drm/i915: add asserts for cursor disabled

Message ID 1379059389-2890-1-git-send-email-jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jani Nikula Sept. 13, 2013, 8:03 a.m. UTC
The cursor is supposed to be disabled during crtc mode set (disabled by
ctrc disable). Assert this is the case.

v2: move cursor disabled assert next to plane asserts (Ville)

Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_display.c |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Chris Wilson Sept. 13, 2013, 8:48 a.m. UTC | #1
On Fri, Sep 13, 2013 at 11:03:08AM +0300, Jani Nikula wrote:
> The cursor is supposed to be disabled during crtc mode set (disabled by
> ctrc disable). Assert this is the case.
> 
> v2: move cursor disabled assert next to plane asserts (Ville)
> 
> Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

Lgtm. There's one extra place for paranoia that I spotted, in
*_update_cursor() we can assert that the cursor in the expected
visibility when we enter the function. That might be overkill for such a
frequently called operation, so just limiting it to the change in
visibility should be paranoid enough.
-Chris
Ville Syrjälä Sept. 13, 2013, 11:57 a.m. UTC | #2
On Fri, Sep 13, 2013 at 11:03:08AM +0300, Jani Nikula wrote:
> The cursor is supposed to be disabled during crtc mode set (disabled by
> ctrc disable). Assert this is the case.
> 
> v2: move cursor disabled assert next to plane asserts (Ville)
> 
> Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  drivers/gpu/drm/i915/intel_display.c |   23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index d0137b6..0446dc7 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -1069,6 +1069,26 @@ static void assert_panel_unlocked(struct drm_i915_private *dev_priv,
>  	     pipe_name(pipe));
>  }
>  
> +static void assert_cursor(struct drm_i915_private *dev_priv,
> +			  enum pipe pipe, bool state)
> +{
> +	struct drm_device *dev = dev_priv->dev;
> +	bool cur_state;
> +
> +	if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev))
> +		cur_state = I915_READ(CURCNTR_IVB(pipe)) & CURSOR_MODE;
> +	else if (IS_845G(dev) || IS_I865G(dev))
> +		cur_state = I915_READ(_CURACNTR) & CURSOR_ENABLE;
> +	else
> +		cur_state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE;
> +
> +	WARN(cur_state != state,
> +	     "cursor on pipe %c assertion failure (expected %s, current %s)\n",
> +	     pipe_name(pipe), state_string(state), state_string(cur_state));
> +}
> +#define assert_cursor_enabled(d, p) assert_cursor(d, p, true)
> +#define assert_cursor_disabled(d, p) assert_cursor(d, p, false)
> +
>  void assert_pipe(struct drm_i915_private *dev_priv,
>  		 enum pipe pipe, bool state)
>  {
> @@ -1670,6 +1690,7 @@ static void intel_enable_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
>  	u32 val;
>  
>  	assert_planes_disabled(dev_priv, pipe);
> +	assert_cursor_disabled(dev_priv, pipe);
>  	assert_sprites_disabled(dev_priv, pipe);
>  
>  	if (HAS_PCH_LPT(dev_priv->dev))
> @@ -1731,6 +1752,7 @@ static void intel_disable_pipe(struct drm_i915_private *dev_priv,
>  	 * or we might hang the display.
>  	 */
>  	assert_planes_disabled(dev_priv, pipe);
> +	assert_cursor_disabled(dev_priv, pipe);
>  	assert_sprites_disabled(dev_priv, pipe);
>  
>  	/* Don't disable pipe A or pipe A PLLs if needed */
> @@ -3867,6 +3889,7 @@ static void intel_crtc_disable(struct drm_crtc *crtc)
>  	dev_priv->display.off(crtc);
>  
>  	assert_plane_disabled(dev->dev_private, to_intel_crtc(crtc)->plane);
> +	assert_cursor_disabled(dev_priv, to_intel_crtc(crtc)->pipe);
>  	assert_pipe_disabled(dev->dev_private, to_intel_crtc(crtc)->pipe);
>  
>  	if (crtc->fb) {
> -- 
> 1.7.9.5
Daniel Vetter Sept. 13, 2013, 12:59 p.m. UTC | #3
On Fri, Sep 13, 2013 at 02:57:37PM +0300, Ville Syrjälä wrote:
> On Fri, Sep 13, 2013 at 11:03:08AM +0300, Jani Nikula wrote:
> > The cursor is supposed to be disabled during crtc mode set (disabled by
> > ctrc disable). Assert this is the case.
> > 
> > v2: move cursor disabled assert next to plane asserts (Ville)
> > 
> > Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> 
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Queued for -next, thanks for the patch.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index d0137b6..0446dc7 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1069,6 +1069,26 @@  static void assert_panel_unlocked(struct drm_i915_private *dev_priv,
 	     pipe_name(pipe));
 }
 
+static void assert_cursor(struct drm_i915_private *dev_priv,
+			  enum pipe pipe, bool state)
+{
+	struct drm_device *dev = dev_priv->dev;
+	bool cur_state;
+
+	if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev))
+		cur_state = I915_READ(CURCNTR_IVB(pipe)) & CURSOR_MODE;
+	else if (IS_845G(dev) || IS_I865G(dev))
+		cur_state = I915_READ(_CURACNTR) & CURSOR_ENABLE;
+	else
+		cur_state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE;
+
+	WARN(cur_state != state,
+	     "cursor on pipe %c assertion failure (expected %s, current %s)\n",
+	     pipe_name(pipe), state_string(state), state_string(cur_state));
+}
+#define assert_cursor_enabled(d, p) assert_cursor(d, p, true)
+#define assert_cursor_disabled(d, p) assert_cursor(d, p, false)
+
 void assert_pipe(struct drm_i915_private *dev_priv,
 		 enum pipe pipe, bool state)
 {
@@ -1670,6 +1690,7 @@  static void intel_enable_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
 	u32 val;
 
 	assert_planes_disabled(dev_priv, pipe);
+	assert_cursor_disabled(dev_priv, pipe);
 	assert_sprites_disabled(dev_priv, pipe);
 
 	if (HAS_PCH_LPT(dev_priv->dev))
@@ -1731,6 +1752,7 @@  static void intel_disable_pipe(struct drm_i915_private *dev_priv,
 	 * or we might hang the display.
 	 */
 	assert_planes_disabled(dev_priv, pipe);
+	assert_cursor_disabled(dev_priv, pipe);
 	assert_sprites_disabled(dev_priv, pipe);
 
 	/* Don't disable pipe A or pipe A PLLs if needed */
@@ -3867,6 +3889,7 @@  static void intel_crtc_disable(struct drm_crtc *crtc)
 	dev_priv->display.off(crtc);
 
 	assert_plane_disabled(dev->dev_private, to_intel_crtc(crtc)->plane);
+	assert_cursor_disabled(dev_priv, to_intel_crtc(crtc)->pipe);
 	assert_pipe_disabled(dev->dev_private, to_intel_crtc(crtc)->pipe);
 
 	if (crtc->fb) {