Skip to content

Commit

Permalink
drm/i915: Prepare connectors for nonblocking checks.
Browse files Browse the repository at this point in the history
intel_unpin_work may not take the list lock because it requires the connector_mutex.
To prevent taking locks we add an array of old and new state. The old state to free,
the new state to commit and verify.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1463490484-19540-18-git-send-email-maarten.lankhorst@linux.intel.com
Reviewed-by: Patrik Jakobsson <patrik.jakobsson@linux.intel.com>
  • Loading branch information
Maarten Lankhorst committed May 19, 2016
1 parent 2099def commit 03f476e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
53 changes: 39 additions & 14 deletions drivers/gpu/drm/i915/intel_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -6249,17 +6249,17 @@ void intel_encoder_destroy(struct drm_encoder *encoder)

/* Cross check the actual hw state with our own modeset state tracking (and it's
* internal consistency). */
static void intel_connector_verify_state(struct intel_connector *connector)
static void intel_connector_verify_state(struct intel_connector *connector,
struct drm_connector_state *conn_state)
{
struct drm_crtc *crtc = connector->base.state->crtc;
struct drm_crtc *crtc = conn_state->crtc;

DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
connector->base.base.id,
connector->base.name);

if (connector->get_hw_state(connector)) {
struct intel_encoder *encoder = connector->encoder;
struct drm_connector_state *conn_state = connector->base.state;

I915_STATE_WARN(!crtc,
"connector enabled without attached crtc\n");
Expand All @@ -6281,7 +6281,7 @@ static void intel_connector_verify_state(struct intel_connector *connector)
} else {
I915_STATE_WARN(crtc && crtc->state->active,
"attached crtc is active, but connector isn't\n");
I915_STATE_WARN(!crtc && connector->base.state->best_encoder,
I915_STATE_WARN(!crtc && conn_state->best_encoder,
"best encoder set without crtc!\n");
}
}
Expand Down Expand Up @@ -10776,6 +10776,14 @@ void intel_mark_idle(struct drm_i915_private *dev_priv)
intel_runtime_pm_put(dev_priv);
}

static void
intel_free_flip_work(struct intel_flip_work *work)
{
kfree(work->old_connector_state);
kfree(work->new_connector_state);
kfree(work);
}

static void intel_crtc_destroy(struct drm_crtc *crtc)
{
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
Expand All @@ -10791,7 +10799,7 @@ static void intel_crtc_destroy(struct drm_crtc *crtc)

cancel_work_sync(&work->mmio_work);
cancel_work_sync(&work->unpin_work);
kfree(work);
intel_free_flip_work(work);

spin_lock_irq(&dev->event_lock);
}
Expand Down Expand Up @@ -10856,11 +10864,32 @@ static void intel_unpin_work_fn(struct work_struct *__work)
/* Make sure mmio work is completely finished before freeing all state here. */
flush_work(&work->mmio_work);

if (!work->can_async_unpin)
if (!work->can_async_unpin &&
(work->new_crtc_state->update_pipe ||
needs_modeset(&work->new_crtc_state->base))) {
/* This must be called before work is unpinned for serialization. */
intel_modeset_verify_crtc(crtc, &work->old_crtc_state->base,
&work->new_crtc_state->base);

for (i = 0; i < work->num_new_connectors; i++) {
struct drm_connector_state *conn_state =
work->new_connector_state[i];
struct drm_connector *con = conn_state->connector;

intel_connector_verify_state(to_intel_connector(con),
conn_state);
}
}

for (i = 0; i < work->num_old_connectors; i++) {
struct drm_connector_state *old_con_state =
work->old_connector_state[i];
struct drm_connector *con =
old_con_state->connector;

con->funcs->atomic_destroy_state(con, old_con_state);
}

if (!work->can_async_unpin || !list_empty(&work->head)) {
spin_lock_irq(&dev->event_lock);
WARN(list_empty(&work->head) != work->can_async_unpin,
Expand Down Expand Up @@ -10906,7 +10935,7 @@ static void intel_unpin_work_fn(struct work_struct *__work)
if (!WARN_ON(atomic_read(&intel_crtc->unpin_work_count) == 0))
atomic_dec(&intel_crtc->unpin_work_count);

kfree(work);
intel_free_flip_work(work);
}


Expand Down Expand Up @@ -11197,7 +11226,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
if (new_crtc_state)
intel_crtc_destroy_state(crtc, new_crtc_state);

kfree(work);
intel_free_flip_work(work);
return ret;
}

Expand Down Expand Up @@ -12319,7 +12348,8 @@ verify_connector_state(struct drm_device *dev, struct drm_crtc *crtc)
if (state->crtc != crtc)
continue;

intel_connector_verify_state(to_intel_connector(connector));
intel_connector_verify_state(to_intel_connector(connector),
connector->state);

I915_STATE_WARN(state->best_encoder != encoder,
"connector's atomic encoder doesn't match legacy encoder\n");
Expand Down Expand Up @@ -12521,12 +12551,7 @@ intel_modeset_verify_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;

verify_wm_state(crtc, new_state);
verify_connector_state(crtc->dev, crtc);
verify_crtc_state(crtc, old_state, new_state);
verify_shared_dpll_state(crtc->dev, crtc, old_state, new_state);
}
Expand Down
4 changes: 4 additions & 0 deletions drivers/gpu/drm/i915/intel_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,10 @@ struct intel_flip_work {
bool can_async_unpin;
unsigned fb_bits;

unsigned num_old_connectors, num_new_connectors;
struct drm_connector_state **old_connector_state;
struct drm_connector_state **new_connector_state;

struct intel_crtc_state *old_crtc_state, *new_crtc_state;
struct intel_plane_state *old_plane_state[I915_MAX_PLANES + 1];
struct intel_plane_state *new_plane_state[I915_MAX_PLANES + 1];
Expand Down

0 comments on commit 03f476e

Please sign in to comment.