Revert "drm/i915: Make intel_display_suspend atomic, v2."
[deliverable/linux.git] / drivers / gpu / drm / i915 / intel_display.c
index 52759c03c9e851ccb114b3243f0537a675921a11..cc7fad9905b9a9a15fb485816f7f3cf6d84b37b1 100644 (file)
@@ -86,8 +86,7 @@ static void i9xx_crtc_clock_get(struct intel_crtc *crtc,
 static void ironlake_pch_clock_get(struct intel_crtc *crtc,
                                   struct intel_crtc_state *pipe_config);
 
-static int intel_set_mode(struct drm_crtc *crtc,
-                         struct drm_atomic_state *state);
+static int intel_set_mode(struct drm_atomic_state *state);
 static int intel_framebuffer_init(struct drm_device *dev,
                                  struct intel_framebuffer *ifb,
                                  struct drm_mode_fb_cmd2 *mode_cmd,
@@ -1699,7 +1698,7 @@ static int intel_num_dvo_pipes(struct drm_device *dev)
        int count = 0;
 
        for_each_intel_crtc(dev, crtc)
-               count += crtc->active &&
+               count += crtc->base.state->active &&
                        intel_pipe_has_type(crtc, INTEL_OUTPUT_DVO);
 
        return count;
@@ -1780,7 +1779,7 @@ static void i9xx_disable_pll(struct intel_crtc *crtc)
        /* Disable DVO 2x clock on both PLLs if necessary */
        if (IS_I830(dev) &&
            intel_pipe_has_type(crtc, INTEL_OUTPUT_DVO) &&
-           intel_num_dvo_pipes(dev) == 1) {
+           !intel_num_dvo_pipes(dev)) {
                I915_WRITE(DPLL(PIPE_B),
                           I915_READ(DPLL(PIPE_B)) & ~DPLL_DVO_2X_MODE);
                I915_WRITE(DPLL(PIPE_A),
@@ -4187,8 +4186,11 @@ struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc,
 {
        struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
        struct intel_shared_dpll *pll;
+       struct intel_shared_dpll_config *shared_dpll;
        enum intel_dpll_id i;
 
+       shared_dpll = intel_atomic_get_shared_dpll_state(crtc_state->base.state);
+
        if (HAS_PCH_IBX(dev_priv->dev)) {
                /* Ironlake PCH has a fixed PLL->PCH pipe mapping. */
                i = (enum intel_dpll_id) crtc->pipe;
@@ -4197,7 +4199,7 @@ struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc,
                DRM_DEBUG_KMS("CRTC:%d using pre-allocated %s\n",
                              crtc->base.base.id, pll->name);
 
-               WARN_ON(pll->new_config->crtc_mask);
+               WARN_ON(shared_dpll[i].crtc_mask);
 
                goto found;
        }
@@ -4217,7 +4219,7 @@ struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc,
                pll = &dev_priv->shared_dplls[i];
                DRM_DEBUG_KMS("CRTC:%d using pre-allocated %s\n",
                        crtc->base.base.id, pll->name);
-               WARN_ON(pll->new_config->crtc_mask);
+               WARN_ON(shared_dpll[i].crtc_mask);
 
                goto found;
        }
@@ -4226,15 +4228,15 @@ struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc,
                pll = &dev_priv->shared_dplls[i];
 
                /* Only want to check enabled timings first */
-               if (pll->new_config->crtc_mask == 0)
+               if (shared_dpll[i].crtc_mask == 0)
                        continue;
 
                if (memcmp(&crtc_state->dpll_hw_state,
-                          &pll->new_config->hw_state,
-                          sizeof(pll->new_config->hw_state)) == 0) {
+                          &shared_dpll[i].hw_state,
+                          sizeof(crtc_state->dpll_hw_state)) == 0) {
                        DRM_DEBUG_KMS("CRTC:%d sharing existing %s (crtc mask 0x%08x, ative %d)\n",
                                      crtc->base.base.id, pll->name,
-                                     pll->new_config->crtc_mask,
+                                     shared_dpll[i].crtc_mask,
                                      pll->active);
                        goto found;
                }
@@ -4243,7 +4245,7 @@ struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc,
        /* Ok no matching timings, maybe there's a free one? */
        for (i = 0; i < dev_priv->num_shared_dpll; i++) {
                pll = &dev_priv->shared_dplls[i];
-               if (pll->new_config->crtc_mask == 0) {
+               if (shared_dpll[i].crtc_mask == 0) {
                        DRM_DEBUG_KMS("CRTC:%d allocated %s\n",
                                      crtc->base.base.id, pll->name);
                        goto found;
@@ -4253,83 +4255,33 @@ struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc,
        return NULL;
 
 found:
-       if (pll->new_config->crtc_mask == 0)
-               pll->new_config->hw_state = crtc_state->dpll_hw_state;
+       if (shared_dpll[i].crtc_mask == 0)
+               shared_dpll[i].hw_state =
+                       crtc_state->dpll_hw_state;
 
        crtc_state->shared_dpll = i;
        DRM_DEBUG_DRIVER("using %s for pipe %c\n", pll->name,
                         pipe_name(crtc->pipe));
 
-       pll->new_config->crtc_mask |= 1 << crtc->pipe;
+       shared_dpll[i].crtc_mask |= 1 << crtc->pipe;
 
        return pll;
 }
 
-/**
- * intel_shared_dpll_start_config - start a new PLL staged config
- * @dev_priv: DRM device
- * @clear_pipes: mask of pipes that will have their PLLs freed
- *
- * Starts a new PLL staged config, copying the current config but
- * releasing the references of pipes specified in clear_pipes.
- */
-static int intel_shared_dpll_start_config(struct drm_i915_private *dev_priv,
-                                         unsigned clear_pipes)
-{
-       struct intel_shared_dpll *pll;
-       enum intel_dpll_id i;
-
-       for (i = 0; i < dev_priv->num_shared_dpll; i++) {
-               pll = &dev_priv->shared_dplls[i];
-
-               pll->new_config = kmemdup(&pll->config, sizeof pll->config,
-                                         GFP_KERNEL);
-               if (!pll->new_config)
-                       goto cleanup;
-
-               pll->new_config->crtc_mask &= ~clear_pipes;
-       }
-
-       return 0;
-
-cleanup:
-       while (--i >= 0) {
-               pll = &dev_priv->shared_dplls[i];
-               kfree(pll->new_config);
-               pll->new_config = NULL;
-       }
-
-       return -ENOMEM;
-}
-
-static void intel_shared_dpll_commit(struct drm_i915_private *dev_priv)
+static void intel_shared_dpll_commit(struct drm_atomic_state *state)
 {
+       struct drm_i915_private *dev_priv = to_i915(state->dev);
+       struct intel_shared_dpll_config *shared_dpll;
        struct intel_shared_dpll *pll;
        enum intel_dpll_id i;
 
-       for (i = 0; i < dev_priv->num_shared_dpll; i++) {
-               pll = &dev_priv->shared_dplls[i];
-
-               WARN_ON(pll->new_config == &pll->config);
-
-               pll->config = *pll->new_config;
-               kfree(pll->new_config);
-               pll->new_config = NULL;
-       }
-}
-
-static void intel_shared_dpll_abort_config(struct drm_i915_private *dev_priv)
-{
-       struct intel_shared_dpll *pll;
-       enum intel_dpll_id i;
+       if (!to_intel_atomic_state(state)->dpll_set)
+               return;
 
+       shared_dpll = to_intel_atomic_state(state)->shared_dpll;
        for (i = 0; i < dev_priv->num_shared_dpll; i++) {
                pll = &dev_priv->shared_dplls[i];
-
-               WARN_ON(pll->new_config == &pll->config);
-
-               kfree(pll->new_config);
-               pll->new_config = NULL;
+               pll->config = shared_dpll[i];
        }
 }
 
@@ -4912,42 +4864,15 @@ static bool hsw_crtc_supports_ips(struct intel_crtc *crtc)
        return HAS_IPS(crtc->base.dev) && crtc->pipe == PIPE_A;
 }
 
-/*
- * This implements the workaround described in the "notes" section of the mode
- * set sequence documentation. When going from no pipes or single pipe to
- * multiple pipes, and planes are enabled after the pipe, we need to wait at
- * least 2 vblanks on the first pipe before enabling planes on the second pipe.
- */
-static void haswell_mode_set_planes_workaround(struct intel_crtc *crtc)
-{
-       struct drm_device *dev = crtc->base.dev;
-       struct intel_crtc *crtc_it, *other_active_crtc = NULL;
-
-       /* We want to get the other_active_crtc only if there's only 1 other
-        * active crtc. */
-       for_each_intel_crtc(dev, crtc_it) {
-               if (!crtc_it->active || crtc_it == crtc)
-                       continue;
-
-               if (other_active_crtc)
-                       return;
-
-               other_active_crtc = crtc_it;
-       }
-       if (!other_active_crtc)
-               return;
-
-       intel_wait_for_vblank(dev, other_active_crtc->pipe);
-       intel_wait_for_vblank(dev, other_active_crtc->pipe);
-}
-
 static void haswell_crtc_enable(struct drm_crtc *crtc)
 {
        struct drm_device *dev = crtc->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
        struct intel_encoder *encoder;
-       int pipe = intel_crtc->pipe;
+       int pipe = intel_crtc->pipe, hsw_workaround_pipe;
+       struct intel_crtc_state *pipe_config =
+               to_intel_crtc_state(crtc->state);
 
        if (WARN_ON(intel_crtc->active))
                return;
@@ -5024,7 +4949,11 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
 
        /* If we change the relative order between pipe/planes enabling, we need
         * to change the workaround. */
-       haswell_mode_set_planes_workaround(intel_crtc);
+       hsw_workaround_pipe = pipe_config->hsw_workaround_pipe;
+       if (IS_HASWELL(dev) && hsw_workaround_pipe != INVALID_PIPE) {
+               intel_wait_for_vblank(dev, hsw_workaround_pipe);
+               intel_wait_for_vblank(dev, hsw_workaround_pipe);
+       }
 }
 
 static void ironlake_pfit_disable(struct intel_crtc *crtc)
@@ -6286,38 +6215,49 @@ void intel_display_suspend(struct drm_device *dev)
 }
 
 /* Master function to enable/disable CRTC and corresponding power wells */
-void intel_crtc_control(struct drm_crtc *crtc, bool enable)
+int intel_crtc_control(struct drm_crtc *crtc, bool enable)
 {
        struct drm_device *dev = crtc->dev;
-       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct drm_mode_config *config = &dev->mode_config;
+       struct drm_modeset_acquire_ctx *ctx = config->acquire_ctx;
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-       enum intel_display_power_domain domain;
-       unsigned long domains;
+       struct intel_crtc_state *pipe_config;
+       struct drm_atomic_state *state;
+       int ret;
 
        if (enable == intel_crtc->active)
-               return;
+               return 0;
 
        if (enable && !crtc->state->enable)
-               return;
+               return 0;
 
-       crtc->state->active = enable;
-       if (enable) {
-               domains = get_crtc_power_domains(crtc);
-               for_each_power_domain(domain, domains)
-                       intel_display_power_get(dev_priv, domain);
-               intel_crtc->enabled_power_domains = domains;
+       /* this function should be called with drm_modeset_lock_all for now */
+       if (WARN_ON(!ctx))
+               return -EIO;
+       lockdep_assert_held(&ctx->ww_ctx);
 
-               dev_priv->display.crtc_enable(crtc);
-               intel_crtc_enable_planes(crtc);
-       } else {
-               intel_crtc_disable_planes(crtc);
-               dev_priv->display.crtc_disable(crtc);
+       state = drm_atomic_state_alloc(dev);
+       if (WARN_ON(!state))
+               return -ENOMEM;
 
-               domains = intel_crtc->enabled_power_domains;
-               for_each_power_domain(domain, domains)
-                       intel_display_power_put(dev_priv, domain);
-               intel_crtc->enabled_power_domains = 0;
+       state->acquire_ctx = ctx;
+       state->allow_modeset = true;
+
+       pipe_config = intel_atomic_get_crtc_state(state, intel_crtc);
+       if (IS_ERR(pipe_config)) {
+               ret = PTR_ERR(pipe_config);
+               goto err;
        }
+       pipe_config->base.active = enable;
+
+       ret = intel_set_mode(state);
+       if (!ret)
+               return ret;
+
+err:
+       DRM_ERROR("Updating crtc active failed with %i\n", ret);
+       drm_atomic_state_free(state);
+       return ret;
 }
 
 /**
@@ -10360,7 +10300,7 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector,
 retry:
        ret = drm_modeset_lock(&config->connection_mutex, ctx);
        if (ret)
-               goto fail_unlock;
+               goto fail;
 
        /*
         * Algorithm gets a little messy:
@@ -10378,10 +10318,10 @@ retry:
 
                ret = drm_modeset_lock(&crtc->mutex, ctx);
                if (ret)
-                       goto fail_unlock;
+                       goto fail;
                ret = drm_modeset_lock(&crtc->primary->mutex, ctx);
                if (ret)
-                       goto fail_unlock;
+                       goto fail;
 
                old->dpms_mode = connector->dpms;
                old->load_detect_temp = false;
@@ -10400,9 +10340,6 @@ retry:
                        continue;
                if (possible_crtc->state->enable)
                        continue;
-               /* This can occur when applying the pipe A quirk on resume. */
-               if (to_intel_crtc(possible_crtc)->new_enabled)
-                       continue;
 
                crtc = possible_crtc;
                break;
@@ -10413,20 +10350,17 @@ retry:
         */
        if (!crtc) {
                DRM_DEBUG_KMS("no pipe available for load-detect\n");
-               goto fail_unlock;
+               goto fail;
        }
 
        ret = drm_modeset_lock(&crtc->mutex, ctx);
        if (ret)
-               goto fail_unlock;
+               goto fail;
        ret = drm_modeset_lock(&crtc->primary->mutex, ctx);
        if (ret)
-               goto fail_unlock;
-       intel_encoder->new_crtc = to_intel_crtc(crtc);
-       to_intel_connector(connector)->new_encoder = intel_encoder;
+               goto fail;
 
        intel_crtc = to_intel_crtc(crtc);
-       intel_crtc->new_enabled = true;
        old->dpms_mode = connector->dpms;
        old->load_detect_temp = true;
        old->release_fb = NULL;
@@ -10482,7 +10416,7 @@ retry:
 
        drm_mode_copy(&crtc_state->base.mode, mode);
 
-       if (intel_set_mode(crtc, state)) {
+       if (intel_set_mode(state)) {
                DRM_DEBUG_KMS("failed to set mode on load-detect pipe\n");
                if (old->release_fb)
                        old->release_fb->funcs->destroy(old->release_fb);
@@ -10494,9 +10428,7 @@ retry:
        intel_wait_for_vblank(dev, intel_crtc->pipe);
        return true;
 
- fail:
-       intel_crtc->new_enabled = crtc->state->enable;
-fail_unlock:
+fail:
        drm_atomic_state_free(state);
        state = NULL;
 
@@ -10542,10 +10474,6 @@ void intel_release_load_detect_pipe(struct drm_connector *connector,
                if (IS_ERR(crtc_state))
                        goto fail;
 
-               to_intel_connector(connector)->new_encoder = NULL;
-               intel_encoder->new_crtc = NULL;
-               intel_crtc->new_enabled = false;
-
                connector_state->best_encoder = NULL;
                connector_state->crtc = NULL;
 
@@ -10556,7 +10484,7 @@ void intel_release_load_detect_pipe(struct drm_connector *connector,
                if (ret)
                        goto fail;
 
-               ret = intel_set_mode(crtc, state);
+               ret = intel_set_mode(state);
                if (ret)
                        goto fail;
 
@@ -11692,33 +11620,6 @@ static const struct drm_crtc_helper_funcs intel_helper_funcs = {
        .atomic_flush = intel_finish_crtc_commit,
 };
 
-/**
- * intel_modeset_update_staged_output_state
- *
- * Updates the staged output configuration state, e.g. after we've read out the
- * current hw state.
- */
-static void intel_modeset_update_staged_output_state(struct drm_device *dev)
-{
-       struct intel_crtc *crtc;
-       struct intel_encoder *encoder;
-       struct intel_connector *connector;
-
-       for_each_intel_connector(dev, connector) {
-               connector->new_encoder =
-                       to_intel_encoder(connector->base.encoder);
-       }
-
-       for_each_intel_encoder(dev, encoder) {
-               encoder->new_crtc =
-                       to_intel_crtc(encoder->base.crtc);
-       }
-
-       for_each_intel_crtc(dev, crtc) {
-               crtc->new_enabled = crtc->base.state->enable;
-       }
-}
-
 /* Transitional helper to copy current connector/encoder state to
  * connector->state. This is needed so that code that is partially
  * converted to atomic does the right thing.
@@ -12068,9 +11969,10 @@ clear_intel_crtc_state(struct intel_crtc_state *crtc_state)
 
 static int
 intel_modeset_pipe_config(struct drm_crtc *crtc,
-                         struct drm_atomic_state *state,
-                         struct intel_crtc_state *pipe_config)
+                         struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state;
+       struct intel_crtc_state *pipe_config;
        struct intel_encoder *encoder;
        struct drm_connector *connector;
        struct drm_connector_state *connector_state;
@@ -12088,6 +11990,12 @@ intel_modeset_pipe_config(struct drm_crtc *crtc,
                return -EINVAL;
        }
 
+       crtc_state = drm_atomic_get_existing_crtc_state(state, crtc);
+       if (WARN_ON(!crtc_state))
+               return -EINVAL;
+
+       pipe_config = to_intel_crtc_state(crtc_state);
+
        /*
         * XXX: Add all connectors to make the crtc state match the encoders.
         */
@@ -12221,14 +12129,12 @@ static void
 intel_modeset_update_state(struct drm_atomic_state *state)
 {
        struct drm_device *dev = state->dev;
-       struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_encoder *intel_encoder;
        struct drm_crtc *crtc;
        struct drm_crtc_state *crtc_state;
        struct drm_connector *connector;
 
-       intel_shared_dpll_commit(dev_priv);
-       drm_atomic_helper_swap_state(state->dev, state);
+       intel_shared_dpll_commit(state);
 
        for_each_intel_encoder(dev, intel_encoder) {
                if (!intel_encoder->base.crtc)
@@ -12243,13 +12149,18 @@ intel_modeset_update_state(struct drm_atomic_state *state)
        }
 
        drm_atomic_helper_update_legacy_modeset_state(state->dev, state);
-       intel_modeset_update_staged_output_state(state->dev);
 
        /* Double check state. */
        for_each_crtc(dev, crtc) {
                WARN_ON(crtc->state->enable != intel_crtc_in_use(crtc));
 
                to_intel_crtc(crtc)->config = to_intel_crtc_state(crtc->state);
+
+               /* Update hwmode for vblank functions */
+               if (crtc->state->active)
+                       crtc->hwmode = crtc->state->adjusted_mode;
+               else
+                       crtc->hwmode.crtc_clock = 0;
        }
 
        list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
@@ -12547,11 +12458,14 @@ check_connector_state(struct drm_device *dev)
        struct intel_connector *connector;
 
        for_each_intel_connector(dev, connector) {
+               struct drm_encoder *encoder = connector->base.encoder;
+               struct drm_connector_state *state = connector->base.state;
+
                /* This also checks the encoder/connector hw state with the
                 * ->get_hw_state callbacks. */
                intel_connector_check_state(connector);
 
-               I915_STATE_WARN(&connector->new_encoder->base != connector->base.encoder,
+               I915_STATE_WARN(state->best_encoder != encoder,
                     "connector's staged encoder doesn't match current encoder\n");
        }
 }
@@ -12571,8 +12485,6 @@ check_encoder_state(struct drm_device *dev)
                              encoder->base.base.id,
                              encoder->base.name);
 
-               I915_STATE_WARN(&encoder->new_crtc->base != encoder->base.crtc,
-                    "encoder's stage crtc doesn't match current crtc\n");
                I915_STATE_WARN(encoder->connectors_active && !encoder->base.crtc,
                     "encoder's active_connectors set, but no crtc\n");
 
@@ -12582,6 +12494,9 @@ check_encoder_state(struct drm_device *dev)
                        enabled = true;
                        if (connector->base.dpms != DRM_MODE_DPMS_OFF)
                                active = true;
+
+                       I915_STATE_WARN(connector->base.state->crtc != encoder->base.crtc,
+                            "encoder's stage crtc doesn't match current crtc\n");
                }
                /*
                 * for MST connectors if we unplug the connector is gone
@@ -12800,48 +12715,7 @@ static void update_scanline_offset(struct intel_crtc *crtc)
                crtc->scanline_offset = 1;
 }
 
-static struct intel_crtc_state *
-intel_modeset_compute_config(struct drm_crtc *crtc,
-                            struct drm_atomic_state *state)
-{
-       struct intel_crtc_state *pipe_config;
-       int ret = 0;
-
-       ret = drm_atomic_helper_check_modeset(state->dev, state);
-       if (ret)
-               return ERR_PTR(ret);
-
-       /*
-        * Note this needs changes when we start tracking multiple modes
-        * and crtcs.  At that point we'll need to compute the whole config
-        * (i.e. one pipe_config for each crtc) rather than just the one
-        * for this crtc.
-        */
-       pipe_config = intel_atomic_get_crtc_state(state, to_intel_crtc(crtc));
-       if (IS_ERR(pipe_config))
-               return pipe_config;
-
-       if (!pipe_config->base.enable &&
-           WARN_ON(pipe_config->base.active))
-               pipe_config->base.active = false;
-
-       if (!pipe_config->base.enable)
-               return pipe_config;
-
-       ret = intel_modeset_pipe_config(crtc, state, pipe_config);
-       if (ret)
-               return ERR_PTR(ret);
-
-       intel_dump_pipe_config(to_intel_crtc(crtc), pipe_config, "[modeset]");
-
-       ret = drm_atomic_helper_check_planes(state->dev, state);
-       if (ret)
-               return ERR_PTR(ret);
-
-       return pipe_config;
-}
-
-static int __intel_set_mode_setup_plls(struct drm_atomic_state *state)
+static int intel_modeset_setup_plls(struct drm_atomic_state *state)
 {
        struct drm_device *dev = state->dev;
        struct drm_i915_private *dev_priv = to_i915(dev);
@@ -12866,9 +12740,13 @@ static int __intel_set_mode_setup_plls(struct drm_atomic_state *state)
                }
        }
 
-       ret = intel_shared_dpll_start_config(dev_priv, clear_pipes);
-       if (ret)
-               goto done;
+       if (clear_pipes) {
+               struct intel_shared_dpll_config *shared_dpll =
+                       intel_atomic_get_shared_dpll_state(state);
+
+               for (i = 0; i < dev_priv->num_shared_dpll; i++)
+                       shared_dpll[i].crtc_mask &= ~clear_pipes;
+       }
 
        for_each_crtc_in_state(state, crtc, crtc_state, i) {
                if (!needs_modeset(crtc_state) || !crtc_state->enable)
@@ -12879,18 +12757,80 @@ static int __intel_set_mode_setup_plls(struct drm_atomic_state *state)
 
                ret = dev_priv->display.crtc_compute_clock(intel_crtc,
                                                           intel_crtc_state);
-               if (ret) {
-                       intel_shared_dpll_abort_config(dev_priv);
-                       goto done;
-               }
+               if (ret)
+                       return ret;
        }
 
-done:
        return ret;
 }
 
+/*
+ * This implements the workaround described in the "notes" section of the mode
+ * set sequence documentation. When going from no pipes or single pipe to
+ * multiple pipes, and planes are enabled after the pipe, we need to wait at
+ * least 2 vblanks on the first pipe before enabling planes on the second pipe.
+ */
+static int haswell_mode_set_planes_workaround(struct drm_atomic_state *state)
+{
+       struct drm_crtc_state *crtc_state;
+       struct intel_crtc *intel_crtc;
+       struct drm_crtc *crtc;
+       struct intel_crtc_state *first_crtc_state = NULL;
+       struct intel_crtc_state *other_crtc_state = NULL;
+       enum pipe first_pipe = INVALID_PIPE, enabled_pipe = INVALID_PIPE;
+       int i;
+
+       /* look at all crtc's that are going to be enabled in during modeset */
+       for_each_crtc_in_state(state, crtc, crtc_state, i) {
+               intel_crtc = to_intel_crtc(crtc);
+
+               if (!crtc_state->active || !needs_modeset(crtc_state))
+                       continue;
+
+               if (first_crtc_state) {
+                       other_crtc_state = to_intel_crtc_state(crtc_state);
+                       break;
+               } else {
+                       first_crtc_state = to_intel_crtc_state(crtc_state);
+                       first_pipe = intel_crtc->pipe;
+               }
+       }
+
+       /* No workaround needed? */
+       if (!first_crtc_state)
+               return 0;
+
+       /* w/a possibly needed, check how many crtc's are already enabled. */
+       for_each_intel_crtc(state->dev, intel_crtc) {
+               struct intel_crtc_state *pipe_config;
+
+               pipe_config = intel_atomic_get_crtc_state(state, intel_crtc);
+               if (IS_ERR(pipe_config))
+                       return PTR_ERR(pipe_config);
+
+               pipe_config->hsw_workaround_pipe = INVALID_PIPE;
+
+               if (!pipe_config->base.active ||
+                   needs_modeset(&pipe_config->base))
+                       continue;
+
+               /* 2 or more enabled crtcs means no need for w/a */
+               if (enabled_pipe != INVALID_PIPE)
+                       return 0;
+
+               enabled_pipe = intel_crtc->pipe;
+       }
+
+       if (enabled_pipe != INVALID_PIPE)
+               first_crtc_state->hsw_workaround_pipe = enabled_pipe;
+       else if (other_crtc_state)
+               other_crtc_state->hsw_workaround_pipe = first_pipe;
+
+       return 0;
+}
+
 /* Code that should eventually be part of atomic_check() */
-static int __intel_set_mode_checks(struct drm_atomic_state *state)
+static int intel_modeset_checks(struct drm_atomic_state *state)
 {
        struct drm_device *dev = state->dev;
        int ret;
@@ -12912,11 +12852,49 @@ static int __intel_set_mode_checks(struct drm_atomic_state *state)
                        return ret;
        }
 
-       ret = __intel_set_mode_setup_plls(state);
+       ret = intel_modeset_setup_plls(state);
        if (ret)
                return ret;
 
-       return 0;
+       if (IS_HASWELL(dev))
+               ret = haswell_mode_set_planes_workaround(state);
+
+       return ret;
+}
+
+static int
+intel_modeset_compute_config(struct drm_atomic_state *state)
+{
+       struct drm_crtc *crtc;
+       struct drm_crtc_state *crtc_state;
+       int ret, i;
+
+       ret = drm_atomic_helper_check_modeset(state->dev, state);
+       if (ret)
+               return ret;
+
+       for_each_crtc_in_state(state, crtc, crtc_state, i) {
+               if (!crtc_state->enable &&
+                   WARN_ON(crtc_state->active))
+                       crtc_state->active = false;
+
+               if (!crtc_state->enable)
+                       continue;
+
+               ret = intel_modeset_pipe_config(crtc, state);
+               if (ret)
+                       return ret;
+
+               intel_dump_pipe_config(to_intel_crtc(crtc),
+                                      to_intel_crtc_state(crtc_state),
+                                      "[modeset]");
+       }
+
+       ret = intel_modeset_checks(state);
+       if (ret)
+               return ret;
+
+       return drm_atomic_helper_check_planes(state->dev, state);
 }
 
 static int __intel_set_mode(struct drm_atomic_state *state)
@@ -12928,22 +12906,18 @@ static int __intel_set_mode(struct drm_atomic_state *state)
        int ret = 0;
        int i;
 
-       ret = __intel_set_mode_checks(state);
-       if (ret < 0)
-               return ret;
-
        ret = drm_atomic_helper_prepare_planes(dev, state);
        if (ret)
                return ret;
 
+       drm_atomic_helper_swap_state(dev, state);
+
        for_each_crtc_in_state(state, crtc, crtc_state, i) {
-               if (!needs_modeset(crtc_state) || !crtc->state->active)
+               if (!needs_modeset(crtc->state) || !crtc_state->active)
                        continue;
 
                intel_crtc_disable_planes(crtc);
                dev_priv->display.crtc_disable(crtc);
-               if (!crtc_state->enable)
-                       drm_plane_helper_disable(crtc->primary);
        }
 
        /* Only after disabling all output pipelines that will be changed can we
@@ -12955,10 +12929,10 @@ static int __intel_set_mode(struct drm_atomic_state *state)
 
        modeset_update_crtc_power_domains(state);
 
-       drm_atomic_helper_commit_planes(dev, state);
-
        /* Now enable the clocks, plane, pipe, and connectors that we set up. */
        for_each_crtc_in_state(state, crtc, crtc_state, i) {
+               drm_atomic_helper_commit_planes_on_crtc(crtc_state);
+
                if (!needs_modeset(crtc->state) || !crtc->state->active)
                        continue;
 
@@ -12977,37 +12951,27 @@ static int __intel_set_mode(struct drm_atomic_state *state)
        return 0;
 }
 
-static int intel_set_mode_with_config(struct drm_crtc *crtc,
-                                     struct intel_crtc_state *pipe_config)
+static int intel_set_mode_checked(struct drm_atomic_state *state)
 {
+       struct drm_device *dev = state->dev;
        int ret;
 
-       ret = __intel_set_mode(pipe_config->base.state);
-
+       ret = __intel_set_mode(state);
        if (ret == 0)
-               intel_modeset_check_state(crtc->dev);
+               intel_modeset_check_state(dev);
 
        return ret;
 }
 
-static int intel_set_mode(struct drm_crtc *crtc,
-                         struct drm_atomic_state *state)
+static int intel_set_mode(struct drm_atomic_state *state)
 {
-       struct intel_crtc_state *pipe_config;
-       int ret = 0;
-
-       pipe_config = intel_modeset_compute_config(crtc, state);
-       if (IS_ERR(pipe_config)) {
-               ret = PTR_ERR(pipe_config);
-               goto out;
-       }
+       int ret;
 
-       ret = intel_set_mode_with_config(crtc, pipe_config);
+       ret = intel_modeset_compute_config(state);
        if (ret)
-               goto out;
+               return ret;
 
-out:
-       return ret;
+       return intel_set_mode_checked(state);
 }
 
 void intel_crtc_restore_mode(struct drm_crtc *crtc)
@@ -13036,11 +13000,11 @@ void intel_crtc_restore_mode(struct drm_crtc *crtc)
         * need to copy the staged config to the atomic state, otherwise the
         * mode set will just reapply the state the HW is already in. */
        for_each_intel_encoder(dev, encoder) {
-               if (&encoder->new_crtc->base != crtc)
+               if (encoder->base.crtc != crtc)
                        continue;
 
                for_each_intel_connector(dev, connector) {
-                       if (connector->new_encoder != encoder)
+                       if (connector->base.state->best_encoder != &encoder->base)
                                continue;
 
                        connector_state = drm_atomic_get_connector_state(state, &connector->base);
@@ -13053,14 +13017,10 @@ void intel_crtc_restore_mode(struct drm_crtc *crtc)
                        }
 
                        connector_state->crtc = crtc;
-                       connector_state->best_encoder = &encoder->base;
                }
        }
 
        for_each_intel_crtc(dev, intel_crtc) {
-               if (intel_crtc->new_enabled == intel_crtc->base.enabled)
-                       continue;
-
                crtc_state = intel_atomic_get_crtc_state(state, intel_crtc);
                if (IS_ERR(crtc_state)) {
                        DRM_DEBUG_KMS("Failed to add [CRTC:%d] to state: %ld\n",
@@ -13069,9 +13029,6 @@ void intel_crtc_restore_mode(struct drm_crtc *crtc)
                        continue;
                }
 
-               crtc_state->base.active = crtc_state->base.enable =
-                       intel_crtc->new_enabled;
-
                if (&intel_crtc->base == crtc)
                        drm_mode_copy(&crtc_state->base.mode, &crtc->mode);
        }
@@ -13079,7 +13036,7 @@ void intel_crtc_restore_mode(struct drm_crtc *crtc)
        intel_modeset_setup_plane_state(state, crtc, &crtc->mode,
                                        crtc->primary->fb, crtc->x, crtc->y);
 
-       ret = intel_set_mode(crtc, state);
+       ret = intel_set_mode(state);
        if (ret)
                drm_atomic_state_free(state);
 }
@@ -13229,7 +13186,6 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
 {
        struct drm_device *dev;
        struct drm_atomic_state *state = NULL;
-       struct intel_crtc_state *pipe_config;
        int ret;
 
        BUG_ON(!set);
@@ -13260,16 +13216,13 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
        if (ret)
                goto out;
 
-       pipe_config = intel_modeset_compute_config(set->crtc, state);
-       if (IS_ERR(pipe_config)) {
-               ret = PTR_ERR(pipe_config);
+       ret = intel_modeset_compute_config(state);
+       if (ret)
                goto out;
-       }
 
        intel_update_pipe_size(to_intel_crtc(set->crtc));
 
-       ret = intel_set_mode_with_config(set->crtc, pipe_config);
-
+       ret = intel_set_mode_checked(state);
        if (ret) {
                DRM_DEBUG_KMS("failed to set mode on [CRTC:%d], err = %d\n",
                              set->crtc->base.id, ret);
@@ -13674,6 +13627,7 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc)
        struct drm_device *dev = crtc->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+       struct drm_crtc_state *crtc_state = intel_crtc->base.state;
        struct intel_plane *intel_plane;
        struct drm_plane *p;
        unsigned fb_bits = 0;
@@ -13717,7 +13671,7 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc)
        intel_runtime_pm_get(dev_priv);
 
        /* Perform vblank evasion around commit operation */
-       if (intel_crtc->active)
+       if (crtc_state->active && !needs_modeset(crtc_state))
                intel_crtc->atomic.evade =
                        intel_pipe_update_start(intel_crtc,
                                                &intel_crtc->atomic.start_vbl_count);
@@ -14602,6 +14556,8 @@ static const struct drm_mode_config_funcs intel_mode_funcs = {
        .output_poll_changed = intel_fbdev_output_poll_changed,
        .atomic_check = intel_atomic_check,
        .atomic_commit = intel_atomic_commit,
+       .atomic_state_alloc = intel_atomic_state_alloc,
+       .atomic_state_clear = intel_atomic_state_clear,
 };
 
 /* Set up chip specific display functions */
@@ -15149,6 +15105,7 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)
                 * ...  */
                plane = crtc->plane;
                to_intel_plane_state(crtc->base.primary->state)->visible = true;
+               crtc->base.primary->crtc = &crtc->base;
                crtc->plane = !plane;
                intel_crtc_control(&crtc->base, false);
                crtc->plane = plane;
@@ -15312,98 +15269,225 @@ static bool primary_get_hw_state(struct intel_crtc *crtc)
 {
        struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
 
-       if (!crtc->active)
+       if (!crtc->base.enabled)
                return false;
 
        return I915_READ(DSPCNTR(crtc->plane)) & DISPLAY_PLANE_ENABLE;
 }
 
-static void intel_modeset_readout_hw_state(struct drm_device *dev)
+static int readout_hw_crtc_state(struct drm_atomic_state *state,
+                                struct intel_crtc *crtc)
 {
-       struct drm_i915_private *dev_priv = dev->dev_private;
-       enum pipe pipe;
-       struct intel_crtc *crtc;
-       struct intel_encoder *encoder;
-       struct intel_connector *connector;
-       int i;
+       struct drm_i915_private *dev_priv = to_i915(state->dev);
+       struct intel_crtc_state *crtc_state;
+       struct drm_plane *primary = crtc->base.primary;
+       struct drm_plane_state *drm_plane_state;
+       struct intel_plane_state *plane_state;
+       int ret;
 
-       for_each_intel_crtc(dev, crtc) {
-               struct drm_plane *primary = crtc->base.primary;
-               struct intel_plane_state *plane_state;
+       crtc_state = intel_atomic_get_crtc_state(state, crtc);
+       if (IS_ERR(crtc_state))
+               return PTR_ERR(crtc_state);
 
-               memset(crtc->config, 0, sizeof(*crtc->config));
+       ret = drm_atomic_add_affected_planes(state, &crtc->base);
+       if (ret)
+               return ret;
 
-               crtc->config->quirks |= PIPE_CONFIG_QUIRK_INHERITED_MODE;
+       memset(crtc_state, 0, sizeof(*crtc_state));
+       crtc_state->base.crtc = &crtc->base;
+       crtc_state->base.state = state;
 
-               crtc->active = dev_priv->display.get_pipe_config(crtc,
-                                                                crtc->config);
+       crtc_state->quirks |= PIPE_CONFIG_QUIRK_INHERITED_MODE;
 
-               crtc->base.state->enable = crtc->active;
-               crtc->base.state->active = crtc->active;
-               crtc->base.enabled = crtc->active;
+       crtc_state->base.enable = crtc_state->base.active =
+       crtc->base.enabled = dev_priv->display.get_pipe_config(crtc, crtc_state);
 
-               plane_state = to_intel_plane_state(primary->state);
-               plane_state->visible = primary_get_hw_state(crtc);
+       /* update transitional state */
+       crtc->active = crtc_state->base.active;
+       crtc->config = crtc_state;
 
-               DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n",
-                             crtc->base.base.id,
-                             crtc->active ? "enabled" : "disabled");
-       }
+       drm_plane_state = drm_atomic_get_plane_state(state, primary);
+       if (IS_ERR(drm_plane_state))
+               return PTR_ERR(drm_plane_state);
+
+       plane_state = to_intel_plane_state(drm_plane_state);
+       plane_state->visible = primary_get_hw_state(crtc);
+
+       if (plane_state->visible) {
+               primary->crtc = &crtc->base;
+               crtc_state->base.plane_mask |= 1 << drm_plane_index(primary);
+       } else
+               crtc_state->base.plane_mask &= ~(1 << drm_plane_index(primary));
+
+       DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n",
+                     crtc->base.base.id,
+                     crtc_state->base.active ? "enabled" : "disabled");
+
+       return 0;
+}
+
+static int readout_hw_pll_state(struct drm_atomic_state *state)
+{
+       struct drm_i915_private *dev_priv = to_i915(state->dev);
+       struct intel_shared_dpll_config *shared_dpll;
+       struct intel_crtc *crtc;
+       struct intel_crtc_state *crtc_state;
+       int i;
 
+       shared_dpll = intel_atomic_get_shared_dpll_state(state);
        for (i = 0; i < dev_priv->num_shared_dpll; i++) {
                struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i];
 
                pll->on = pll->get_hw_state(dev_priv, pll,
-                                           &pll->config.hw_state);
+                                           &shared_dpll[i].hw_state);
+
                pll->active = 0;
-               pll->config.crtc_mask = 0;
-               for_each_intel_crtc(dev, crtc) {
-                       if (crtc->active && intel_crtc_to_shared_dpll(crtc) == pll) {
+               shared_dpll[i].crtc_mask = 0;
+
+               for_each_intel_crtc(state->dev, crtc) {
+                       crtc_state = intel_atomic_get_crtc_state(state, crtc);
+                       if (IS_ERR(crtc_state))
+                               return PTR_ERR(crtc_state);
+
+                       if (crtc_state->base.active &&
+                           crtc_state->shared_dpll == i) {
                                pll->active++;
-                               pll->config.crtc_mask |= 1 << crtc->pipe;
+                               shared_dpll[i].crtc_mask |=
+                                       1 << crtc->pipe;
                        }
                }
 
                DRM_DEBUG_KMS("%s hw state readout: crtc_mask 0x%08x, on %i\n",
-                             pll->name, pll->config.crtc_mask, pll->on);
+                             pll->name, shared_dpll[i].crtc_mask,
+                             pll->on);
 
-               if (pll->config.crtc_mask)
+               if (shared_dpll[i].crtc_mask)
                        intel_display_power_get(dev_priv, POWER_DOMAIN_PLLS);
        }
 
-       for_each_intel_encoder(dev, encoder) {
-               pipe = 0;
+       return 0;
+}
 
-               if (encoder->get_hw_state(encoder, &pipe)) {
-                       crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
-                       encoder->base.crtc = &crtc->base;
-                       encoder->get_config(encoder, crtc->config);
-               } else {
-                       encoder->base.crtc = NULL;
-               }
+static struct drm_connector_state *
+get_connector_state_for_encoder(struct drm_atomic_state *state,
+                               struct intel_encoder *encoder)
+{
+       struct drm_connector *connector;
+       struct drm_connector_state *connector_state;
+       int i;
 
-               encoder->connectors_active = false;
-               DRM_DEBUG_KMS("[ENCODER:%d:%s] hw state readout: %s, pipe %c\n",
-                             encoder->base.base.id,
-                             encoder->base.name,
-                             encoder->base.crtc ? "enabled" : "disabled",
-                             pipe_name(pipe));
-       }
+       for_each_connector_in_state(state, connector, connector_state, i)
+               if (connector_state->best_encoder == &encoder->base)
+                       return connector_state;
+
+       return NULL;
+}
+
+static int readout_hw_connector_encoder_state(struct drm_atomic_state *state)
+{
+       struct drm_device *dev = state->dev;
+       struct drm_i915_private *dev_priv = to_i915(state->dev);
+       struct intel_crtc *crtc;
+       struct drm_crtc_state *drm_crtc_state;
+       struct intel_crtc_state *crtc_state;
+       struct intel_encoder *encoder;
+       struct intel_connector *connector;
+       struct drm_connector_state *connector_state;
+       enum pipe pipe;
 
        for_each_intel_connector(dev, connector) {
+               connector_state =
+                       drm_atomic_get_connector_state(state, &connector->base);
+               if (IS_ERR(connector_state))
+                       return PTR_ERR(connector_state);
+
                if (connector->get_hw_state(connector)) {
                        connector->base.dpms = DRM_MODE_DPMS_ON;
-                       connector->encoder->connectors_active = true;
                        connector->base.encoder = &connector->encoder->base;
                } else {
                        connector->base.dpms = DRM_MODE_DPMS_OFF;
                        connector->base.encoder = NULL;
                }
+
+               /* We'll update the crtc field when reading encoder state */
+               connector_state->crtc = NULL;
+
+               connector_state->best_encoder = connector->base.encoder;
+
                DRM_DEBUG_KMS("[CONNECTOR:%d:%s] hw state readout: %s\n",
                              connector->base.base.id,
                              connector->base.name,
                              connector->base.encoder ? "enabled" : "disabled");
        }
+
+       for_each_intel_encoder(dev, encoder) {
+               pipe = 0;
+
+               connector_state =
+                       get_connector_state_for_encoder(state, encoder);
+
+               encoder->connectors_active = !!connector_state;
+
+               if (encoder->get_hw_state(encoder, &pipe)) {
+                       encoder->base.crtc =
+                               dev_priv->pipe_to_crtc_mapping[pipe];
+                       crtc = to_intel_crtc(encoder->base.crtc);
+
+                       drm_crtc_state =
+                               state->crtc_states[drm_crtc_index(&crtc->base)];
+                       crtc_state = to_intel_crtc_state(drm_crtc_state);
+
+                       encoder->get_config(encoder, crtc_state);
+
+                       if (connector_state)
+                               connector_state->crtc = &crtc->base;
+               } else {
+                       encoder->base.crtc = NULL;
+               }
+
+               DRM_DEBUG_KMS("[ENCODER:%d:%s] hw state readout: %s, pipe %c\n",
+                             encoder->base.base.id,
+                             encoder->base.name,
+                             encoder->base.crtc ? "enabled" : "disabled",
+                             pipe_name(pipe));
+       }
+
+       return 0;
+}
+
+static struct drm_atomic_state *
+intel_modeset_readout_hw_state(struct drm_device *dev)
+{
+       struct intel_crtc *crtc;
+       int ret = 0;
+
+       struct drm_atomic_state *state;
+
+       state = drm_atomic_state_alloc(dev);
+       if (!state)
+               return ERR_PTR(-ENOMEM);
+
+       state->acquire_ctx = dev->mode_config.acquire_ctx;
+
+       for_each_intel_crtc(dev, crtc) {
+               ret = readout_hw_crtc_state(state, crtc);
+               if (ret)
+                       goto err_free;
+       }
+
+       ret = readout_hw_pll_state(state);
+       if (ret)
+               goto err_free;
+
+       ret = readout_hw_connector_encoder_state(state);
+       if (ret)
+               goto err_free;
+
+       return state;
+
+err_free:
+       drm_atomic_state_free(state);
+       return ERR_PTR(ret);
 }
 
 /* Scan out the current hw modeset state, sanitizes it and maps it into the drm
@@ -15412,37 +15496,57 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
                                  bool force_restore)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
-       enum pipe pipe;
-       struct intel_crtc *crtc;
+       struct drm_crtc *crtc;
+       struct drm_crtc_state *crtc_state;
        struct intel_encoder *encoder;
+       struct drm_atomic_state *state;
+       struct intel_shared_dpll_config shared_dplls[I915_NUM_PLLS];
        int i;
 
-       intel_modeset_readout_hw_state(dev);
-
-       /*
-        * Now that we have the config, copy it to each CRTC struct
-        * Note that this could go away if we move to using crtc_config
-        * checking everywhere.
-        */
-       for_each_intel_crtc(dev, crtc) {
-               if (crtc->active && i915.fastboot) {
-                       intel_mode_from_pipe_config(&crtc->base.mode,
-                                                   crtc->config);
-                       DRM_DEBUG_KMS("[CRTC:%d] found active mode: ",
-                                     crtc->base.base.id);
-                       drm_mode_debug_printmodeline(&crtc->base.mode);
-               }
+       state = intel_modeset_readout_hw_state(dev);
+       if (IS_ERR(state)) {
+               DRM_ERROR("Failed to read out hw state\n");
+               return;
        }
 
+       drm_atomic_helper_swap_state(dev, state);
+
+       /* swap sw/hw dpll state */
+       intel_atomic_duplicate_dpll_state(dev_priv, shared_dplls);
+       intel_shared_dpll_commit(state);
+       memcpy(to_intel_atomic_state(state)->shared_dpll,
+              shared_dplls, sizeof(*shared_dplls) * dev_priv->num_shared_dpll);
+
        /* HW state is read out, now we need to sanitize this mess. */
        for_each_intel_encoder(dev, encoder) {
                intel_sanitize_encoder(encoder);
        }
 
-       for_each_pipe(dev_priv, pipe) {
-               crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
-               intel_sanitize_crtc(crtc);
-               intel_dump_pipe_config(crtc, crtc->config,
+       for_each_crtc_in_state(state, crtc, crtc_state, i) {
+               struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+
+               /* prevent unnneeded restores with force_restore */
+               crtc_state->active_changed =
+               crtc_state->mode_changed =
+               crtc_state->planes_changed = false;
+
+               if (crtc->enabled) {
+                       intel_mode_from_pipe_config(&crtc->state->mode,
+                               to_intel_crtc_state(crtc->state));
+
+                       drm_mode_copy(&crtc->mode, &crtc->state->mode);
+                       drm_mode_copy(&crtc->hwmode,
+                                     &crtc->state->adjusted_mode);
+               }
+
+               intel_sanitize_crtc(intel_crtc);
+
+               /*
+                * sanitize_crtc may have forced an update of crtc->state,
+                * so reload in intel_dump_pipe_config
+                */
+               intel_dump_pipe_config(intel_crtc,
+                                      to_intel_crtc_state(crtc->state),
                                       "[setup_hw_state]");
        }
 
@@ -15466,20 +15570,17 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
                ilk_wm_get_hw_state(dev);
 
        if (force_restore) {
-               i915_redisable_vga(dev);
+               int ret;
 
-               /*
-                * We need to use raw interfaces for restoring state to avoid
-                * checking (bogus) intermediate states.
-                */
-               for_each_pipe(dev_priv, pipe) {
-                       struct drm_crtc *crtc =
-                               dev_priv->pipe_to_crtc_mapping[pipe];
+               i915_redisable_vga(dev);
 
-                       intel_crtc_restore_mode(crtc);
+               ret = intel_set_mode(state);
+               if (ret) {
+                       DRM_ERROR("Failed to restore previous mode\n");
+                       drm_atomic_state_free(state);
                }
        } else {
-               intel_modeset_update_staged_output_state(dev);
+               drm_atomic_state_free(state);
        }
 
        intel_modeset_check_state(dev);
This page took 0.056054 seconds and 5 git commands to generate.