Commit af157b76 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Stop using mode->private_flags

Replace the use of mode->private_flags with a truly private bitmaks
in our own crtc state. We also need a copy in the crtc itself so the
vblank code can get at it. We already have scanline_offset in there
for a similar reason, as well as the vblank->hwmode which is assigned
via drm_calc_timestamping_constants(). Fortunately we now have a
nice place for doing the crtc_state->crtc copy in
intel_crtc_update_active_timings() which gets called both for
modesets and init/resume readout.

The one slightly iffy spot is the INHERITED flag which we want to
preserve until userspace/fb_helper does the first proper commit after
actually calling .detecti() on the connectors. Otherwise we don't have
the full sink capabilities (audio,infoframes,etc.) when .compute_config()
gets called and thus we will fail to enable those features when the
first userspace commit happens. The only internal commit we do prior to
that should be from intel_initial_commit() and there we can simply
preserve the INHERITED flag from the readout.

v2: Deal with INHERITED in sanitize_watermarks() as well

CC: Sam Ravnborg <sam@ravnborg.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200429103904.11727-1-ville.syrjala@linux.intel.com
parent 2010b7f0
...@@ -1469,8 +1469,7 @@ static void gen11_dsi_get_config(struct intel_encoder *encoder, ...@@ -1469,8 +1469,7 @@ static void gen11_dsi_get_config(struct intel_encoder *encoder,
pipe_config->pipe_bpp = bdw_get_pipemisc_bpp(crtc); pipe_config->pipe_bpp = bdw_get_pipemisc_bpp(crtc);
if (gen11_dsi_is_periodic_cmd_mode(intel_dsi)) if (gen11_dsi_is_periodic_cmd_mode(intel_dsi))
pipe_config->hw.adjusted_mode.private_flags |= pipe_config->mode_flags |= I915_MODE_FLAG_DSI_PERIODIC_CMD_MODE;
I915_MODE_FLAG_DSI_PERIODIC_CMD_MODE;
} }
static int gen11_dsi_dsc_compute_config(struct intel_encoder *encoder, static int gen11_dsi_dsc_compute_config(struct intel_encoder *encoder,
...@@ -1558,10 +1557,6 @@ static int gen11_dsi_compute_config(struct intel_encoder *encoder, ...@@ -1558,10 +1557,6 @@ static int gen11_dsi_compute_config(struct intel_encoder *encoder,
pipe_config->port_clock = afe_clk(encoder, pipe_config) / 5; pipe_config->port_clock = afe_clk(encoder, pipe_config) / 5;
/* We would not operate in periodic command mode */
pipe_config->hw.adjusted_mode.private_flags &=
~I915_MODE_FLAG_DSI_PERIODIC_CMD_MODE;
/* /*
* In case of TE GATE cmd mode, we * In case of TE GATE cmd mode, we
* receive TE from the slave if * receive TE from the slave if
...@@ -1569,14 +1564,14 @@ static int gen11_dsi_compute_config(struct intel_encoder *encoder, ...@@ -1569,14 +1564,14 @@ static int gen11_dsi_compute_config(struct intel_encoder *encoder,
*/ */
if (is_cmd_mode(intel_dsi)) { if (is_cmd_mode(intel_dsi)) {
if (intel_dsi->ports == (BIT(PORT_B) | BIT(PORT_A))) if (intel_dsi->ports == (BIT(PORT_B) | BIT(PORT_A)))
pipe_config->hw.adjusted_mode.private_flags |= pipe_config->mode_flags |=
I915_MODE_FLAG_DSI_USE_TE1 | I915_MODE_FLAG_DSI_USE_TE1 |
I915_MODE_FLAG_DSI_USE_TE0; I915_MODE_FLAG_DSI_USE_TE0;
else if (intel_dsi->ports == BIT(PORT_B)) else if (intel_dsi->ports == BIT(PORT_B))
pipe_config->hw.adjusted_mode.private_flags |= pipe_config->mode_flags |=
I915_MODE_FLAG_DSI_USE_TE1; I915_MODE_FLAG_DSI_USE_TE1;
else else
pipe_config->hw.adjusted_mode.private_flags |= pipe_config->mode_flags |=
I915_MODE_FLAG_DSI_USE_TE0; I915_MODE_FLAG_DSI_USE_TE0;
} }
......
...@@ -253,6 +253,7 @@ intel_crtc_duplicate_state(struct drm_crtc *crtc) ...@@ -253,6 +253,7 @@ intel_crtc_duplicate_state(struct drm_crtc *crtc)
crtc_state->fb_bits = 0; crtc_state->fb_bits = 0;
crtc_state->update_planes = 0; crtc_state->update_planes = 0;
crtc_state->dsb = NULL; crtc_state->dsb = NULL;
crtc_state->mode_flags &= ~I915_MODE_FLAG_INHERITED;
return &crtc_state->uapi; return &crtc_state->uapi;
} }
......
...@@ -6425,7 +6425,7 @@ static bool hsw_post_update_enable_ips(const struct intel_crtc_state *old_crtc_s ...@@ -6425,7 +6425,7 @@ static bool hsw_post_update_enable_ips(const struct intel_crtc_state *old_crtc_s
* forcibly enable IPS on the first fastset. * forcibly enable IPS on the first fastset.
*/ */
if (new_crtc_state->update_pipe && if (new_crtc_state->update_pipe &&
old_crtc_state->hw.adjusted_mode.private_flags & I915_MODE_FLAG_INHERITED) old_crtc_state->mode_flags & I915_MODE_FLAG_INHERITED)
return true; return true;
return !old_crtc_state->ips_enabled; return !old_crtc_state->ips_enabled;
...@@ -13605,8 +13605,8 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config, ...@@ -13605,8 +13605,8 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
bool ret = true; bool ret = true;
u32 bp_gamma = 0; u32 bp_gamma = 0;
bool fixup_inherited = fastset && bool fixup_inherited = fastset &&
(current_config->hw.mode.private_flags & I915_MODE_FLAG_INHERITED) && (current_config->mode_flags & I915_MODE_FLAG_INHERITED) &&
!(pipe_config->hw.mode.private_flags & I915_MODE_FLAG_INHERITED); !(pipe_config->mode_flags & I915_MODE_FLAG_INHERITED);
if (fixup_inherited && !fastboot_enabled(dev_priv)) { if (fixup_inherited && !fastboot_enabled(dev_priv)) {
drm_dbg_kms(&dev_priv->drm, drm_dbg_kms(&dev_priv->drm,
...@@ -14414,6 +14414,8 @@ intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state) ...@@ -14414,6 +14414,8 @@ intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state)
drm_calc_timestamping_constants(&crtc->base, adjusted_mode); drm_calc_timestamping_constants(&crtc->base, adjusted_mode);
crtc->mode_flags = crtc_state->mode_flags;
/* /*
* The scanline counter increments at the leading edge of hsync. * The scanline counter increments at the leading edge of hsync.
* *
...@@ -14814,8 +14816,7 @@ static int intel_atomic_check(struct drm_device *dev, ...@@ -14814,8 +14816,7 @@ static int intel_atomic_check(struct drm_device *dev,
/* Catch I915_MODE_FLAG_INHERITED */ /* Catch I915_MODE_FLAG_INHERITED */
for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
new_crtc_state, i) { new_crtc_state, i) {
if (new_crtc_state->uapi.mode.private_flags != if (new_crtc_state->mode_flags != old_crtc_state->mode_flags)
old_crtc_state->uapi.mode.private_flags)
new_crtc_state->uapi.mode_changed = true; new_crtc_state->uapi.mode_changed = true;
} }
...@@ -15185,7 +15186,7 @@ static void intel_update_crtc(struct intel_atomic_state *state, ...@@ -15185,7 +15186,7 @@ static void intel_update_crtc(struct intel_atomic_state *state,
* of enabling them on the CRTC's first fastset. * of enabling them on the CRTC's first fastset.
*/ */
if (new_crtc_state->update_pipe && !modeset && if (new_crtc_state->update_pipe && !modeset &&
old_crtc_state->hw.mode.private_flags & I915_MODE_FLAG_INHERITED) old_crtc_state->mode_flags & I915_MODE_FLAG_INHERITED)
intel_crtc_arm_fifo_underrun(crtc, new_crtc_state); intel_crtc_arm_fifo_underrun(crtc, new_crtc_state);
} }
...@@ -17505,14 +17506,22 @@ void intel_modeset_init_hw(struct drm_i915_private *i915) ...@@ -17505,14 +17506,22 @@ void intel_modeset_init_hw(struct drm_i915_private *i915)
static int sanitize_watermarks_add_affected(struct drm_atomic_state *state) static int sanitize_watermarks_add_affected(struct drm_atomic_state *state)
{ {
struct drm_plane *plane; struct drm_plane *plane;
struct drm_crtc *crtc; struct intel_crtc *crtc;
drm_for_each_crtc(crtc, state->dev) { for_each_intel_crtc(state->dev, crtc) {
struct drm_crtc_state *crtc_state; struct intel_crtc_state *crtc_state;
crtc_state = drm_atomic_get_crtc_state(state, crtc); crtc_state = intel_atomic_get_crtc_state(state, crtc);
if (IS_ERR(crtc_state)) if (IS_ERR(crtc_state))
return PTR_ERR(crtc_state); return PTR_ERR(crtc_state);
if (crtc_state->hw.active) {
/*
* Preserve the inherited flag to avoid
* taking the full modeset path.
*/
crtc_state->mode_flags |= I915_MODE_FLAG_INHERITED;
}
} }
drm_for_each_plane(plane, state->dev) { drm_for_each_plane(plane, state->dev) {
...@@ -17654,6 +17663,15 @@ static int intel_initial_commit(struct drm_device *dev) ...@@ -17654,6 +17663,15 @@ static int intel_initial_commit(struct drm_device *dev)
} }
if (crtc_state->hw.active) { if (crtc_state->hw.active) {
/*
* We've not yet detected sink capabilities
* (audio,infoframes,etc.) and thus we don't want to
* force a full state recomputation yet. We want that to
* happen only for the first real commit from userspace.
* So preserve the inherited flag for the time being.
*/
crtc_state->mode_flags |= I915_MODE_FLAG_INHERITED;
ret = drm_atomic_add_affected_planes(state, &crtc->base); ret = drm_atomic_add_affected_planes(state, &crtc->base);
if (ret) if (ret)
goto out; goto out;
...@@ -18432,7 +18450,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) ...@@ -18432,7 +18450,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
* set a flag to indicate that a full recalculation is * set a flag to indicate that a full recalculation is
* needed on the next commit. * needed on the next commit.
*/ */
mode->private_flags = I915_MODE_FLAG_INHERITED; crtc_state->mode_flags |= I915_MODE_FLAG_INHERITED;
intel_crtc_compute_pixel_rate(crtc_state); intel_crtc_compute_pixel_rate(crtc_state);
......
...@@ -630,7 +630,7 @@ struct intel_crtc_scaler_state { ...@@ -630,7 +630,7 @@ struct intel_crtc_scaler_state {
int scaler_id; int scaler_id;
}; };
/* drm_mode->private_flags */ /* {crtc,crtc_state}->mode_flags */
#define I915_MODE_FLAG_INHERITED (1<<0) #define I915_MODE_FLAG_INHERITED (1<<0)
/* Flag to get scanline using frame time stamps */ /* Flag to get scanline using frame time stamps */
#define I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP (1<<1) #define I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP (1<<1)
...@@ -943,6 +943,9 @@ struct intel_crtc_state { ...@@ -943,6 +943,9 @@ struct intel_crtc_state {
/* Used by SDVO (and if we ever fix it, HDMI). */ /* Used by SDVO (and if we ever fix it, HDMI). */
unsigned pixel_multiplier; unsigned pixel_multiplier;
/* I915_MODE_FLAG_* */
u8 mode_flags;
u8 lane_count; u8 lane_count;
/* /*
...@@ -1108,6 +1111,10 @@ struct intel_crtc { ...@@ -1108,6 +1111,10 @@ struct intel_crtc {
*/ */
bool active; bool active;
u8 plane_ids_mask; u8 plane_ids_mask;
/* I915_MODE_FLAG_* */
u8 mode_flags;
unsigned long long enabled_power_domains; unsigned long long enabled_power_domains;
struct intel_overlay *overlay; struct intel_overlay *overlay;
......
...@@ -1161,7 +1161,7 @@ intel_tv_get_config(struct intel_encoder *encoder, ...@@ -1161,7 +1161,7 @@ intel_tv_get_config(struct intel_encoder *encoder,
/* pixel counter doesn't work on i965gm TV output */ /* pixel counter doesn't work on i965gm TV output */
if (IS_I965GM(dev_priv)) if (IS_I965GM(dev_priv))
adjusted_mode->private_flags |= pipe_config->mode_flags |=
I915_MODE_FLAG_USE_SCANLINE_COUNTER; I915_MODE_FLAG_USE_SCANLINE_COUNTER;
} }
...@@ -1331,7 +1331,7 @@ intel_tv_compute_config(struct intel_encoder *encoder, ...@@ -1331,7 +1331,7 @@ intel_tv_compute_config(struct intel_encoder *encoder,
/* pixel counter doesn't work on i965gm TV output */ /* pixel counter doesn't work on i965gm TV output */
if (IS_I965GM(dev_priv)) if (IS_I965GM(dev_priv))
adjusted_mode->private_flags |= pipe_config->mode_flags |=
I915_MODE_FLAG_USE_SCANLINE_COUNTER; I915_MODE_FLAG_USE_SCANLINE_COUNTER;
return 0; return 0;
......
...@@ -298,7 +298,7 @@ static int intel_dsi_compute_config(struct intel_encoder *encoder, ...@@ -298,7 +298,7 @@ static int intel_dsi_compute_config(struct intel_encoder *encoder,
if (IS_GEN9_LP(dev_priv)) { if (IS_GEN9_LP(dev_priv)) {
/* Enable Frame time stamp based scanline reporting */ /* Enable Frame time stamp based scanline reporting */
adjusted_mode->private_flags |= pipe_config->mode_flags |=
I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP; I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP;
/* Dual link goes to DSI transcoder A. */ /* Dual link goes to DSI transcoder A. */
...@@ -1097,8 +1097,8 @@ static void bxt_dsi_get_pipe_config(struct intel_encoder *encoder, ...@@ -1097,8 +1097,8 @@ static void bxt_dsi_get_pipe_config(struct intel_encoder *encoder,
pipe_config->pipe_bpp = bdw_get_pipemisc_bpp(crtc); pipe_config->pipe_bpp = bdw_get_pipemisc_bpp(crtc);
/* Enable Frame time stamo based scanline reporting */ /* Enable Frame time stamo based scanline reporting */
adjusted_mode->private_flags |= pipe_config->mode_flags |=
I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP; I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP;
/* In terms of pixels */ /* In terms of pixels */
adjusted_mode->crtc_hdisplay = adjusted_mode->crtc_hdisplay =
......
...@@ -777,7 +777,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc) ...@@ -777,7 +777,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
vblank = &crtc->base.dev->vblank[drm_crtc_index(&crtc->base)]; vblank = &crtc->base.dev->vblank[drm_crtc_index(&crtc->base)];
mode = &vblank->hwmode; mode = &vblank->hwmode;
if (mode->private_flags & I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP) if (crtc->mode_flags & I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP)
return __intel_get_crtc_scanline_from_timestamp(crtc); return __intel_get_crtc_scanline_from_timestamp(crtc);
vtotal = mode->crtc_vtotal; vtotal = mode->crtc_vtotal;
...@@ -836,7 +836,7 @@ static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc, ...@@ -836,7 +836,7 @@ static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc,
unsigned long irqflags; unsigned long irqflags;
bool use_scanline_counter = INTEL_GEN(dev_priv) >= 5 || bool use_scanline_counter = INTEL_GEN(dev_priv) >= 5 ||
IS_G4X(dev_priv) || IS_GEN(dev_priv, 2) || IS_G4X(dev_priv) || IS_GEN(dev_priv, 2) ||
mode->private_flags & I915_MODE_FLAG_USE_SCANLINE_COUNTER; crtc->mode_flags & I915_MODE_FLAG_USE_SCANLINE_COUNTER;
if (drm_WARN_ON(&dev_priv->drm, !mode->crtc_clock)) { if (drm_WARN_ON(&dev_priv->drm, !mode->crtc_clock)) {
drm_dbg(&dev_priv->drm, drm_dbg(&dev_priv->drm,
......
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