Patch "drm/i915: Add .get_hw_state() method for planes" has been added to the 4.14-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
drm/i915: Add .get_hw_state() method for planes
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
drm-i915-add-.get_hw_state-method-for-planes.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
d87ce76402950b8e4d5117276d44465658e886a4Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= <[email protected]>
Date: Fri, 17 Nov 2017 21:19:08 +0200
Subject: drm/i915: Add .get_hw_state() method for planes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Ville Syrjälä <[email protected]>
commit d87ce76402950b8e4d5117276d44465658e886a4 upstream.
Add a .get_hw_state() method for planes, returning true or false depending on whether the plane is enabled. Use it to rewrite the plane enabled/disabled asserts in platform agnostic fashion.
We do lose the pre-gen4 plane<->pipe mapping checks, but since we're supposed sanitize that anyway it doesn't really matter.
v2: Reoder patches to not depend on enum old_plane_id
Just call assert_plane_disabled() from assert_planes_disabled()
v3: Deal with disabled power wells in .get_hw_state()
v4: Rebase due skl primary plane code removal
--- drivers/gpu/drm/i915/intel_display.c | 188 ++++++++++++++++------------------- drivers/gpu/drm/i915/intel_drv.h | 2 drivers/gpu/drm/i915/intel_sprite.c | 83 +++++++++++++++ 3 files changed, 175 insertions(+), 98 deletions(-)
drivers/gpu/drm/i915/intel_display.c +90 -98
@@ -1211,23 +1211,6 @@ void assert_panel_unlocked(struct drm_i9 pipe_name(pipe)); } -static void assert_cursor (struct drm_i915_private *dev_priv, -enum pipe pipe,bool state) -{ -bool cur_state; - -if (IS_I845G (dev_priv) ||IS_I865G (dev_priv)) - cur_state =I915_READ (CURCNTR (PIPE_A )) &CURSOR_ENABLE ; -else - cur_state =I915_READ (CURCNTR (pipe)) &CURSOR_MODE ; - -I915_STATE_WARN (cur_state != state, -"cursor on pipe %c assertion failure (expected %s, current %s)\n" , -pipe_name (pipe),onoff (state),onoff (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) {
@@ -1255,77 +1238,25 @@ void assert_pipe(struct drm_i915_private pipe_name(pipe), onoff(state), onoff(cur_state)); } -static void assert_plane (struct drm_i915_private *dev_priv, -enum plane plane,bool state) +static void assert_plane (struct intel_plane *plane,bool state) { -u32 val; -bool cur_state; +bool cur_state = plane->get_hw_state (plane); - val =I915_READ (DSPCNTR (plane)); - cur_state = !!(val &DISPLAY_PLANE_ENABLE );I915_STATE_WARN (cur_state != state, -"plane %c assertion failure (expected %s, current %s)\n" , -plane_name (plane),onoff (state),onoff (cur_state)); +"%s assertion failure (expected %s, current %s)\n" , + plane->base.name,onoff (state),onoff (cur_state)); } -#define assert_plane_enabled (d, p) assert_plane(d, p, true) -#define assert_plane_disabled (d, p) assert_plane(d, p, false) - -static void assert_planes_disabled (struct drm_i915_private *dev_priv, -enum pipe pipe) -{ -int i; - -/* Primary planes are fixed to pipes on gen4+ */ -if (INTEL_GEN (dev_priv) >=4 ) { -u32 val =I915_READ (DSPCNTR (pipe)); -I915_STATE_WARN (val &DISPLAY_PLANE_ENABLE , -"plane %c assertion failure, should be disabled but not\n" , -plane_name (pipe)); -return ; - } - -/* Need to check both planes against the pipe */ -for_each_pipe (dev_priv, i) { -u32 val =I915_READ (DSPCNTR (i)); -enum pipe cur_pipe = (val &DISPPLANE_SEL_PIPE_MASK ) >> -DISPPLANE_SEL_PIPE_SHIFT ; -I915_STATE_WARN ((val &DISPLAY_PLANE_ENABLE ) && pipe == cur_pipe, -"plane %c assertion failure, should be off on pipe %c but is still active\n" , -plane_name (i),pipe_name (pipe)); - } -} +#define assert_plane_enabled (p) assert_plane(p, true) +#define assert_plane_disabled (p) assert_plane(p, false) -static void assert_sprites_disabled (struct drm_i915_private *dev_priv, -enum pipe pipe) +static void assert_planes_disabled (struct intel_crtc *crtc) { -int sprite; +struct drm_i915_private *dev_priv =to_i915 (crtc->base.dev); +struct intel_plane *plane; -if (INTEL_GEN (dev_priv) >=9 ) { -for_each_sprite (dev_priv, pipe, sprite) { -u32 val =I915_READ (PLANE_CTL (pipe, sprite)); -I915_STATE_WARN (val &PLANE_CTL_ENABLE , -"plane %d assertion failure, should be off on pipe %c but is still active\n" , - sprite,pipe_name (pipe)); - } - }else if (IS_VALLEYVIEW (dev_priv) ||IS_CHERRYVIEW (dev_priv)) { -for_each_sprite (dev_priv, pipe, sprite) { -u32 val =I915_READ (SPCNTR (pipe,PLANE_SPRITE0 + sprite)); -I915_STATE_WARN (val &SP_ENABLE , -"sprite %c assertion failure, should be off on pipe %c but is still active\n" , -sprite_name (pipe, sprite),pipe_name (pipe)); - } - }else if (INTEL_GEN (dev_priv) >=7 ) { -u32 val =I915_READ (SPRCTL (pipe)); -I915_STATE_WARN (val &SPRITE_ENABLE , -"sprite %c assertion failure, should be off on pipe %c but is still active\n" , -plane_name (pipe),pipe_name (pipe)); - }else if (INTEL_GEN (dev_priv) >=5 ||IS_G4X (dev_priv)) { -u32 val =I915_READ (DVSCNTR (pipe)); -I915_STATE_WARN (val &DVS_ENABLE , -"sprite %c assertion failure, should be off on pipe %c but is still active\n" , -plane_name (pipe),pipe_name (pipe)); - } +for_each_intel_plane_on_crtc (&dev_priv->drm, crtc, plane) +assert_plane_disabled (plane); }static void assert_vblank_disabled (struct drm_crtc *crtc)
@@ -1926,9 +1857,7 @@ static void intel_enable_pipe(struct intDRM_DEBUG_KMS ("enabling pipe %c\n" ,pipe_name (pipe)); -assert_planes_disabled (dev_priv, pipe); -assert_cursor_disabled (dev_priv, pipe); -assert_sprites_disabled (dev_priv, pipe); +assert_planes_disabled (crtc);/* * A pipe without a PLL won't actually be able to drive bits from
@@ -1997,9 +1926,7 @@ static void intel_disable_pipe(struct in* Make sure planes won't keep trying to pump pixels to us, * or we might hang the display. */ -assert_planes_disabled (dev_priv, pipe); -assert_cursor_disabled (dev_priv, pipe); -assert_sprites_disabled (dev_priv, pipe); +assert_planes_disabled (crtc); reg =PIPECONF (cpu_transcoder); val =I915_READ (reg);
@@ -3397,6 +3324,31 @@ static void i9xx_disable_primary_plane(sspin_unlock_irqrestore (&dev_priv->uncore.lock, irqflags); } +static bool i9xx_plane_get_hw_state (struct intel_plane *primary) +{ + +struct drm_i915_private *dev_priv =to_i915 (primary->base.dev); +enum intel_display_power_domain power_domain; +enum plane plane = primary->plane; +enum pipe pipe = primary->pipe; +bool ret; + +/* +* Not 100% correct for planes that can move between pipes, +* but that's only the case for gen2-4 which don't have any +* display power wells. +*/ + power_domain =POWER_DOMAIN_PIPE (pipe); +if (!intel_display_power_get_if_enabled (dev_priv, power_domain)) +return false; + + ret =I915_READ (DSPCNTR (plane)) &DISPLAY_PLANE_ENABLE ; + +intel_display_power_put (dev_priv, power_domain); + +return ret; +} +static u32 intel_fb_stride_alignment (const struct drm_framebuffer *fb,int plane) {
@@ -4973,7 +4925,8 @@ void hsw_enable_ips(struct intel_crtc *c* a vblank wait. */ -assert_plane_enabled (dev_priv, crtc->plane); +assert_plane_enabled (to_intel_plane (crtc->base.primary)); +if (IS_BROADWELL (dev_priv)) {mutex_lock (&dev_priv->rps.hw_lock);WARN_ON (sandybridge_pcode_write (dev_priv,DISPLAY_IPS_CONTROL ,0xc0000000 ));
@@ -5005,7 +4958,8 @@ void hsw_disable_ips(struct intel_crtc *if (!crtc->config->ips_enabled)return ; -assert_plane_enabled (dev_priv, crtc->plane); +assert_plane_enabled (to_intel_plane (crtc->base.primary)); +if (IS_BROADWELL (dev_priv)) {mutex_lock (&dev_priv->rps.hw_lock);WARN_ON (sandybridge_pcode_write (dev_priv,DISPLAY_IPS_CONTROL ,0 ));
@@ -9577,6 +9531,23 @@ static void i845_disable_cursor(struct ii845_update_cursor (plane,NULL ,NULL ); } +static bool i845_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); +enum intel_display_power_domain power_domain; +bool ret; + + power_domain =POWER_DOMAIN_PIPE (PIPE_A ); +if (!intel_display_power_get_if_enabled (dev_priv, power_domain)) +return false; + + ret =I915_READ (CURCNTR (PIPE_A )) &CURSOR_ENABLE ; + +intel_display_power_put (dev_priv, power_domain); + +return ret; +} +static u32 i9xx_cursor_ctl (const struct intel_crtc_state *crtc_state,const struct intel_plane_state *plane_state) {
@@ -9770,6 +9741,28 @@ static void i9xx_disable_cursor(struct ii9xx_update_cursor (plane,NULL ,NULL ); } +static bool i9xx_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); +enum intel_display_power_domain power_domain; +enum pipe pipe = plane->pipe; +bool ret; + +/* +* Not 100% correct for planes that can move between pipes, +* but that's only the case for gen2-3 which don't have any +* display power wells. +*/ + power_domain =POWER_DOMAIN_PIPE (pipe); +if (!intel_display_power_get_if_enabled (dev_priv, power_domain)) +return false; + + ret =I915_READ (CURCNTR (pipe)) &CURSOR_MODE ; + +intel_display_power_put (dev_priv, power_domain); + +return ret; +}/* VESA 640x480x72Hz mode to set on the pipe */ static struct drm_display_mode load_detect_mode = {
@@ -13240,6 +13233,7 @@ intel_primary_plane_create(struct drm_i9 primary->update_plane = skylake_update_primary_plane; primary->disable_plane = skylake_disable_primary_plane; + primary->get_hw_state = skl_plane_get_hw_state; }else if (INTEL_GEN (dev_priv) >=9 ) { intel_primary_formats = skl_primary_formats; num_formats =ARRAY_SIZE (skl_primary_formats);
@@ -13250,6 +13244,7 @@ intel_primary_plane_create(struct drm_i9 primary->update_plane = skylake_update_primary_plane; primary->disable_plane = skylake_disable_primary_plane; + primary->get_hw_state = skl_plane_get_hw_state; }else if (INTEL_GEN (dev_priv) >=4 ) { intel_primary_formats = i965_primary_formats; num_formats =ARRAY_SIZE (i965_primary_formats);
@@ -13257,6 +13252,7 @@ intel_primary_plane_create(struct drm_i9 primary->update_plane = i9xx_update_primary_plane; primary->disable_plane = i9xx_disable_primary_plane; + primary->get_hw_state = i9xx_plane_get_hw_state; }else { intel_primary_formats = i8xx_primary_formats; num_formats =ARRAY_SIZE (i8xx_primary_formats);
@@ -13264,6 +13260,7 @@ intel_primary_plane_create(struct drm_i9 primary->update_plane = i9xx_update_primary_plane; primary->disable_plane = i9xx_disable_primary_plane; + primary->get_hw_state = i9xx_plane_get_hw_state; }if (INTEL_GEN (dev_priv) >=9 )
@@ -13353,10 +13350,12 @@ intel_cursor_plane_create(struct drm_i91if (IS_I845G (dev_priv) ||IS_I865G (dev_priv)) { cursor->update_plane = i845_update_cursor; cursor->disable_plane = i845_disable_cursor; + cursor->get_hw_state = i845_cursor_get_hw_state; cursor->check_plane = i845_check_cursor; }else { cursor->update_plane = i9xx_update_cursor; cursor->disable_plane = i9xx_disable_cursor; + cursor->get_hw_state = i9xx_cursor_get_hw_state; cursor->check_plane = i9xx_check_cursor; }
@@ -14704,8 +14703,8 @@ void i830_disable_pipe(struct drm_i915_pDRM_DEBUG_KMS ("disabling pipe %c due to force quirk\n" ,pipe_name (pipe)); -assert_plane_disabled (dev_priv,PLANE_A ); -assert_plane_disabled (dev_priv,PLANE_B ); +assert_planes_disabled (intel_get_crtc_for_pipe (dev_priv,PIPE_A )); +assert_planes_disabled (intel_get_crtc_for_pipe (dev_priv,PIPE_B ));I915_WRITE (PIPECONF (pipe),0 );POSTING_READ (PIPECONF (pipe));
@@ -14918,20 +14917,13 @@ void i915_redisable_vga(struct drm_i915_intel_display_power_put (dev_priv,POWER_DOMAIN_VGA ); } -static bool primary_get_hw_state (struct intel_plane *plane) -{ -struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); - -return I915_READ (DSPCNTR (plane->plane)) &DISPLAY_PLANE_ENABLE ; -} -/* FIXME read out full plane state for all planes */ static void readout_plane_state (struct intel_crtc *crtc) {struct intel_plane *primary =to_intel_plane (crtc->base.primary);bool visible; - visible = crtc->active &&primary_get_hw_state (primary); + visible = crtc->active && primary->get_hw_state (primary); intel_set_plane_visible(to_intel_crtc_state(crtc->base.state), to_intel_plane_state(primary->base.state),
drivers/gpu/drm/i915/intel_drv.h +2 -0
@@ -863,6 +863,7 @@ struct intel_plane { const struct intel_plane_state *plane_state);void (*disable_plane)(struct intel_plane *plane,struct intel_crtc *crtc); +bool (*get_hw_state)(struct intel_plane *plane);int (*check_plane)(struct intel_plane *plane,struct intel_crtc_state *crtc_state,struct intel_plane_state *state);
@@ -1885,6 +1886,7 @@ int intel_sprite_set_colorkey(struct drm struct drm_file *file_priv);void intel_pipe_update_start (struct intel_crtc *crtc);void intel_pipe_update_end (struct intel_crtc *crtc); +bool skl_plane_get_hw_state (struct intel_plane *plane);/* intel_tv.c */ void intel_tv_init (struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_sprite.c +83 -0
137 lines not on this page · raw message
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/drm-i915-redo-plane-sanitation-during-readout.patch queue-4.14/drm-i915-add-.get_hw_state-method-for-planes.patch queue-4.14/drm-i915-fix-deadlock-in-i830_disable_pipe.patch