提交 e7c84544 编写于 作者: M Maarten Lankhorst

drm/i915: Make modeset state verifier take crtc as argument.

This will make it easier to keep the crtc checker when atomic
commit is reworked for asynchronous commits. This prevents checking
crtc's that were not part of the state. It's safe to verify disabled
encoders, connectors and dpll's that are not part of the state,
because during modeset connection_mutex is held.
Signed-off-by: NMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1458741487-23801-2-git-send-email-maarten.lankhorst@linux.intel.comReviewed-by: NMatt Roper <matthew.d.roper@intel.com>
[mlankhorst: Extend commit message and rename check to verify.]
上级 5dd8e50c
...@@ -12756,48 +12756,43 @@ static void intel_pipe_config_sanity_check(struct drm_i915_private *dev_priv, ...@@ -12756,48 +12756,43 @@ static void intel_pipe_config_sanity_check(struct drm_i915_private *dev_priv,
} }
} }
static void check_wm_state(struct drm_device *dev) static void check_wm_state(struct drm_crtc *crtc,
struct drm_crtc_state *new_state)
{ {
struct drm_device *dev = crtc->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct skl_ddb_allocation hw_ddb, *sw_ddb; struct skl_ddb_allocation hw_ddb, *sw_ddb;
struct intel_crtc *intel_crtc; struct skl_ddb_entry *hw_entry, *sw_entry;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
const enum pipe pipe = intel_crtc->pipe;
int plane; int plane;
if (INTEL_INFO(dev)->gen < 9) if (INTEL_INFO(dev)->gen < 9 || !new_state->active)
return; return;
skl_ddb_get_hw_state(dev_priv, &hw_ddb); skl_ddb_get_hw_state(dev_priv, &hw_ddb);
sw_ddb = &dev_priv->wm.skl_hw.ddb; sw_ddb = &dev_priv->wm.skl_hw.ddb;
for_each_intel_crtc(dev, intel_crtc) { /* planes */
struct skl_ddb_entry *hw_entry, *sw_entry; for_each_plane(dev_priv, pipe, plane) {
const enum pipe pipe = intel_crtc->pipe; hw_entry = &hw_ddb.plane[pipe][plane];
sw_entry = &sw_ddb->plane[pipe][plane];
if (!intel_crtc->active) if (skl_ddb_entry_equal(hw_entry, sw_entry))
continue; continue;
/* planes */ DRM_ERROR("mismatch in DDB state pipe %c plane %d "
for_each_plane(dev_priv, pipe, plane) { "(expected (%u,%u), found (%u,%u))\n",
hw_entry = &hw_ddb.plane[pipe][plane]; pipe_name(pipe), plane + 1,
sw_entry = &sw_ddb->plane[pipe][plane]; sw_entry->start, sw_entry->end,
hw_entry->start, hw_entry->end);
if (skl_ddb_entry_equal(hw_entry, sw_entry)) }
continue;
DRM_ERROR("mismatch in DDB state pipe %c plane %d "
"(expected (%u,%u), found (%u,%u))\n",
pipe_name(pipe), plane + 1,
sw_entry->start, sw_entry->end,
hw_entry->start, hw_entry->end);
}
/* cursor */
hw_entry = &hw_ddb.plane[pipe][PLANE_CURSOR];
sw_entry = &sw_ddb->plane[pipe][PLANE_CURSOR];
if (skl_ddb_entry_equal(hw_entry, sw_entry)) /* cursor */
continue; hw_entry = &hw_ddb.plane[pipe][PLANE_CURSOR];
sw_entry = &sw_ddb->plane[pipe][PLANE_CURSOR];
if (!skl_ddb_entry_equal(hw_entry, sw_entry)) {
DRM_ERROR("mismatch in DDB state pipe %c cursor " DRM_ERROR("mismatch in DDB state pipe %c cursor "
"(expected (%u,%u), found (%u,%u))\n", "(expected (%u,%u), found (%u,%u))\n",
pipe_name(pipe), pipe_name(pipe),
...@@ -12807,19 +12802,17 @@ static void check_wm_state(struct drm_device *dev) ...@@ -12807,19 +12802,17 @@ static void check_wm_state(struct drm_device *dev)
} }
static void static void
check_connector_state(struct drm_device *dev, check_connector_state(struct drm_device *dev, struct drm_crtc *crtc)
struct drm_atomic_state *old_state)
{ {
struct drm_connector_state *old_conn_state;
struct drm_connector *connector; struct drm_connector *connector;
int i;
for_each_connector_in_state(old_state, connector, old_conn_state, i) { drm_for_each_connector(connector, dev) {
struct drm_encoder *encoder = connector->encoder; struct drm_encoder *encoder = connector->encoder;
struct drm_connector_state *state = connector->state; struct drm_connector_state *state = connector->state;
/* This also checks the encoder/connector hw state with the if (state->crtc != crtc)
* ->get_hw_state callbacks. */ continue;
intel_connector_check_state(to_intel_connector(connector)); intel_connector_check_state(to_intel_connector(connector));
I915_STATE_WARN(state->best_encoder != encoder, I915_STATE_WARN(state->best_encoder != encoder,
...@@ -12868,144 +12861,201 @@ check_encoder_state(struct drm_device *dev) ...@@ -12868,144 +12861,201 @@ check_encoder_state(struct drm_device *dev)
} }
static void static void
check_crtc_state(struct drm_device *dev, struct drm_atomic_state *old_state) check_crtc_state(struct drm_crtc *crtc,
struct drm_crtc_state *old_crtc_state,
struct drm_crtc_state *new_crtc_state)
{ {
struct drm_device *dev = crtc->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_encoder *encoder; struct intel_encoder *encoder;
struct drm_crtc_state *old_crtc_state; struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
struct drm_crtc *crtc; struct intel_crtc_state *pipe_config, *sw_config;
int i; struct drm_atomic_state *old_state;
bool active;
for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
struct intel_crtc_state *pipe_config, *sw_config;
bool active;
if (!needs_modeset(crtc->state) &&
!to_intel_crtc_state(crtc->state)->update_pipe)
continue;
__drm_atomic_helper_crtc_destroy_state(crtc, old_crtc_state); old_state = old_crtc_state->state;
pipe_config = to_intel_crtc_state(old_crtc_state); __drm_atomic_helper_crtc_destroy_state(crtc, old_crtc_state);
memset(pipe_config, 0, sizeof(*pipe_config)); pipe_config = to_intel_crtc_state(old_crtc_state);
pipe_config->base.crtc = crtc; memset(pipe_config, 0, sizeof(*pipe_config));
pipe_config->base.state = old_state; pipe_config->base.crtc = crtc;
pipe_config->base.state = old_state;
DRM_DEBUG_KMS("[CRTC:%d]\n", DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id);
crtc->base.id);
active = dev_priv->display.get_pipe_config(intel_crtc, active = dev_priv->display.get_pipe_config(intel_crtc, pipe_config);
pipe_config);
/* hw state is inconsistent with the pipe quirk */ /* hw state is inconsistent with the pipe quirk */
if ((intel_crtc->pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE) || if ((intel_crtc->pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE) ||
(intel_crtc->pipe == PIPE_B && dev_priv->quirks & QUIRK_PIPEB_FORCE)) (intel_crtc->pipe == PIPE_B && dev_priv->quirks & QUIRK_PIPEB_FORCE))
active = crtc->state->active; active = new_crtc_state->active;
I915_STATE_WARN(crtc->state->active != active, I915_STATE_WARN(new_crtc_state->active != active,
"crtc active state doesn't match with hw state " "crtc active state doesn't match with hw state "
"(expected %i, found %i)\n", crtc->state->active, active); "(expected %i, found %i)\n", new_crtc_state->active, active);
I915_STATE_WARN(intel_crtc->active != crtc->state->active, I915_STATE_WARN(intel_crtc->active != new_crtc_state->active,
"transitional active state does not match atomic hw state " "transitional active state does not match atomic hw state "
"(expected %i, found %i)\n", crtc->state->active, intel_crtc->active); "(expected %i, found %i)\n", new_crtc_state->active, intel_crtc->active);
for_each_encoder_on_crtc(dev, crtc, encoder) { for_each_encoder_on_crtc(dev, crtc, encoder) {
enum pipe pipe; enum pipe pipe;
active = encoder->get_hw_state(encoder, &pipe); active = encoder->get_hw_state(encoder, &pipe);
I915_STATE_WARN(active != crtc->state->active, I915_STATE_WARN(active != new_crtc_state->active,
"[ENCODER:%i] active %i with crtc active %i\n", "[ENCODER:%i] active %i with crtc active %i\n",
encoder->base.base.id, active, crtc->state->active); encoder->base.base.id, active, new_crtc_state->active);
I915_STATE_WARN(active && intel_crtc->pipe != pipe, I915_STATE_WARN(active && intel_crtc->pipe != pipe,
"Encoder connected to wrong pipe %c\n", "Encoder connected to wrong pipe %c\n",
pipe_name(pipe)); pipe_name(pipe));
if (active) if (active)
encoder->get_config(encoder, pipe_config); encoder->get_config(encoder, pipe_config);
} }
if (!crtc->state->active) if (!new_crtc_state->active)
continue; return;
intel_pipe_config_sanity_check(dev_priv, pipe_config); intel_pipe_config_sanity_check(dev_priv, pipe_config);
sw_config = to_intel_crtc_state(crtc->state); sw_config = to_intel_crtc_state(crtc->state);
if (!intel_pipe_config_compare(dev, sw_config, if (!intel_pipe_config_compare(dev, sw_config,
pipe_config, false)) { pipe_config, false)) {
I915_STATE_WARN(1, "pipe state doesn't match!\n"); I915_STATE_WARN(1, "pipe state doesn't match!\n");
intel_dump_pipe_config(intel_crtc, pipe_config, intel_dump_pipe_config(intel_crtc, pipe_config,
"[hw state]"); "[hw state]");
intel_dump_pipe_config(intel_crtc, sw_config, intel_dump_pipe_config(intel_crtc, sw_config,
"[sw state]"); "[sw state]");
}
} }
} }
static void static void
check_shared_dpll_state(struct drm_device *dev) check_single_dpll_state(struct drm_i915_private *dev_priv,
struct intel_shared_dpll *pll,
struct drm_crtc *crtc,
struct drm_crtc_state *new_state)
{ {
struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *crtc;
struct intel_dpll_hw_state dpll_hw_state; struct intel_dpll_hw_state dpll_hw_state;
int i; unsigned crtc_mask;
bool active;
for (i = 0; i < dev_priv->num_shared_dpll; i++) { memset(&dpll_hw_state, 0, sizeof(dpll_hw_state));
struct intel_shared_dpll *pll =
intel_get_shared_dpll_by_id(dev_priv, i);
unsigned enabled_crtcs = 0, active_crtcs = 0;
bool active;
memset(&dpll_hw_state, 0, sizeof(dpll_hw_state)); DRM_DEBUG_KMS("%s\n", pll->name);
DRM_DEBUG_KMS("%s\n", pll->name); active = pll->funcs.get_hw_state(dev_priv, pll, &dpll_hw_state);
active = pll->funcs.get_hw_state(dev_priv, pll, &dpll_hw_state); if (!(pll->flags & INTEL_DPLL_ALWAYS_ON)) {
I915_STATE_WARN(!pll->on && pll->active_mask,
"pll in active use but not on in sw tracking\n");
I915_STATE_WARN(pll->on && !pll->active_mask,
"pll is on but not used by any active crtc\n");
I915_STATE_WARN(pll->on != active,
"pll on state mismatch (expected %i, found %i)\n",
pll->on, active);
}
if (!crtc) {
I915_STATE_WARN(pll->active_mask & ~pll->config.crtc_mask, I915_STATE_WARN(pll->active_mask & ~pll->config.crtc_mask,
"more active pll users than references: %x vs %x\n", "more active pll users than references: %x vs %x\n",
pll->active_mask, pll->config.crtc_mask); pll->active_mask, pll->config.crtc_mask);
if (!(pll->flags & INTEL_DPLL_ALWAYS_ON)) { return;
I915_STATE_WARN(!pll->on && pll->active_mask, }
"pll in active use but not on in sw tracking\n");
I915_STATE_WARN(pll->on && !pll->active_mask,
"pll is on but not used by any active crtc\n");
I915_STATE_WARN(pll->on != active,
"pll on state mismatch (expected %i, found %i)\n",
pll->on, active);
}
for_each_intel_crtc(dev, crtc) { crtc_mask = 1 << drm_crtc_index(crtc);
if (crtc->base.state->enable && crtc->config->shared_dpll == pll)
enabled_crtcs |= 1 << drm_crtc_index(&crtc->base); if (new_state->active)
if (crtc->base.state->active && crtc->config->shared_dpll == pll) I915_STATE_WARN(!(pll->active_mask & crtc_mask),
active_crtcs |= 1 << drm_crtc_index(&crtc->base); "pll active mismatch (expected pipe %c in active mask 0x%02x)\n",
} pipe_name(drm_crtc_index(crtc)), pll->active_mask);
else
I915_STATE_WARN(pll->active_mask & crtc_mask,
"pll active mismatch (didn't expect pipe %c in active mask 0x%02x)\n",
pipe_name(drm_crtc_index(crtc)), pll->active_mask);
I915_STATE_WARN(!(pll->config.crtc_mask & crtc_mask),
"pll enabled crtcs mismatch (expected 0x%x in 0x%02x)\n",
crtc_mask, pll->config.crtc_mask);
I915_STATE_WARN(pll->active_mask != active_crtcs, I915_STATE_WARN(pll->on && memcmp(&pll->config.hw_state,
"pll active crtcs mismatch (expected %x, found %x)\n", &dpll_hw_state,
pll->active_mask, active_crtcs); sizeof(dpll_hw_state)),
I915_STATE_WARN(pll->config.crtc_mask != enabled_crtcs, "pll hw state mismatch\n");
"pll enabled crtcs mismatch (expected %x, found %x)\n", }
pll->config.crtc_mask, enabled_crtcs);
I915_STATE_WARN(pll->on && memcmp(&pll->config.hw_state, &dpll_hw_state, static void
sizeof(dpll_hw_state)), check_shared_dpll_state(struct drm_device *dev, struct drm_crtc *crtc,
"pll hw state mismatch\n"); struct drm_crtc_state *old_crtc_state,
struct drm_crtc_state *new_crtc_state)
{
struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc_state *old_state = to_intel_crtc_state(old_crtc_state);
struct intel_crtc_state *new_state = to_intel_crtc_state(new_crtc_state);
if (new_state->shared_dpll)
check_single_dpll_state(dev_priv, new_state->shared_dpll, crtc, new_crtc_state);
if (old_state->shared_dpll &&
old_state->shared_dpll != new_state->shared_dpll) {
unsigned crtc_mask = 1 << drm_crtc_index(crtc);
struct intel_shared_dpll *pll = old_state->shared_dpll;
I915_STATE_WARN(pll->active_mask & crtc_mask,
"pll active mismatch (didn't expect pipe %c in active mask)\n",
pipe_name(drm_crtc_index(crtc)));
I915_STATE_WARN(pll->config.crtc_mask & crtc_mask,
"pll enabled crtcs mismatch (found %x in enabled mask)\n",
pipe_name(drm_crtc_index(crtc)));
} }
} }
static void
intel_modeset_check_crtc(struct drm_crtc *crtc,
struct drm_crtc_state *old_state,
struct drm_crtc_state *new_state)
{
if (!needs_modeset(new_state) &&
!to_intel_crtc_state(new_state)->update_pipe)
return;
check_wm_state(crtc, new_state);
check_connector_state(crtc->dev, crtc);
check_crtc_state(crtc, old_state, new_state);
check_shared_dpll_state(crtc->dev, crtc, old_state, new_state);
}
static void
check_disabled_dpll_state(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
int i;
for (i = 0; i < dev_priv->num_shared_dpll; i++)
check_single_dpll_state(dev_priv, &dev_priv->shared_dplls[i], NULL, NULL);
}
static void
intel_modeset_check_disabled(struct drm_device *dev,
struct drm_atomic_state *old_state)
{
check_encoder_state(dev);
check_connector_state(dev, NULL);
check_disabled_dpll_state(dev);
}
static void static void
intel_modeset_check_state(struct drm_device *dev, intel_modeset_check_state(struct drm_device *dev,
struct drm_atomic_state *old_state) struct drm_atomic_state *old_state)
{ {
check_wm_state(dev); struct drm_crtc_state *old_crtc_state;
check_connector_state(dev, old_state); struct drm_crtc *crtc;
check_encoder_state(dev); int i;
check_crtc_state(dev, old_state);
check_shared_dpll_state(dev); for_each_crtc_in_state(old_state, crtc, old_crtc_state, i)
intel_modeset_check_crtc(crtc, old_crtc_state, crtc->state);
intel_modeset_check_disabled(dev, old_state);
} }
static void update_scanline_offset(struct intel_crtc *crtc) static void update_scanline_offset(struct intel_crtc *crtc)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册