@@ -1167,23 +1167,10 @@ intel_dp_hotplug(struct intel_encoder *encoder,
state = intel_encoder_hotplug(encoder, connector);
- drm_modeset_acquire_init(&ctx, 0);
-
- for (;;) {
+ drm_modeset_lock_ctx_retry(&ctx, NULL, 0, ret)
ret = intel_dp_retrain_link(encoder, &ctx);
- if (ret == -EDEADLK) {
- drm_modeset_backoff(&ctx);
- continue;
- }
-
- break;
- }
-
- drm_modeset_drop_locks(&ctx);
- drm_modeset_acquire_fini(&ctx);
- drm_WARN(encoder->base.dev, ret,
- "Acquiring modeset locks failed with %i\n", ret);
+ drm_WARN_ON(encoder->base.dev, ret);
/*
* Keeping it consistent with intel_ddi_hotplug() and
@@ -969,28 +969,17 @@ static void glk_force_audio_cdclk(struct drm_i915_private *dev_priv,
if (!crtc)
return;
- drm_modeset_acquire_init(&ctx, 0);
state = drm_atomic_state_alloc(&dev_priv->drm);
if (drm_WARN_ON(&dev_priv->drm, !state))
return;
- state->acquire_ctx = &ctx;
-
-retry:
- ret = glk_force_audio_cdclk_commit(to_intel_atomic_state(state), crtc,
- enable);
- if (ret == -EDEADLK) {
- drm_atomic_state_clear(state);
- drm_modeset_backoff(&ctx);
- goto retry;
- }
+ drm_modeset_lock_ctx_retry(&ctx, state, 0, ret)
+ ret = glk_force_audio_cdclk_commit(to_intel_atomic_state(state),
+ crtc, enable);
drm_WARN_ON(&dev_priv->drm, ret);
drm_atomic_state_put(state);
-
- drm_modeset_drop_locks(&ctx);
- drm_modeset_acquire_fini(&ctx);
}
static unsigned long i915_audio_component_get_power(struct device *kdev)
@@ -4210,26 +4210,14 @@ intel_ddi_hotplug(struct intel_encoder *encoder,
state = intel_encoder_hotplug(encoder, connector);
- drm_modeset_acquire_init(&ctx, 0);
-
- for (;;) {
+ drm_modeset_lock_ctx_retry(&ctx, NULL, 0, ret) {
if (connector->base.connector_type == DRM_MODE_CONNECTOR_HDMIA)
ret = intel_hdmi_reset_link(encoder, &ctx);
else
ret = intel_dp_retrain_link(encoder, &ctx);
-
- if (ret == -EDEADLK) {
- drm_modeset_backoff(&ctx);
- continue;
- }
-
- break;
}
- drm_modeset_drop_locks(&ctx);
- drm_modeset_acquire_fini(&ctx);
- drm_WARN(encoder->base.dev, ret,
- "Acquiring modeset locks failed with %i\n", ret);
+ drm_WARN_ON(encoder->base.dev, ret);
/*
* Unpowered type-c dongles can take some time to boot and be
@@ -12057,40 +12057,30 @@ static void sanitize_watermarks(struct drm_i915_private *dev_priv)
intel_state = to_intel_atomic_state(state);
- drm_modeset_acquire_init(&ctx, 0);
+ drm_modeset_lock_ctx_retry(&ctx, state, 0, ret) {
+ /*
+ * Hardware readout is the only time we don't want to calculate
+ * intermediate watermarks (since we don't trust the current
+ * watermarks).
+ */
+ if (!HAS_GMCH(dev_priv))
+ intel_state->skip_intermediate_wm = true;
-retry:
- state->acquire_ctx = &ctx;
+ ret = sanitize_watermarks_add_affected(state);
+ if (ret)
+ continue;
- /*
- * Hardware readout is the only time we don't want to calculate
- * intermediate watermarks (since we don't trust the current
- * watermarks).
- */
- if (!HAS_GMCH(dev_priv))
- intel_state->skip_intermediate_wm = true;
+ ret = intel_atomic_check(&dev_priv->drm, state);
+ if (ret)
+ continue;
- ret = sanitize_watermarks_add_affected(state);
- if (ret)
- goto fail;
+ /* Write calculated watermark values back */
+ for_each_new_intel_crtc_in_state(intel_state, crtc, crtc_state, i) {
+ crtc_state->wm.need_postvbl_update = true;
+ dev_priv->display.optimize_watermarks(intel_state, crtc);
- ret = intel_atomic_check(&dev_priv->drm, state);
- if (ret)
- goto fail;
-
- /* Write calculated watermark values back */
- for_each_new_intel_crtc_in_state(intel_state, crtc, crtc_state, i) {
- crtc_state->wm.need_postvbl_update = true;
- dev_priv->display.optimize_watermarks(intel_state, crtc);
-
- to_intel_crtc_state(crtc->base.state)->wm = crtc_state->wm;
- }
-
-fail:
- if (ret == -EDEADLK) {
- drm_atomic_state_clear(state);
- drm_modeset_backoff(&ctx);
- goto retry;
+ to_intel_crtc_state(crtc->base.state)->wm = crtc_state->wm;
+ }
}
/*
@@ -12108,9 +12098,6 @@ static void sanitize_watermarks(struct drm_i915_private *dev_priv)
"Could not determine valid watermarks for inherited state\n");
drm_atomic_state_put(state);
-
- drm_modeset_drop_locks(&ctx);
- drm_modeset_acquire_fini(&ctx);
}
static void intel_update_fdi_pll_freq(struct drm_i915_private *dev_priv)
@@ -12181,38 +12168,28 @@ static int intel_initial_commit(struct drm_device *dev)
{
struct drm_modeset_acquire_ctx ctx;
struct drm_atomic_state *state;
- struct intel_crtc *crtc;
int ret;
state = drm_atomic_state_alloc(dev);
if (!state)
return -ENOMEM;
- drm_modeset_acquire_init(&ctx, 0);
+ drm_modeset_lock_ctx_retry(&ctx, state, 0, ret) {
+ struct intel_crtc *crtc;
-retry:
- state->acquire_ctx = &ctx;
-
- for_each_intel_crtc(dev, crtc) {
- ret = intel_crtc_initial_commit(to_intel_atomic_state(state), crtc);
+ for_each_intel_crtc(dev, crtc) {
+ ret = intel_crtc_initial_commit(to_intel_atomic_state(state), crtc);
+ if (ret)
+ break;
+ }
if (ret)
- goto out;
- }
+ continue;
- ret = drm_atomic_commit(state);
-
-out:
- if (ret == -EDEADLK) {
- drm_atomic_state_clear(state);
- drm_modeset_backoff(&ctx);
- goto retry;
+ ret = drm_atomic_commit(state);
}
drm_atomic_state_put(state);
- drm_modeset_drop_locks(&ctx);
- drm_modeset_acquire_fini(&ctx);
-
return ret;
}
@@ -13323,25 +13300,14 @@ void intel_display_resume(struct drm_device *dev)
return;
dev_priv->modeset_restore_state = NULL;
- if (state)
- state->acquire_ctx = &ctx;
- drm_modeset_acquire_init(&ctx, 0);
-
- while (1) {
- ret = drm_modeset_lock_all_ctx(dev, &ctx);
- if (ret != -EDEADLK)
- break;
-
- drm_modeset_backoff(&ctx);
- }
-
- if (!ret)
+ drm_modeset_lock_all_ctx_retry(dev, &ctx, state, 0, ret) {
ret = __intel_display_resume(dev, state, &ctx);
+ if (ret)
+ continue;
- intel_enable_ipc(dev_priv);
- drm_modeset_drop_locks(&ctx);
- drm_modeset_acquire_fini(&ctx);
+ intel_enable_ipc(dev_priv);
+ }
if (ret)
drm_err(&dev_priv->drm,
@@ -2294,44 +2294,32 @@ static int i915_dsc_fec_support_show(struct seq_file *m, void *data)
{
struct drm_connector *connector = m->private;
struct drm_device *dev = connector->dev;
- struct drm_crtc *crtc;
- struct intel_dp *intel_dp;
struct drm_modeset_acquire_ctx ctx;
- struct intel_crtc_state *crtc_state = NULL;
- int ret = 0;
- bool try_again = false;
+ int ret;
- drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
+ drm_modeset_lock_ctx_retry(&ctx, NULL, DRM_MODESET_ACQUIRE_INTERRUPTIBLE, ret) {
+ struct intel_crtc_state *crtc_state;
+ struct intel_dp *intel_dp;
+ struct drm_crtc *crtc;
- do {
- try_again = false;
ret = drm_modeset_lock(&dev->mode_config.connection_mutex,
&ctx);
- if (ret) {
- if (ret == -EDEADLK && !drm_modeset_backoff(&ctx)) {
- try_again = true;
- continue;
- }
- break;
- }
+ if (ret)
+ continue;
+
crtc = connector->state->crtc;
if (connector->status != connector_status_connected || !crtc) {
ret = -ENODEV;
- break;
+ continue;
}
+
ret = drm_modeset_lock(&crtc->mutex, &ctx);
- if (ret == -EDEADLK) {
- ret = drm_modeset_backoff(&ctx);
- if (!ret) {
- try_again = true;
- continue;
- }
- break;
- } else if (ret) {
- break;
- }
+ if (ret)
+ continue;
+
intel_dp = intel_attached_dp(to_intel_connector(connector));
crtc_state = to_intel_crtc_state(crtc->state);
+
seq_printf(m, "DSC_Enabled: %s\n",
yesno(crtc_state->dsc.compression_enable));
seq_printf(m, "DSC_Sink_Support: %s\n",
@@ -2341,10 +2329,7 @@ static int i915_dsc_fec_support_show(struct seq_file *m, void *data)
if (!intel_dp_is_edp(intel_dp))
seq_printf(m, "FEC_Sink_Support: %s\n",
yesno(drm_dp_sink_supports_fec(intel_dp->fec_capable)));
- } while (try_again);
-
- drm_modeset_drop_locks(&ctx);
- drm_modeset_acquire_fini(&ctx);
+ }
return ret;
}
@@ -293,46 +293,34 @@ intel_crtc_crc_setup_workarounds(struct intel_crtc *crtc, bool enable)
struct drm_modeset_acquire_ctx ctx;
int ret;
- drm_modeset_acquire_init(&ctx, 0);
-
state = drm_atomic_state_alloc(&dev_priv->drm);
if (!state) {
ret = -ENOMEM;
goto unlock;
}
- state->acquire_ctx = &ctx;
+ drm_modeset_lock_ctx_retry(&ctx, state, 0, ret) {
+ pipe_config = intel_atomic_get_crtc_state(state, crtc);
+ if (IS_ERR(pipe_config)) {
+ ret = PTR_ERR(pipe_config);
+ continue;
+ }
-retry:
- pipe_config = intel_atomic_get_crtc_state(state, crtc);
- if (IS_ERR(pipe_config)) {
- ret = PTR_ERR(pipe_config);
- goto put_state;
- }
+ pipe_config->uapi.mode_changed = pipe_config->has_psr;
+ pipe_config->crc_enabled = enable;
- pipe_config->uapi.mode_changed = pipe_config->has_psr;
- pipe_config->crc_enabled = enable;
+ if (IS_HASWELL(dev_priv) &&
+ pipe_config->hw.active && crtc->pipe == PIPE_A &&
+ pipe_config->cpu_transcoder == TRANSCODER_EDP)
+ pipe_config->uapi.mode_changed = true;
- if (IS_HASWELL(dev_priv) &&
- pipe_config->hw.active && crtc->pipe == PIPE_A &&
- pipe_config->cpu_transcoder == TRANSCODER_EDP)
- pipe_config->uapi.mode_changed = true;
-
- ret = drm_atomic_commit(state);
-
-put_state:
- if (ret == -EDEADLK) {
- drm_atomic_state_clear(state);
- drm_modeset_backoff(&ctx);
- goto retry;
+ ret = drm_atomic_commit(state);
}
drm_atomic_state_put(state);
unlock:
drm_WARN(&dev_priv->drm, ret,
"Toggling workaround to %i returns %i\n", enable, ret);
- drm_modeset_drop_locks(&ctx);
- drm_modeset_acquire_fini(&ctx);
}
static int ivb_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv,