Skip to content

Commit e2c8b87

Browse files
committed
drm/i915: Use atomic helpers for suspend, v2.
Instead of duplicating the functionality now that we no longer need to preserve dpll state we can move to using the upstream suspend helper. Changes since v1: - Call hw readout with all mutexes held. - Rework intel_display_suspend to only assign modeset_restore_state on success. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/56C2E686.5060803@linux.intel.com Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
1 parent 1db6e2e commit e2c8b87

File tree

3 files changed

+45
-85
lines changed

3 files changed

+45
-85
lines changed

drivers/gpu/drm/i915/i915_drv.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -603,13 +603,7 @@ static int i915_drm_suspend(struct drm_device *dev)
603603

604604
intel_suspend_gt_powersave(dev);
605605

606-
/*
607-
* Disable CRTCs directly since we want to preserve sw state
608-
* for _thaw. Also, power gate the CRTC power wells.
609-
*/
610-
drm_modeset_lock_all(dev);
611606
intel_display_suspend(dev);
612-
drm_modeset_unlock_all(dev);
613607

614608
intel_dp_mst_suspend(dev);
615609

@@ -764,9 +758,7 @@ static int i915_drm_resume(struct drm_device *dev)
764758
dev_priv->display.hpd_irq_setup(dev);
765759
spin_unlock_irq(&dev_priv->irq_lock);
766760

767-
drm_modeset_lock_all(dev);
768761
intel_display_resume(dev);
769-
drm_modeset_unlock_all(dev);
770762

771763
intel_dp_mst_resume(dev);
772764

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,7 @@ struct drm_i915_private {
18481848

18491849
enum modeset_restore modeset_restore;
18501850
struct mutex modeset_restore_lock;
1851+
struct drm_atomic_state *modeset_restore_state;
18511852

18521853
struct list_head vm_list; /* Global list of all address spaces */
18531854
struct i915_gtt gtt; /* VM representing the global address space */

drivers/gpu/drm/i915/intel_display.c

Lines changed: 44 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -6397,55 +6397,16 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
63976397
*/
63986398
int intel_display_suspend(struct drm_device *dev)
63996399
{
6400-
struct drm_mode_config *config = &dev->mode_config;
6401-
struct drm_modeset_acquire_ctx *ctx = config->acquire_ctx;
6400+
struct drm_i915_private *dev_priv = to_i915(dev);
64026401
struct drm_atomic_state *state;
6403-
struct drm_crtc *crtc;
6404-
unsigned crtc_mask = 0;
6405-
int ret = 0;
6406-
6407-
if (WARN_ON(!ctx))
6408-
return 0;
6409-
6410-
lockdep_assert_held(&ctx->ww_ctx);
6411-
state = drm_atomic_state_alloc(dev);
6412-
if (WARN_ON(!state))
6413-
return -ENOMEM;
6414-
6415-
state->acquire_ctx = ctx;
6416-
state->allow_modeset = true;
6417-
6418-
for_each_crtc(dev, crtc) {
6419-
struct drm_crtc_state *crtc_state =
6420-
drm_atomic_get_crtc_state(state, crtc);
6421-
6422-
ret = PTR_ERR_OR_ZERO(crtc_state);
6423-
if (ret)
6424-
goto free;
6425-
6426-
if (!crtc_state->active)
6427-
continue;
6428-
6429-
crtc_state->active = false;
6430-
crtc_mask |= 1 << drm_crtc_index(crtc);
6431-
}
6432-
6433-
if (crtc_mask) {
6434-
ret = drm_atomic_commit(state);
6435-
6436-
if (!ret) {
6437-
for_each_crtc(dev, crtc)
6438-
if (crtc_mask & (1 << drm_crtc_index(crtc)))
6439-
crtc->state->active = true;
6440-
6441-
return ret;
6442-
}
6443-
}
6402+
int ret;
64446403

6445-
free:
6404+
state = drm_atomic_helper_suspend(dev);
6405+
ret = PTR_ERR_OR_ZERO(state);
64466406
if (ret)
64476407
DRM_ERROR("Suspending crtc's failed with %i\n", ret);
6448-
drm_atomic_state_free(state);
6408+
else
6409+
dev_priv->modeset_restore_state = state;
64496410
return ret;
64506411
}
64516412

@@ -15918,51 +15879,57 @@ intel_modeset_setup_hw_state(struct drm_device *dev)
1591815879

1591915880
void intel_display_resume(struct drm_device *dev)
1592015881
{
15921-
struct drm_atomic_state *state = drm_atomic_state_alloc(dev);
15922-
struct intel_connector *conn;
15923-
struct intel_plane *plane;
15924-
struct drm_crtc *crtc;
15882+
struct drm_i915_private *dev_priv = to_i915(dev);
15883+
struct drm_atomic_state *state = dev_priv->modeset_restore_state;
15884+
struct drm_modeset_acquire_ctx ctx;
1592515885
int ret;
15886+
bool setup = false;
1592615887

15927-
if (!state)
15928-
return;
15888+
dev_priv->modeset_restore_state = NULL;
1592915889

15930-
state->acquire_ctx = dev->mode_config.acquire_ctx;
15890+
drm_modeset_acquire_init(&ctx, 0);
1593115891

15932-
for_each_crtc(dev, crtc) {
15933-
struct drm_crtc_state *crtc_state =
15934-
drm_atomic_get_crtc_state(state, crtc);
15892+
retry:
15893+
ret = drm_modeset_lock_all_ctx(dev, &ctx);
1593515894

15936-
ret = PTR_ERR_OR_ZERO(crtc_state);
15937-
if (ret)
15938-
goto err;
15895+
if (ret == 0 && !setup) {
15896+
setup = true;
1593915897

15940-
/* force a restore */
15941-
crtc_state->mode_changed = true;
15898+
intel_modeset_setup_hw_state(dev);
15899+
i915_redisable_vga(dev);
1594215900
}
1594315901

15944-
for_each_intel_plane(dev, plane) {
15945-
ret = PTR_ERR_OR_ZERO(drm_atomic_get_plane_state(state, &plane->base));
15946-
if (ret)
15947-
goto err;
15948-
}
15902+
if (ret == 0 && state) {
15903+
struct drm_crtc_state *crtc_state;
15904+
struct drm_crtc *crtc;
15905+
int i;
1594915906

15950-
for_each_intel_connector(dev, conn) {
15951-
ret = PTR_ERR_OR_ZERO(drm_atomic_get_connector_state(state, &conn->base));
15952-
if (ret)
15953-
goto err;
15907+
state->acquire_ctx = &ctx;
15908+
15909+
for_each_crtc_in_state(state, crtc, crtc_state, i) {
15910+
/*
15911+
* Force recalculation even if we restore
15912+
* current state. With fast modeset this may not result
15913+
* in a modeset when the state is compatible.
15914+
*/
15915+
crtc_state->mode_changed = true;
15916+
}
15917+
15918+
ret = drm_atomic_commit(state);
1595415919
}
1595515920

15956-
intel_modeset_setup_hw_state(dev);
15921+
if (ret == -EDEADLK) {
15922+
drm_modeset_backoff(&ctx);
15923+
goto retry;
15924+
}
1595715925

15958-
i915_redisable_vga(dev);
15959-
ret = drm_atomic_commit(state);
15960-
if (!ret)
15961-
return;
15926+
drm_modeset_drop_locks(&ctx);
15927+
drm_modeset_acquire_fini(&ctx);
1596215928

15963-
err:
15964-
DRM_ERROR("Restoring old state failed with %i\n", ret);
15965-
drm_atomic_state_free(state);
15929+
if (ret) {
15930+
DRM_ERROR("Restoring old state failed with %i\n", ret);
15931+
drm_atomic_state_free(state);
15932+
}
1596615933
}
1596715934

1596815935
void intel_modeset_gem_init(struct drm_device *dev)

0 commit comments

Comments
 (0)