Commit 5363096f authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Extract intel_crtc_dbuf_weights()

Extract the code to calculate the weights used to chunk up the dbuf
between pipes. There's still extra stuff in there that shouldn't be
there and must be moved out, but that requires a bit more state to
be tracked in the dbuf state.

v2: Keep crtc_state->wm.skl.ddb
Reviewed-by: default avatarStanislav Lisovskiy <stanislav.lisovskiy@intel.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210122205633.18492-7-ville.syrjala@linux.intel.com
parent 47a14955
...@@ -4103,63 +4103,35 @@ static unsigned int intel_crtc_ddb_weight(const struct intel_crtc_state *crtc_st ...@@ -4103,63 +4103,35 @@ static unsigned int intel_crtc_ddb_weight(const struct intel_crtc_state *crtc_st
static u8 skl_compute_dbuf_slices(struct intel_crtc *crtc, static u8 skl_compute_dbuf_slices(struct intel_crtc *crtc,
u8 active_pipes); u8 active_pipes);
static int static int intel_crtc_dbuf_weights(struct intel_atomic_state *state,
skl_ddb_get_pipe_allocation_limits(struct drm_i915_private *dev_priv, struct intel_crtc *for_crtc,
struct intel_crtc_state *crtc_state, unsigned int *weight_start,
const u64 total_data_rate, unsigned int *weight_end,
struct skl_ddb_entry *alloc, /* out */ unsigned int *weight_total)
int *num_active /* out */)
{ {
struct drm_atomic_state *state = crtc_state->uapi.state;
struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
struct intel_crtc *for_crtc = to_intel_crtc(crtc_state->uapi.crtc);
struct intel_crtc *crtc;
unsigned int pipe_weight = 0, total_weight = 0, weight_before_pipe = 0;
enum pipe for_pipe = for_crtc->pipe;
struct intel_dbuf_state *new_dbuf_state =
intel_atomic_get_new_dbuf_state(intel_state);
const struct intel_dbuf_state *old_dbuf_state = const struct intel_dbuf_state *old_dbuf_state =
intel_atomic_get_old_dbuf_state(intel_state); intel_atomic_get_old_dbuf_state(state);
struct intel_dbuf_state *new_dbuf_state =
intel_atomic_get_new_dbuf_state(state);
u8 active_pipes = new_dbuf_state->active_pipes; u8 active_pipes = new_dbuf_state->active_pipes;
struct skl_ddb_entry ddb_slices; enum pipe for_pipe = for_crtc->pipe;
u32 ddb_range_size; const struct intel_crtc_state *crtc_state;
u32 i; struct intel_crtc *crtc;
u32 dbuf_slice_mask; u8 dbuf_slice_mask;
u32 total_slice_mask; u8 total_slice_mask;
u32 start, end; int i, ret;
int ret;
*num_active = hweight8(active_pipes);
if (!crtc_state->hw.active) {
alloc->start = 0;
alloc->end = 0;
crtc_state->wm.skl.ddb = *alloc;
return 0;
}
/*
* If the state doesn't change the active CRTC's or there is no
* modeset request, then there's no need to recalculate;
* the existing pipe allocation limits should remain unchanged.
* Note that we're safe from racing commits since any racing commit
* that changes the active CRTC list or do modeset would need to
* grab _all_ crtc locks, including the one we currently hold.
*/
if (old_dbuf_state->active_pipes == new_dbuf_state->active_pipes &&
!dev_priv->wm.distrust_bios_wm)
return 0;
/* /*
* Get allowed DBuf slices for correspondent pipe and platform. * Get allowed DBuf slices for correspondent pipe and platform.
*/ */
dbuf_slice_mask = skl_compute_dbuf_slices(for_crtc, active_pipes); dbuf_slice_mask = skl_compute_dbuf_slices(for_crtc, active_pipes);
total_slice_mask = dbuf_slice_mask;
skl_ddb_entry_for_slices(dev_priv, dbuf_slice_mask, &ddb_slices); *weight_start = 0;
ddb_range_size = skl_ddb_entry_size(&ddb_slices); *weight_end = 0;
*weight_total = 0;
total_slice_mask = dbuf_slice_mask; for_each_new_intel_crtc_in_state(state, crtc, crtc_state, i) {
for_each_new_intel_crtc_in_state(intel_state, crtc, crtc_state, i) {
enum pipe pipe = crtc->pipe; enum pipe pipe = crtc->pipe;
unsigned int weight; unsigned int weight;
u8 pipe_dbuf_slice_mask; u8 pipe_dbuf_slice_mask;
...@@ -4190,12 +4162,14 @@ skl_ddb_get_pipe_allocation_limits(struct drm_i915_private *dev_priv, ...@@ -4190,12 +4162,14 @@ skl_ddb_get_pipe_allocation_limits(struct drm_i915_private *dev_priv,
continue; continue;
weight = intel_crtc_ddb_weight(crtc_state); weight = intel_crtc_ddb_weight(crtc_state);
total_weight += weight; *weight_total += weight;
if (pipe < for_pipe) if (pipe < for_pipe) {
weight_before_pipe += weight; *weight_start += weight;
else if (pipe == for_pipe) *weight_end += weight;
pipe_weight = weight; } else if (pipe == for_pipe) {
*weight_end += weight;
}
} }
/* /*
...@@ -4210,8 +4184,67 @@ skl_ddb_get_pipe_allocation_limits(struct drm_i915_private *dev_priv, ...@@ -4210,8 +4184,67 @@ skl_ddb_get_pipe_allocation_limits(struct drm_i915_private *dev_priv,
return ret; return ret;
} }
start = ddb_range_size * weight_before_pipe / total_weight; return 0;
end = ddb_range_size * (weight_before_pipe + pipe_weight) / total_weight; }
static int
skl_ddb_get_pipe_allocation_limits(struct drm_i915_private *dev_priv,
struct intel_crtc_state *crtc_state,
const u64 total_data_rate,
struct skl_ddb_entry *alloc, /* out */
int *num_active /* out */)
{
struct intel_atomic_state *state =
to_intel_atomic_state(crtc_state->uapi.state);
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
unsigned int weight_start, weight_end, weight_total;
const struct intel_dbuf_state *old_dbuf_state =
intel_atomic_get_old_dbuf_state(state);
struct intel_dbuf_state *new_dbuf_state =
intel_atomic_get_new_dbuf_state(state);
u8 active_pipes = new_dbuf_state->active_pipes;
struct skl_ddb_entry ddb_slices;
u32 ddb_range_size;
u32 dbuf_slice_mask;
u32 start, end;
int ret;
*num_active = hweight8(active_pipes);
if (!crtc_state->hw.active) {
alloc->start = 0;
alloc->end = 0;
crtc_state->wm.skl.ddb = *alloc;
return 0;
}
/*
* If the state doesn't change the active CRTC's or there is no
* modeset request, then there's no need to recalculate;
* the existing pipe allocation limits should remain unchanged.
* Note that we're safe from racing commits since any racing commit
* that changes the active CRTC list or do modeset would need to
* grab _all_ crtc locks, including the one we currently hold.
*/
if (old_dbuf_state->active_pipes == new_dbuf_state->active_pipes &&
!dev_priv->wm.distrust_bios_wm)
return 0;
/*
* Get allowed DBuf slices for correspondent pipe and platform.
*/
dbuf_slice_mask = skl_compute_dbuf_slices(crtc, active_pipes);
skl_ddb_entry_for_slices(dev_priv, dbuf_slice_mask, &ddb_slices);
ddb_range_size = skl_ddb_entry_size(&ddb_slices);
ret = intel_crtc_dbuf_weights(state, crtc,
&weight_start, &weight_end, &weight_total);
if (ret)
return ret;
start = ddb_range_size * weight_start / weight_total;
end = ddb_range_size * weight_end / weight_total;
alloc->start = ddb_slices.start + start; alloc->start = ddb_slices.start + start;
alloc->end = ddb_slices.start + end; alloc->end = ddb_slices.start + end;
...@@ -4219,7 +4252,7 @@ skl_ddb_get_pipe_allocation_limits(struct drm_i915_private *dev_priv, ...@@ -4219,7 +4252,7 @@ skl_ddb_get_pipe_allocation_limits(struct drm_i915_private *dev_priv,
drm_dbg_kms(&dev_priv->drm, drm_dbg_kms(&dev_priv->drm,
"[CRTC:%d:%s] dbuf slices 0x%x, ddb (%d - %d), active pipes 0x%x\n", "[CRTC:%d:%s] dbuf slices 0x%x, ddb (%d - %d), active pipes 0x%x\n",
for_crtc->base.base.id, for_crtc->base.name, crtc->base.base.id, crtc->base.name,
dbuf_slice_mask, alloc->start, alloc->end, active_pipes); dbuf_slice_mask, alloc->start, alloc->end, active_pipes);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment