Wrap up ILK-style atomic watermarks, try two
Subsystems (2)
cover Wrap up ILK-style atomic watermarks, try two
Patches #3 and #4 here are the final two patches from the atomic watermark series that was posted here:
http://lists.freedesktop.org/archives/intel-gfx/2015-September/076634.html
We had to pull those out when Jani reported a BDW boot regression (divide by zero during watermark calculation). Although we never found a smoking gun for that divide by zero, I haven't been able to reproduce the issue on a similar system. There's been a lot of code churn since that time, so I'm hoping that we've either already fixed the issue without realizing it, or that the extra paranoia added in patch #2 here will avoid the crash and highlight the culprit.
The first patch here solves a legitimate bug that could cause a divide-by-zero (just not the one Jani was seeing). The second patch adds extra guards on divide operations to verify our invariants and ensure that bugs elsewhere in the driver can't lead to a fatal divide-by-zero (at least on the ILK codepaths).
Please don't merge #3 or #4 here until we at least get a positive test result from Jani.
Matt Roper (4):
drm/i915: Convert hsw_compute_linetime_wm to use in-flight state drm/i915: Add extra paranoia to ILK watermark calculations drm/i915: Sanitize watermarks after hardware state readout drm/i915: Add two-stage ILK-style watermark programming (v6)
drivers/gpu/drm/i915/i915_drv.h | 5 + drivers/gpu/drm/i915/intel_atomic.c | 1 + drivers/gpu/drm/i915/intel_display.c | 137 +++++++++++++++++++++++++- drivers/gpu/drm/i915/intel_drv.h | 31 +++++- drivers/gpu/drm/i915/intel_pm.c | 186 +++++++++++++++++++++++++---------- 5 files changed, 305 insertions(+), 55 deletions(-)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/4 drm/i915: Convert hsw_compute_linetime_wm to use in-flight state
When watermark calculation was moved up to the atomic check phase, the code was updated to calculate based on in-flight atomic state rather than already-committed state. However the hsw_compute_linetime_wm() didn't get updated and continued to pull values out of the currently-committed CRTC state. On platforms that call this function (HSW/BDW only), this will cause problems when we go to enable the CRTC since we'll pull the current mode (off) rather than the mode we're calculating for and wind up with a divide by zero error.
This was an oversight in commit:
commit a28170f3389f4e42db95e595b0d86384a79de696
Author: Matt Roper <[email protected]>
Date: Thu Sep 24 15:53:16 2015 -0700
drm/i915: Calculate ILK-style watermarks during atomic check (v3)
--- drivers/gpu/drm/i915/intel_pm.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +10 -6
@@ -1990,14 +1990,19 @@ static void ilk_compute_wm_level(const struct drm_i915_private *dev_priv, }static uint32_t -hsw_compute_linetime_wm (struct drm_device *dev,struct drm_crtc *crtc) +hsw_compute_linetime_wm (struct drm_device *dev, +struct intel_crtc_state *cstate) {struct drm_i915_private *dev_priv = dev->dev_private; -struct intel_crtc *intel_crtc =to_intel_crtc (crtc); -const struct drm_display_mode *adjusted_mode = &intel_crtc->config->base.adjusted_mode; +const struct drm_display_mode *adjusted_mode = + &cstate->base.adjusted_mode;u32 linetime, ips_linetime; -if (!intel_crtc->active) +if (!cstate->base.active) +return 0 ; +if (WARN_ON (adjusted_mode->crtc_clock ==0 )) +return 0 ; +if (WARN_ON (dev_priv->cdclk_freq ==0 ))return 0 ;/* The WM are computed with base on how long it takes to fill a single
@@ -2305,8 +2310,7 @@ static int ilk_compute_pipe_wm(struct intel_crtc *intel_crtc, pristate, sprstate, curstate, &pipe_wm->wm[0]);if (IS_HASWELL (dev) ||IS_BROADWELL (dev)) - pipe_wm->linetime =hsw_compute_linetime_wm (dev, - &intel_crtc->base); + pipe_wm->linetime =hsw_compute_linetime_wm (dev, cstate);/* LP0 watermarks always use 1/2 DDB partitioning */ ilk_compute_wm_maximums (dev,0 , &config,INTEL_DDB_PART_1_2 , &max);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/4 drm/i915: Add extra paranoia to ILK watermark calculations
In reply to Matt RoperOur low-level watermark calculation functions don't get called when the CRTC is disabled or the relevant plane is invisible, so they should never see a zero htotal or zero bpp. However add some checks to ensure this is true so that we don't wind up dividing by zero if we make a mistake elsewhere in the driver (which the atomic watermark series has revealed we might be).
References: http://lists.freedesktop.org/archives/intel-gfx/2015-October/077370.html
--- drivers/gpu/drm/i915/intel_pm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +16 -0
@@ -1664,6 +1664,9 @@ uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config)if (pipe_h < pfit_h) pipe_h = pfit_h; +if (WARN_ON (!pfit_w || !pfit_h)) +return pixel_rate; + pixel_rate =div_u64 ((uint64_t ) pixel_rate * pipe_w * pipe_h, pfit_w * pfit_h); }
@@ -1695,6 +1698,8 @@ static uint32_t ilk_wm_method2(uint32_t pixel_rate, uint32_t pipe_htotal,if (WARN (latency ==0 ,"Latency value missing\n" ))return UINT_MAX ; +if (WARN_ON (!pipe_htotal)) +return UINT_MAX ; ret = (latency * pixel_rate) / (pipe_htotal *10000 ); ret = (ret +1 ) * horiz_pixels * bytes_per_pixel;
@@ -1705,6 +1710,17 @@ static uint32_t ilk_wm_method2(uint32_t pixel_rate, uint32_t pipe_htotal,static uint32_t ilk_wm_fbc (uint32_t pri_val,uint32_t horiz_pixels,uint8_t bytes_per_pixel) { +/* +* Neither of these should be possible since this function shouldn't be +* called if the CRTC is off or the plane is invisible. But let's be +* extra paranoid to avoid a potential divide-by-zero if we screw up +* elsewhere in the driver. +*/ +if (WARN_ON (!bytes_per_pixel)) +return 0 ; +if (WARN_ON (!horiz_pixels)) +return 0 ; +return DIV_ROUND_UP (pri_val *64 , horiz_pixels * bytes_per_pixel) +2 ; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 drm/i915: Sanitize watermarks after hardware state readout
In reply to Matt RoperAlthough we can do a good job of reading out hardware state, the graphics firmware may have programmed the watermarks in a creative way that doesn't match how i915 would have chosen to program them. We shouldn't trust the firmware's watermark programming, but should rather re-calculate how we think WM's should be programmed and then shove those values into the hardware.
We can do this pretty easily by creating a dummy top-level state, running it through the check process to calculate all the values, and then just programming the watermarks for each CRTC.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 51 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 14 +++++----- 3 files changed, 60 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -629,6 +629,7 @@ struct drm_i915_display_funcs { struct dpll *best_clock);int (*compute_pipe_wm)(struct intel_crtc *crtc,struct drm_atomic_state *state); +void (*program_watermarks)(struct intel_crtc_state *cstate);void (*update_wm)(struct drm_crtc *crtc);int (*modeset_calc_cdclk)(struct drm_atomic_state *state);void (*modeset_commit_cdclk)(struct drm_atomic_state *state);
drivers/gpu/drm/i915/intel_display.c +51 -0
63 lines not on this page · raw message
drivers/gpu/drm/i915/intel_pm.c +8 -6
@@ -3611,15 +3611,19 @@ static void skl_update_wm(struct drm_crtc *crtc) dev_priv->wm.skl_hw = *results; } -static void ilk_program_watermarks (struct drm_i915_private *dev_priv) +static void ilk_program_watermarks (struct intel_crtc_state *cstate) { -struct drm_device *dev = dev_priv->dev; +struct drm_crtc *crtc = cstate->base.crtc; +struct drm_device *dev = crtc->dev; +struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_pipe_wm lp_wm_1_2 = {}, lp_wm_5_6 = {}, *best_lp_wm;struct ilk_wm_maximums max;struct intel_wm_config *config = &dev_priv->wm.config;struct ilk_wm_values results = {};enum intel_ddb_partitioning partitioning; +to_intel_crtc (crtc)->wm.active.ilk = cstate->wm.optimal.ilk; +ilk_compute_wm_maximums (dev,1 , config,INTEL_DDB_PART_1_2 , &max);ilk_wm_merge (dev, config, &max, &lp_wm_1_2);
@@ -3644,7 +3648,6 @@ static void ilk_program_watermarks(struct drm_i915_private *dev_priv)static void ilk_update_wm (struct drm_crtc *crtc) { -struct drm_i915_private *dev_priv =to_i915 (crtc->dev);struct intel_crtc *intel_crtc =to_intel_crtc (crtc);struct intel_crtc_state *cstate =to_intel_crtc_state (crtc->state);
@@ -3662,9 +3665,7 @@ static void ilk_update_wm(struct drm_crtc *crtc)intel_wait_for_vblank (crtc->dev, intel_crtc->pipe); } - intel_crtc->wm.active.ilk = cstate->wm.optimal.ilk; - -ilk_program_watermarks (dev_priv); +ilk_program_watermarks (cstate); } static void skl_pipe_wm_active_state(uint32_t val,
@@ -6972,6 +6973,7 @@ void intel_init_pm(struct drm_device *dev) dev_priv->wm.spr_latency[0] && dev_priv->wm.cur_latency[0])) { dev_priv->display.update_wm = ilk_update_wm; dev_priv->display.compute_pipe_wm = ilk_compute_pipe_wm; + dev_priv->display.program_watermarks = ilk_program_watermarks; } else {DRM_DEBUG_KMS ("Failed to read display plane latency. " "Disable CxSR\n" );
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/4 drm/i915: Add two-stage ILK-style watermark programming (v6)
In reply to Matt RoperIn addition to calculating final watermarks, let's also pre-calculate a set of intermediate watermark values at atomic check time. These intermediate watermarks are a combination of the watermarks for the old state and the new state; they should satisfy the requirements of both states which means they can be programmed immediately when we commit the atomic state (without waiting for a vblank). Once the vblank does happen, we can then re-program watermarks to the more optimal final value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity (Maarten)
- Don't due async watermark optimization; just do it at the end of the atomic transaction, after waiting for vblanks. We do want it to be async eventually, but adding that now will cause more trouble for Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the need_postvbl_update flag. Since we don't have async yet it isn't terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose .initial_watermarks() and .optimize_watermarks() functions to do watermark programming. These should lock wm_mutex, copy the appropriate state values into intel_crtc->active, and then call the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware readout since we don't trust the existing HW values (and don't have valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have atomic watermarks yet. (Maarten)
v6:
- Rebase
Reviewed-by(v5): Maarten Lankhorst <[email protected]>
--- drivers/gpu/drm/i915/i915_drv.h | 6 +- drivers/gpu/drm/i915/intel_atomic.c | 1 + drivers/gpu/drm/i915/intel_display.c | 90 +++++++++++++++++++- drivers/gpu/drm/i915/intel_drv.h | 31 ++++++- drivers/gpu/drm/i915/intel_pm.c | 160 ++++++++++++++++++++++++----------- 5 files changed, 232 insertions(+), 56 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +5 -1
@@ -629,7 +629,11 @@ struct drm_i915_display_funcs { struct dpll *best_clock);int (*compute_pipe_wm)(struct intel_crtc *crtc,struct drm_atomic_state *state); -void (*program_watermarks)(struct intel_crtc_state *cstate); +int (*compute_intermediate_wm)(struct drm_device *dev, +struct intel_crtc *intel_crtc, +struct intel_crtc_state *newstate); +void (*initial_watermarks)(struct intel_crtc_state *cstate); +void (*optimize_watermarks)(struct intel_crtc_state *cstate);void (*update_wm)(struct drm_crtc *crtc);int (*modeset_calc_cdclk)(struct drm_atomic_state *state);void (*modeset_commit_cdclk)(struct drm_atomic_state *state);
drivers/gpu/drm/i915/intel_atomic.c +1 -0
@@ -95,6 +95,7 @@ intel_crtc_duplicate_state(struct drm_crtc *crtc) crtc_state->update_pipe = false; crtc_state->disable_lp_wm = false; + crtc_state->wm.need_postvbl_update = false;return &crtc_state->base; }
drivers/gpu/drm/i915/intel_display.c +86 -4
151 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +29 -2
@@ -251,6 +251,12 @@ struct intel_atomic_state {bool dpll_set;struct intel_shared_dpll_config shared_dpll[I915_NUM_PLLS ];struct intel_wm_config wm_config; + +/* +* Current watermarks can't be trusted during hardware readout, so +* don't bother calculating intermediate watermarks. +*/ +bool skip_intermediate_wm; };struct intel_plane_state {
@@ -493,13 +499,29 @@ struct intel_crtc_state {struct {/* -* optimal watermarks, programmed post-vblank when this state -* is committed +* Optimal watermarks, programmed post-vblank when this state +* is committed. */ union {struct intel_pipe_wm ilk;struct skl_pipe_wm skl; } optimal; + +/* +* Intermediate watermarks; these can be programmed immediately +* since they satisfy both the current configuration we're +* switching away from and the new configuration we're switching +* to. +*/ +struct intel_pipe_wm intermediate; + +/* +* Platforms with two-step watermark programming will need to +* update watermark programming post-vblank to switch from the +* safe intermediate watermarks to the optimal final +* watermarks. +*/ +bool need_postvbl_update; } wm; };
@@ -589,8 +611,12 @@ struct intel_crtc {struct intel_pipe_wm ilk;struct skl_pipe_wm skl; } active; +/* allow CxSR on this pipe */ bool cxsr_allowed; + +/* Protects active and need_postvbl_update */ +struct mutex wm_mutex; } wm;int scanline_offset;
@@ -1439,6 +1465,7 @@ void skl_wm_get_hw_state(struct drm_device *dev);void skl_ddb_get_hw_state (struct drm_i915_private *dev_priv,struct skl_ddb_allocation *ddb/* out */ );uint32_t ilk_pipe_pixel_rate (const struct intel_crtc_state *pipe_config); +bool ilk_disable_lp_wm (struct drm_device *dev);/* intel_sdvo.c */ bool intel_sdvo_init (struct drm_device *dev,uint32_t sdvo_reg,bool is_sdvob);
drivers/gpu/drm/i915/intel_pm.c +111 -49
251 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/4 drm/i915: Add two-stage ILK-style watermark programming (v7)
In addition to calculating final watermarks, let's also pre-calculate a set of intermediate watermark values at atomic check time. These intermediate watermarks are a combination of the watermarks for the old state and the new state; they should satisfy the requirements of both states which means they can be programmed immediately when we commit the atomic state (without waiting for a vblank). Once the vblank does happen, we can then re-program watermarks to the more optimal final value.
v2: Significant rebasing/rewriting.
v3:
- Move 'need_postvbl_update' flag to CRTC state (Daniel)
- Don't forget to check intermediate watermark values for validity (Maarten)
- Don't due async watermark optimization; just do it at the end of the atomic transaction, after waiting for vblanks. We do want it to be async eventually, but adding that now will cause more trouble for Maarten's in-progress work. (Maarten)
- Don't allocate space in crtc_state for intermediate watermarks on platforms that don't need it (gen9+).
- Move WaCxSRDisabledForSpriteScaling:ivb into intel_begin_crtc_commit now that ilk_update_wm is gone.
v4:
- Add a wm_mutex to cover updates to intel_crtc->active and the need_postvbl_update flag. Since we don't have async yet it isn't terribly important yet, but might as well add it now.
- Change interface to program watermarks. Platforms will now expose .initial_watermarks() and .optimize_watermarks() functions to do watermark programming. These should lock wm_mutex, copy the appropriate state values into intel_crtc->active, and then call the internal program watermarks function.
v5:
- Skip intermediate watermark calculation/check during initial hardware readout since we don't trust the existing HW values (and don't have valid values of our own yet).
- Don't try to call .optimize_watermarks() on platforms that don't have atomic watermarks yet. (Maarten)
v6:
- Rebase
v7:
- Further rebase
Reviewed-by(v5): Maarten Lankhorst <[email protected]>
--- drivers/gpu/drm/i915/i915_drv.h | 6 +- drivers/gpu/drm/i915/intel_atomic.c | 1 + drivers/gpu/drm/i915/intel_display.c | 90 +++++++++++++++++++- drivers/gpu/drm/i915/intel_drv.h | 31 ++++++- drivers/gpu/drm/i915/intel_pm.c | 160 ++++++++++++++++++++++++----------- 5 files changed, 232 insertions(+), 56 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +5 -1
@@ -629,7 +629,11 @@ struct drm_i915_display_funcs { struct dpll *best_clock);int (*compute_pipe_wm)(struct intel_crtc *crtc,struct drm_atomic_state *state); -void (*program_watermarks)(struct intel_crtc_state *cstate); +int (*compute_intermediate_wm)(struct drm_device *dev, +struct intel_crtc *intel_crtc, +struct intel_crtc_state *newstate); +void (*initial_watermarks)(struct intel_crtc_state *cstate); +void (*optimize_watermarks)(struct intel_crtc_state *cstate);void (*update_wm)(struct drm_crtc *crtc);int (*modeset_calc_cdclk)(struct drm_atomic_state *state);void (*modeset_commit_cdclk)(struct drm_atomic_state *state);
drivers/gpu/drm/i915/intel_atomic.c +1 -0
@@ -95,6 +95,7 @@ intel_crtc_duplicate_state(struct drm_crtc *crtc) crtc_state->update_pipe = false; crtc_state->disable_lp_wm = false; + crtc_state->wm.need_postvbl_update = false;return &crtc_state->base; }
drivers/gpu/drm/i915/intel_display.c +86 -4
151 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +29 -2
@@ -251,6 +251,12 @@ struct intel_atomic_state {bool dpll_set;struct intel_shared_dpll_config shared_dpll[I915_NUM_PLLS ];struct intel_wm_config wm_config; + +/* +* Current watermarks can't be trusted during hardware readout, so +* don't bother calculating intermediate watermarks. +*/ +bool skip_intermediate_wm; };struct intel_plane_state {
@@ -493,13 +499,29 @@ struct intel_crtc_state {struct {/* -* optimal watermarks, programmed post-vblank when this state -* is committed +* Optimal watermarks, programmed post-vblank when this state +* is committed. */ union {struct intel_pipe_wm ilk;struct skl_pipe_wm skl; } optimal; + +/* +* Intermediate watermarks; these can be programmed immediately +* since they satisfy both the current configuration we're +* switching away from and the new configuration we're switching +* to. +*/ +struct intel_pipe_wm intermediate; + +/* +* Platforms with two-step watermark programming will need to +* update watermark programming post-vblank to switch from the +* safe intermediate watermarks to the optimal final +* watermarks. +*/ +bool need_postvbl_update; } wm; };
@@ -589,8 +611,12 @@ struct intel_crtc {struct intel_pipe_wm ilk;struct skl_pipe_wm skl; } active; +/* allow CxSR on this pipe */ bool cxsr_allowed; + +/* Protects active and need_postvbl_update */ +struct mutex wm_mutex; } wm;int scanline_offset;
@@ -1439,6 +1465,7 @@ void skl_wm_get_hw_state(struct drm_device *dev);void skl_ddb_get_hw_state (struct drm_i915_private *dev_priv,struct skl_ddb_allocation *ddb/* out */ );uint32_t ilk_pipe_pixel_rate (const struct intel_crtc_state *pipe_config); +bool ilk_disable_lp_wm (struct drm_device *dev);/* intel_sdvo.c */ bool intel_sdvo_init (struct drm_device *dev,uint32_t sdvo_reg,bool is_sdvob);
drivers/gpu/drm/i915/intel_pm.c +111 -49
251 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 12 lines · Matt Roper
Patches #3 and #4 here are the final two patches from the atomic watermark series that was posted here:
http://lists.freedesktop.org/archives/intel-gfx/2015-September/076634.htmlWe had to pull those out when Jani reported a BDW boot regression (divide by zero during watermark calculation). Although we never found a smoking gun for that divide by zero, I haven't been able to reproduce the issue on a similar system. There's been a lot of code churn since that time, so I'm hoping that we've either already fixed the issue without realizing it, or that the extra paranoia added in patch #2 here will avoid the crash and highlight the culprit.
Quoted 8 lines
The first patch here solves a legitimate bug that could cause a divide-by-zero (just not the one Jani was seeing). The second patch adds extra guards on divide operations to verify our invariants and ensure that bugs elsewhere in the driver can't lead to a fatal divide-by-zero (at least on the ILK codepaths).
Please don't merge #3 or #4 here until we at least get a positive test result from Jani.
Still gives me warnings. I didn't try one patch at a time, but here are the dmesgs before http://pastebin.com/GVG9UC1U and after
http://pastebin.com/1HaXTJ3Z applying the series on top of today's nightly.
BR,
Jani.
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 drm/i915: Sanitize watermarks after hardware state readout (v2)
Although we can do a good job of reading out hardware state, the graphics firmware may have programmed the watermarks in a creative way that doesn't match how i915 would have chosen to program them. We shouldn't trust the firmware's watermark programming, but should rather re-calculate how we think WM's should be programmed and then shove those values into the hardware.
We can do this pretty easily by creating a dummy top-level state, running it through the check process to calculate all the values, and then just programming the watermarks for each CRTC.
v2: Move watermark sanitization after our BIOS fb reconstruction; the
watermark calculations that we do here need to look at pstate->fb, which isn't setup yet in intel_modeset_setup_hw_state(), even though we have an enabled & visible plane.
---
Jani, based on your logs it looks like the culprit is that we're calculating watermarks at startup time after we've read out preliminary hardware state (so we know the primary plane is enabled & visible), but before we reconstruct the BIOS fb (so pstate->fb is NULL). I think moving the watermark sanitization later in the process so that we'll have a proper fb setup should hopefully solve the issue. Can you test this version when you get a chance? I'll also send a rebased patch #4 since the code movement here means that the previous version won't apply cleanly.
drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 55 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 14 +++++---- 3 files changed, 64 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -629,6 +629,7 @@ struct drm_i915_display_funcs { struct dpll *best_clock);int (*compute_pipe_wm)(struct intel_crtc *crtc,struct drm_atomic_state *state); +void (*program_watermarks)(struct intel_crtc_state *cstate);void (*update_wm)(struct drm_crtc *crtc);int (*modeset_calc_cdclk)(struct drm_atomic_state *state);void (*modeset_commit_cdclk)(struct drm_atomic_state *state);
drivers/gpu/drm/i915/intel_display.c +55 -0
67 lines not on this page · raw message
drivers/gpu/drm/i915/intel_pm.c +8 -6
@@ -3611,15 +3611,19 @@ static void skl_update_wm(struct drm_crtc *crtc) dev_priv->wm.skl_hw = *results; } -static void ilk_program_watermarks (struct drm_i915_private *dev_priv) +static void ilk_program_watermarks (struct intel_crtc_state *cstate) { -struct drm_device *dev = dev_priv->dev; +struct drm_crtc *crtc = cstate->base.crtc; +struct drm_device *dev = crtc->dev; +struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_pipe_wm lp_wm_1_2 = {}, lp_wm_5_6 = {}, *best_lp_wm;struct ilk_wm_maximums max;struct intel_wm_config *config = &dev_priv->wm.config;struct ilk_wm_values results = {};enum intel_ddb_partitioning partitioning; +to_intel_crtc (crtc)->wm.active.ilk = cstate->wm.optimal.ilk; +ilk_compute_wm_maximums (dev,1 , config,INTEL_DDB_PART_1_2 , &max);ilk_wm_merge (dev, config, &max, &lp_wm_1_2);
@@ -3644,7 +3648,6 @@ static void ilk_program_watermarks(struct drm_i915_private *dev_priv)static void ilk_update_wm (struct drm_crtc *crtc) { -struct drm_i915_private *dev_priv =to_i915 (crtc->dev);struct intel_crtc *intel_crtc =to_intel_crtc (crtc);struct intel_crtc_state *cstate =to_intel_crtc_state (crtc->state);
@@ -3662,9 +3665,7 @@ static void ilk_update_wm(struct drm_crtc *crtc)intel_wait_for_vblank (crtc->dev, intel_crtc->pipe); } - intel_crtc->wm.active.ilk = cstate->wm.optimal.ilk; - -ilk_program_watermarks (dev_priv); +ilk_program_watermarks (cstate); } static void skl_pipe_wm_active_state(uint32_t val,
@@ -6972,6 +6973,7 @@ void intel_init_pm(struct drm_device *dev) dev_priv->wm.spr_latency[0] && dev_priv->wm.cur_latency[0])) { dev_priv->display.update_wm = ilk_update_wm; dev_priv->display.compute_pipe_wm = ilk_compute_pipe_wm; + dev_priv->display.program_watermarks = ilk_program_watermarks; } else {DRM_DEBUG_KMS ("Failed to read display plane latency. " "Disable CxSR\n" );
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Sanitize watermarks after hardware state readout (v2)
Quoted 19 lines · Matt Roper
Although we can do a good job of reading out hardware state, the graphics firmware may have programmed the watermarks in a creative way that doesn't match how i915 would have chosen to program them. We shouldn't trust the firmware's watermark programming, but should rather re-calculate how we think WM's should be programmed and then shove those values into the hardware.
We can do this pretty easily by creating a dummy top-level state, running it through the check process to calculate all the values, and then just programming the watermarks for each CRTC.
v2: Move watermark sanitization after our BIOS fb reconstruction; the
watermark calculations that we do here need to look atpstate->fb, which isn't setup yet inintel_modeset_setup_hw_state(), even though we have an enabled & visible plane.Cc Jani Nikula <[email protected]>Cc Maarten Lankhorst <[email protected]>Signed-off-by Matt Roper <[email protected]>
Quoted 9 lines
---
Jani, based on your logs it looks like the culprit is that we're calculating watermarks at startup time after we've read out preliminary hardware state (so we know the primary plane is enabled & visible), but before we reconstruct the BIOS fb (sopstate->fbis NULL). I think moving the watermark sanitization later in the process so that we'll have a proper fb setup should hopefully solve the issue. Can you test this version when you get a chance? I'll also send a rebased patch #4 since the code movement here means that the previous version won't apply cleanly.
Sorry Matt, black screen with new versions of patches 3-4. Dmesg at
http://pastebin.com/3LXZwvWu
BR,
Jani.
Quoted 144 lines
drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 55 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 14 +++++---- 3 files changed, 64 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -629,6 +629,7 @@ struct drm_i915_display_funcs { struct dpll *best_clock);int (*compute_pipe_wm)(struct intel_crtc *crtc,struct drm_atomic_state *state); +void (*program_watermarks)(struct intel_crtc_state *cstate);void (*update_wm)(struct drm_crtc *crtc);int (*modeset_calc_cdclk)(struct drm_atomic_state *state);void (*modeset_commit_cdclk)(struct drm_atomic_state *state);drivers/gpu/drm/i915/intel_display.c +55
-0@@ -14936,6 +14936,54 @@ void intel_modeset_init_hw(struct drm_device *dev)intel_enable_gt_powersave (dev); } +/* +* Calculate what we think the watermarks should be for the state we've read +* out of the hardware and then immediately program those watermarks so that +* we ensure the hardware settings match our internal state. +*/ +static void sanitize_watermarks (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv =to_i915 (dev); +struct drm_atomic_state *state; +struct drm_crtc *crtc; +struct drm_crtc_state *cstate; +int ret; +int i; + +/* Only supported on platforms that use atomic watermark design */ +if (!dev_priv->display.program_watermarks) +return ; + +/* +* Calculate what we think WM's should be by creating a dummy state and +* running it through the atomic check code. +*/ + state =drm_atomic_helper_duplicate_state (dev, + dev->mode_config.acquire_ctx); +if (WARN_ON (IS_ERR (state))) +return ; + + ret =intel_atomic_check (dev, state); +if (ret) { +/* +* Just give up and leave watermarks untouched if we get an +* error back from 'check' +*/ +DRM_DEBUG_KMS ("Could not determine valid watermarks for inherited state\n" ); +return ; + } + +/* Write calculated watermark values back */ +to_i915 (dev)->wm.config =to_intel_atomic_state (state)->wm_config; +for_each_crtc_in_state (state, crtc, cstate, i) { +struct intel_crtc_state *cs =to_intel_crtc_state (cstate); + + dev_priv->display.program_watermarks (cs); + } + +drm_atomic_state_free (state); +} +void intel_modeset_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;@@ -15059,6 +15107,13 @@ void intel_modeset_init(struct drm_device *dev)*/ intel_find_initial_plane_obj (crtc, &plane_config); } + +/* +* Make sure hardware watermarks really match the state we read out. +* Note that we need to do this after reconstructing the BIOS fb's +* since the watermark calculation done here will use pstate->fb. +*/ +sanitize_watermarks (dev); }static void intel_enable_pipe_a (struct drm_device *dev)drivers/gpu/drm/i915/intel_pm.c +8
-6@@ -3611,15 +3611,19 @@ static void skl_update_wm(struct drm_crtc *crtc) dev_priv->wm.skl_hw = *results; } -static void ilk_program_watermarks (struct drm_i915_private *dev_priv) +static void ilk_program_watermarks (struct intel_crtc_state *cstate) { -struct drm_device *dev = dev_priv->dev; +struct drm_crtc *crtc = cstate->base.crtc; +struct drm_device *dev = crtc->dev; +struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_pipe_wm lp_wm_1_2 = {}, lp_wm_5_6 = {}, *best_lp_wm;struct ilk_wm_maximums max;struct intel_wm_config *config = &dev_priv->wm.config;struct ilk_wm_values results = {};enum intel_ddb_partitioning partitioning; +to_intel_crtc (crtc)->wm.active.ilk = cstate->wm.optimal.ilk; +ilk_compute_wm_maximums (dev,1 , config,INTEL_DDB_PART_1_2 , &max);ilk_wm_merge (dev, config, &max, &lp_wm_1_2);@@ -3644,7 +3648,6 @@ static void ilk_program_watermarks(struct drm_i915_private *dev_priv)static void ilk_update_wm (struct drm_crtc *crtc) { -struct drm_i915_private *dev_priv =to_i915 (crtc->dev);struct intel_crtc *intel_crtc =to_intel_crtc (crtc);struct intel_crtc_state *cstate =to_intel_crtc_state (crtc->state);@@ -3662,9 +3665,7 @@ static void ilk_update_wm(struct drm_crtc *crtc)intel_wait_for_vblank (crtc->dev, intel_crtc->pipe); } - intel_crtc->wm.active.ilk = cstate->wm.optimal.ilk; - -ilk_program_watermarks (dev_priv); +ilk_program_watermarks (cstate); } static void skl_pipe_wm_active_state(uint32_t val,@@ -6972,6 +6973,7 @@ void intel_init_pm(struct drm_device *dev) dev_priv->wm.spr_latency[0] && dev_priv->wm.cur_latency[0])) { dev_priv->display.update_wm = ilk_update_wm; dev_priv->display.compute_pipe_wm = ilk_compute_pipe_wm; + dev_priv->display.program_watermarks = ilk_program_watermarks; } else {DRM_DEBUG_KMS ("Failed to read display plane latency. " "Disable CxSR\n" );
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Sanitize watermarks after hardware state readout (v2)
Quoted 30 lines · Jani Nikula
Quoted 19 lines · Matt Roper
Although we can do a good job of reading out hardware state, the graphics firmware may have programmed the watermarks in a creative way that doesn't match how i915 would have chosen to program them. We shouldn't trust the firmware's watermark programming, but should rather re-calculate how we think WM's should be programmed and then shove those values into the hardware.
We can do this pretty easily by creating a dummy top-level state, running it through the check process to calculate all the values, and then just programming the watermarks for each CRTC.
v2: Move watermark sanitization after our BIOS fb reconstruction; the
watermark calculations that we do here need to look atpstate->fb, which isn't setup yet inintel_modeset_setup_hw_state(), even though we have an enabled & visible plane.Cc Jani Nikula <[email protected]>Cc Maarten Lankhorst <[email protected]>Signed-off-by Matt Roper <[email protected]>Quoted 9 lines
---
Jani, based on your logs it looks like the culprit is that we're calculating watermarks at startup time after we've read out preliminary hardware state (so we know the primary plane is enabled & visible), but before we reconstruct the BIOS fb (sopstate->fbis NULL). I think moving the watermark sanitization later in the process so that we'll have a proper fb setup should hopefully solve the issue. Can you test this version when you get a chance? I'll also send a rebased patch #4 since the code movement here means that the previous version won't apply cleanly.
Quoted 2 lines
Sorry Matt, black screen with new versions of patches 3-4. Dmesg at
http://pastebin.com/3LXZwvWu
Hmm, okay, looks like we're getting closer (successfully avoided the divide by zero problem), but I neglected to grab the necessary locks so the sanitization doesn't actually happen. Does applying
http://paste.debian.net/322932 on top of the series work any better for you? I haven't had time to pull back out an ILK-style system, so that's only compile-tested at the moment.
Matt
Quoted 153 lines
BR,
Jani.Quoted 144 lines
drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 55 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 14 +++++---- 3 files changed, 64 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -629,6 +629,7 @@ struct drm_i915_display_funcs { struct dpll *best_clock);int (*compute_pipe_wm)(struct intel_crtc *crtc,struct drm_atomic_state *state); +void (*program_watermarks)(struct intel_crtc_state *cstate);void (*update_wm)(struct drm_crtc *crtc);int (*modeset_calc_cdclk)(struct drm_atomic_state *state);void (*modeset_commit_cdclk)(struct drm_atomic_state *state);drivers/gpu/drm/i915/intel_display.c +55
-0@@ -14936,6 +14936,54 @@ void intel_modeset_init_hw(struct drm_device *dev)intel_enable_gt_powersave (dev); } +/* +* Calculate what we think the watermarks should be for the state we've read +* out of the hardware and then immediately program those watermarks so that +* we ensure the hardware settings match our internal state. +*/ +static void sanitize_watermarks (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv =to_i915 (dev); +struct drm_atomic_state *state; +struct drm_crtc *crtc; +struct drm_crtc_state *cstate; +int ret; +int i; + +/* Only supported on platforms that use atomic watermark design */ +if (!dev_priv->display.program_watermarks) +return ; + +/* +* Calculate what we think WM's should be by creating a dummy state and +* running it through the atomic check code. +*/ + state =drm_atomic_helper_duplicate_state (dev, + dev->mode_config.acquire_ctx); +if (WARN_ON (IS_ERR (state))) +return ; + + ret =intel_atomic_check (dev, state); +if (ret) { +/* +* Just give up and leave watermarks untouched if we get an +* error back from 'check' +*/ +DRM_DEBUG_KMS ("Could not determine valid watermarks for inherited state\n" ); +return ; + } + +/* Write calculated watermark values back */ +to_i915 (dev)->wm.config =to_intel_atomic_state (state)->wm_config; +for_each_crtc_in_state (state, crtc, cstate, i) { +struct intel_crtc_state *cs =to_intel_crtc_state (cstate); + + dev_priv->display.program_watermarks (cs); + } + +drm_atomic_state_free (state); +} +void intel_modeset_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;@@ -15059,6 +15107,13 @@ void intel_modeset_init(struct drm_device *dev)*/ intel_find_initial_plane_obj (crtc, &plane_config); } + +/* +* Make sure hardware watermarks really match the state we read out. +* Note that we need to do this after reconstructing the BIOS fb's +* since the watermark calculation done here will use pstate->fb. +*/ +sanitize_watermarks (dev); }static void intel_enable_pipe_a (struct drm_device *dev)drivers/gpu/drm/i915/intel_pm.c +8
-6@@ -3611,15 +3611,19 @@ static void skl_update_wm(struct drm_crtc *crtc) dev_priv->wm.skl_hw = *results; } -static void ilk_program_watermarks (struct drm_i915_private *dev_priv) +static void ilk_program_watermarks (struct intel_crtc_state *cstate) { -struct drm_device *dev = dev_priv->dev; +struct drm_crtc *crtc = cstate->base.crtc; +struct drm_device *dev = crtc->dev; +struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_pipe_wm lp_wm_1_2 = {}, lp_wm_5_6 = {}, *best_lp_wm;struct ilk_wm_maximums max;struct intel_wm_config *config = &dev_priv->wm.config;struct ilk_wm_values results = {};enum intel_ddb_partitioning partitioning; +to_intel_crtc (crtc)->wm.active.ilk = cstate->wm.optimal.ilk; +ilk_compute_wm_maximums (dev,1 , config,INTEL_DDB_PART_1_2 , &max);ilk_wm_merge (dev, config, &max, &lp_wm_1_2);@@ -3644,7 +3648,6 @@ static void ilk_program_watermarks(struct drm_i915_private *dev_priv)static void ilk_update_wm (struct drm_crtc *crtc) { -struct drm_i915_private *dev_priv =to_i915 (crtc->dev);struct intel_crtc *intel_crtc =to_intel_crtc (crtc);struct intel_crtc_state *cstate =to_intel_crtc_state (crtc->state);@@ -3662,9 +3665,7 @@ static void ilk_update_wm(struct drm_crtc *crtc)intel_wait_for_vblank (crtc->dev, intel_crtc->pipe); } - intel_crtc->wm.active.ilk = cstate->wm.optimal.ilk; - -ilk_program_watermarks (dev_priv); +ilk_program_watermarks (cstate); } static void skl_pipe_wm_active_state(uint32_t val,@@ -6972,6 +6973,7 @@ void intel_init_pm(struct drm_device *dev) dev_priv->wm.spr_latency[0] && dev_priv->wm.cur_latency[0])) { dev_priv->display.update_wm = ilk_update_wm; dev_priv->display.compute_pipe_wm = ilk_compute_pipe_wm; + dev_priv->display.program_watermarks = ilk_program_watermarks; } else {DRM_DEBUG_KMS ("Failed to read display plane latency. " "Disable CxSR\n" );Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Signature · 9 lines
Matt Roper Graphics Software Engineer IoTG Platform Enabling & Development Intel Corporation (916) 356-2795 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Sanitize watermarks after hardware state readout (v2)
Quoted 34 lines · Matt Roper
Quoted 30 lines · Jani Nikula
Quoted 19 lines · Matt Roper
Although we can do a good job of reading out hardware state, the graphics firmware may have programmed the watermarks in a creative way that doesn't match how i915 would have chosen to program them. We shouldn't trust the firmware's watermark programming, but should rather re-calculate how we think WM's should be programmed and then shove those values into the hardware.
We can do this pretty easily by creating a dummy top-level state, running it through the check process to calculate all the values, and then just programming the watermarks for each CRTC.
v2: Move watermark sanitization after our BIOS fb reconstruction; the
watermark calculations that we do here need to look atpstate->fb, which isn't setup yet inintel_modeset_setup_hw_state(), even though we have an enabled & visible plane.Cc Jani Nikula <[email protected]>Cc Maarten Lankhorst <[email protected]>Signed-off-by Matt Roper <[email protected]>Quoted 9 lines
---
Jani, based on your logs it looks like the culprit is that we're calculating watermarks at startup time after we've read out preliminary hardware state (so we know the primary plane is enabled & visible), but before we reconstruct the BIOS fb (sopstate->fbis NULL). I think moving the watermark sanitization later in the process so that we'll have a proper fb setup should hopefully solve the issue. Can you test this version when you get a chance? I'll also send a rebased patch #4 since the code movement here means that the previous version won't apply cleanly.Quoted 2 lines
Sorry Matt, black screen with new versions of patches 3-4. Dmesg at
http://pastebin.com/3LXZwvWu
Quoted 6 lines
Hmm, okay, looks like we're getting closer (successfully avoided the divide by zero problem), but I neglected to grab the necessary locks so the sanitization doesn't actually happen. Does applying
http://paste.debian.net/322932 on top of the series work any better for you? I haven't had time to pull back out an ILK-style system, so that's only compile-tested at the moment.
Still warns http://pastebin.com/yGtde5X2
BR,
Jani.
Quoted 157 lines
Matt
Quoted 153 lines
BR,
Jani.Quoted 144 lines
drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 55 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 14 +++++---- 3 files changed, 64 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -629,6 +629,7 @@ struct drm_i915_display_funcs { struct dpll *best_clock);int (*compute_pipe_wm)(struct intel_crtc *crtc,struct drm_atomic_state *state); +void (*program_watermarks)(struct intel_crtc_state *cstate);void (*update_wm)(struct drm_crtc *crtc);int (*modeset_calc_cdclk)(struct drm_atomic_state *state);void (*modeset_commit_cdclk)(struct drm_atomic_state *state);drivers/gpu/drm/i915/intel_display.c +55
-0@@ -14936,6 +14936,54 @@ void intel_modeset_init_hw(struct drm_device *dev)intel_enable_gt_powersave (dev); } +/* +* Calculate what we think the watermarks should be for the state we've read +* out of the hardware and then immediately program those watermarks so that +* we ensure the hardware settings match our internal state. +*/ +static void sanitize_watermarks (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv =to_i915 (dev); +struct drm_atomic_state *state; +struct drm_crtc *crtc; +struct drm_crtc_state *cstate; +int ret; +int i; + +/* Only supported on platforms that use atomic watermark design */ +if (!dev_priv->display.program_watermarks) +return ; + +/* +* Calculate what we think WM's should be by creating a dummy state and +* running it through the atomic check code. +*/ + state =drm_atomic_helper_duplicate_state (dev, + dev->mode_config.acquire_ctx); +if (WARN_ON (IS_ERR (state))) +return ; + + ret =intel_atomic_check (dev, state); +if (ret) { +/* +* Just give up and leave watermarks untouched if we get an +* error back from 'check' +*/ +DRM_DEBUG_KMS ("Could not determine valid watermarks for inherited state\n" ); +return ; + } + +/* Write calculated watermark values back */ +to_i915 (dev)->wm.config =to_intel_atomic_state (state)->wm_config; +for_each_crtc_in_state (state, crtc, cstate, i) { +struct intel_crtc_state *cs =to_intel_crtc_state (cstate); + + dev_priv->display.program_watermarks (cs); + } + +drm_atomic_state_free (state); +} +void intel_modeset_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;@@ -15059,6 +15107,13 @@ void intel_modeset_init(struct drm_device *dev)*/ intel_find_initial_plane_obj (crtc, &plane_config); } + +/* +* Make sure hardware watermarks really match the state we read out. +* Note that we need to do this after reconstructing the BIOS fb's +* since the watermark calculation done here will use pstate->fb. +*/ +sanitize_watermarks (dev); }static void intel_enable_pipe_a (struct drm_device *dev)drivers/gpu/drm/i915/intel_pm.c +8
-6@@ -3611,15 +3611,19 @@ static void skl_update_wm(struct drm_crtc *crtc) dev_priv->wm.skl_hw = *results; } -static void ilk_program_watermarks (struct drm_i915_private *dev_priv) +static void ilk_program_watermarks (struct intel_crtc_state *cstate) { -struct drm_device *dev = dev_priv->dev; +struct drm_crtc *crtc = cstate->base.crtc; +struct drm_device *dev = crtc->dev; +struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_pipe_wm lp_wm_1_2 = {}, lp_wm_5_6 = {}, *best_lp_wm;struct ilk_wm_maximums max;struct intel_wm_config *config = &dev_priv->wm.config;struct ilk_wm_values results = {};enum intel_ddb_partitioning partitioning; +to_intel_crtc (crtc)->wm.active.ilk = cstate->wm.optimal.ilk; +ilk_compute_wm_maximums (dev,1 , config,INTEL_DDB_PART_1_2 , &max);ilk_wm_merge (dev, config, &max, &lp_wm_1_2);@@ -3644,7 +3648,6 @@ static void ilk_program_watermarks(struct drm_i915_private *dev_priv)static void ilk_update_wm (struct drm_crtc *crtc) { -struct drm_i915_private *dev_priv =to_i915 (crtc->dev);struct intel_crtc *intel_crtc =to_intel_crtc (crtc);struct intel_crtc_state *cstate =to_intel_crtc_state (crtc->state);@@ -3662,9 +3665,7 @@ static void ilk_update_wm(struct drm_crtc *crtc)intel_wait_for_vblank (crtc->dev, intel_crtc->pipe); } - intel_crtc->wm.active.ilk = cstate->wm.optimal.ilk; - -ilk_program_watermarks (dev_priv); +ilk_program_watermarks (cstate); } static void skl_pipe_wm_active_state(uint32_t val,@@ -6972,6 +6973,7 @@ void intel_init_pm(struct drm_device *dev) dev_priv->wm.spr_latency[0] && dev_priv->wm.cur_latency[0])) { dev_priv->display.update_wm = ilk_update_wm; dev_priv->display.compute_pipe_wm = ilk_compute_pipe_wm; + dev_priv->display.program_watermarks = ilk_program_watermarks; } else {DRM_DEBUG_KMS ("Failed to read display plane latency. " "Disable CxSR\n" );Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Sanitize watermarks after hardware state readout (v2)
Quoted 42 lines · Jani Nikula
Quoted 34 lines · Matt Roper
Quoted 30 lines · Jani Nikula
Quoted 19 lines · Matt Roper
Although we can do a good job of reading out hardware state, the graphics firmware may have programmed the watermarks in a creative way that doesn't match how i915 would have chosen to program them. We shouldn't trust the firmware's watermark programming, but should rather re-calculate how we think WM's should be programmed and then shove those values into the hardware.
We can do this pretty easily by creating a dummy top-level state, running it through the check process to calculate all the values, and then just programming the watermarks for each CRTC.
v2: Move watermark sanitization after our BIOS fb reconstruction; the
watermark calculations that we do here need to look atpstate->fb, which isn't setup yet inintel_modeset_setup_hw_state(), even though we have an enabled & visible plane.Cc Jani Nikula <[email protected]>Cc Maarten Lankhorst <[email protected]>Signed-off-by Matt Roper <[email protected]>Quoted 9 lines
---
Jani, based on your logs it looks like the culprit is that we're calculating watermarks at startup time after we've read out preliminary hardware state (so we know the primary plane is enabled & visible), but before we reconstruct the BIOS fb (sopstate->fbis NULL). I think moving the watermark sanitization later in the process so that we'll have a proper fb setup should hopefully solve the issue. Can you test this version when you get a chance? I'll also send a rebased patch #4 since the code movement here means that the previous version won't apply cleanly.Quoted 2 lines
Sorry Matt, black screen with new versions of patches 3-4. Dmesg at
http://pastebin.com/3LXZwvWuQuoted 6 lines
Hmm, okay, looks like we're getting closer (successfully avoided the divide by zero problem), but I neglected to grab the necessary locks so the sanitization doesn't actually happen. Does applying
http://paste.debian.net/322932 on top of the series work any better for you? I haven't had time to pull back out an ILK-style system, so that's only compile-tested at the moment.
Quoted 4 lines
Still warns http://pastebin.com/yGtde5X2
BR,
Jani.
Sorry this is taking so long to zero in on. When you have some free time would you mind running tag 'forjani/watermark_debug-v1' from
https://github.com/mattrope/kernel.git
with debug messages turned on? I was a bit confused by your earlier logs because apparently some of our startup-time state dumping was giving misleading/inaccurate information; hopefully with the changes here, I'll get more useful debug information and better understand what's leading to the failures on your system.
Thanks again for your help.
Matt
Quoted 162 lines
Quoted 159 lines
Matt
Quoted 153 lines
BR,
Jani.Quoted 144 lines
drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 55 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 14 +++++---- 3 files changed, 64 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -629,6 +629,7 @@ struct drm_i915_display_funcs { struct dpll *best_clock);int (*compute_pipe_wm)(struct intel_crtc *crtc,struct drm_atomic_state *state); +void (*program_watermarks)(struct intel_crtc_state *cstate);void (*update_wm)(struct drm_crtc *crtc);int (*modeset_calc_cdclk)(struct drm_atomic_state *state);void (*modeset_commit_cdclk)(struct drm_atomic_state *state);drivers/gpu/drm/i915/intel_display.c +55
-0@@ -14936,6 +14936,54 @@ void intel_modeset_init_hw(struct drm_device *dev)intel_enable_gt_powersave (dev); } +/* +* Calculate what we think the watermarks should be for the state we've read +* out of the hardware and then immediately program those watermarks so that +* we ensure the hardware settings match our internal state. +*/ +static void sanitize_watermarks (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv =to_i915 (dev); +struct drm_atomic_state *state; +struct drm_crtc *crtc; +struct drm_crtc_state *cstate; +int ret; +int i; + +/* Only supported on platforms that use atomic watermark design */ +if (!dev_priv->display.program_watermarks) +return ; + +/* +* Calculate what we think WM's should be by creating a dummy state and +* running it through the atomic check code. +*/ + state =drm_atomic_helper_duplicate_state (dev, + dev->mode_config.acquire_ctx); +if (WARN_ON (IS_ERR (state))) +return ; + + ret =intel_atomic_check (dev, state); +if (ret) { +/* +* Just give up and leave watermarks untouched if we get an +* error back from 'check' +*/ +DRM_DEBUG_KMS ("Could not determine valid watermarks for inherited state\n" ); +return ; + } + +/* Write calculated watermark values back */ +to_i915 (dev)->wm.config =to_intel_atomic_state (state)->wm_config; +for_each_crtc_in_state (state, crtc, cstate, i) { +struct intel_crtc_state *cs =to_intel_crtc_state (cstate); + + dev_priv->display.program_watermarks (cs); + } + +drm_atomic_state_free (state); +} +void intel_modeset_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;@@ -15059,6 +15107,13 @@ void intel_modeset_init(struct drm_device *dev)*/ intel_find_initial_plane_obj (crtc, &plane_config); } + +/* +* Make sure hardware watermarks really match the state we read out. +* Note that we need to do this after reconstructing the BIOS fb's +* since the watermark calculation done here will use pstate->fb. +*/ +sanitize_watermarks (dev); }static void intel_enable_pipe_a (struct drm_device *dev)drivers/gpu/drm/i915/intel_pm.c +8
-6@@ -3611,15 +3611,19 @@ static void skl_update_wm(struct drm_crtc *crtc) dev_priv->wm.skl_hw = *results; } -static void ilk_program_watermarks (struct drm_i915_private *dev_priv) +static void ilk_program_watermarks (struct intel_crtc_state *cstate) { -struct drm_device *dev = dev_priv->dev; +struct drm_crtc *crtc = cstate->base.crtc; +struct drm_device *dev = crtc->dev; +struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_pipe_wm lp_wm_1_2 = {}, lp_wm_5_6 = {}, *best_lp_wm;struct ilk_wm_maximums max;struct intel_wm_config *config = &dev_priv->wm.config;struct ilk_wm_values results = {};enum intel_ddb_partitioning partitioning; +to_intel_crtc (crtc)->wm.active.ilk = cstate->wm.optimal.ilk; +ilk_compute_wm_maximums (dev,1 , config,INTEL_DDB_PART_1_2 , &max);ilk_wm_merge (dev, config, &max, &lp_wm_1_2);@@ -3644,7 +3648,6 @@ static void ilk_program_watermarks(struct drm_i915_private *dev_priv)static void ilk_update_wm (struct drm_crtc *crtc) { -struct drm_i915_private *dev_priv =to_i915 (crtc->dev);struct intel_crtc *intel_crtc =to_intel_crtc (crtc);struct intel_crtc_state *cstate =to_intel_crtc_state (crtc->state);@@ -3662,9 +3665,7 @@ static void ilk_update_wm(struct drm_crtc *crtc)intel_wait_for_vblank (crtc->dev, intel_crtc->pipe); } - intel_crtc->wm.active.ilk = cstate->wm.optimal.ilk; - -ilk_program_watermarks (dev_priv); +ilk_program_watermarks (cstate); } static void skl_pipe_wm_active_state(uint32_t val,@@ -6972,6 +6973,7 @@ void intel_init_pm(struct drm_device *dev) dev_priv->wm.spr_latency[0] && dev_priv->wm.cur_latency[0])) { dev_priv->display.update_wm = ilk_update_wm; dev_priv->display.compute_pipe_wm = ilk_compute_pipe_wm; + dev_priv->display.program_watermarks = ilk_program_watermarks; } else {DRM_DEBUG_KMS ("Failed to read display plane latency. " "Disable CxSR\n" );Signature · 1 line
Jani Nikula, Intel Open Source Technology CenterSignature · 1 line
Jani Nikula, Intel Open Source Technology Center
Signature · 9 lines
Matt Roper Graphics Software Engineer IoTG Platform Enabling & Development Intel Corporation (916) 356-2795 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Sanitize watermarks after hardware state readout (v2)
In reply to Jani NikulaQuoted 42 lines · Jani Nikula
Quoted 34 lines · Matt Roper
Quoted 30 lines · Jani Nikula
Quoted 19 lines · Matt Roper
Although we can do a good job of reading out hardware state, the graphics firmware may have programmed the watermarks in a creative way that doesn't match how i915 would have chosen to program them. We shouldn't trust the firmware's watermark programming, but should rather re-calculate how we think WM's should be programmed and then shove those values into the hardware.
We can do this pretty easily by creating a dummy top-level state, running it through the check process to calculate all the values, and then just programming the watermarks for each CRTC.
v2: Move watermark sanitization after our BIOS fb reconstruction; the
watermark calculations that we do here need to look atpstate->fb, which isn't setup yet inintel_modeset_setup_hw_state(), even though we have an enabled & visible plane.Cc Jani Nikula <[email protected]>Cc Maarten Lankhorst <[email protected]>Signed-off-by Matt Roper <[email protected]>Quoted 9 lines
---
Jani, based on your logs it looks like the culprit is that we're calculating watermarks at startup time after we've read out preliminary hardware state (so we know the primary plane is enabled & visible), but before we reconstruct the BIOS fb (sopstate->fbis NULL). I think moving the watermark sanitization later in the process so that we'll have a proper fb setup should hopefully solve the issue. Can you test this version when you get a chance? I'll also send a rebased patch #4 since the code movement here means that the previous version won't apply cleanly.Quoted 2 lines
Sorry Matt, black screen with new versions of patches 3-4. Dmesg at
http://pastebin.com/3LXZwvWuQuoted 6 lines
Hmm, okay, looks like we're getting closer (successfully avoided the divide by zero problem), but I neglected to grab the necessary locks so the sanitization doesn't actually happen. Does applying
http://paste.debian.net/322932 on top of the series work any better for you? I haven't had time to pull back out an ILK-style system, so that's only compile-tested at the moment.
Quoted 4 lines
Still warns http://pastebin.com/yGtde5X2
BR,
Jani.
Okay, thanks to Jani setting up his machine so that I can debug remotely, I think I understand where we're going wrong now. The missing piece of the puzzle is that Jani's display is 3840x2160. That means the BIOS FB we need to inherit is deemed too large by our initial hardware readout code (i.e., greater than half of dev_priv->gtt.stolen_usable_size), so we don't even bother inheriting the FB and pstate->fb stays NULL, even though pstate->visible = true and the plane is part of the CRTC's plane_mask.
Adding Maarten, Ville, and Ander to Cc since I think they may have some insights on how best to handle this. Seems like our options are:
* If our watermark code comes up with a NULL FB while pstate->visible, just pretend we're working on a 32-bit framebuffer that matches the CRTC mode dimensions. We'll then calculate appropriate watermark values, even though we don't have any real information for the FB that the hardware is scanning out of.
* Set pstate->visible = false and clear the bit from plane_mask. I think we'll run into state verification warnings then ("plane A should be disabled but is not") since our HW state and SW state don't match.
* Actually turn off the primary plane (hardware-wise) if we fail to inherit the BIOS FB.
Seems like the first option may be the simplest. Thoughts? Anything
I'm overlooking?
Matt
Quoted 162 lines
Quoted 159 lines
Matt
Quoted 153 lines
BR,
Jani.Quoted 144 lines
drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 55 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 14 +++++---- 3 files changed, 64 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -629,6 +629,7 @@ struct drm_i915_display_funcs { struct dpll *best_clock);int (*compute_pipe_wm)(struct intel_crtc *crtc,struct drm_atomic_state *state); +void (*program_watermarks)(struct intel_crtc_state *cstate);void (*update_wm)(struct drm_crtc *crtc);int (*modeset_calc_cdclk)(struct drm_atomic_state *state);void (*modeset_commit_cdclk)(struct drm_atomic_state *state);drivers/gpu/drm/i915/intel_display.c +55
-0@@ -14936,6 +14936,54 @@ void intel_modeset_init_hw(struct drm_device *dev)intel_enable_gt_powersave (dev); } +/* +* Calculate what we think the watermarks should be for the state we've read +* out of the hardware and then immediately program those watermarks so that +* we ensure the hardware settings match our internal state. +*/ +static void sanitize_watermarks (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv =to_i915 (dev); +struct drm_atomic_state *state; +struct drm_crtc *crtc; +struct drm_crtc_state *cstate; +int ret; +int i; + +/* Only supported on platforms that use atomic watermark design */ +if (!dev_priv->display.program_watermarks) +return ; + +/* +* Calculate what we think WM's should be by creating a dummy state and +* running it through the atomic check code. +*/ + state =drm_atomic_helper_duplicate_state (dev, + dev->mode_config.acquire_ctx); +if (WARN_ON (IS_ERR (state))) +return ; + + ret =intel_atomic_check (dev, state); +if (ret) { +/* +* Just give up and leave watermarks untouched if we get an +* error back from 'check' +*/ +DRM_DEBUG_KMS ("Could not determine valid watermarks for inherited state\n" ); +return ; + } + +/* Write calculated watermark values back */ +to_i915 (dev)->wm.config =to_intel_atomic_state (state)->wm_config; +for_each_crtc_in_state (state, crtc, cstate, i) { +struct intel_crtc_state *cs =to_intel_crtc_state (cstate); + + dev_priv->display.program_watermarks (cs); + } + +drm_atomic_state_free (state); +} +void intel_modeset_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;@@ -15059,6 +15107,13 @@ void intel_modeset_init(struct drm_device *dev)*/ intel_find_initial_plane_obj (crtc, &plane_config); } + +/* +* Make sure hardware watermarks really match the state we read out. +* Note that we need to do this after reconstructing the BIOS fb's +* since the watermark calculation done here will use pstate->fb. +*/ +sanitize_watermarks (dev); }static void intel_enable_pipe_a (struct drm_device *dev)drivers/gpu/drm/i915/intel_pm.c +8
-6@@ -3611,15 +3611,19 @@ static void skl_update_wm(struct drm_crtc *crtc) dev_priv->wm.skl_hw = *results; } -static void ilk_program_watermarks (struct drm_i915_private *dev_priv) +static void ilk_program_watermarks (struct intel_crtc_state *cstate) { -struct drm_device *dev = dev_priv->dev; +struct drm_crtc *crtc = cstate->base.crtc; +struct drm_device *dev = crtc->dev; +struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_pipe_wm lp_wm_1_2 = {}, lp_wm_5_6 = {}, *best_lp_wm;struct ilk_wm_maximums max;struct intel_wm_config *config = &dev_priv->wm.config;struct ilk_wm_values results = {};enum intel_ddb_partitioning partitioning; +to_intel_crtc (crtc)->wm.active.ilk = cstate->wm.optimal.ilk; +ilk_compute_wm_maximums (dev,1 , config,INTEL_DDB_PART_1_2 , &max);ilk_wm_merge (dev, config, &max, &lp_wm_1_2);@@ -3644,7 +3648,6 @@ static void ilk_program_watermarks(struct drm_i915_private *dev_priv)static void ilk_update_wm (struct drm_crtc *crtc) { -struct drm_i915_private *dev_priv =to_i915 (crtc->dev);struct intel_crtc *intel_crtc =to_intel_crtc (crtc);struct intel_crtc_state *cstate =to_intel_crtc_state (crtc->state);@@ -3662,9 +3665,7 @@ static void ilk_update_wm(struct drm_crtc *crtc)intel_wait_for_vblank (crtc->dev, intel_crtc->pipe); } - intel_crtc->wm.active.ilk = cstate->wm.optimal.ilk; - -ilk_program_watermarks (dev_priv); +ilk_program_watermarks (cstate); } static void skl_pipe_wm_active_state(uint32_t val,@@ -6972,6 +6973,7 @@ void intel_init_pm(struct drm_device *dev) dev_priv->wm.spr_latency[0] && dev_priv->wm.cur_latency[0])) { dev_priv->display.update_wm = ilk_update_wm; dev_priv->display.compute_pipe_wm = ilk_compute_pipe_wm; + dev_priv->display.program_watermarks = ilk_program_watermarks; } else {DRM_DEBUG_KMS ("Failed to read display plane latency. " "Disable CxSR\n" );Signature · 1 line
Jani Nikula, Intel Open Source Technology CenterSignature · 1 line
Jani Nikula, Intel Open Source Technology Center
Signature · 9 lines
Matt Roper Graphics Software Engineer IoTG Platform Enabling & Development Intel Corporation (916) 356-2795 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Sanitize watermarks after hardware state readout (v2)
Quoted 57 lines · Matt Roper
Quoted 42 lines · Jani Nikula
Quoted 34 lines · Matt Roper
Quoted 30 lines · Jani Nikula
Quoted 19 lines · Matt Roper
Although we can do a good job of reading out hardware state, the graphics firmware may have programmed the watermarks in a creative way that doesn't match how i915 would have chosen to program them. We shouldn't trust the firmware's watermark programming, but should rather re-calculate how we think WM's should be programmed and then shove those values into the hardware.
We can do this pretty easily by creating a dummy top-level state, running it through the check process to calculate all the values, and then just programming the watermarks for each CRTC.
v2: Move watermark sanitization after our BIOS fb reconstruction; the
watermark calculations that we do here need to look atpstate->fb, which isn't setup yet inintel_modeset_setup_hw_state(), even though we have an enabled & visible plane.Cc Jani Nikula <[email protected]>Cc Maarten Lankhorst <[email protected]>Signed-off-by Matt Roper <[email protected]>Quoted 9 lines
---
Jani, based on your logs it looks like the culprit is that we're calculating watermarks at startup time after we've read out preliminary hardware state (so we know the primary plane is enabled & visible), but before we reconstruct the BIOS fb (sopstate->fbis NULL). I think moving the watermark sanitization later in the process so that we'll have a proper fb setup should hopefully solve the issue. Can you test this version when you get a chance? I'll also send a rebased patch #4 since the code movement here means that the previous version won't apply cleanly.Quoted 2 lines
Sorry Matt, black screen with new versions of patches 3-4. Dmesg at
http://pastebin.com/3LXZwvWuQuoted 6 lines
Hmm, okay, looks like we're getting closer (successfully avoided the divide by zero problem), but I neglected to grab the necessary locks so the sanitization doesn't actually happen. Does applying
http://paste.debian.net/322932 on top of the series work any better for you? I haven't had time to pull back out an ILK-style system, so that's only compile-tested at the moment.Quoted 4 lines
Still warns http://pastebin.com/yGtde5X2
BR,
Jani.Okay, thanks to Jani setting up his machine so that I can debug remotely, I think I understand where we're going wrong now. The missing piece of the puzzle is that Jani's display is 3840x2160. That means the BIOS FB we need to inherit is deemed too large by our initial hardware readout code (i.e., greater than half of
dev_priv->gtt.stolen_usable_size), so we don't even bother inheriting the FB andpstate->fbstays NULL, even thoughpstate->visible= true and the plane is part of the CRTC'splane_mask.
Quoted 13 lines
Adding Maarten, Ville, and Ander to Cc since I think they may have some insights on how best to handle this. Seems like our options are:
* If our watermark code comes up with a NULL FB whilepstate->visible, just pretend we're working on a 32-bit framebuffer that matches the CRTC mode dimensions. We'll then calculate appropriate watermark values, even though we don't have any real information for the FB that the hardware is scanning out of.
* Setpstate->visible= false and clear the bit fromplane_mask. I think we'll run into state verification warnings then ("plane A should be disabled but is not") since our HW state and SW state don't match.
* Actually turn off the primary plane (hardware-wise) if we fail to inherit the BIOS FB.
This one. We do clear crtc_state->plane_mask already, but we fail to disable the hw plane and we also don't reset plane_state->visble.
For added chaos the plane readout/sanitize code is splattered over at least intel_find_initial_plane_obj, readout_plane_state and intel_modeset_gem_init. It would be really great if we can at least somewhat consolidate this.
-Daniel
Quoted 180 lines
Seems like the first option may be the simplest. Thoughts? Anything
I'm overlooking?Matt
Quoted 162 lines
Quoted 159 lines
Matt
Quoted 153 lines
BR,
Jani.Quoted 144 lines
drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/intel_display.c | 55 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_pm.c | 14 +++++---- 3 files changed, 64 insertions(+), 6 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -629,6 +629,7 @@ struct drm_i915_display_funcs { struct dpll *best_clock);int (*compute_pipe_wm)(struct intel_crtc *crtc,struct drm_atomic_state *state); +void (*program_watermarks)(struct intel_crtc_state *cstate);void (*update_wm)(struct drm_crtc *crtc);int (*modeset_calc_cdclk)(struct drm_atomic_state *state);void (*modeset_commit_cdclk)(struct drm_atomic_state *state);drivers/gpu/drm/i915/intel_display.c +55
-0@@ -14936,6 +14936,54 @@ void intel_modeset_init_hw(struct drm_device *dev)intel_enable_gt_powersave (dev); } +/* +* Calculate what we think the watermarks should be for the state we've read +* out of the hardware and then immediately program those watermarks so that +* we ensure the hardware settings match our internal state. +*/ +static void sanitize_watermarks (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv =to_i915 (dev); +struct drm_atomic_state *state; +struct drm_crtc *crtc; +struct drm_crtc_state *cstate; +int ret; +int i; + +/* Only supported on platforms that use atomic watermark design */ +if (!dev_priv->display.program_watermarks) +return ; + +/* +* Calculate what we think WM's should be by creating a dummy state and +* running it through the atomic check code. +*/ + state =drm_atomic_helper_duplicate_state (dev, + dev->mode_config.acquire_ctx); +if (WARN_ON (IS_ERR (state))) +return ; + + ret =intel_atomic_check (dev, state); +if (ret) { +/* +* Just give up and leave watermarks untouched if we get an +* error back from 'check' +*/ +DRM_DEBUG_KMS ("Could not determine valid watermarks for inherited state\n" ); +return ; + } + +/* Write calculated watermark values back */ +to_i915 (dev)->wm.config =to_intel_atomic_state (state)->wm_config; +for_each_crtc_in_state (state, crtc, cstate, i) { +struct intel_crtc_state *cs =to_intel_crtc_state (cstate); + + dev_priv->display.program_watermarks (cs); + } + +drm_atomic_state_free (state); +} +void intel_modeset_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;@@ -15059,6 +15107,13 @@ void intel_modeset_init(struct drm_device *dev)*/ intel_find_initial_plane_obj (crtc, &plane_config); } + +/* +* Make sure hardware watermarks really match the state we read out. +* Note that we need to do this after reconstructing the BIOS fb's +* since the watermark calculation done here will use pstate->fb. +*/ +sanitize_watermarks (dev); }static void intel_enable_pipe_a (struct drm_device *dev)drivers/gpu/drm/i915/intel_pm.c +8
-6@@ -3611,15 +3611,19 @@ static void skl_update_wm(struct drm_crtc *crtc) dev_priv->wm.skl_hw = *results; } -static void ilk_program_watermarks (struct drm_i915_private *dev_priv) +static void ilk_program_watermarks (struct intel_crtc_state *cstate) { -struct drm_device *dev = dev_priv->dev; +struct drm_crtc *crtc = cstate->base.crtc; +struct drm_device *dev = crtc->dev; +struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_pipe_wm lp_wm_1_2 = {}, lp_wm_5_6 = {}, *best_lp_wm;struct ilk_wm_maximums max;struct intel_wm_config *config = &dev_priv->wm.config;struct ilk_wm_values results = {};enum intel_ddb_partitioning partitioning; +to_intel_crtc (crtc)->wm.active.ilk = cstate->wm.optimal.ilk; +ilk_compute_wm_maximums (dev,1 , config,INTEL_DDB_PART_1_2 , &max);ilk_wm_merge (dev, config, &max, &lp_wm_1_2);@@ -3644,7 +3648,6 @@ static void ilk_program_watermarks(struct drm_i915_private *dev_priv)static void ilk_update_wm (struct drm_crtc *crtc) { -struct drm_i915_private *dev_priv =to_i915 (crtc->dev);struct intel_crtc *intel_crtc =to_intel_crtc (crtc);struct intel_crtc_state *cstate =to_intel_crtc_state (crtc->state);@@ -3662,9 +3665,7 @@ static void ilk_update_wm(struct drm_crtc *crtc)intel_wait_for_vblank (crtc->dev, intel_crtc->pipe); } - intel_crtc->wm.active.ilk = cstate->wm.optimal.ilk; - -ilk_program_watermarks (dev_priv); +ilk_program_watermarks (cstate); } static void skl_pipe_wm_active_state(uint32_t val,@@ -6972,6 +6973,7 @@ void intel_init_pm(struct drm_device *dev) dev_priv->wm.spr_latency[0] && dev_priv->wm.cur_latency[0])) { dev_priv->display.update_wm = ilk_update_wm; dev_priv->display.compute_pipe_wm = ilk_compute_pipe_wm; + dev_priv->display.program_watermarks = ilk_program_watermarks; } else {DRM_DEBUG_KMS ("Failed to read display plane latency. " "Disable CxSR\n" );Signature · 1 line
Jani Nikula, Intel Open Source Technology CenterSignature · 1 line
Jani Nikula, Intel Open Source Technology CenterSignature · 9 lines
Matt Roper Graphics Software Engineer IoTG Platform Enabling & Development Intel Corporation (916) 356-2795 _______________________________________________ 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: Sanitize watermarks after hardware state readout (v2)
In reply to Matt RoperQuoted 48 lines · Matt Roper
Quoted 42 lines · Jani Nikula
Quoted 34 lines · Matt Roper
Quoted 30 lines · Jani Nikula
Quoted 19 lines · Matt Roper
Although we can do a good job of reading out hardware state, the graphics firmware may have programmed the watermarks in a creative way that doesn't match how i915 would have chosen to program them. We shouldn't trust the firmware's watermark programming, but should rather re-calculate how we think WM's should be programmed and then shove those values into the hardware.
We can do this pretty easily by creating a dummy top-level state, running it through the check process to calculate all the values, and then just programming the watermarks for each CRTC.
v2: Move watermark sanitization after our BIOS fb reconstruction; the
watermark calculations that we do here need to look atpstate->fb, which isn't setup yet inintel_modeset_setup_hw_state(), even though we have an enabled & visible plane.Cc Jani Nikula <[email protected]>Cc Maarten Lankhorst <[email protected]>Signed-off-by Matt Roper <[email protected]>Quoted 9 lines
---
Jani, based on your logs it looks like the culprit is that we're calculating watermarks at startup time after we've read out preliminary hardware state (so we know the primary plane is enabled & visible), but before we reconstruct the BIOS fb (sopstate->fbis NULL). I think moving the watermark sanitization later in the process so that we'll have a proper fb setup should hopefully solve the issue. Can you test this version when you get a chance? I'll also send a rebased patch #4 since the code movement here means that the previous version won't apply cleanly.Quoted 2 lines
Sorry Matt, black screen with new versions of patches 3-4. Dmesg at
http://pastebin.com/3LXZwvWuQuoted 6 lines
Hmm, okay, looks like we're getting closer (successfully avoided the divide by zero problem), but I neglected to grab the necessary locks so the sanitization doesn't actually happen. Does applying
http://paste.debian.net/322932 on top of the series work any better for you? I haven't had time to pull back out an ILK-style system, so that's only compile-tested at the moment.Quoted 4 lines
Still warns http://pastebin.com/yGtde5X2
BR,
Jani.
Quoted 6 lines
Okay, thanks to Jani setting up his machine so that I can debug remotely, I think I understand where we're going wrong now. The missing piece of the puzzle is that Jani's display is 3840x2160. That means the BIOS FB we need to inherit is deemed too large by our initial hardware readout code (i.e., greater than half of
dev_priv->gtt.stolen_usable_size),
I would just revert the patch that added that restriction. IMO it makes no sense as long as FBC remains disabled by default. And even worse it doesn't even check that FBC is even supported by the platform. We're just wasting memory now.
Quoted 4 lines
so we don't even bother inheriting
the FB andpstate->fbstays NULL, even thoughpstate->visible= true and the plane is part of the CRTC'splane_mask.
Quoted 13 lines
Adding Maarten, Ville, and Ander to Cc since I think they may have some insights on how best to handle this. Seems like our options are:
* If our watermark code comes up with a NULL FB whilepstate->visible, just pretend we're working on a 32-bit framebuffer that matches the CRTC mode dimensions. We'll then calculate appropriate watermark values, even though we don't have any real information for the FB that the hardware is scanning out of.
* Setpstate->visible= false and clear the bit fromplane_mask. I think we'll run into state verification warnings then ("plane A should be disabled but is not") since our HW state and SW state don't match.
* Actually turn off the primary plane (hardware-wise) if we fail to inherit the BIOS FB.
And yes, option 3 is what I also think we should do.
Signature · 17 lines
Ville Syrjälä Intel OTC --------------------------------------------------------------------- Intel Finland Oy Registered Address: PL 281, 00181 Helsinki Business Identity Code: 0357606 - 4 Domiciled in Helsinki This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx