diff mbox

drm/i915: fix suspend/resume breakage in lid notifier

Message ID 20090914105848.39a2b3cb@jbarnes-g45 (mailing list archive)
State Accepted
Headers show

Commit Message

Jesse Barnes Sept. 14, 2009, 5:58 p.m. UTC
We now unconditionally restore the mode at lid open time since some
platforms turn off the panel, pipes or other display elements when the
lid is closed.  There's a problem with doing this at resume time
however.

At resume time, we'll get a lid event, but restoring the mode at that
time may not be safe (e.g. if we get the lid event before global state
has been restored), so check the suspended state and make sure our
restore is locked against other mode updates.

Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

Comments

Ben Gamari Sept. 14, 2009, 8:01 p.m. UTC | #1
On Mon, Sep 14, 2009 at 10:58:48AM -0700, Jesse Barnes wrote:
> We now unconditionally restore the mode at lid open time since some
> platforms turn off the panel, pipes or other display elements when the
> lid is closed.  There's a problem with doing this at resume time
> however.
> 
> At resume time, we'll get a lid event, but restoring the mode at that
> time may not be safe (e.g. if we get the lid event before global state
> has been restored), so check the suspended state and make sure our
> restore is locked against other mode updates.
> 
> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Tested-by: Ben Gamari <bgamari.foss@gmail.com>

Thanks,
- Ben
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index dbe568c..86bd414 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -89,6 +89,8 @@  static int i915_suspend(struct drm_device *dev, pm_message_t state)
 		pci_set_power_state(dev->pdev, PCI_D3hot);
 	}
 
+	dev_priv->suspended = 1;
+
 	return 0;
 }
 
@@ -124,6 +126,8 @@  static int i915_resume(struct drm_device *dev)
 		drm_helper_resume_force_mode(dev);
 	}
 
+	dev_priv->suspended = 0;
+
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 0344afd..f1e5889 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -247,6 +247,7 @@  typedef struct drm_i915_private {
 	struct workqueue_struct *wq;
 
 	/* Register state */
+	bool suspended;
 	u8 saveLBB;
 	u32 saveDSPACNTR;
 	u32 saveDSPBCNTR;
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index c4799bd..5a10bb6 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -646,8 +646,11 @@  static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
 		container_of(nb, struct drm_i915_private, lid_notifier);
 	struct drm_device *dev = dev_priv->dev;
 
-	if (acpi_lid_open())
+	if (acpi_lid_open() && !dev_priv->suspended) {
+		mutex_lock(&dev->mode_config.mutex);
 		drm_helper_resume_force_mode(dev);
+		mutex_unlock(&dev->mode_config.mutex);
+	}
 
 	drm_sysfs_hotplug_event(dev_priv->dev);