Pre-calculate SKL-style atomicwatermarks
Subsystems (2)
v4 cover Pre-calculate SKL-style atomicwatermarks
For a detailed explanation of this series, please see the original cover letter:
https://lists.freedesktop.org/archives/intel-gfx/2016-April/091293.html
This version is pretty much the same as v3 except that it should also fix the problems that appear if the BIOS programs bogus/unexpected DDB values before the driver starts up. Aside from rebasing to the latest -nightly, the only only changes this time around are the addition of patch #8 (track whether we consider the DDB to be in a sane state or not) and modifications to patch #9 to force a full DDB recompute if the flag is set.
Sorry for the delay getting this out; I've been out of office for the last two weeks (no access to hardware) and just got back today.
Matt Roper (17):
drm/i915: Reorganize WM structs/unions in CRTC state drm/i915: Rename s/skl_compute_pipe_wm/skl_build_pipe_wm/ drm/i915/gen9: Cache plane data rates in CRTC state drm/i915/gen9: Allow calculation of data rate for in-flight state (v2) drm/i915/gen9: Store plane minimum blocks in CRTC wm state (v2) drm/i915: Track whether an atomic transaction changes the active
CRTC's
drm/i915/gen9: Allow skl_allocate_pipe_ddb() to operate on in-flight
state (v3)
drm/i915: Add distrust_bios_wm flag to dev_priv
drm/i915/gen9: Compute DDB allocation at atomic check time (v4)
drm/i915/gen9: Drop re-allocation of DDB at atomic commit (v2)
drm/i915/gen9: Calculate plane WM's from state
drm/i915/gen9: Allow watermark calculation on in-flight atomic state
(v3) drm/i915/gen9: Use a bitmask to track dirty pipe watermarks drm/i915/gen9: Propagate watermark calculation failures up the call
chain
drm/i915/gen9: Calculate watermarks during atomic 'check' drm/i915/gen9: Reject display updates that exceed wm limitations (v2) drm/i915: Remove wm_config from dev_priv/intel_atomic_state
drivers/gpu/drm/i915/i915_drv.h | 23 +- drivers/gpu/drm/i915/intel_display.c | 51 ++- drivers/gpu/drm/i915/intel_drv.h | 83 +++-- drivers/gpu/drm/i915/intel_pm.c | 611 +++++++++++++++++++++++------------ 4 files changed, 495 insertions(+), 273 deletions(-)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 1/17 drm/i915: Reorganize WM structs/unions in CRTC state
Reorganize the nested structures and unions we have for pipe watermark data in intel_crtc_state so that platform-specific data can be added in a more sensible manner (and save a bit of memory at the same time).
The change basically changes the organization from:
union {
struct intel_pipe_wm ilk;
struct intel_pipe_wm skl;
} optimal;
struct intel_pipe_wm intermediate /* ILK-only */to
union {
struct {
struct intel_pipe_wm intermediate;
struct intel_pipe_wm optimal;
} ilk;
struct {
struct intel_pipe_wm optimal;
} skl;
}There should be no functional change here, but it will allow us to add more platform-specific fields going forward (and more easily extend to other platform types like VLV).
While we're at it, let's move the entire watermark substructure out to its own structure definition to make the code slightly more readable.
--- drivers/gpu/drm/i915/intel_drv.h | 61 +++++++++++++++++++++++----------------- drivers/gpu/drm/i915/intel_pm.c | 18 ++++++------ 2 files changed, 44 insertions(+), 35 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +35 -26
@@ -405,6 +405,40 @@ struct skl_pipe_wm {uint32_t linetime; }; +struct intel_crtc_wm_state { +union { +struct { +/* +* 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; + +/* +* Optimal watermarks, programmed post-vblank +* when this state is committed. +*/ +struct intel_pipe_wm optimal; + } ilk; + +struct { +/* gen9+ only needs 1-step wm programming */ +struct skl_pipe_wm optimal; + } skl; + }; + +/* +* 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; +}; +struct intel_crtc_state {struct drm_crtc_state base;
@@ -558,32 +592,7 @@ struct intel_crtc_state {/* IVB sprite scaling w/a (WaCxSRDisabledForSpriteScaling:ivb) */ bool disable_lp_wm; -struct { -/* -* 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; +struct intel_crtc_wm_state wm;/* Gamma mode programmed on the pipe */ uint32_t gamma_mode;
drivers/gpu/drm/i915/intel_pm.c +9 -9
@@ -2309,7 +2309,7 @@ static int ilk_compute_pipe_wm(struct intel_crtc_state *cstate)int level, max_level =ilk_wm_max_level (dev), usable_level;struct ilk_wm_maximums max; - pipe_wm = &cstate->wm.optimal.ilk; + pipe_wm = &cstate->wm.ilk.optimal;for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) {struct intel_plane_state *ps;
@@ -2391,7 +2391,7 @@ static int ilk_compute_intermediate_wm(struct drm_device *dev,struct intel_crtc *intel_crtc, struct intel_crtc_state *newstate) { - struct intel_pipe_wm *a = &newstate->wm.intermediate; + struct intel_pipe_wm *a = &newstate->wm.ilk.intermediate;struct intel_pipe_wm *b = &intel_crtc->wm.active.ilk;int level, max_level =ilk_wm_max_level (dev);
@@ -2400,7 +2400,7 @@ static int ilk_compute_intermediate_wm(struct drm_device *dev,* currently active watermarks to get values that are safe both before * and after the vblank. */ - *a = newstate->wm.optimal.ilk; + *a = newstate->wm.ilk.optimal; a->pipe_enabled |= b->pipe_enabled; a->sprites_enabled |= b->sprites_enabled; a->sprites_scaled |= b->sprites_scaled;
@@ -2429,7 +2429,7 @@ static int ilk_compute_intermediate_wm(struct drm_device *dev,* If our intermediate WM are identical to the final WM, then we can * omit the post-vblank programming; only update if it's different. */ -if (memcmp (a, &newstate->wm.optimal.ilk,sizeof (*a)) ==0 ) +if (memcmp (a, &newstate->wm.ilk.optimal,sizeof (*a)) ==0 ) newstate->wm.need_postvbl_update = false;return 0 ;
@@ -3678,7 +3678,7 @@ static void skl_update_wm(struct drm_crtc *crtc)struct drm_i915_private *dev_priv = dev->dev_private;struct skl_wm_values *results = &dev_priv->wm.skl_results;struct intel_crtc_state *cstate =to_intel_crtc_state (crtc->state); -struct skl_pipe_wm *pipe_wm = &cstate->wm.optimal.skl; +struct skl_pipe_wm *pipe_wm = &cstate->wm.skl.optimal;/* Clear all dirty flags */
@@ -3757,7 +3757,7 @@ static void ilk_initial_watermarks(struct intel_crtc_state *cstate)struct intel_crtc *intel_crtc =to_intel_crtc (cstate->base.crtc);mutex_lock (&dev_priv->wm.wm_mutex); - intel_crtc->wm.active.ilk = cstate->wm.intermediate; + intel_crtc->wm.active.ilk = cstate->wm.ilk.intermediate;ilk_program_watermarks (dev_priv);mutex_unlock (&dev_priv->wm.wm_mutex); }
@@ -3769,7 +3769,7 @@ static void ilk_optimize_watermarks(struct intel_crtc_state *cstate)mutex_lock (&dev_priv->wm.wm_mutex);if (cstate->wm.need_postvbl_update) { - intel_crtc->wm.active.ilk = cstate->wm.optimal.ilk; + intel_crtc->wm.active.ilk = cstate->wm.ilk.optimal;ilk_program_watermarks (dev_priv); }mutex_unlock (&dev_priv->wm.wm_mutex);
@@ -3826,7 +3826,7 @@ static void skl_pipe_wm_get_hw_state(struct drm_crtc *crtc)struct skl_wm_values *hw = &dev_priv->wm.skl_hw;struct intel_crtc *intel_crtc =to_intel_crtc (crtc);struct intel_crtc_state *cstate =to_intel_crtc_state (crtc->state); -struct skl_pipe_wm *active = &cstate->wm.optimal.skl; +struct skl_pipe_wm *active = &cstate->wm.skl.optimal;enum pipe pipe = intel_crtc->pipe;int level, i, max_level;uint32_t temp;
@@ -3892,7 +3892,7 @@ static void ilk_pipe_wm_get_hw_state(struct drm_crtc *crtc)struct ilk_wm_values *hw = &dev_priv->wm.hw;struct intel_crtc *intel_crtc =to_intel_crtc (crtc);struct intel_crtc_state *cstate =to_intel_crtc_state (crtc->state); -struct intel_pipe_wm *active = &cstate->wm.optimal.ilk; +struct intel_pipe_wm *active = &cstate->wm.ilk.optimal;enum pipe pipe = intel_crtc->pipe;static const i915_reg_t wm0_pipe_reg[] = { [PIPE_A ] =WM0_PIPEA_ILK ,
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 2/17 drm/i915: Rename s/skl_compute_pipe_wm/skl_build_pipe_wm/
In reply to Matt RoperWhen we added atomic watermarks, we added a new display vfunc 'compute_pipe_wm' that is used to compute any pipe-specific watermark information that we can at atomic check time. This was a somewhat poor naming choice since we already had a 'skl_compute_pipe_wm' function that doesn't quite fit this model --- the existing SKL function is something that gets used at atomic commit time, after the DDB allocation has been determined. Let's rename the existing SKL function to avoid confusion.
--- drivers/gpu/drm/i915/intel_pm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +4 -4
@@ -3327,9 +3327,9 @@ static void skl_compute_transition_wm(struct intel_crtc_state *cstate, } } -static void skl_compute_pipe_wm (struct intel_crtc_state *cstate, -struct skl_ddb_allocation *ddb, -struct skl_pipe_wm *pipe_wm) +static void skl_build_pipe_wm (struct intel_crtc_state *cstate, +struct skl_ddb_allocation *ddb, +struct skl_pipe_wm *pipe_wm) {struct drm_device *dev = cstate->base.crtc->dev;const struct drm_i915_private *dev_priv = dev->dev_private;
@@ -3596,7 +3596,7 @@ static bool skl_update_pipe_wm(struct drm_crtc *crtc,struct intel_crtc_state *cstate =to_intel_crtc_state (crtc->state);skl_allocate_pipe_ddb (cstate, ddb); -skl_compute_pipe_wm (cstate, ddb, pipe_wm); +skl_build_pipe_wm (cstate, ddb, pipe_wm);if (!memcmp (&intel_crtc->wm.active.skl, pipe_wm,sizeof (*pipe_wm)))return false;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 3/17 drm/i915/gen9: Cache plane data rates in CRTC state
In reply to Matt RoperThis will be important when we start calculating CRTC data rates for in-flight CRTC states since it will allow us to calculate the total data rate without needing to grab the plane state for any planes that aren't updated by the transaction.
--- drivers/gpu/drm/i915/intel_drv.h | 4 ++ drivers/gpu/drm/i915/intel_pm.c | 92 ++++++++++++++++++++++++++-------------- 2 files changed, 63 insertions(+), 33 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +4 -0
@@ -427,6 +427,10 @@ struct intel_crtc_wm_state {struct {/* gen9+ only needs 1-step wm programming */ struct skl_pipe_wm optimal; + +/* cached plane data rate */ +unsigned plane_data_rate[I915_MAX_PLANES ]; +unsigned plane_y_data_rate[I915_MAX_PLANES ]; } skl; };
drivers/gpu/drm/i915/intel_pm.c +59 -33
157 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 4/17 drm/i915/gen9: Allow calculation of data rate for in-flight state (v2)
In reply to Matt RoperOur skl_get_total_relative_data_rate() function gets passed a crtc state object to calculate the data rate for, but it currently always looks up the committed plane states that correspond to that CRTC. Let's check whether the CRTC state is an in-flight state (meaning cstate->state is non-NULL) and if so, use the corresponding in-flight plane states.
We'll soon be using this function exclusively for in-flight states; at that time we'll be able to simplify the function a bit, but for now we allow it to be used in either mode.
v2:
- Rebase on top of changes to cache plane data rates.
--- drivers/gpu/drm/i915/intel_pm.c | 74 +++++++++++++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +60 -14
@@ -2975,25 +2975,69 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,* 3 * 4096 * 8192 * 4 < 2^32 */ static unsigned int -skl_get_total_relative_data_rate (struct intel_crtc_state *cstate) +skl_get_total_relative_data_rate (struct intel_crtc_state *intel_cstate) { -struct intel_crtc *intel_crtc =to_intel_crtc (cstate->base.crtc); -struct drm_device *dev = intel_crtc->base.dev; +struct drm_crtc_state *cstate = &intel_cstate->base; +struct drm_atomic_state *state = cstate->state; +struct drm_crtc *crtc = cstate->crtc; +struct drm_device *dev = crtc->dev; +struct intel_crtc *intel_crtc =to_intel_crtc (crtc);const struct intel_plane *intel_plane;unsigned int rate, total_data_rate =0 ; +int id;/* Calculate and cache data rate for each plane */ -for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) { -const struct drm_plane_state *pstate = intel_plane->base.state; -int id =skl_wm_plane_id (intel_plane); +/* +* FIXME: At the moment this function can be called on either an +* in-flight or a committed state object. If it's in-flight then we +* only want to re-calculate the plane data rate for planes that are +* part of the transaction (i.e., we don't want to grab any additional +* plane states if we don't have to). If we're operating on committed +* state, we'll just go ahead and recalculate the plane data rate for +* all planes. +* +* Once we finish moving our DDB allocation to the atomic check phase, +* we'll only be calling this function on in-flight state objects, so +* the 'else' branch here will go away. +*/ +if (state) { +struct drm_plane *plane; +struct drm_plane_state *pstate; +int i; + +for_each_plane_in_state (state, plane, pstate, i) { + intel_plane =to_intel_plane (plane); + id =skl_wm_plane_id (intel_plane); + +if (intel_plane->pipe != intel_crtc->pipe) +continue ; + +/* packed/uv */ + rate =skl_plane_relative_data_rate (intel_cstate, + pstate,0 ); + intel_cstate->wm.skl.plane_data_rate[id] = rate; + +/* y-plane */ + rate =skl_plane_relative_data_rate (intel_cstate, + pstate,1 ); + intel_cstate->wm.skl.plane_y_data_rate[id] = rate; + } + }else { +for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) { +const struct drm_plane_state *pstate = + intel_plane->base.state; +int id =skl_wm_plane_id (intel_plane); -/* packed/uv */ - rate =skl_plane_relative_data_rate (cstate, pstate,0 ); - cstate->wm.skl.plane_data_rate[id] = rate; +/* packed/uv */ + rate =skl_plane_relative_data_rate (intel_cstate, + pstate,0 ); + intel_cstate->wm.skl.plane_data_rate[id] = rate; -/* y-plane */ - rate =skl_plane_relative_data_rate (cstate, pstate,1 ); - cstate->wm.skl.plane_y_data_rate[id] = rate; +/* y-plane */ + rate =skl_plane_relative_data_rate (intel_cstate, + pstate,1 ); + intel_cstate->wm.skl.plane_y_data_rate[id] = rate; + } }/* Calculate CRTC's total data rate from cached values */
@@ -3001,10 +3045,12 @@ skl_get_total_relative_data_rate(struct intel_crtc_state *cstate)int id =skl_wm_plane_id (intel_plane);/* packed/uv */ - total_data_rate += cstate->wm.skl.plane_data_rate[id]; - total_data_rate += cstate->wm.skl.plane_y_data_rate[id]; + total_data_rate += intel_cstate->wm.skl.plane_data_rate[id]; + total_data_rate += intel_cstate->wm.skl.plane_y_data_rate[id]; } +WARN_ON (cstate->plane_mask && total_data_rate ==0 ); +return total_data_rate; }
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 5/17 drm/i915/gen9: Store plane minimum blocks in CRTC wm state (v2)
In reply to Matt RoperThis will eventually allow us to re-use old values without re-calculating them for unchanged planes (which also helps us avoid re-grabbing extra plane states).
v2:
- Drop unnecessary memset's; they were meant for a later patch (which got reworked anyway to not need them, but were mis-rebased into this one. (Maarten)
--- drivers/gpu/drm/i915/intel_drv.h | 4 ++++ drivers/gpu/drm/i915/intel_pm.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +4 -0
@@ -431,6 +431,10 @@ struct intel_crtc_wm_state {/* cached plane data rate */ unsigned plane_data_rate[I915_MAX_PLANES ];unsigned plane_y_data_rate[I915_MAX_PLANES ]; + +/* minimum block allocation */ +uint16_t minimum_blocks[I915_MAX_PLANES ]; +uint16_t minimum_y_blocks[I915_MAX_PLANES ]; } skl; };
drivers/gpu/drm/i915/intel_pm.c +2 -2
@@ -3067,8 +3067,8 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate,enum pipe pipe = intel_crtc->pipe;struct skl_ddb_entry *alloc = &ddb->pipe[pipe];uint16_t alloc_size, start, cursor_blocks; -uint16_t minimum[I915_MAX_PLANES ]; -uint16_t y_minimum[I915_MAX_PLANES ]; +uint16_t *minimum = cstate->wm.skl.minimum_blocks; +uint16_t *y_minimum = cstate->wm.skl.minimum_y_blocks;unsigned int total_data_rate;skl_ddb_get_pipe_allocation_limits (dev, cstate, config, alloc);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 6/17 drm/i915: Track whether an atomic transaction changes the active CRTC's
In reply to Matt RoperFor the purposes of DDB re-allocation we need to know whether a transaction changes the list of CRTC's that are active. While state->modeset could be used for this purpose, that would be slightly too aggressive since it would lead us to re-allocate the DDB when a CRTC's mode changes, but not its final active state.
--- drivers/gpu/drm/i915/intel_display.c | 3 +++ drivers/gpu/drm/i915/intel_drv.h | 10 ++++++++++ 2 files changed, 13 insertions(+)
drivers/gpu/drm/i915/intel_display.c +3 -0
@@ -13271,6 +13271,9 @@ static int intel_modeset_checks(struct drm_atomic_state *state) intel_state->active_crtcs |=1 << i; else intel_state->active_crtcs &= ~(1 << i); + +if (crtc_state->active != crtc->state->active) + intel_state->active_pipe_changes |=drm_crtc_mask (crtc); }/*
drivers/gpu/drm/i915/intel_drv.h +10 -0
@@ -291,6 +291,16 @@ struct intel_atomic_state {bool dpll_set, modeset; +/* +* Does this transaction change the pipes that are active? This mask +* tracks which CRTC's have changed their active state at the end of +* the transaction (not counting the temporary disable during modesets). +* This mask should only be non-zero when intel_state->modeset is true, +* but the converse is not necessarily true; simply changing a mode may +* not flip the final active status of any CRTC's +*/ +unsigned int active_pipe_changes; +unsigned int active_crtcs;unsigned int min_pixclk[I915_MAX_PIPES ];
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 7/17 drm/i915/gen9: Allow skl_allocate_pipe_ddb() to operate on in-flight state (v3)
In reply to Matt RoperWe eventually want to calculate watermark values at atomic 'check' time instead of atomic 'commit' time so that any requested configurations that result in impossible watermark requirements are properly rejected. The first step along this path is to allocate the DDB at atomic 'check' time. As we perform this transition, allow the main allocation function to operate successfully on either an in-flight state or an already-commited state. Once we complete the transition in a future patch, we'll come back and remove the unnecessary logic for the already-committed case.
v2: Rebase/refactor; we should no longer need to grab extra plane states
while allocating the DDB since we can pull cached data rates and minimum block counts from the CRTC state for any planes that aren't being modified by this transaction.
v3:
- Simplify memsets to clear DDB plane entries. (Maarten)
- Drop a redundant memset of plane[pipe][PLANE_CURSOR] that was added by an earlier Coccinelle patch. (Maarten)
- Assign *num_active at the top of skl_ddb_get_pipe_allocation_limits() so that no code paths return without setting it. (kbuild robot)
--- drivers/gpu/drm/i915/i915_drv.h | 6 ++ drivers/gpu/drm/i915/intel_pm.c | 179 +++++++++++++++++++++++++++++----------- 2 files changed, 139 insertions(+), 46 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +6 -0
@@ -324,6 +324,12 @@ struct i915_hotplug { &dev->mode_config.plane_list, \ base.head) +#define for_each_intel_plane_mask (dev, intel_plane, plane_mask) \ + list_for_each_entry(intel_plane, &dev->mode_config.plane_list, \ + base.head) \ + for_each_if ((plane_mask) & \ + (1 << drm_plane_index(&intel_plane->base))) +#define for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) \ list_for_each_entry(intel_plane, \ &(dev)->mode_config.plane_list, \
drivers/gpu/drm/i915/intel_pm.c +133 -46
273 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 8/17 drm/i915: Add distrust_bios_wm flag to dev_priv
In reply to Matt RoperSKL-style platforms can't fully trust the watermark/DDB settings programmed by the BIOS and need to do extra sanitization on their first atomic update. Add a flag to dev_priv that is set during hardware readout and cleared at the end of the first commit.
Note that for the somewhat common case where everything is turned off when the driver starts up, we don't need to bother with a recompute...we know exactly what the DDB should be (all zero's) so just setup the DDB directly in that case.
--- drivers/gpu/drm/i915/i915_drv.h | 7 +++++++ drivers/gpu/drm/i915/intel_display.c | 7 +++++++ drivers/gpu/drm/i915/intel_pm.c | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +7 -0
@@ -1993,6 +1993,13 @@ struct drm_i915_private {* cstate->wm.need_postvbl_update. */ struct mutex wm_mutex; + +/* +* Set during HW readout of watermarks/DDB. Some platforms +* need to know when we're still using BIOS-provided values +* (which we don't fully trust). +*/ +bool distrust_bios_wm; } wm;struct i915_runtime_pm pm;
drivers/gpu/drm/i915/intel_display.c +7 -0
@@ -13703,6 +13703,13 @@ static int intel_atomic_commit(struct drm_device *dev, dev_priv->display.optimize_watermarks (intel_cstate); } +/* +* We've now finished at least one atomic commit following hw readout, +* so any platforms that needed to do extra sanitization of watermarks +* should have done it by now. +*/ + dev_priv->wm.distrust_bios_wm = false; +for_each_crtc_in_state (state, crtc, old_crtc_state, i) {intel_post_plane_update (to_intel_crtc_state (old_crtc_state));
drivers/gpu/drm/i915/intel_pm.c +14 -1
@@ -4021,11 +4021,24 @@ void skl_wm_get_hw_state(struct drm_device *dev)struct skl_ddb_allocation *ddb = &dev_priv->wm.skl_hw.ddb;struct drm_crtc *crtc;struct intel_crtc *intel_crtc; +bool any_on = false;skl_ddb_get_hw_state (dev_priv, ddb); -list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) +list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {skl_pipe_wm_get_hw_state (crtc); +if (crtc->state->active) + any_on = true; + } + +if (any_on) { +/* Fully recompute DDB on first atomic commit */ + dev_priv->wm.distrust_bios_wm = true; + }else { +/* Easy/common case; just sanitize DDB now if everything off */ +memset (ddb,0 ,sizeof (*ddb)); + } +/* Calculate plane data rates */ for_each_intel_crtc (dev, intel_crtc) {struct intel_crtc_state *cstate = intel_crtc->config;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 08/17] drm/i915: Add distrust_bios_wm flag to dev_priv
Op 10-05-16 om 03:21 schreef Matt Roper:
Quoted 41 lines
SKL-style platforms can't fully trust the watermark/DDB settings programmed by the BIOS and need to do extra sanitization on their first atomic update. Add a flag to
dev_privthat is set during hardware readout and cleared at the end of the first commit.Note that for the somewhat common case where everything is turned off when the driver starts up, we don't need to bother with a recompute...we know exactly what the DDB should be (all zero's) so just setup the DDB directly in that case.
Cc Maarten Lankhorst <[email protected]>Signed-off-by Matt Roper <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 7 +++++++ drivers/gpu/drm/i915/intel_display.c | 7 +++++++ drivers/gpu/drm/i915/intel_pm.c | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_drv.h +7
-0@@ -1993,6 +1993,13 @@ struct drm_i915_private {* cstate->wm.need_postvbl_update. */ struct mutex wm_mutex; + +/* +* Set during HW readout of watermarks/DDB. Some platforms +* need to know when we're still using BIOS-provided values +* (which we don't fully trust). +*/ +bool distrust_bios_wm; } wm;struct i915_runtime_pm pm;drivers/gpu/drm/i915/intel_display.c +0
-0
drivers/gpu/drm/i915/intel_display.c static int intel_atomic_commit(struct drm_device *dev, · line 13711
Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +6
-0@@ -13703,6 +13703,13 @@ static int intel_atomic_commit(struct drm_device *dev, dev_priv->display.optimize_watermarks (intel_cstate); } +/* +* We've now finished at least one atomic commit following hw readout, +* so any platforms that needed to do extra sanitization of watermarks +* should have done it by now. +*/ + dev_priv->wm.distrust_bios_wm = false;
I guess at this point atomic wm commit doesn't work yet?
When it does it should be put after swap_state, or kill it and rely on skip_intermediate_wm. :)
Quoted 12 lines
drivers/gpu/drm/i915/intel_display.c +0
-0for_each_crtc_in_state (state, crtc, old_crtc_state, i) {intel_post_plane_update (to_intel_crtc_state (old_crtc_state));drivers/gpu/drm/i915/intel_pm.c +1
-0@@ -4021,11 +4021,24 @@ void skl_wm_get_hw_state(struct drm_device *dev)struct skl_ddb_allocation *ddb = &dev_priv->wm.skl_hw.ddb;struct drm_crtc *crtc;struct intel_crtc *intel_crtc; +bool any_on = false;
drivers/gpu/drm/i915/intel_pm.c void skl_wm_get_hw_state(struct drm_device *dev) · line 4033
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +5
-1skl_ddb_get_hw_state (dev_priv, ddb); -list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) +list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {skl_pipe_wm_get_hw_state (crtc); +if (crtc->state->active) + any_on = true; + } +
dev_priv->active_crtcs?
drivers/gpu/drm/i915/intel_pm.c void skl_wm_get_hw_state(struct drm_device *dev) · line 4044
Quoted 11 lines
drivers/gpu/drm/i915/intel_pm.c +8
-0+if (any_on) { +/* Fully recompute DDB on first atomic commit */ + dev_priv->wm.distrust_bios_wm = true; + }else { +/* Easy/common case; just sanitize DDB now if everything off */ +memset (ddb,0 ,sizeof (*ddb)); + } +/* Calculate plane data rates */ for_each_intel_crtc (dev, intel_crtc) {struct intel_crtc_state *cstate = intel_crtc->config;
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 08/17] drm/i915: Add distrust_bios_wm flag to dev_priv
Quoted 53 lines · Maarten Lankhorst
Op 10-05-16 om 03:21 schreef Matt Roper:
Quoted 41 lines
SKL-style platforms can't fully trust the watermark/DDB settings programmed by the BIOS and need to do extra sanitization on their first atomic update. Add a flag to
dev_privthat is set during hardware readout and cleared at the end of the first commit.Note that for the somewhat common case where everything is turned off when the driver starts up, we don't need to bother with a recompute...we know exactly what the DDB should be (all zero's) so just setup the DDB directly in that case.
Cc Maarten Lankhorst <[email protected]>Signed-off-by Matt Roper <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 7 +++++++ drivers/gpu/drm/i915/intel_display.c | 7 +++++++ drivers/gpu/drm/i915/intel_pm.c | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_drv.h +7
-0@@ -1993,6 +1993,13 @@ struct drm_i915_private {* cstate->wm.need_postvbl_update. */ struct mutex wm_mutex; + +/* +* Set during HW readout of watermarks/DDB. Some platforms +* need to know when we're still using BIOS-provided values +* (which we don't fully trust). +*/ +bool distrust_bios_wm; } wm;struct i915_runtime_pm pm;drivers/gpu/drm/i915/intel_display.c +0
-0drivers/gpu/drm/i915/intel_display.c static int intel_atomic_commit(struct drm_device *dev, · line 13711
Quoted 9 lines
drivers/gpu/drm/i915/intel_display.c +6
-0@@ -13703,6 +13703,13 @@ static int intel_atomic_commit(struct drm_device *dev, dev_priv->display.optimize_watermarks (intel_cstate); } +/* +* We've now finished at least one atomic commit following hw readout, +* so any platforms that needed to do extra sanitization of watermarks +* should have done it by now. +*/ + dev_priv->wm.distrust_bios_wm = false;I guess at this point atomic wm commit doesn't work yet?
Quoted 1 line
When it does it should be put after
swap_state, or kill it and rely onskip_intermediate_wm. :)
Yeah, moving it to swap_state might be a more natural location. I'll update the patch to do that.
Since we don't need two-step watermark programming on gen9, I haven't touched the commit side of watermarks here, just the check/compute side. I think there's some improvements that could be done around the whole DDB write dance that gets done on gen9, but I haven't had time to really think carefully about that yet. If I make some changes there in the future, then I'll probably switch the commit of watermarks from the old update_wm entrypoint to the atomic entrypoints and that will let the same sanitization that runs on ILK-style platforms to just do a dummy commit to setup the DDB properly.
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/i915/intel_display.c +0
-0for_each_crtc_in_state (state, crtc, old_crtc_state, i) {intel_post_plane_update (to_intel_crtc_state (old_crtc_state));drivers/gpu/drm/i915/intel_pm.c +2
-1@@ -4021,11 +4021,24 @@ void skl_wm_get_hw_state(struct drm_device *dev)struct skl_ddb_allocation *ddb = &dev_priv->wm.skl_hw.ddb;struct drm_crtc *crtc;struct intel_crtc *intel_crtc; +bool any_on = false;skl_ddb_get_hw_state (dev_priv, ddb); -list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) +list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) {skl_pipe_wm_get_hw_state (crtc);
Quoted 5 lines
drivers/gpu/drm/i915/intel_pm.c void skl_wm_get_hw_state(struct drm_device *dev) · line 4033
Quoted 4 lines
drivers/gpu/drm/i915/intel_pm.c +4
-0+if (crtc->state->active) + any_on = true; + } +
dev_priv->active_crtcs?
Hmm, you're right. For some reason I had convinced myself that it wasn't initialized yet at this point, but it looks like it should be (intel_modeset_readout_hw_state has already run). I'll switch over to just use that. Thanks.
Matt
Quoted 14 lines
Quoted 12 lines
drivers/gpu/drm/i915/intel_pm.c +8
-0+if (any_on) { +/* Fully recompute DDB on first atomic commit */ + dev_priv->wm.distrust_bios_wm = true; + }else { +/* Easy/common case; just sanitize DDB now if everything off */ +memset (ddb,0 ,sizeof (*ddb)); + } +/* Calculate plane data rates */ for_each_intel_crtc (dev, intel_crtc) {struct intel_crtc_state *cstate = intel_crtc->config;
Signature · 9 lines
Matt Roper Graphics Software Engineer IoTG Platform Enabling & Development Intel Corporation (916) 356-2795 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 8/17 drm/i915: Add distrust_bios_wm flag to dev_priv (v2)
In reply to Maarten LankhorstSKL-style platforms can't fully trust the watermark/DDB settings programmed by the BIOS and need to do extra sanitization on their first atomic update. Add a flag to dev_priv that is set during hardware readout and cleared at the end of the first commit.
Note that for the somewhat common case where everything is turned off when the driver starts up, we don't need to bother with a recompute...we know exactly what the DDB should be (all zero's) so just setup the DDB directly in that case.
v2:
- Move clearing of distrust_bios_wm up below the swap_state call since it's a more natural / self-explanatory location. (Maarten)
- Use dev_priv->active_crtcs to test whether any CRTC's are turned on during HW WM readout rather than trying to count the active CRTC's again ourselves. (Maarten)
--- drivers/gpu/drm/i915/i915_drv.h | 7 +++++++ drivers/gpu/drm/i915/intel_display.c | 1 + drivers/gpu/drm/i915/intel_pm.c | 8 ++++++++ 3 files changed, 16 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +7 -0
@@ -1993,6 +1993,13 @@ struct drm_i915_private {* cstate->wm.need_postvbl_update. */ struct mutex wm_mutex; + +/* +* Set during HW readout of watermarks/DDB. Some platforms +* need to know when we're still using BIOS-provided values +* (which we don't fully trust). +*/ +bool distrust_bios_wm; } wm;struct i915_runtime_pm pm;
drivers/gpu/drm/i915/intel_display.c +1 -0
@@ -13595,6 +13595,7 @@ static int intel_atomic_commit(struct drm_device *dev,drm_atomic_helper_swap_state (dev, state); dev_priv->wm.config = intel_state->wm_config; + dev_priv->wm.distrust_bios_wm = false;intel_shared_dpll_commit (state);if (intel_state->modeset) {
drivers/gpu/drm/i915/intel_pm.c +8 -0
@@ -4026,6 +4026,14 @@ void skl_wm_get_hw_state(struct drm_device *dev)list_for_each_entry (crtc, &dev->mode_config.crtc_list, head)skl_pipe_wm_get_hw_state (crtc); +if (dev_priv->active_crtcs) { +/* Fully recompute DDB on first atomic commit */ + dev_priv->wm.distrust_bios_wm = true; + }else { +/* Easy/common case; just sanitize DDB now if everything off */ +memset (ddb,0 ,sizeof (*ddb)); + } +/* Calculate plane data rates */ for_each_intel_crtc (dev, intel_crtc) {struct intel_crtc_state *cstate = intel_crtc->config;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v4 08/17] drm/i915: Add distrust_bios_wm flag to dev_priv (v2)
Op 11-05-16 om 18:02 schreef Matt Roper:
Quoted 64 lines
SKL-style platforms can't fully trust the watermark/DDB settings programmed by the BIOS and need to do extra sanitization on their first atomic update. Add a flag to
dev_privthat is set during hardware readout and cleared at the end of the first commit.Note that for the somewhat common case where everything is turned off when the driver starts up, we don't need to bother with a recompute...we know exactly what the DDB should be (all zero's) so just setup the DDB directly in that case.
v2:
- Move clearing ofdistrust_bios_wmup below theswap_statecall since it's a more natural / self-explanatory location. (Maarten)
- Usedev_priv->active_crtcsto test whether any CRTC's are turned on during HW WM readout rather than trying to count the active CRTC's again ourselves. (Maarten)Cc Maarten Lankhorst <[email protected]>Signed-off-by Matt Roper <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 7 +++++++ drivers/gpu/drm/i915/intel_display.c | 1 + drivers/gpu/drm/i915/intel_pm.c | 8 ++++++++ 3 files changed, 16 insertions(+)drivers/gpu/drm/i915/i915_drv.h +7
-0@@ -1993,6 +1993,13 @@ struct drm_i915_private {* cstate->wm.need_postvbl_update. */ struct mutex wm_mutex; + +/* +* Set during HW readout of watermarks/DDB. Some platforms +* need to know when we're still using BIOS-provided values +* (which we don't fully trust). +*/ +bool distrust_bios_wm; } wm;struct i915_runtime_pm pm;drivers/gpu/drm/i915/intel_display.c +1
-0@@ -13595,6 +13595,7 @@ static int intel_atomic_commit(struct drm_device *dev,drm_atomic_helper_swap_state (dev, state); dev_priv->wm.config = intel_state->wm_config; + dev_priv->wm.distrust_bios_wm = false;intel_shared_dpll_commit (state);if (intel_state->modeset) {drivers/gpu/drm/i915/intel_pm.c +1
-0@@ -4026,6 +4026,14 @@ void skl_wm_get_hw_state(struct drm_device *dev)list_for_each_entry (crtc, &dev->mode_config.crtc_list, head)skl_pipe_wm_get_hw_state (crtc); +if (dev_priv->active_crtcs) {
drivers/gpu/drm/i915/intel_pm.c void skl_wm_get_hw_state(struct drm_device *dev) · line 4039
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +7
-0+/* Fully recompute DDB on first atomic commit */ + dev_priv->wm.distrust_bios_wm = true; + }else { +/* Easy/common case; just sanitize DDB now if everything off */ +memset (ddb,0 ,sizeof (*ddb)); + } +/* Calculate plane data rates */ for_each_intel_crtc (dev, intel_crtc) {struct intel_crtc_state *cstate = intel_crtc->config;
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 9/17 drm/i915/gen9: Compute DDB allocation at atomic check time (v4)
In reply to Matt RoperCalculate the DDB blocks needed to satisfy the current atomic transaction at atomic check time. This is a prerequisite to calculating SKL watermarks during the 'check' phase and rejecting any configurations that we can't find valid watermarks for.
Due to the nature of DDB allocation, it's possible for the addition of a new CRTC to make the watermark configuration already in use on another, unchanged CRTC become invalid. A change in which CRTC's are active triggers a recompute of the entire DDB, which unfortunately means we need to disallow any other atomic commits from racing with such an update. If the active CRTC's change, we need to grab the lock on all CRTC's and run all CRTC's through their 'check' handler to recompute and re-check their per-CRTC DDB allocations.
Note that with this patch we only compute the DDB allocation but we don't actually use the computed values during watermark programming yet. For ease of review/testing/bisecting, we still recompute the DDB at watermark programming time and just WARN() if it doesn't match the precomputed values. A future patch will switch over to using the precomputed values once we're sure they're being properly computed.
Another clarifying note: DDB allocation itself shouldn't ever fail with the algorithm we use today (i.e., we have enough DDB blocks on BXT to support the minimum needs of the worst-case scenario of every pipe/plane enabled at full size). However the watermarks calculations based on the DDB may fail and we'll be moving those to the atomic check as well in future patches.
v2:
- Skip DDB calculations in the rare case where our transaction doesn't actually touch any CRTC's at all. Assuming at least one CRTC state is present in our transaction, then it means we can't race with any transactions that would update dev_priv->active_crtcs (which requires _all_ CRTC locks).
v3:
- Also calculate DDB during initial hw readout, to prevent using incorrect bios values. (Maarten)
v4:
- Use new distrust_bios_wm flag instead of skip_initial_wm (which was never actually set).
- Set intel_state->active_pipe_changes instead of just realloc_pipes
--- drivers/gpu/drm/i915/i915_drv.h | 5 +++ drivers/gpu/drm/i915/intel_display.c | 18 ++++++++ drivers/gpu/drm/i915/intel_drv.h | 3 ++ drivers/gpu/drm/i915/intel_pm.c | 79 ++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +5 -0
@@ -339,6 +339,10 @@ struct i915_hotplug {#define for_each_intel_crtc (dev, intel_crtc) \ list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list, base.head) +#define for_each_intel_crtc_mask (dev, intel_crtc, crtc_mask) \ + list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list, base.head) \ + for_each_if ((crtc_mask) & (1 << drm_crtc_index(&intel_crtc->base))) +#define for_each_intel_encoder (dev, intel_encoder) \ list_for_each_entry(intel_encoder, \ &(dev)->mode_config.encoder_list, \
@@ -594,6 +598,7 @@ struct drm_i915_display_funcs { struct intel_crtc_state *newstate);void (*initial_watermarks)(struct intel_crtc_state *cstate);void (*optimize_watermarks)(struct intel_crtc_state *cstate); +int (*compute_global_watermarks)(struct drm_atomic_state *state);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 +18 -0
@@ -13313,6 +13313,7 @@ static int intel_modeset_checks(struct drm_atomic_state *state)static void calc_watermark_data (struct drm_atomic_state *state) {struct drm_device *dev = state->dev; +struct drm_i915_private *dev_priv =to_i915 (dev);struct intel_atomic_state *intel_state =to_intel_atomic_state (state);struct drm_crtc *crtc;struct drm_crtc_state *cstate;
@@ -13342,6 +13343,10 @@ static void calc_watermark_data(struct drm_atomic_state *state) pstate->crtc_h != pstate->src_h >> 16) intel_state->wm_config.sprites_scaled = true; } + +/* Is there platform-specific watermark information to calculate? */ +if (dev_priv->display.compute_global_watermarks) + dev_priv->display.compute_global_watermarks (state); }/**
@@ -13719,6 +13724,19 @@ static int intel_atomic_commit(struct drm_device *dev,intel_modeset_verify_crtc (crtc, old_crtc_state, crtc->state); } +/* +* Temporary sanity check: make sure our pre-computed DDB matches the +* one we actually wind up programming. +* +* Not a great place to put this, but the easiest place we have access +* to both the pre-computed and final DDB's; we'll be removing this +* check in the next patch anyway. +*/ +WARN (IS_GEN9 (dev) && +memcmp (&intel_state->ddb, &dev_priv->wm.skl_results.ddb, +sizeof (intel_state->ddb)), +"Pre-computed DDB does not match final DDB!\n" ); +if (intel_state->modeset)intel_display_power_put (dev_priv,POWER_DOMAIN_MODESET );
drivers/gpu/drm/i915/intel_drv.h +3 -0
@@ -312,6 +312,9 @@ struct intel_atomic_state {* don't bother calculating intermediate watermarks. */ bool skip_intermediate_wm; + +/* Gen9+ only */ +struct skl_ddb_allocation ddb; };struct intel_plane_state {
drivers/gpu/drm/i915/intel_pm.c +79 -0
91 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 10/17 drm/i915/gen9: Drop re-allocation of DDB at atomic commit (v2)
In reply to Matt RoperNow that we're properly pre-allocating the DDB during the atomic check phase and we trust that the allocation is appropriate, let's actually use the allocation computed and not duplicate that work during the commit phase.
v2:
- Significant rebasing now that we can use cached data rates and minimum block allocations to avoid grabbing additional plane states.
--- drivers/gpu/drm/i915/intel_display.c | 14 +-- drivers/gpu/drm/i915/intel_pm.c | 224 +++++++++++------------------------ 2 files changed, 67 insertions(+), 171 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -13
@@ -13600,6 +13600,7 @@ static int intel_atomic_commit(struct drm_device *dev,drm_atomic_helper_swap_state (dev, state); dev_priv->wm.config = intel_state->wm_config; + dev_priv->wm.skl_results.ddb = intel_state->ddb;intel_shared_dpll_commit (state);if (intel_state->modeset) {
@@ -13724,19 +13725,6 @@ static int intel_atomic_commit(struct drm_device *dev,intel_modeset_verify_crtc (crtc, old_crtc_state, crtc->state); } -/* -* Temporary sanity check: make sure our pre-computed DDB matches the -* one we actually wind up programming. -* -* Not a great place to put this, but the easiest place we have access -* to both the pre-computed and final DDB's; we'll be removing this -* check in the next patch anyway. -*/ -WARN (IS_GEN9 (dev) && -memcmp (&intel_state->ddb, &dev_priv->wm.skl_results.ddb, -sizeof (intel_state->ddb)), -"Pre-computed DDB does not match final DDB!\n" ); -if (intel_state->modeset)intel_display_power_put (dev_priv,POWER_DOMAIN_MODESET );
drivers/gpu/drm/i915/intel_pm.c +66 -158
307 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 11/17 drm/i915/gen9: Calculate plane WM's from state
In reply to Matt RoperIn a future patch we'll want to calculate plane watermarks for in-flight atomic state rather than the already-committed state.
--- drivers/gpu/drm/i915/intel_pm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +8 -8
@@ -3240,16 +3240,14 @@ static bool skl_ddb_allocation_changed(const struct skl_ddb_allocation *new_ddb,static bool skl_compute_plane_wm (const struct drm_i915_private *dev_priv,struct intel_crtc_state *cstate, -struct intel_plane *intel_plane, +struct intel_plane_state *intel_pstate,uint16_t ddb_allocation,int level,uint16_t *out_blocks,/* out */ uint8_t *out_lines/* out */ ) { -struct drm_plane *plane = &intel_plane->base; -struct drm_framebuffer *fb = plane->state->fb; -struct intel_plane_state *intel_pstate = -to_intel_plane_state (plane->state); +struct drm_plane_state *pstate = &intel_pstate->base; +struct drm_framebuffer *fb = pstate->fb;uint32_t latency = dev_priv->wm.skl_latency[level];uint32_t method1, method2;uint32_t plane_bytes_per_line, plane_blocks_per_line;
@@ -3264,7 +3262,7 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv, width =drm_rect_width (&intel_pstate->src) >>16 ; height =drm_rect_height (&intel_pstate->src) >>16 ; -if (intel_rotation_90_or_270 (plane->state->rotation)) +if (intel_rotation_90_or_270 (pstate->rotation))swap (width, height); cpp =drm_format_plane_cpp (fb->pixel_format,0 );
@@ -3284,7 +3282,7 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv, fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED) {uint32_t min_scanlines =4 ;uint32_t y_tile_minimum; -if (intel_rotation_90_or_270 (plane->state->rotation)) { +if (intel_rotation_90_or_270 (pstate->rotation)) {int cpp = (fb->pixel_format ==DRM_FORMAT_NV12 ) ?drm_format_plane_cpp (fb->pixel_format,1 ) :drm_format_plane_cpp (fb->pixel_format,0 );
@@ -3338,17 +3336,19 @@ static void skl_compute_wm_level(const struct drm_i915_private *dev_priv,struct drm_device *dev = dev_priv->dev;struct intel_crtc *intel_crtc =to_intel_crtc (cstate->base.crtc);struct intel_plane *intel_plane; +struct intel_plane_state *intel_pstate;uint16_t ddb_blocks;enum pipe pipe = intel_crtc->pipe;for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) {int i =skl_wm_plane_id (intel_plane); + intel_pstate =to_intel_plane_state (intel_plane->base.state); ddb_blocks =skl_ddb_entry_size (&ddb->plane[pipe][i]); result->plane_en[i] = skl_compute_plane_wm(dev_priv, cstate, - intel_plane, + intel_pstate, ddb_blocks, level, &result->plane_res_b[i],
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 12/17 drm/i915/gen9: Allow watermark calculation on in-flight atomic state (v3)
In reply to Matt RoperIn an upcoming patch we'll move this calculation to the atomic 'check' phase so that the display update can be rejected early if no valid watermark programming is possible.
v2:
- Drop intel_pstate_for_cstate_plane() helper and add note about how the code needs to evolve in the future if we start allowing more than one pending commit against a CRTC. (Maarten)
v3:
- Only have skl_compute_wm_level calculate watermarks for enabled planes; we can just set the other planes on a CRTC to disabled without having to look at the plane state. This is important because despite our CRTC lock we can still have racing commits that modify a disabled plane's property without turning it on. (Maarten)
--- drivers/gpu/drm/i915/intel_pm.c | 61 ++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +48 -13
@@ -3327,23 +3327,56 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,return true; } -static void skl_compute_wm_level (const struct drm_i915_private *dev_priv, -struct skl_ddb_allocation *ddb, -struct intel_crtc_state *cstate, -int level, -struct skl_wm_level *result) +static int +skl_compute_wm_level (const struct drm_i915_private *dev_priv, +struct skl_ddb_allocation *ddb, +struct intel_crtc_state *cstate, +int level, +struct skl_wm_level *result) {struct drm_device *dev = dev_priv->dev; +struct drm_atomic_state *state = cstate->base.state;struct intel_crtc *intel_crtc =to_intel_crtc (cstate->base.crtc); +struct drm_plane *plane;struct intel_plane *intel_plane;struct intel_plane_state *intel_pstate;uint16_t ddb_blocks;enum pipe pipe = intel_crtc->pipe; -for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) { +/* +* We'll only calculate watermarks for planes that are actually +* enabled, so make sure all other planes are set as disabled. +*/ +memset (result,0 ,sizeof (*result)); + +for_each_intel_plane_mask (dev, intel_plane, cstate->base.plane_mask) {int i =skl_wm_plane_id (intel_plane); - intel_pstate =to_intel_plane_state (intel_plane->base.state); + plane = &intel_plane->base; + intel_pstate =NULL ; +if (state) + intel_pstate = +intel_atomic_get_existing_plane_state (state, + intel_plane); + +/* +* Note: If we start supporting multiple pending atomic commits +* against the same planes/CRTC's in the future, plane->state +* will no longer be the correct pre-state to use for the +* calculations here and we'll need to change where we get the +* 'unchanged' plane data from. +* +* For now this is fine because we only allow one queued commit +* against a CRTC. Even if the plane isn't modified by this +* transaction and we don't have a plane lock, we still have +* the CRTC's lock, so we know that no other transactions are +* racing with us to update it. +*/ +if (!intel_pstate) + intel_pstate =to_intel_plane_state (plane->state); + +WARN_ON (!intel_pstate->base.fb); + ddb_blocks =skl_ddb_entry_size (&ddb->plane[pipe][i]); result->plane_en[i] = skl_compute_plane_wm(dev_priv,
@@ -3354,6 +3387,8 @@ static void skl_compute_wm_level(const struct drm_i915_private *dev_priv, &result->plane_res_b[i], &result->plane_res_l[i]); } + +return 0 ; } static uint32_t
@@ -3648,14 +3683,14 @@ static void skl_flush_wm_values(struct drm_i915_private *dev_priv, } } -static bool skl_update_pipe_wm (struct drm_crtc *crtc, +static bool skl_update_pipe_wm (struct drm_crtc_state *cstate,struct skl_ddb_allocation *ddb,/* out */ struct skl_pipe_wm *pipe_wm/* out */ ) { -struct intel_crtc *intel_crtc =to_intel_crtc (crtc); -struct intel_crtc_state *cstate =to_intel_crtc_state (crtc->state); +struct intel_crtc *intel_crtc =to_intel_crtc (cstate->crtc); +struct intel_crtc_state *intel_cstate =to_intel_crtc_state (cstate); -skl_build_pipe_wm (cstate, ddb, pipe_wm); +skl_build_pipe_wm (intel_cstate, ddb, pipe_wm);if (!memcmp (&intel_crtc->wm.active.skl, pipe_wm,sizeof (*pipe_wm)))return false;
@@ -3695,7 +3730,7 @@ static void skl_update_other_pipe_wm(struct drm_device *dev,if (!intel_crtc->active)continue ; - wm_changed =skl_update_pipe_wm (&intel_crtc->base, + wm_changed =skl_update_pipe_wm (intel_crtc->base.state, &r->ddb, &pipe_wm);/*
@@ -3813,7 +3848,7 @@ static void skl_update_wm(struct drm_crtc *crtc)skl_clear_wm (results, intel_crtc->pipe); -if (!skl_update_pipe_wm (crtc, &results->ddb, pipe_wm)) +if (!skl_update_pipe_wm (crtc->state, &results->ddb, pipe_wm))return ;skl_compute_wm_results (dev, pipe_wm, results, intel_crtc);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 13/17 drm/i915/gen9: Use a bitmask to track dirty pipe watermarks
In reply to Matt RoperSlightly easier to work with than an array of bools.
--- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_pm.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -1596,7 +1596,7 @@ struct skl_ddb_allocation { };struct skl_wm_values { -bool dirty[I915_MAX_PIPES ]; +unsigned dirty_pipes;struct skl_ddb_allocation ddb;uint32_t wm_linetime[I915_MAX_PIPES ];uint32_t plane[I915_MAX_PIPES ][I915_MAX_PLANES ][8 ];
drivers/gpu/drm/i915/intel_pm.c +5 -5
@@ -3516,7 +3516,7 @@ static void skl_write_wm_values(struct drm_i915_private *dev_priv,int i, level, max_level =ilk_wm_max_level (dev);enum pipe pipe = crtc->pipe; -if (!new->dirty[pipe]) +if ((new->dirty_pipes &drm_crtc_mask (&crtc->base)) ==0 )continue ;I915_WRITE (PIPE_WM_LINETIME (pipe), new->wm_linetime[pipe]);
@@ -3741,7 +3741,7 @@ static void skl_update_other_pipe_wm(struct drm_device *dev,WARN_ON (!wm_changed);skl_compute_wm_results (dev, &pipe_wm, r, intel_crtc); - r->dirty[intel_crtc->pipe] = true; + r->dirty_pipes |=drm_crtc_mask (&intel_crtc->base); } }
@@ -3844,7 +3844,7 @@ static void skl_update_wm(struct drm_crtc *crtc)/* Clear all dirty flags */ -memset (results->dirty,0 ,sizeof (bool ) *I915_MAX_PIPES ); + results->dirty_pipes =0 ;skl_clear_wm (results, intel_crtc->pipe);
@@ -3852,7 +3852,7 @@ static void skl_update_wm(struct drm_crtc *crtc)return ;skl_compute_wm_results (dev, pipe_wm, results, intel_crtc); - results->dirty[intel_crtc->pipe] = true; + results->dirty_pipes |=drm_crtc_mask (&intel_crtc->base);skl_update_other_pipe_wm (dev, crtc, results);skl_write_wm_values (dev_priv, results);
@@ -4011,7 +4011,7 @@ static void skl_pipe_wm_get_hw_state(struct drm_crtc *crtc)if (!intel_crtc->active)return ; - hw->dirty[pipe] = true; + hw->dirty_pipes |=drm_crtc_mask (crtc); active->linetime = hw->wm_linetime[pipe];
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 14/17 drm/i915/gen9: Propagate watermark calculation failures up the call chain
In reply to Matt RoperOnce we move watermark calculation to the atomic check phase, we'll want to start rejecting display configurations that exceed out watermark limits. At the moment we just assume that there's always a valid set of watermarks, even though this may not actually be true. Let's prepare by passing return codes up through the call stack in preparation.
--- drivers/gpu/drm/i915/intel_display.c | 10 ++-- drivers/gpu/drm/i915/intel_pm.c | 90 ++++++++++++++++++++++-------------- 2 files changed, 61 insertions(+), 39 deletions(-)
drivers/gpu/drm/i915/intel_display.c +5 -5
@@ -13310,7 +13310,7 @@ static int intel_modeset_checks(struct drm_atomic_state *state)* phase. The code here should be run after the per-crtc and per-plane 'check' * handlers to ensure that all derived state has been updated. */ -static void calc_watermark_data (struct drm_atomic_state *state) +static int calc_watermark_data (struct drm_atomic_state *state) {struct drm_device *dev = state->dev;struct drm_i915_private *dev_priv =to_i915 (dev);
@@ -13346,7 +13346,9 @@ static void calc_watermark_data(struct drm_atomic_state *state)/* Is there platform-specific watermark information to calculate? */ if (dev_priv->display.compute_global_watermarks) - dev_priv->display.compute_global_watermarks (state); +return dev_priv->display.compute_global_watermarks (state); + +return 0 ; }/**
@@ -13433,9 +13435,7 @@ static int intel_atomic_check(struct drm_device *dev,return ret;intel_fbc_choose_crtc (dev_priv, state); -calc_watermark_data (state); - -return 0 ; +return calc_watermark_data (state); } static int intel_atomic_prepare_commit(struct drm_device *dev,
drivers/gpu/drm/i915/intel_pm.c +56 -34
173 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 15/17 drm/i915/gen9: Calculate watermarks during atomic 'check'
In reply to Matt RoperMoving watermark calculation into the check phase will allow us to to reject display configurations for which there are no valid watermark values before we start trying to program the hardware (although those tests will come in a subsequent patch).
Another advantage of moving this calculation to the check phase is that we can calculate the watermarks in a single shot as part of the atomic transaction. The watermark interfaces we inherited from our legacy modesetting days are a bit broken in the atomic design because they use per-crtc entry points but actually re-calculate and re-program something that is really more of a global state. That worked okay in the legacy modesetting world because operations only ever updated a single CRTC at a time. However in the atomic world, a transaction can involve multiple CRTC's, which means we wind up computing and programming the watermarks NxN times (where N is the number of CRTC's involved). With this patch we eliminate the redundant re-calculation of watermark data for atomic states (which was the cause of the WARN_ON(!wm_changed) problems that have plagued us for a while).
We still need to work on the 'commit' side of watermark handling so that we aren't doing redundant NxN programming of watermarks, but that's content for future patches.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89055
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92181
--- drivers/gpu/drm/i915/intel_display.c | 2 +- drivers/gpu/drm/i915/intel_drv.h | 2 +- drivers/gpu/drm/i915/intel_pm.c | 138 +++++++++++++---------------------- 3 files changed, 52 insertions(+), 90 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
@@ -13600,7 +13600,7 @@ static int intel_atomic_commit(struct drm_device *dev,drm_atomic_helper_swap_state (dev, state); dev_priv->wm.config = intel_state->wm_config; - dev_priv->wm.skl_results.ddb = intel_state->ddb; + dev_priv->wm.skl_results = intel_state->wm_results;intel_shared_dpll_commit (state);if (intel_state->modeset) {
drivers/gpu/drm/i915/intel_drv.h +1 -1
@@ -314,7 +314,7 @@ struct intel_atomic_state {bool skip_intermediate_wm;/* Gen9+ only */ -struct skl_ddb_allocation ddb; +struct skl_wm_values wm_results; };struct intel_plane_state {
drivers/gpu/drm/i915/intel_pm.c +50 -88
204 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 16/17 drm/i915/gen9: Reject display updates that exceed wm limitations (v2)
In reply to Matt RoperIf we can't find any valid level 0 watermark values for the requested atomic transaction, reject the configuration before we try to start programming the hardware.
v2:
- Add extra debugging output when we reject level 0 watermarks so that we can more easily debug how/why they were rejected.
--- drivers/gpu/drm/i915/intel_pm.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_pm.c +16 -1
@@ -3306,7 +3306,22 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,if (res_blocks >= ddb_allocation || res_lines >31 ) { *enabled = false; -return 0 ; + +/* +* If there are no valid level 0 watermarks, then we can't +* support this display configuration. +*/ +if (level) { +return 0 ; + }else { +DRM_DEBUG_KMS ("Requested display configuration exceeds system watermark limitations\n" ); +DRM_DEBUG_KMS ("Plane %d.%d: blocks required = %u/%u, lines required = %u/31\n" , +to_intel_crtc (cstate->base.crtc)->pipe, +skl_wm_plane_id (to_intel_plane (pstate->plane)), + res_blocks, ddb_allocation, res_lines); + +return -EINVAL ; + } } *out_blocks = res_blocks;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 17/17 drm/i915: Remove wm_config from dev_priv/intel_atomic_state
In reply to Matt RoperWe calculate the watermark config into intel_atomic_state and then save it into dev_priv, but never actually use it from there. This is left-over from some early ILK-style watermark programming designs that got changed over time.
--- drivers/gpu/drm/i915/i915_drv.h | 3 --- drivers/gpu/drm/i915/intel_display.c | 31 ------------------------------- drivers/gpu/drm/i915/intel_drv.h | 1 - 3 files changed, 35 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -3
@@ -1973,9 +1973,6 @@ struct drm_i915_private {*/ uint16_t skl_latency[8 ]; -/* Committed wm config */ -struct intel_wm_config config; -/* * The skl_wm_values structure is a bit too big for stack * allocation, so we keep the staging struct where we store
drivers/gpu/drm/i915/intel_display.c +0 -31
@@ -13314,35 +13314,6 @@ static int calc_watermark_data(struct drm_atomic_state *state) {struct drm_device *dev = state->dev;struct drm_i915_private *dev_priv =to_i915 (dev); -struct intel_atomic_state *intel_state =to_intel_atomic_state (state); -struct drm_crtc *crtc; -struct drm_crtc_state *cstate; -struct drm_plane *plane; -struct drm_plane_state *pstate; - -/* -* Calculate watermark configuration details now that derived -* plane/crtc state is all properly updated. -*/ -drm_for_each_crtc (crtc, dev) { - cstate =drm_atomic_get_existing_crtc_state (state, crtc) ?: - crtc->state; - -if (cstate->active) - intel_state->wm_config.num_pipes_active++; - } -drm_for_each_legacy_plane (plane, dev) { - pstate =drm_atomic_get_existing_plane_state (state, plane) ?: - plane->state; - -if (!to_intel_plane_state (pstate)->visible) -continue ; - - intel_state->wm_config.sprites_enabled = true; -if (pstate->crtc_w != pstate->src_w >>16 || - pstate->crtc_h != pstate->src_h >>16 ) - intel_state->wm_config.sprites_scaled = true; - }/* Is there platform-specific watermark information to calculate? */ if (dev_priv->display.compute_global_watermarks)
@@ -13599,7 +13570,6 @@ static int intel_atomic_commit(struct drm_device *dev, }drm_atomic_helper_swap_state (dev, state); - dev_priv->wm.config = intel_state->wm_config; dev_priv->wm.skl_results = intel_state->wm_results;intel_shared_dpll_commit (state);
@@ -15374,7 +15344,6 @@ retry: }/* 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);
drivers/gpu/drm/i915/intel_drv.h +0 -1
@@ -305,7 +305,6 @@ struct intel_atomic_state {unsigned int min_pixclk[I915_MAX_PIPES ];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
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Ro.CI.BAT: failure for Pre-calculate SKL-style atomicwatermarks (rev2)
In reply to Matt Roper== Series Details ==
== Series Details ==
Series: Pre-calculate SKL-style atomicwatermarks (rev2)
URL : https://patchwork.freedesktop.org/series/6944/
State : failure
== Summary ==
Applying: drm/i915: Reorganize WM structs/unions in CRTC state
Applying: drm/i915: Rename s/skl_compute_pipe_wm/skl_build_pipe_wm/
Applying: drm/i915/gen9: Cache plane data rates in CRTC state
Applying: drm/i915/gen9: Allow calculation of data rate for in-flight state (v2)
Applying: drm/i915/gen9: Store plane minimum blocks in CRTC wm state (v2)
Applying: drm/i915: Track whether an atomic transaction changes the active CRTC's
Applying: drm/i915/gen9: Allow skl_allocate_pipe_ddb() to operate on in-flight state (v3)
Applying: drm/i915: Add distrust_bios_wm flag to dev_priv (v2)
Applying: drm/i915/gen9: Compute DDB allocation at atomic check time (v4)
Applying: drm/i915/gen9: Drop re-allocation of DDB at atomic commit (v2) Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/intel_display.c
M drivers/gpu/drm/i915/intel_pm.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/intel_pm.c
Auto-merging drivers/gpu/drm/i915/intel_display.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/intel_display.c Patch failed at 0010 drm/i915/gen9: Drop re-allocation of DDB at atomic commit (v2) The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx