Commit 61caf87c authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Linus Torvalds

i915 / PM: Fix hibernate regression caused by suspend/resume splitting

Commit 84b79f8d (drm/i915: Fix crash
while aborting hibernation) attempted to fix a regression introduced
by commit cbda12d7 (drm/i915:
implement new pm ops for i915), but it went too far trying to split
the freeze/suspend and resume/thaw parts of the code.  As a result,
it introduced another regression, which only is visible on some systems.

Fix the problem by merging i915_drm_suspend() with
i915_drm_freeze() and moving some code from i915_resume()
into i915_drm_thaw(), so that intel_opregion_free() and
intel_opregion_init() are also executed in the freeze and thaw code
paths, respectively.
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Reported-and-tested-by: default avatarPedro Ribeiro <pedrib@gmail.com>
Tested-by: default avatarTino Keitel <tino.keitel@tikei.de>
Acked-by: default avatarEric Anholt <eric@anholt.net>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4386b583
...@@ -176,6 +176,8 @@ MODULE_DEVICE_TABLE(pci, pciidlist); ...@@ -176,6 +176,8 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
static int i915_drm_freeze(struct drm_device *dev) static int i915_drm_freeze(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = dev->dev_private;
pci_save_state(dev->pdev); pci_save_state(dev->pdev);
/* If KMS is active, we do the leavevt stuff here */ /* If KMS is active, we do the leavevt stuff here */
...@@ -191,17 +193,12 @@ static int i915_drm_freeze(struct drm_device *dev) ...@@ -191,17 +193,12 @@ static int i915_drm_freeze(struct drm_device *dev)
i915_save_state(dev); i915_save_state(dev);
return 0;
}
static void i915_drm_suspend(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
intel_opregion_free(dev, 1); intel_opregion_free(dev, 1);
/* Modeset on resume, not lid events */ /* Modeset on resume, not lid events */
dev_priv->modeset_on_lid = 0; dev_priv->modeset_on_lid = 0;
return 0;
} }
static int i915_suspend(struct drm_device *dev, pm_message_t state) static int i915_suspend(struct drm_device *dev, pm_message_t state)
...@@ -221,8 +218,6 @@ static int i915_suspend(struct drm_device *dev, pm_message_t state) ...@@ -221,8 +218,6 @@ static int i915_suspend(struct drm_device *dev, pm_message_t state)
if (error) if (error)
return error; return error;
i915_drm_suspend(dev);
if (state.event == PM_EVENT_SUSPEND) { if (state.event == PM_EVENT_SUSPEND) {
/* Shut down the device */ /* Shut down the device */
pci_disable_device(dev->pdev); pci_disable_device(dev->pdev);
...@@ -237,6 +232,10 @@ static int i915_drm_thaw(struct drm_device *dev) ...@@ -237,6 +232,10 @@ static int i915_drm_thaw(struct drm_device *dev)
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
int error = 0; int error = 0;
i915_restore_state(dev);
intel_opregion_init(dev, 1);
/* KMS EnterVT equivalent */ /* KMS EnterVT equivalent */
if (drm_core_check_feature(dev, DRIVER_MODESET)) { if (drm_core_check_feature(dev, DRIVER_MODESET)) {
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
...@@ -263,10 +262,6 @@ static int i915_resume(struct drm_device *dev) ...@@ -263,10 +262,6 @@ static int i915_resume(struct drm_device *dev)
pci_set_master(dev->pdev); pci_set_master(dev->pdev);
i915_restore_state(dev);
intel_opregion_init(dev, 1);
return i915_drm_thaw(dev); return i915_drm_thaw(dev);
} }
...@@ -423,8 +418,6 @@ static int i915_pm_suspend(struct device *dev) ...@@ -423,8 +418,6 @@ static int i915_pm_suspend(struct device *dev)
if (error) if (error)
return error; return error;
i915_drm_suspend(drm_dev);
pci_disable_device(pdev); pci_disable_device(pdev);
pci_set_power_state(pdev, PCI_D3hot); pci_set_power_state(pdev, PCI_D3hot);
...@@ -464,13 +457,8 @@ static int i915_pm_poweroff(struct device *dev) ...@@ -464,13 +457,8 @@ static int i915_pm_poweroff(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
struct drm_device *drm_dev = pci_get_drvdata(pdev); struct drm_device *drm_dev = pci_get_drvdata(pdev);
int error;
error = i915_drm_freeze(drm_dev);
if (!error)
i915_drm_suspend(drm_dev);
return error; return i915_drm_freeze(drm_dev);
} }
const struct dev_pm_ops i915_pm_ops = { const struct dev_pm_ops i915_pm_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment