drm/i915: Assign hwmode after encoder state readout
Subsystems (2)
PATCH 1/4 drm/i915: Assign hwmode after encoder state readout
From: Ville Syrjälä <[email protected]>
The dotclock is often calculated in encoder .get_config(), so we shouldn't copy the adjusted_mode to hwmode until we have read out the dotclock.
Gets rid of some warnings like these:
[drm:drm_calc_timestamping_constants [drm]] *ERROR* crtc 21: Can't calculate constants, dotclock = 0! [drm:i915_get_vblank_timestamp] crtc 0 is disabled
v2: Steal Maarten's idea to move crtc->mode etc. assignment too
--- drivers/gpu/drm/i915/intel_display.c | 57 +++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 27 deletions(-)
drivers/gpu/drm/i915/intel_display.c +30 -27
@@ -15094,33 +15094,6 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) crtc->base.state->active = crtc->active; crtc->base.enabled = crtc->active; -memset (&crtc->base.mode,0 ,sizeof (crtc->base.mode)); -if (crtc->base.state->active) { -intel_mode_from_pipe_config (&crtc->base.mode, crtc->config); -intel_mode_from_pipe_config (&crtc->base.state->adjusted_mode, crtc->config); -WARN_ON (drm_atomic_set_mode_for_crtc (crtc->base.state, &crtc->base.mode)); - -/* -* The initial mode needs to be set in order to keep -* the atomic core happy. It wants a valid mode if the -* crtc's enabled, so we do the above call. -* -* At this point some state updated by the connectors -* in their ->detect() callback has not run yet, so -* no recalculation can be done yet. -* -* Even if we could do a recalculation and modeset -* right now it would cause a double modeset if -* fbdev or userspace chooses a different initial mode. -* -* If that happens, someone indicated they wanted a -* mode change, which means it's safe to do a full -* recalculation. -*/ - crtc->base.state->mode.private_flags =I915_MODE_FLAG_INHERITED ; - } - - crtc->base.hwmode = crtc->config->base.adjusted_mode;readout_plane_state (crtc,to_intel_crtc_state (crtc->base.state)); DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n",
@@ -15180,6 +15153,36 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) connector->base.name, connector->base.encoder ? "enabled" : "disabled"); } + +for_each_intel_crtc (dev, crtc) { + crtc->base.hwmode = crtc->config->base.adjusted_mode; + +memset (&crtc->base.mode,0 ,sizeof (crtc->base.mode)); +if (crtc->base.state->active) { +intel_mode_from_pipe_config (&crtc->base.mode, crtc->config); +intel_mode_from_pipe_config (&crtc->base.state->adjusted_mode, crtc->config); +WARN_ON (drm_atomic_set_mode_for_crtc (crtc->base.state, &crtc->base.mode)); + +/* +* The initial mode needs to be set in order to keep +* the atomic core happy. It wants a valid mode if the +* crtc's enabled, so we do the above call. +* +* At this point some state updated by the connectors +* in their ->detect() callback has not run yet, so +* no recalculation can be done yet. +* +* Even if we could do a recalculation and modeset +* right now it would cause a double modeset if +* fbdev or userspace chooses a different initial mode. +* +* If that happens, someone indicated they wanted a +* mode change, which means it's safe to do a full +* recalculation. +*/ + crtc->base.state->mode.private_flags =I915_MODE_FLAG_INHERITED ; + } + } }/* Scan out the current hw modeset state,
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/4 drm/i915: Move sprite/cursor plane disable to intel_sanitize_crtc()
From: Ville Syrjälä <[email protected]>
Move the sprite/cursor plane disabling to occur in intel_sanitize_crtc() where it belongs instead of doing it in intel_modeset_readout_hw_state().
The plane disabling was first added in 4cf0ebbd4fafbdf8e6431dbb315e5511c3efdc3b drm/i915: Rework plane readout.
I got the idea from some patches from Partik and/or Maarten but those moved also the plane state readout to intel_sanitize_crtc() which isn't quite right in my opinion.
--- drivers/gpu/drm/i915/intel_display.c | 44 ++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/intel_display.c +20 -24
@@ -14878,9 +14878,19 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)/* restore vblank interrupts to correct state */ drm_crtc_vblank_reset (&crtc->base);if (crtc->active) { +struct intel_plane *plane; +drm_calc_timestamping_constants (&crtc->base, &crtc->base.hwmode);update_scanline_offset (crtc);drm_crtc_vblank_on (&crtc->base); + +/* Disable everything but the primary plane */ +for_each_intel_plane_on_crtc (dev, crtc, plane) { +if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY ) +continue ; + + plane->disable_plane (&plane->base, &crtc->base); + } }/* We need to sanitize the plane -> pipe mapping first because this will
@@ -15043,35 +15053,21 @@ void i915_redisable_vga(struct drm_device *dev)i915_redisable_vga_power_on (dev); } -static bool primary_get_hw_state (struct intel_crtc *crtc) +static bool primary_get_hw_state (struct intel_plane *plane) { -struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); -return !!(I915_READ (DSPCNTR (crtc->plane)) &DISPLAY_PLANE_ENABLE ); +return I915_READ (DSPCNTR (plane->plane)) &DISPLAY_PLANE_ENABLE ; } -static void readout_plane_state (struct intel_crtc *crtc, -struct intel_crtc_state *crtc_state) +/* FIXME read out full plane state for all planes */ +static void readout_plane_state (struct intel_crtc *crtc) { -struct intel_plane *p; -struct intel_plane_state *plane_state; -bool active = crtc_state->base.active; +struct intel_plane_state *plane_state = +to_intel_plane_state (crtc->base.primary->state); -for_each_intel_plane (crtc->base.dev, p) { -if (crtc->pipe != p->pipe) -continue ; - - plane_state =to_intel_plane_state (p->base.state); - -if (p->base.type ==DRM_PLANE_TYPE_PRIMARY ) - plane_state->visible =primary_get_hw_state (crtc); -else { -if (active) - p->disable_plane (&p->base, &crtc->base); - - plane_state->visible = false; - } - } + plane_state->visible = +primary_get_hw_state (to_intel_plane (crtc->base.primary)); }static void intel_modeset_readout_hw_state (struct drm_device *dev)
@@ -15094,7 +15090,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) crtc->base.state->active = crtc->active; crtc->base.enabled = crtc->active; -readout_plane_state (crtc,to_intel_crtc_state (crtc->base.state)); +readout_plane_state (crtc); DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n", crtc->base.base.id,
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/4] drm/i915: Move sprite/cursor plane disable to intel_sanitize_crtc()
Quoted 11 lines · On Thu, Sep 10, 2015 at 06:59:08PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Move the sprite/cursor plane disabling to occur in
intel_sanitize_crtc()where it belongs instead of doing it inintel_modeset_readout_hw_state().The plane disabling was first added in
4cf0ebbd4fafbdf8e6431dbb315e5511c3efdc3bdrm/i915: Rework plane readout.I got the idea from some patches from Partik and/or Maarten but those moved also the plane state readout to
intel_sanitize_crtc()which isn't quite right in my opinion.
I agree, this is better.
Probably related bug report:
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91910
Quoted 89 lines
Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 44 ++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 24 deletions(-)drivers/gpu/drm/i915/intel_display.c +20
-24@@ -14878,9 +14878,19 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)/* restore vblank interrupts to correct state */ drm_crtc_vblank_reset (&crtc->base);if (crtc->active) { +struct intel_plane *plane; +drm_calc_timestamping_constants (&crtc->base, &crtc->base.hwmode);update_scanline_offset (crtc);drm_crtc_vblank_on (&crtc->base); + +/* Disable everything but the primary plane */ +for_each_intel_plane_on_crtc (dev, crtc, plane) { +if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY ) +continue ; + + plane->disable_plane (&plane->base, &crtc->base); + } }/* We need to sanitize the plane -> pipe mapping first because this will @@ -15043,35 +15053,21 @@ void i915_redisable_vga(struct drm_device *dev)i915_redisable_vga_power_on (dev); } -static bool primary_get_hw_state (struct intel_crtc *crtc) +static bool primary_get_hw_state (struct intel_plane *plane) { -struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); -return !!(I915_READ (DSPCNTR (crtc->plane)) &DISPLAY_PLANE_ENABLE ); +return I915_READ (DSPCNTR (plane->plane)) &DISPLAY_PLANE_ENABLE ; } -static void readout_plane_state (struct intel_crtc *crtc, -struct intel_crtc_state *crtc_state) +/* FIXME read out full plane state for all planes */ +static void readout_plane_state (struct intel_crtc *crtc) { -struct intel_plane *p; -struct intel_plane_state *plane_state; -bool active = crtc_state->base.active; +struct intel_plane_state *plane_state = +to_intel_plane_state (crtc->base.primary->state); -for_each_intel_plane (crtc->base.dev, p) { -if (crtc->pipe != p->pipe) -continue ; - - plane_state =to_intel_plane_state (p->base.state); - -if (p->base.type ==DRM_PLANE_TYPE_PRIMARY ) - plane_state->visible =primary_get_hw_state (crtc); -else { -if (active) - p->disable_plane (&p->base, &crtc->base); - - plane_state->visible = false; - } - } + plane_state->visible = +primary_get_hw_state (to_intel_plane (crtc->base.primary)); }static void intel_modeset_readout_hw_state (struct drm_device *dev)@@ -15094,7 +15090,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) crtc->base.state->active = crtc->active; crtc->base.enabled = crtc->active; -readout_plane_state (crtc,to_intel_crtc_state (crtc->base.state)); +readout_plane_state (crtc); DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n", crtc->base.base.id,Signature · 1 line
2.4.6
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 drm/i915: Add .get_hw_state() method for planes
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Add a .get_hw_state() method for planes, returning true or false depending on whether the plane is enabled. Use it to populate the plane state 'visible' during state readout.
--- drivers/gpu/drm/i915/intel_display.c | 67 ++++++++++++++++++++++++++++-------- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_sprite.c | 37 ++++++++++++++++++++ 3 files changed, 91 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_display.c +53 -14
@@ -2841,6 +2841,13 @@ static void ironlake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (reg); } +static bool i9xx_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (DSPSURF (plane->plane)) &DISPLAY_PLANE_ENABLE ; +} +u32 intel_fb_stride_alignment (struct drm_device *dev,uint64_t fb_modifier,uint32_t pixel_format) {
@@ -3104,6 +3111,13 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (PLANE_SURF (pipe,0 )); } +static bool skylake_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (PLANE_CTL (plane->pipe,0 )) &PLANE_CTL_ENABLE ; +} +/* Assume fb object is pinned & idle & fenced and just update base pointers */ static int intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,
@@ -9862,6 +9876,13 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base) } } +static bool i845_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (_CURACNTR) &CURSOR_ENABLE ; +} +static void i9xx_update_cursor (struct drm_crtc *crtc,u32 base) {struct drm_device *dev = crtc->dev;
@@ -9909,6 +9930,13 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) intel_crtc->cursor_base = base; } +static bool i9xx_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (CURCNTR (plane->pipe)) &CURSOR_MODE ; +} +/* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */ static void intel_crtc_update_cursor (struct drm_crtc *crtc,bool on)
@@ -13518,12 +13546,17 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, } primary->pipe = pipe; primary->plane = pipe; +if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) + primary->plane = !pipe; primary->frontbuffer_bit =INTEL_FRONTBUFFER_PRIMARY (pipe); primary->check_plane = intel_check_primary_plane; primary->commit_plane = intel_commit_primary_plane; primary->disable_plane = intel_disable_primary_plane; -if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) - primary->plane = !pipe; + +if (INTEL_INFO (dev)->gen >=9 ) + primary->get_hw_state = skylake_primary_get_hw_state; +else + primary->get_hw_state = i9xx_primary_get_hw_state;if (INTEL_INFO (dev)->gen >=9 ) { intel_primary_formats = skl_primary_formats;
@@ -13679,6 +13712,11 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, cursor->commit_plane = intel_commit_cursor_plane; cursor->disable_plane = intel_disable_cursor_plane; +if (IS_845G (dev) ||IS_I865G (dev)) + cursor->get_hw_state = i845_cursor_get_hw_state; +else + cursor->get_hw_state = i9xx_cursor_get_hw_state; + drm_universal_plane_init(dev, &cursor->base, 0, &intel_plane_funcs, intel_cursor_formats,
@@ -14886,7 +14924,11 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)/* Disable everything but the primary plane */ for_each_intel_plane_on_crtc (dev, crtc, plane) { -if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY ) +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + +if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY || + !state->visible)continue ; plane->disable_plane (&plane->base, &crtc->base);
@@ -15053,21 +15095,18 @@ void i915_redisable_vga(struct drm_device *dev)i915_redisable_vga_power_on (dev); } -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_state *plane_state = -to_intel_plane_state (crtc->base.primary->state); +struct drm_device *dev = crtc->base.dev; +struct intel_plane *plane; - plane_state->visible = -primary_get_hw_state (to_intel_plane (crtc->base.primary)); +for_each_intel_plane_on_crtc (dev, crtc, plane) { +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + + state->visible = plane->get_hw_state (plane); + } }static void intel_modeset_readout_hw_state (struct drm_device *dev)
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -628,6 +628,7 @@ struct intel_plane { struct intel_plane_state *state);void (*commit_plane)(struct drm_plane *plane,struct intel_plane_state *state); +bool (*get_hw_state)(struct intel_plane *plane); };struct intel_watermark_params {
drivers/gpu/drm/i915/intel_sprite.c +37 -0
@@ -290,6 +290,15 @@ skl_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)intel_update_sprite_watermarks (dplane, crtc,0 ,0 ,0 , false, false); } +static bool +skl_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (PLANE_CTL (plane->pipe, + plane->plane +1 )) &PLANE_CTL_ENABLE ; +} +static void chv_update_csc (struct intel_plane *intel_plane,uint32_t format) {
@@ -469,6 +478,14 @@ vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)POSTING_READ (SPSURF (pipe, plane)); } +static bool +vlv_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (SPCNTR (plane->pipe, plane->plane)) &SP_ENABLE ; +} + static void ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb,
@@ -611,6 +628,14 @@ ivb_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)POSTING_READ (SPRSURF (pipe)); } +static bool +ivb_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (SPRCTL (plane->pipe)) &SPRITE_ENABLE ; +} + static void ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb,
@@ -739,6 +764,14 @@ ilk_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)POSTING_READ (DVSSURF (pipe)); } +static bool +ilk_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (DVSCNTR (plane->pipe)) &DVS_ENABLE ; +} + static int intel_check_sprite_plane(struct drm_plane *plane, struct intel_crtc_state *crtc_state,
@@ -1075,6 +1108,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) intel_plane->max_downscale =16 ; intel_plane->update_plane = ilk_update_plane; intel_plane->disable_plane = ilk_disable_plane; + intel_plane->get_hw_state = ilk_plane_get_hw_state;if (IS_GEN6 (dev)) { plane_formats = snb_plane_formats;
@@ -1098,12 +1132,14 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)if (IS_VALLEYVIEW (dev)) { intel_plane->update_plane = vlv_update_plane; intel_plane->disable_plane = vlv_disable_plane; + intel_plane->get_hw_state = vlv_plane_get_hw_state; plane_formats = vlv_plane_formats; num_plane_formats =ARRAY_SIZE (vlv_plane_formats); }else { intel_plane->update_plane = ivb_update_plane; intel_plane->disable_plane = ivb_disable_plane; + intel_plane->get_hw_state = ivb_plane_get_hw_state; plane_formats = snb_plane_formats; num_plane_formats =ARRAY_SIZE (snb_plane_formats);
@@ -1113,6 +1149,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) intel_plane->can_scale = true; intel_plane->update_plane = skl_update_plane; intel_plane->disable_plane = skl_disable_plane; + intel_plane->get_hw_state = skl_plane_get_hw_state; state->scaler_id =-1 ; plane_formats = skl_plane_formats;
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Add .get_hw_state() method for planes
Quoted 9 lines · On Thu, Sep 10, 2015 at 06:59:09PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add a .get_hw_state() method for planes, returning true or false depending on whether the plane is enabled. Use it to populate the plane state 'visible' during state readout.
Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>
Do we really need this? The plane readout is fairly limited and we don't really care about recovering anything but the initial primary plane on driver load. Anything else can just be nuked if it misfits ... -Daniel
Quoted 256 lines
--- drivers/gpu/drm/i915/intel_display.c | 67 ++++++++++++++++++++++++++++-------- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_sprite.c | 37 ++++++++++++++++++++ 3 files changed, 91 insertions(+), 14 deletions(-)drivers/gpu/drm/i915/intel_display.c +53
-14@@ -2841,6 +2841,13 @@ static void ironlake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (reg); } +static bool i9xx_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (DSPSURF (plane->plane)) &DISPLAY_PLANE_ENABLE ; +} +u32 intel_fb_stride_alignment (struct drm_device *dev,uint64_t fb_modifier,uint32_t pixel_format) {@@ -3104,6 +3111,13 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (PLANE_SURF (pipe,0 )); } +static bool skylake_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (PLANE_CTL (plane->pipe,0 )) &PLANE_CTL_ENABLE ; +} +/* Assume fb object is pinned & idle & fenced and just update base pointers */ static int intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -9862,6 +9876,13 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base) } } +static bool i845_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (_CURACNTR) &CURSOR_ENABLE ; +} +static void i9xx_update_cursor (struct drm_crtc *crtc,u32 base) {struct drm_device *dev = crtc->dev;@@ -9909,6 +9930,13 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) intel_crtc->cursor_base = base; } +static bool i9xx_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (CURCNTR (plane->pipe)) &CURSOR_MODE ; +} +/* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */ static void intel_crtc_update_cursor (struct drm_crtc *crtc,bool on)@@ -13518,12 +13546,17 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, } primary->pipe = pipe; primary->plane = pipe; +if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) + primary->plane = !pipe; primary->frontbuffer_bit =INTEL_FRONTBUFFER_PRIMARY (pipe); primary->check_plane = intel_check_primary_plane; primary->commit_plane = intel_commit_primary_plane; primary->disable_plane = intel_disable_primary_plane; -if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) - primary->plane = !pipe; + +if (INTEL_INFO (dev)->gen >=9 ) + primary->get_hw_state = skylake_primary_get_hw_state; +else + primary->get_hw_state = i9xx_primary_get_hw_state;if (INTEL_INFO (dev)->gen >=9 ) { intel_primary_formats = skl_primary_formats;@@ -13679,6 +13712,11 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, cursor->commit_plane = intel_commit_cursor_plane; cursor->disable_plane = intel_disable_cursor_plane; +if (IS_845G (dev) ||IS_I865G (dev)) + cursor->get_hw_state = i845_cursor_get_hw_state; +else + cursor->get_hw_state = i9xx_cursor_get_hw_state; + drm_universal_plane_init(dev, &cursor->base, 0, &intel_plane_funcs, intel_cursor_formats,@@ -14886,7 +14924,11 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)/* Disable everything but the primary plane */ for_each_intel_plane_on_crtc (dev, crtc, plane) { -if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY ) +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + +if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY || + !state->visible)continue ; plane->disable_plane (&plane->base, &crtc->base);@@ -15053,21 +15095,18 @@ void i915_redisable_vga(struct drm_device *dev)i915_redisable_vga_power_on (dev); } -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_state *plane_state = -to_intel_plane_state (crtc->base.primary->state); +struct drm_device *dev = crtc->base.dev; +struct intel_plane *plane; - plane_state->visible = -primary_get_hw_state (to_intel_plane (crtc->base.primary)); +for_each_intel_plane_on_crtc (dev, crtc, plane) { +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + + state->visible = plane->get_hw_state (plane); + } }static void intel_modeset_readout_hw_state (struct drm_device *dev)drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -628,6 +628,7 @@ struct intel_plane { struct intel_plane_state *state);void (*commit_plane)(struct drm_plane *plane,struct intel_plane_state *state); +bool (*get_hw_state)(struct intel_plane *plane); };struct intel_watermark_params {drivers/gpu/drm/i915/intel_sprite.c +37
-0@@ -290,6 +290,15 @@ skl_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)intel_update_sprite_watermarks (dplane, crtc,0 ,0 ,0 , false, false); } +static bool +skl_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (PLANE_CTL (plane->pipe, + plane->plane +1 )) &PLANE_CTL_ENABLE ; +} +static void chv_update_csc (struct intel_plane *intel_plane,uint32_t format) {@@ -469,6 +478,14 @@ vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)POSTING_READ (SPSURF (pipe, plane)); } +static bool +vlv_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (SPCNTR (plane->pipe, plane->plane)) &SP_ENABLE ; +} + static void ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -611,6 +628,14 @@ ivb_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)POSTING_READ (SPRSURF (pipe)); } +static bool +ivb_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (SPRCTL (plane->pipe)) &SPRITE_ENABLE ; +} + static void ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -739,6 +764,14 @@ ilk_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)POSTING_READ (DVSSURF (pipe)); } +static bool +ilk_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (DVSCNTR (plane->pipe)) &DVS_ENABLE ; +} + static int intel_check_sprite_plane(struct drm_plane *plane, struct intel_crtc_state *crtc_state,@@ -1075,6 +1108,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) intel_plane->max_downscale =16 ; intel_plane->update_plane = ilk_update_plane; intel_plane->disable_plane = ilk_disable_plane; + intel_plane->get_hw_state = ilk_plane_get_hw_state;if (IS_GEN6 (dev)) { plane_formats = snb_plane_formats;@@ -1098,12 +1132,14 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)if (IS_VALLEYVIEW (dev)) { intel_plane->update_plane = vlv_update_plane; intel_plane->disable_plane = vlv_disable_plane; + intel_plane->get_hw_state = vlv_plane_get_hw_state; plane_formats = vlv_plane_formats; num_plane_formats =ARRAY_SIZE (vlv_plane_formats); }else { intel_plane->update_plane = ivb_update_plane; intel_plane->disable_plane = ivb_disable_plane; + intel_plane->get_hw_state = ivb_plane_get_hw_state; plane_formats = snb_plane_formats; num_plane_formats =ARRAY_SIZE (snb_plane_formats);@@ -1113,6 +1149,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) intel_plane->can_scale = true; intel_plane->update_plane = skl_update_plane; intel_plane->disable_plane = skl_disable_plane; + intel_plane->get_hw_state = skl_plane_get_hw_state; state->scaler_id =-1 ; plane_formats = skl_plane_formats;Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Add .get_hw_state() method for planes
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · On Thu, Sep 10, 2015 at 06:59:09PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add a .get_hw_state() method for planes, returning true or false depending on whether the plane is enabled. Use it to populate the plane state 'visible' during state readout.
Quoted 7 lines
Quoted 3 lines
Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>Do we really need this? The plane readout is fairly limited and we don't really care about recovering anything but the initial primary plane on driver load. Anything else can just be nuked if it misfits ...
At least avoids calling ->disable_plane for an already disabled plane. We could even put a WARN there to catch broken code.
Quoted 263 lines
-Daniel
Quoted 256 lines
--- drivers/gpu/drm/i915/intel_display.c | 67 ++++++++++++++++++++++++++++-------- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_sprite.c | 37 ++++++++++++++++++++ 3 files changed, 91 insertions(+), 14 deletions(-)drivers/gpu/drm/i915/intel_display.c +53
-14@@ -2841,6 +2841,13 @@ static void ironlake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (reg); } +static bool i9xx_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (DSPSURF (plane->plane)) &DISPLAY_PLANE_ENABLE ; +} +u32 intel_fb_stride_alignment (struct drm_device *dev,uint64_t fb_modifier,uint32_t pixel_format) {@@ -3104,6 +3111,13 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (PLANE_SURF (pipe,0 )); } +static bool skylake_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (PLANE_CTL (plane->pipe,0 )) &PLANE_CTL_ENABLE ; +} +/* Assume fb object is pinned & idle & fenced and just update base pointers */ static int intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -9862,6 +9876,13 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base) } } +static bool i845_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (_CURACNTR) &CURSOR_ENABLE ; +} +static void i9xx_update_cursor (struct drm_crtc *crtc,u32 base) {struct drm_device *dev = crtc->dev;@@ -9909,6 +9930,13 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) intel_crtc->cursor_base = base; } +static bool i9xx_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (CURCNTR (plane->pipe)) &CURSOR_MODE ; +} +/* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */ static void intel_crtc_update_cursor (struct drm_crtc *crtc,bool on)@@ -13518,12 +13546,17 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, } primary->pipe = pipe; primary->plane = pipe; +if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) + primary->plane = !pipe; primary->frontbuffer_bit =INTEL_FRONTBUFFER_PRIMARY (pipe); primary->check_plane = intel_check_primary_plane; primary->commit_plane = intel_commit_primary_plane; primary->disable_plane = intel_disable_primary_plane; -if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) - primary->plane = !pipe; + +if (INTEL_INFO (dev)->gen >=9 ) + primary->get_hw_state = skylake_primary_get_hw_state; +else + primary->get_hw_state = i9xx_primary_get_hw_state;if (INTEL_INFO (dev)->gen >=9 ) { intel_primary_formats = skl_primary_formats;@@ -13679,6 +13712,11 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, cursor->commit_plane = intel_commit_cursor_plane; cursor->disable_plane = intel_disable_cursor_plane; +if (IS_845G (dev) ||IS_I865G (dev)) + cursor->get_hw_state = i845_cursor_get_hw_state; +else + cursor->get_hw_state = i9xx_cursor_get_hw_state; + drm_universal_plane_init(dev, &cursor->base, 0, &intel_plane_funcs, intel_cursor_formats,@@ -14886,7 +14924,11 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)/* Disable everything but the primary plane */ for_each_intel_plane_on_crtc (dev, crtc, plane) { -if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY ) +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + +if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY || + !state->visible)continue ; plane->disable_plane (&plane->base, &crtc->base);@@ -15053,21 +15095,18 @@ void i915_redisable_vga(struct drm_device *dev)i915_redisable_vga_power_on (dev); } -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_state *plane_state = -to_intel_plane_state (crtc->base.primary->state); +struct drm_device *dev = crtc->base.dev; +struct intel_plane *plane; - plane_state->visible = -primary_get_hw_state (to_intel_plane (crtc->base.primary)); +for_each_intel_plane_on_crtc (dev, crtc, plane) { +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + + state->visible = plane->get_hw_state (plane); + } }static void intel_modeset_readout_hw_state (struct drm_device *dev)drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -628,6 +628,7 @@ struct intel_plane { struct intel_plane_state *state);void (*commit_plane)(struct drm_plane *plane,struct intel_plane_state *state); +bool (*get_hw_state)(struct intel_plane *plane); };struct intel_watermark_params {drivers/gpu/drm/i915/intel_sprite.c +37
-0@@ -290,6 +290,15 @@ skl_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)intel_update_sprite_watermarks (dplane, crtc,0 ,0 ,0 , false, false); } +static bool +skl_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (PLANE_CTL (plane->pipe, + plane->plane +1 )) &PLANE_CTL_ENABLE ; +} +static void chv_update_csc (struct intel_plane *intel_plane,uint32_t format) {@@ -469,6 +478,14 @@ vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)POSTING_READ (SPSURF (pipe, plane)); } +static bool +vlv_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (SPCNTR (plane->pipe, plane->plane)) &SP_ENABLE ; +} + static void ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -611,6 +628,14 @@ ivb_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)POSTING_READ (SPRSURF (pipe)); } +static bool +ivb_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (SPRCTL (plane->pipe)) &SPRITE_ENABLE ; +} + static void ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -739,6 +764,14 @@ ilk_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)POSTING_READ (DVSSURF (pipe)); } +static bool +ilk_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (DVSCNTR (plane->pipe)) &DVS_ENABLE ; +} + static int intel_check_sprite_plane(struct drm_plane *plane, struct intel_crtc_state *crtc_state,@@ -1075,6 +1108,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) intel_plane->max_downscale =16 ; intel_plane->update_plane = ilk_update_plane; intel_plane->disable_plane = ilk_disable_plane; + intel_plane->get_hw_state = ilk_plane_get_hw_state;if (IS_GEN6 (dev)) { plane_formats = snb_plane_formats;@@ -1098,12 +1132,14 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)if (IS_VALLEYVIEW (dev)) { intel_plane->update_plane = vlv_update_plane; intel_plane->disable_plane = vlv_disable_plane; + intel_plane->get_hw_state = vlv_plane_get_hw_state; plane_formats = vlv_plane_formats; num_plane_formats =ARRAY_SIZE (vlv_plane_formats); }else { intel_plane->update_plane = ivb_update_plane; intel_plane->disable_plane = ivb_disable_plane; + intel_plane->get_hw_state = ivb_plane_get_hw_state; plane_formats = snb_plane_formats; num_plane_formats =ARRAY_SIZE (snb_plane_formats);@@ -1113,6 +1149,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) intel_plane->can_scale = true; intel_plane->update_plane = skl_update_plane; intel_plane->disable_plane = skl_disable_plane; + intel_plane->get_hw_state = skl_plane_get_hw_state; state->scaler_id =-1 ; plane_formats = skl_plane_formats;Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Add .get_hw_state() method for planes
Quoted 12 lines · Ville Syrjälä
Quoted 11 lines · Daniel Vetter
Quoted 9 lines · On Thu, Sep 10, 2015 at 06:59:09PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add a .get_hw_state() method for planes, returning true or false depending on whether the plane is enabled. Use it to populate the plane state 'visible' during state readout.
Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>
Quoted 6 lines
Quoted 3 lines
Do we really need this? The plane readout is fairly limited and we don't really care about recovering anything but the initial primary plane on driver load. Anything else can just be nuked if it misfits ...
At least avoids calling ->disable_plane for an already disabled plane. We could even put a WARN there to catch broken code.
Oh and we could also do something likefor_each_plane()
assert(visible == get_hw_state);
somewhere to perhaps catch even more crap.
Quoted 268 lines
Quoted 264 lines
-Daniel
Quoted 256 lines
--- drivers/gpu/drm/i915/intel_display.c | 67 ++++++++++++++++++++++++++++-------- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_sprite.c | 37 ++++++++++++++++++++ 3 files changed, 91 insertions(+), 14 deletions(-)drivers/gpu/drm/i915/intel_display.c +53
-14@@ -2841,6 +2841,13 @@ static void ironlake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (reg); } +static bool i9xx_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (DSPSURF (plane->plane)) &DISPLAY_PLANE_ENABLE ; +} +u32 intel_fb_stride_alignment (struct drm_device *dev,uint64_t fb_modifier,uint32_t pixel_format) {@@ -3104,6 +3111,13 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (PLANE_SURF (pipe,0 )); } +static bool skylake_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (PLANE_CTL (plane->pipe,0 )) &PLANE_CTL_ENABLE ; +} +/* Assume fb object is pinned & idle & fenced and just update base pointers */ static int intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -9862,6 +9876,13 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base) } } +static bool i845_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (_CURACNTR) &CURSOR_ENABLE ; +} +static void i9xx_update_cursor (struct drm_crtc *crtc,u32 base) {struct drm_device *dev = crtc->dev;@@ -9909,6 +9930,13 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) intel_crtc->cursor_base = base; } +static bool i9xx_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (CURCNTR (plane->pipe)) &CURSOR_MODE ; +} +/* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */ static void intel_crtc_update_cursor (struct drm_crtc *crtc,bool on)@@ -13518,12 +13546,17 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, } primary->pipe = pipe; primary->plane = pipe; +if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) + primary->plane = !pipe; primary->frontbuffer_bit =INTEL_FRONTBUFFER_PRIMARY (pipe); primary->check_plane = intel_check_primary_plane; primary->commit_plane = intel_commit_primary_plane; primary->disable_plane = intel_disable_primary_plane; -if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) - primary->plane = !pipe; + +if (INTEL_INFO (dev)->gen >=9 ) + primary->get_hw_state = skylake_primary_get_hw_state; +else + primary->get_hw_state = i9xx_primary_get_hw_state;if (INTEL_INFO (dev)->gen >=9 ) { intel_primary_formats = skl_primary_formats;@@ -13679,6 +13712,11 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, cursor->commit_plane = intel_commit_cursor_plane; cursor->disable_plane = intel_disable_cursor_plane; +if (IS_845G (dev) ||IS_I865G (dev)) + cursor->get_hw_state = i845_cursor_get_hw_state; +else + cursor->get_hw_state = i9xx_cursor_get_hw_state; + drm_universal_plane_init(dev, &cursor->base, 0, &intel_plane_funcs, intel_cursor_formats,@@ -14886,7 +14924,11 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)/* Disable everything but the primary plane */ for_each_intel_plane_on_crtc (dev, crtc, plane) { -if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY ) +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + +if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY || + !state->visible)continue ; plane->disable_plane (&plane->base, &crtc->base);@@ -15053,21 +15095,18 @@ void i915_redisable_vga(struct drm_device *dev)i915_redisable_vga_power_on (dev); } -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_state *plane_state = -to_intel_plane_state (crtc->base.primary->state); +struct drm_device *dev = crtc->base.dev; +struct intel_plane *plane; - plane_state->visible = -primary_get_hw_state (to_intel_plane (crtc->base.primary)); +for_each_intel_plane_on_crtc (dev, crtc, plane) { +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + + state->visible = plane->get_hw_state (plane); + } }static void intel_modeset_readout_hw_state (struct drm_device *dev)drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -628,6 +628,7 @@ struct intel_plane { struct intel_plane_state *state);void (*commit_plane)(struct drm_plane *plane,struct intel_plane_state *state); +bool (*get_hw_state)(struct intel_plane *plane); };struct intel_watermark_params {drivers/gpu/drm/i915/intel_sprite.c +37
-0@@ -290,6 +290,15 @@ skl_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)intel_update_sprite_watermarks (dplane, crtc,0 ,0 ,0 , false, false); } +static bool +skl_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (PLANE_CTL (plane->pipe, + plane->plane +1 )) &PLANE_CTL_ENABLE ; +} +static void chv_update_csc (struct intel_plane *intel_plane,uint32_t format) {@@ -469,6 +478,14 @@ vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)POSTING_READ (SPSURF (pipe, plane)); } +static bool +vlv_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (SPCNTR (plane->pipe, plane->plane)) &SP_ENABLE ; +} + static void ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -611,6 +628,14 @@ ivb_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)POSTING_READ (SPRSURF (pipe)); } +static bool +ivb_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (SPRCTL (plane->pipe)) &SPRITE_ENABLE ; +} + static void ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -739,6 +764,14 @@ ilk_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)POSTING_READ (DVSSURF (pipe)); } +static bool +ilk_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (DVSCNTR (plane->pipe)) &DVS_ENABLE ; +} + static int intel_check_sprite_plane(struct drm_plane *plane, struct intel_crtc_state *crtc_state,@@ -1075,6 +1108,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) intel_plane->max_downscale =16 ; intel_plane->update_plane = ilk_update_plane; intel_plane->disable_plane = ilk_disable_plane; + intel_plane->get_hw_state = ilk_plane_get_hw_state;if (IS_GEN6 (dev)) { plane_formats = snb_plane_formats;@@ -1098,12 +1132,14 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)if (IS_VALLEYVIEW (dev)) { intel_plane->update_plane = vlv_update_plane; intel_plane->disable_plane = vlv_disable_plane; + intel_plane->get_hw_state = vlv_plane_get_hw_state; plane_formats = vlv_plane_formats; num_plane_formats =ARRAY_SIZE (vlv_plane_formats); }else { intel_plane->update_plane = ivb_update_plane; intel_plane->disable_plane = ivb_disable_plane; + intel_plane->get_hw_state = ivb_plane_get_hw_state; plane_formats = snb_plane_formats; num_plane_formats =ARRAY_SIZE (snb_plane_formats);@@ -1113,6 +1149,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) intel_plane->can_scale = true; intel_plane->update_plane = skl_update_plane; intel_plane->disable_plane = skl_disable_plane; + intel_plane->get_hw_state = skl_plane_get_hw_state; state->scaler_id =-1 ; plane_formats = skl_plane_formats;Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.chSignature · 2 lines
Ville Syrjälä Intel OTC
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Add .get_hw_state() method for planes
Quoted 17 lines · Ville Syrjälä
Quoted 16 lines · Ville Syrjälä
Quoted 14 lines · Daniel Vetter
Quoted 9 lines · On Thu, Sep 10, 2015 at 06:59:09PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add a .get_hw_state() method for planes, returning true or false depending on whether the plane is enabled. Use it to populate the plane state 'visible' during state readout.
Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>Do we really need this? The plane readout is fairly limited and we don't really care about recovering anything but the initial primary plane on driver load. Anything else can just be nuked if it misfits ...
Quoted 8 lines
Quoted 2 lines
At least avoids calling ->disable_plane for an already disabled plane. We could even put a WARN there to catch broken code.
Oh and we could also do something like
for_each_plane()assert(visible == get_hw_state);somewhere to perhaps catch even more crap.
Yeah maybe, but I think that should be done as part of the patch series with this patch here. As-is I don't think it adds a lot really ... -Daniel
Quoted 274 lines
Quoted 270 lines
Quoted 266 lines
-Daniel
Quoted 256 lines
--- drivers/gpu/drm/i915/intel_display.c | 67 ++++++++++++++++++++++++++++-------- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_sprite.c | 37 ++++++++++++++++++++ 3 files changed, 91 insertions(+), 14 deletions(-)drivers/gpu/drm/i915/intel_display.c +53
-14@@ -2841,6 +2841,13 @@ static void ironlake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (reg); } +static bool i9xx_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (DSPSURF (plane->plane)) &DISPLAY_PLANE_ENABLE ; +} +u32 intel_fb_stride_alignment (struct drm_device *dev,uint64_t fb_modifier,uint32_t pixel_format) {@@ -3104,6 +3111,13 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (PLANE_SURF (pipe,0 )); } +static bool skylake_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (PLANE_CTL (plane->pipe,0 )) &PLANE_CTL_ENABLE ; +} +/* Assume fb object is pinned & idle & fenced and just update base pointers */ static int intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -9862,6 +9876,13 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base) } } +static bool i845_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (_CURACNTR) &CURSOR_ENABLE ; +} +static void i9xx_update_cursor (struct drm_crtc *crtc,u32 base) {struct drm_device *dev = crtc->dev;@@ -9909,6 +9930,13 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) intel_crtc->cursor_base = base; } +static bool i9xx_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (CURCNTR (plane->pipe)) &CURSOR_MODE ; +} +/* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */ static void intel_crtc_update_cursor (struct drm_crtc *crtc,bool on)@@ -13518,12 +13546,17 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, } primary->pipe = pipe; primary->plane = pipe; +if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) + primary->plane = !pipe; primary->frontbuffer_bit =INTEL_FRONTBUFFER_PRIMARY (pipe); primary->check_plane = intel_check_primary_plane; primary->commit_plane = intel_commit_primary_plane; primary->disable_plane = intel_disable_primary_plane; -if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) - primary->plane = !pipe; + +if (INTEL_INFO (dev)->gen >=9 ) + primary->get_hw_state = skylake_primary_get_hw_state; +else + primary->get_hw_state = i9xx_primary_get_hw_state;if (INTEL_INFO (dev)->gen >=9 ) { intel_primary_formats = skl_primary_formats;@@ -13679,6 +13712,11 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, cursor->commit_plane = intel_commit_cursor_plane; cursor->disable_plane = intel_disable_cursor_plane; +if (IS_845G (dev) ||IS_I865G (dev)) + cursor->get_hw_state = i845_cursor_get_hw_state; +else + cursor->get_hw_state = i9xx_cursor_get_hw_state; + drm_universal_plane_init(dev, &cursor->base, 0, &intel_plane_funcs, intel_cursor_formats,@@ -14886,7 +14924,11 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)/* Disable everything but the primary plane */ for_each_intel_plane_on_crtc (dev, crtc, plane) { -if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY ) +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + +if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY || + !state->visible)continue ; plane->disable_plane (&plane->base, &crtc->base);@@ -15053,21 +15095,18 @@ void i915_redisable_vga(struct drm_device *dev)i915_redisable_vga_power_on (dev); } -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_state *plane_state = -to_intel_plane_state (crtc->base.primary->state); +struct drm_device *dev = crtc->base.dev; +struct intel_plane *plane; - plane_state->visible = -primary_get_hw_state (to_intel_plane (crtc->base.primary)); +for_each_intel_plane_on_crtc (dev, crtc, plane) { +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + + state->visible = plane->get_hw_state (plane); + } }static void intel_modeset_readout_hw_state (struct drm_device *dev)drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -628,6 +628,7 @@ struct intel_plane { struct intel_plane_state *state);void (*commit_plane)(struct drm_plane *plane,struct intel_plane_state *state); +bool (*get_hw_state)(struct intel_plane *plane); };struct intel_watermark_params {drivers/gpu/drm/i915/intel_sprite.c +37
-0@@ -290,6 +290,15 @@ skl_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)intel_update_sprite_watermarks (dplane, crtc,0 ,0 ,0 , false, false); } +static bool +skl_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (PLANE_CTL (plane->pipe, + plane->plane +1 )) &PLANE_CTL_ENABLE ; +} +static void chv_update_csc (struct intel_plane *intel_plane,uint32_t format) {@@ -469,6 +478,14 @@ vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)POSTING_READ (SPSURF (pipe, plane)); } +static bool +vlv_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (SPCNTR (plane->pipe, plane->plane)) &SP_ENABLE ; +} + static void ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -611,6 +628,14 @@ ivb_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)POSTING_READ (SPRSURF (pipe)); } +static bool +ivb_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (SPRCTL (plane->pipe)) &SPRITE_ENABLE ; +} + static void ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -739,6 +764,14 @@ ilk_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)POSTING_READ (DVSSURF (pipe)); } +static bool +ilk_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (DVSCNTR (plane->pipe)) &DVS_ENABLE ; +} + static int intel_check_sprite_plane(struct drm_plane *plane, struct intel_crtc_state *crtc_state,@@ -1075,6 +1108,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) intel_plane->max_downscale =16 ; intel_plane->update_plane = ilk_update_plane; intel_plane->disable_plane = ilk_disable_plane; + intel_plane->get_hw_state = ilk_plane_get_hw_state;if (IS_GEN6 (dev)) { plane_formats = snb_plane_formats;@@ -1098,12 +1132,14 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)if (IS_VALLEYVIEW (dev)) { intel_plane->update_plane = vlv_update_plane; intel_plane->disable_plane = vlv_disable_plane; + intel_plane->get_hw_state = vlv_plane_get_hw_state; plane_formats = vlv_plane_formats; num_plane_formats =ARRAY_SIZE (vlv_plane_formats); }else { intel_plane->update_plane = ivb_update_plane; intel_plane->disable_plane = ivb_disable_plane; + intel_plane->get_hw_state = ivb_plane_get_hw_state; plane_formats = snb_plane_formats; num_plane_formats =ARRAY_SIZE (snb_plane_formats);@@ -1113,6 +1149,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) intel_plane->can_scale = true; intel_plane->update_plane = skl_update_plane; intel_plane->disable_plane = skl_disable_plane; + intel_plane->get_hw_state = skl_plane_get_hw_state; state->scaler_id =-1 ; plane_formats = skl_plane_formats;Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.chSignature · 2 lines
Ville Syrjälä Intel OTCSignature · 2 lines
Ville Syrjälä Intel OTC
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Add .get_hw_state() method for planes
Quoted 21 lines · Daniel Vetter
Quoted 20 lines · Ville Syrjälä
Quoted 18 lines · Ville Syrjälä
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · On Thu, Sep 10, 2015 at 06:59:09PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add a .get_hw_state() method for planes, returning true or false depending on whether the plane is enabled. Use it to populate the plane state 'visible' during state readout.
Quoted 7 lines
Quoted 3 lines
Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>Do we really need this? The plane readout is fairly limited and we don't really care about recovering anything but the initial primary plane on driver load. Anything else can just be nuked if it misfits ...
At least avoids calling ->disable_plane for an already disabled plane. We could even put a WARN there to catch broken code.
Quoted 8 lines
Quoted 5 lines
Oh and we could also do something like
for_each_plane()assert(visible == get_hw_state);somewhere to perhaps catch even more crap.
Yeah maybe, but I think that should be done as part of the patch series with this patch here. As-is I don't think it adds a lot really ...
It would at least fix SKL/BXT primary readout, which I forgot to mention in the commit message naturally.
Quoted 281 lines
-Daniel
Quoted 274 lines
Quoted 270 lines
Quoted 266 lines
-Daniel
Quoted 256 lines
--- drivers/gpu/drm/i915/intel_display.c | 67 ++++++++++++++++++++++++++++-------- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_sprite.c | 37 ++++++++++++++++++++ 3 files changed, 91 insertions(+), 14 deletions(-)drivers/gpu/drm/i915/intel_display.c +53
-14@@ -2841,6 +2841,13 @@ static void ironlake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (reg); } +static bool i9xx_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (DSPSURF (plane->plane)) &DISPLAY_PLANE_ENABLE ; +} +u32 intel_fb_stride_alignment (struct drm_device *dev,uint64_t fb_modifier,uint32_t pixel_format) {@@ -3104,6 +3111,13 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (PLANE_SURF (pipe,0 )); } +static bool skylake_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (PLANE_CTL (plane->pipe,0 )) &PLANE_CTL_ENABLE ; +} +/* Assume fb object is pinned & idle & fenced and just update base pointers */ static int intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -9862,6 +9876,13 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base) } } +static bool i845_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (_CURACNTR) &CURSOR_ENABLE ; +} +static void i9xx_update_cursor (struct drm_crtc *crtc,u32 base) {struct drm_device *dev = crtc->dev;@@ -9909,6 +9930,13 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) intel_crtc->cursor_base = base; } +static bool i9xx_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (CURCNTR (plane->pipe)) &CURSOR_MODE ; +} +/* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */ static void intel_crtc_update_cursor (struct drm_crtc *crtc,bool on)@@ -13518,12 +13546,17 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, } primary->pipe = pipe; primary->plane = pipe; +if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) + primary->plane = !pipe; primary->frontbuffer_bit =INTEL_FRONTBUFFER_PRIMARY (pipe); primary->check_plane = intel_check_primary_plane; primary->commit_plane = intel_commit_primary_plane; primary->disable_plane = intel_disable_primary_plane; -if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) - primary->plane = !pipe; + +if (INTEL_INFO (dev)->gen >=9 ) + primary->get_hw_state = skylake_primary_get_hw_state; +else + primary->get_hw_state = i9xx_primary_get_hw_state;if (INTEL_INFO (dev)->gen >=9 ) { intel_primary_formats = skl_primary_formats;@@ -13679,6 +13712,11 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, cursor->commit_plane = intel_commit_cursor_plane; cursor->disable_plane = intel_disable_cursor_plane; +if (IS_845G (dev) ||IS_I865G (dev)) + cursor->get_hw_state = i845_cursor_get_hw_state; +else + cursor->get_hw_state = i9xx_cursor_get_hw_state; + drm_universal_plane_init(dev, &cursor->base, 0, &intel_plane_funcs, intel_cursor_formats,@@ -14886,7 +14924,11 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)/* Disable everything but the primary plane */ for_each_intel_plane_on_crtc (dev, crtc, plane) { -if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY ) +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + +if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY || + !state->visible)continue ; plane->disable_plane (&plane->base, &crtc->base);@@ -15053,21 +15095,18 @@ void i915_redisable_vga(struct drm_device *dev)i915_redisable_vga_power_on (dev); } -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_state *plane_state = -to_intel_plane_state (crtc->base.primary->state); +struct drm_device *dev = crtc->base.dev; +struct intel_plane *plane; - plane_state->visible = -primary_get_hw_state (to_intel_plane (crtc->base.primary)); +for_each_intel_plane_on_crtc (dev, crtc, plane) { +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + + state->visible = plane->get_hw_state (plane); + } }static void intel_modeset_readout_hw_state (struct drm_device *dev)drivers/gpu/drm/i915/intel_drv.h +1
-0@@ -628,6 +628,7 @@ struct intel_plane { struct intel_plane_state *state);void (*commit_plane)(struct drm_plane *plane,struct intel_plane_state *state); +bool (*get_hw_state)(struct intel_plane *plane); };struct intel_watermark_params {drivers/gpu/drm/i915/intel_sprite.c +37
-0@@ -290,6 +290,15 @@ skl_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)intel_update_sprite_watermarks (dplane, crtc,0 ,0 ,0 , false, false); } +static bool +skl_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (PLANE_CTL (plane->pipe, + plane->plane +1 )) &PLANE_CTL_ENABLE ; +} +static void chv_update_csc (struct intel_plane *intel_plane,uint32_t format) {@@ -469,6 +478,14 @@ vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)POSTING_READ (SPSURF (pipe, plane)); } +static bool +vlv_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (SPCNTR (plane->pipe, plane->plane)) &SP_ENABLE ; +} + static void ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -611,6 +628,14 @@ ivb_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)POSTING_READ (SPRSURF (pipe)); } +static bool +ivb_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (SPRCTL (plane->pipe)) &SPRITE_ENABLE ; +} + static void ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -739,6 +764,14 @@ ilk_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)POSTING_READ (DVSSURF (pipe)); } +static bool +ilk_plane_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (DVSCNTR (plane->pipe)) &DVS_ENABLE ; +} + static int intel_check_sprite_plane(struct drm_plane *plane, struct intel_crtc_state *crtc_state,@@ -1075,6 +1108,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) intel_plane->max_downscale =16 ; intel_plane->update_plane = ilk_update_plane; intel_plane->disable_plane = ilk_disable_plane; + intel_plane->get_hw_state = ilk_plane_get_hw_state;if (IS_GEN6 (dev)) { plane_formats = snb_plane_formats;@@ -1098,12 +1132,14 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)if (IS_VALLEYVIEW (dev)) { intel_plane->update_plane = vlv_update_plane; intel_plane->disable_plane = vlv_disable_plane; + intel_plane->get_hw_state = vlv_plane_get_hw_state; plane_formats = vlv_plane_formats; num_plane_formats =ARRAY_SIZE (vlv_plane_formats); }else { intel_plane->update_plane = ivb_update_plane; intel_plane->disable_plane = ivb_disable_plane; + intel_plane->get_hw_state = ivb_plane_get_hw_state; plane_formats = snb_plane_formats; num_plane_formats =ARRAY_SIZE (snb_plane_formats);@@ -1113,6 +1149,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) intel_plane->can_scale = true; intel_plane->update_plane = skl_update_plane; intel_plane->disable_plane = skl_disable_plane; + intel_plane->get_hw_state = skl_plane_get_hw_state; state->scaler_id =-1 ; plane_formats = skl_plane_formats;Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.chSignature · 2 lines
Ville Syrjälä Intel OTCSignature · 2 lines
Ville Syrjälä Intel OTCSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Add .get_hw_state() method for planes
Quoted 26 lines · Ville Syrjälä
Quoted 25 lines · Daniel Vetter
Quoted 24 lines · Ville Syrjälä
Quoted 12 lines · Ville Syrjälä
Quoted 11 lines · Daniel Vetter
Quoted 9 lines · On Thu, Sep 10, 2015 at 06:59:09PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add a .get_hw_state() method for planes, returning true or false depending on whether the plane is enabled. Use it to populate the plane state 'visible' during state readout.
Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>Quoted 6 lines
Quoted 3 lines
Do we really need this? The plane readout is fairly limited and we don't really care about recovering anything but the initial primary plane on driver load. Anything else can just be nuked if it misfits ...
At least avoids calling ->disable_plane for an already disabled plane. We could even put a WARN there to catch broken code.
Oh and we could also do something like
for_each_plane()assert(visible == get_hw_state);
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
somewhere to perhaps catch even more crap.
Yeah maybe, but I think that should be done as part of the patch series with this patch here. As-is I don't think it adds a lot really ...
It would at least fix SKL/BXT primary readout, which I forgot to mention in the commit message naturally.
Yeah, please hide the bugfix less ;-) Adding ->get_hw_state shouldn't be the subject either, it should be something like "Add plane hw state readouf for skl" and the commit message then explains why you added a new vfunc.
And we should have some idea what to do about the get_initial_plane_config hook - having two very similar hooks is a bit confusing imo. -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Add .get_hw_state() method for planes
In reply to [email protected]Op 10-09-15 om 17:59 schreef [email protected]:
Quoted 139 lines
From: Ville Syrjälä <[email protected]>
Add a .get_hw_state() method for planes, returning true or false depending on whether the plane is enabled. Use it to populate the plane state 'visible' during state readout.
Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 67 ++++++++++++++++++++++++++++-------- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_sprite.c | 37 ++++++++++++++++++++ 3 files changed, 91 insertions(+), 14 deletions(-)drivers/gpu/drm/i915/intel_display.c +47
-12@@ -2841,6 +2841,13 @@ static void ironlake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (reg); } +static bool i9xx_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (DSPSURF (plane->plane)) &DISPLAY_PLANE_ENABLE ; +} +u32 intel_fb_stride_alignment (struct drm_device *dev,uint64_t fb_modifier,uint32_t pixel_format) {@@ -3104,6 +3111,13 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (PLANE_SURF (pipe,0 )); } +static bool skylake_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (PLANE_CTL (plane->pipe,0 )) &PLANE_CTL_ENABLE ; +} +/* Assume fb object is pinned & idle & fenced and just update base pointers */ static int intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -9862,6 +9876,13 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base) } } +static bool i845_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (_CURACNTR) &CURSOR_ENABLE ; +} +static void i9xx_update_cursor (struct drm_crtc *crtc,u32 base) {struct drm_device *dev = crtc->dev;@@ -9909,6 +9930,13 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) intel_crtc->cursor_base = base; } +static bool i9xx_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (CURCNTR (plane->pipe)) &CURSOR_MODE ; +} +/* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */ static void intel_crtc_update_cursor (struct drm_crtc *crtc,bool on)@@ -13518,12 +13546,17 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, } primary->pipe = pipe; primary->plane = pipe; +if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) + primary->plane = !pipe; primary->frontbuffer_bit =INTEL_FRONTBUFFER_PRIMARY (pipe); primary->check_plane = intel_check_primary_plane; primary->commit_plane = intel_commit_primary_plane; primary->disable_plane = intel_disable_primary_plane; -if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) - primary->plane = !pipe; + +if (INTEL_INFO (dev)->gen >=9 ) + primary->get_hw_state = skylake_primary_get_hw_state; +else + primary->get_hw_state = i9xx_primary_get_hw_state;if (INTEL_INFO (dev)->gen >=9 ) { intel_primary_formats = skl_primary_formats;@@ -13679,6 +13712,11 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, cursor->commit_plane = intel_commit_cursor_plane; cursor->disable_plane = intel_disable_cursor_plane; +if (IS_845G (dev) ||IS_I865G (dev)) + cursor->get_hw_state = i845_cursor_get_hw_state; +else + cursor->get_hw_state = i9xx_cursor_get_hw_state; + drm_universal_plane_init(dev, &cursor->base, 0, &intel_plane_funcs, intel_cursor_formats,@@ -14886,7 +14924,11 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)/* Disable everything but the primary plane */ for_each_intel_plane_on_crtc (dev, crtc, plane) { -if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY ) +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + +if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY || + !state->visible)continue ; plane->disable_plane (&plane->base, &crtc->base);@@ -15053,21 +15095,18 @@ void i915_redisable_vga(struct drm_device *dev)i915_redisable_vga_power_on (dev); } -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_state *plane_state = -to_intel_plane_state (crtc->base.primary->state); +struct drm_device *dev = crtc->base.dev; +struct intel_plane *plane;
drivers/gpu/drm/i915/intel_display.c void i915_redisable_vga(struct drm_device *dev) · line 15111
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +6
-2- plane_state->visible = -primary_get_hw_state (to_intel_plane (crtc->base.primary)); +for_each_intel_plane_on_crtc (dev, crtc, plane) { +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + + state->visible = plane->get_hw_state (plane); + } }
I would like a get_hw_state for the state checker, but it would need to take a intel_plane_state. I don't think you need it here, blindly calling disable_plane would be good enough if it's done after setting up mode.
~Maarten
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Add .get_hw_state() method for planes
Quoted 140 lines · Maarten Lankhorst
Op 10-09-15 om 17:59 schreef [email protected]:
Quoted 139 lines
From: Ville Syrjälä <[email protected]>
Add a .get_hw_state() method for planes, returning true or false depending on whether the plane is enabled. Use it to populate the plane state 'visible' during state readout.
Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 67 ++++++++++++++++++++++++++++-------- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_sprite.c | 37 ++++++++++++++++++++ 3 files changed, 91 insertions(+), 14 deletions(-)drivers/gpu/drm/i915/intel_display.c +47
-12@@ -2841,6 +2841,13 @@ static void ironlake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (reg); } +static bool i9xx_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (DSPSURF (plane->plane)) &DISPLAY_PLANE_ENABLE ; +} +u32 intel_fb_stride_alignment (struct drm_device *dev,uint64_t fb_modifier,uint32_t pixel_format) {@@ -3104,6 +3111,13 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,POSTING_READ (PLANE_SURF (pipe,0 )); } +static bool skylake_primary_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (PLANE_CTL (plane->pipe,0 )) &PLANE_CTL_ENABLE ; +} +/* Assume fb object is pinned & idle & fenced and just update base pointers */ static int intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,@@ -9862,6 +9876,13 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base) } } +static bool i845_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (_CURACNTR) &CURSOR_ENABLE ; +} +static void i9xx_update_cursor (struct drm_crtc *crtc,u32 base) {struct drm_device *dev = crtc->dev;@@ -9909,6 +9930,13 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) intel_crtc->cursor_base = base; } +static bool i9xx_cursor_get_hw_state (struct intel_plane *plane) +{ +struct drm_i915_private *dev_priv =to_i915 (plane->base.dev); + +return I915_READ (CURCNTR (plane->pipe)) &CURSOR_MODE ; +} +/* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */ static void intel_crtc_update_cursor (struct drm_crtc *crtc,bool on)@@ -13518,12 +13546,17 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, } primary->pipe = pipe; primary->plane = pipe; +if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) + primary->plane = !pipe; primary->frontbuffer_bit =INTEL_FRONTBUFFER_PRIMARY (pipe); primary->check_plane = intel_check_primary_plane; primary->commit_plane = intel_commit_primary_plane; primary->disable_plane = intel_disable_primary_plane; -if (HAS_FBC (dev) &&INTEL_INFO (dev)->gen <4 ) - primary->plane = !pipe; + +if (INTEL_INFO (dev)->gen >=9 ) + primary->get_hw_state = skylake_primary_get_hw_state; +else + primary->get_hw_state = i9xx_primary_get_hw_state;if (INTEL_INFO (dev)->gen >=9 ) { intel_primary_formats = skl_primary_formats;@@ -13679,6 +13712,11 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, cursor->commit_plane = intel_commit_cursor_plane; cursor->disable_plane = intel_disable_cursor_plane; +if (IS_845G (dev) ||IS_I865G (dev)) + cursor->get_hw_state = i845_cursor_get_hw_state; +else + cursor->get_hw_state = i9xx_cursor_get_hw_state; + drm_universal_plane_init(dev, &cursor->base, 0, &intel_plane_funcs, intel_cursor_formats,@@ -14886,7 +14924,11 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)/* Disable everything but the primary plane */ for_each_intel_plane_on_crtc (dev, crtc, plane) { -if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY ) +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + +if (plane->base.type ==DRM_PLANE_TYPE_PRIMARY || + !state->visible)continue ; plane->disable_plane (&plane->base, &crtc->base);@@ -15053,21 +15095,18 @@ void i915_redisable_vga(struct drm_device *dev)i915_redisable_vga_power_on (dev); } -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_state *plane_state = -to_intel_plane_state (crtc->base.primary->state); +struct drm_device *dev = crtc->base.dev; +struct intel_plane *plane;
Quoted 11 lines
drivers/gpu/drm/i915/intel_display.c void i915_redisable_vga(struct drm_device *dev) · line 15111
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +6
-2- plane_state->visible = -primary_get_hw_state (to_intel_plane (crtc->base.primary)); +for_each_intel_plane_on_crtc (dev, crtc, plane) { +struct intel_plane_state *state = +to_intel_plane_state (plane->base.state); + + state->visible = plane->get_hw_state (plane); + } }I would like a
get_hw_statefor the state checker, but it would need to take aintel_plane_state.
That would be inconsistent with existing practices. .get_hw_state() != .get_config()
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/4 drm/i915: Move scanline_offset and timestamping constant setup to intel_modeset_readout_hw_state()
In reply to [email protected]From: Ville Syrjälä <[email protected]>
intel_modeset_readout_hw_state() seems like the more appropriate place for populating the scanline_offset and timestamping constants than intel_sanitize_crtc() since they are basically part of the state we read out.
--- drivers/gpu/drm/i915/intel_display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -2
@@ -14918,8 +14918,6 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)if (crtc->active) {struct intel_plane *plane; -drm_calc_timestamping_constants (&crtc->base, &crtc->base.hwmode); -update_scanline_offset (crtc);drm_crtc_vblank_on (&crtc->base);/* Disable everything but the primary plane */
@@ -15216,6 +15214,9 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)* recalculation. */ crtc->base.state->mode.private_flags =I915_MODE_FLAG_INHERITED ; + +drm_calc_timestamping_constants (&crtc->base, &crtc->base.hwmode); +update_scanline_offset (crtc); } } }
Signature · 6 lines
2.4.6 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/4] drm/i915: Move scanline_offset and timestamping constant setup to intel_modeset_readout_hw_state()
Op 10-09-15 om 17:59 schreef [email protected]:
Quoted 28 lines
From: Ville Syrjälä <[email protected]>
intel_modeset_readout_hw_state()seems like the more appropriate place for populating thescanline_offsetand timestamping constants thanintel_sanitize_crtc()since they are basically part of the state we read out.Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_display.c +0
-2@@ -14918,8 +14918,6 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)if (crtc->active) {struct intel_plane *plane; -drm_calc_timestamping_constants (&crtc->base, &crtc->base.hwmode); -update_scanline_offset (crtc);drm_crtc_vblank_on (&crtc->base);/* Disable everything but the primary plane */
drivers/gpu/drm/i915/intel_display.c static void intel_modeset_readout_hw_state(struct drm_device *dev) · line 15222
Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +3
-0@@ -15216,6 +15214,9 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)* recalculation. */ crtc->base.state->mode.private_flags =I915_MODE_FLAG_INHERITED ; + +drm_calc_timestamping_constants (&crtc->base, &crtc->base.hwmode); +update_scanline_offset (crtc); } } }
Can you move drm_vblank_reset and drm_vblank_on too?
_______________________________________________
Intel-gfx mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/4] drm/i915: Move scanline_offset and timestamping constant setup to intel_modeset_readout_hw_state()
Quoted 27 lines · Maarten Lankhorst
Op 10-09-15 om 17:59 schreef [email protected]:
Quoted 26 lines
From: Ville Syrjälä <[email protected]>
intel_modeset_readout_hw_state()seems like the more appropriate place for populating thescanline_offsetand timestamping constants thanintel_sanitize_crtc()since they are basically part of the state we read out.Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_display.c +0
-2@@ -14918,8 +14918,6 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)if (crtc->active) {struct intel_plane *plane; -drm_calc_timestamping_constants (&crtc->base, &crtc->base.hwmode); -update_scanline_offset (crtc);drm_crtc_vblank_on (&crtc->base);
Quoted 12 lines
drivers/gpu/drm/i915/intel_display.c static void intel_modeset_readout_hw_state(struct drm_device *dev) · line 15222
Quoted 11 lines
drivers/gpu/drm/i915/intel_display.c +3
-0/* Disable everything but the primary plane */ @@ -15216,6 +15214,9 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)* recalculation. */ crtc->base.state->mode.private_flags =I915_MODE_FLAG_INHERITED ; + +drm_calc_timestamping_constants (&crtc->base, &crtc->base.hwmode); +update_scanline_offset (crtc); } } }Can you move
drm_vblank_resetanddrm_vblank_ontoo?
I'm not sure I really want to move those. They can actually modify the hardware state, so I don't think they really belong in intel_modeset_readout_hw_state(). intel_sanitize_crtc() feels like a better fit.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Maarten Lankhorst
Reviewed-byRe: [PATCH 4/4] drm/i915: Move scanline_offset and timestamping constant setup to intel_modeset_readout_hw_state()
Hey,
Op 14-09-15 om 16:23 schreef Ville Syrjälä:
Quoted 40 lines · Maarten Lankhorst
Quoted 27 lines
Op 10-09-15 om 17:59 schreef [email protected]:
Quoted 26 lines
From: Ville Syrjälä <[email protected]>
intel_modeset_readout_hw_state()seems like the more appropriate place for populating thescanline_offsetand timestamping constants thanintel_sanitize_crtc()since they are basically part of the state we read out.Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_display.c +0
-2@@ -14918,8 +14918,6 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)if (crtc->active) {struct intel_plane *plane; -drm_calc_timestamping_constants (&crtc->base, &crtc->base.hwmode); -update_scanline_offset (crtc);drm_crtc_vblank_on (&crtc->base);Quoted 12 lines
drivers/gpu/drm/i915/intel_display.c static void intel_modeset_readout_hw_state(struct drm_device *dev) · line 15222
Quoted 11 lines
drivers/gpu/drm/i915/intel_display.c +3
-0/* Disable everything but the primary plane */ @@ -15216,6 +15214,9 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)* recalculation. */ crtc->base.state->mode.private_flags =I915_MODE_FLAG_INHERITED ; + +drm_calc_timestamping_constants (&crtc->base, &crtc->base.hwmode); +update_scanline_offset (crtc); } } }Can you move
drm_vblank_resetanddrm_vblank_ontoo?
Quoted 4 lines
I'm not sure I really want to move those. They can actually modify the hardware state, so I don't think they really belong in
intel_modeset_readout_hw_state().intel_sanitize_crtc()feels like a better fit.
Well the changes are all useful and they're blocking other work. So I think it's better these get in as is.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/4] drm/i915: Move scanline_offset and timestamping constant setup to intel_modeset_readout_hw_state()
In reply to [email protected]Quoted 10 lines · On Thu, Sep 10, 2015 at 06:59:10PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
intel_modeset_readout_hw_state()seems like the more appropriate place for populating thescanline_offsetand timestamping constants thanintel_sanitize_crtc()since they are basically part of the state we read out.Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>
Makes sense to move it.
Quoted 30 lines
--- drivers/gpu/drm/i915/intel_display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_display.c +3
-2@@ -14918,8 +14918,6 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)if (crtc->active) {struct intel_plane *plane; -drm_calc_timestamping_constants (&crtc->base, &crtc->base.hwmode); -update_scanline_offset (crtc);drm_crtc_vblank_on (&crtc->base);/* Disable everything but the primary plane */ @@ -15216,6 +15214,9 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)* recalculation. */ crtc->base.state->mode.private_flags =I915_MODE_FLAG_INHERITED ; + +drm_calc_timestamping_constants (&crtc->base, &crtc->base.hwmode); +update_scanline_offset (crtc); } } }Signature · 1 line
2.4.6
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/4] drm/i915: Move scanline_offset and timestamping constant setup to intel_modeset_readout_hw_state()
Quoted 8 lines · Patrik Jakobsson
Quoted 7 lines · On Thu, Sep 10, 2015 at 06:59:10PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
intel_modeset_readout_hw_state()seems like the more appropriate place for populating thescanline_offsetand timestamping constants thanintel_sanitize_crtc()since they are basically part of the state we read out.
Quoted 7 lines
Quoted 3 lines
Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>Makes sense to move it.
Reviewed-by Patrik Jakobsson <[email protected]>
Merged all but patch 3 (since that one seems to still be contended) to dinq.
Thanks, Daniel
Quoted 34 lines
Quoted 30 lines
--- drivers/gpu/drm/i915/intel_display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_display.c +3
-2@@ -14918,8 +14918,6 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)if (crtc->active) {struct intel_plane *plane; -drm_calc_timestamping_constants (&crtc->base, &crtc->base.hwmode); -update_scanline_offset (crtc);drm_crtc_vblank_on (&crtc->base);/* Disable everything but the primary plane */ @@ -15216,6 +15214,9 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)* recalculation. */ crtc->base.state->mode.private_flags =I915_MODE_FLAG_INHERITED ; + +drm_calc_timestamping_constants (&crtc->base, &crtc->base.hwmode); +update_scanline_offset (crtc); } } }Signature · 1 line
2.4.6_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 11 lines · On Thu, Sep 10, 2015 at 06:59:07PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
The dotclock is often calculated in encoder .get_config(), so we shouldn't copy the
adjusted_modeto hwmode until we have read out the dotclock.Gets rid of some warnings like these:
[drm:drm_calc_timestamping_constants [drm]] *ERROR* crtc 21: Can't calculate constants, dotclock = 0! [drm:i915_get_vblank_timestamp] crtc 0 is disabledv2: Steal Maarten's idea to move
crtc->modeetc. assignment too
Tested and looks good. Here's a bug fixed by this patch.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91428
Quoted 86 lines
Cc Maarten Lankhorst <[email protected]>Cc Patrik Jakobsson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 57 +++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 27 deletions(-)drivers/gpu/drm/i915/intel_display.c +30
-27@@ -15094,33 +15094,6 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) crtc->base.state->active = crtc->active; crtc->base.enabled = crtc->active; -memset (&crtc->base.mode,0 ,sizeof (crtc->base.mode)); -if (crtc->base.state->active) { -intel_mode_from_pipe_config (&crtc->base.mode, crtc->config); -intel_mode_from_pipe_config (&crtc->base.state->adjusted_mode, crtc->config); -WARN_ON (drm_atomic_set_mode_for_crtc (crtc->base.state, &crtc->base.mode)); - -/* -* The initial mode needs to be set in order to keep -* the atomic core happy. It wants a valid mode if the -* crtc's enabled, so we do the above call. -* -* At this point some state updated by the connectors -* in their ->detect() callback has not run yet, so -* no recalculation can be done yet. -* -* Even if we could do a recalculation and modeset -* right now it would cause a double modeset if -* fbdev or userspace chooses a different initial mode. -* -* If that happens, someone indicated they wanted a -* mode change, which means it's safe to do a full -* recalculation. -*/ - crtc->base.state->mode.private_flags =I915_MODE_FLAG_INHERITED ; - } - - crtc->base.hwmode = crtc->config->base.adjusted_mode;readout_plane_state (crtc,to_intel_crtc_state (crtc->base.state)); DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n",@@ -15180,6 +15153,36 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) connector->base.name, connector->base.encoder ? "enabled" : "disabled"); } + +for_each_intel_crtc (dev, crtc) { + crtc->base.hwmode = crtc->config->base.adjusted_mode; + +memset (&crtc->base.mode,0 ,sizeof (crtc->base.mode)); +if (crtc->base.state->active) { +intel_mode_from_pipe_config (&crtc->base.mode, crtc->config); +intel_mode_from_pipe_config (&crtc->base.state->adjusted_mode, crtc->config); +WARN_ON (drm_atomic_set_mode_for_crtc (crtc->base.state, &crtc->base.mode)); + +/* +* The initial mode needs to be set in order to keep +* the atomic core happy. It wants a valid mode if the +* crtc's enabled, so we do the above call. +* +* At this point some state updated by the connectors +* in their ->detect() callback has not run yet, so +* no recalculation can be done yet. +* +* Even if we could do a recalculation and modeset +* right now it would cause a double modeset if +* fbdev or userspace chooses a different initial mode. +* +* If that happens, someone indicated they wanted a +* mode change, which means it's safe to do a full +* recalculation. +*/ + crtc->base.state->mode.private_flags =I915_MODE_FLAG_INHERITED ; + } + } }/* Scan out the current hw modeset state, Signature · 1 line
2.4.6
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx