Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 358197
b: refs/heads/master
c: b8efb17
h: refs/heads/master
i:
  358195: 1e82c1e
v: v3
  • Loading branch information
Zhang Rui authored and Daniel Vetter committed Feb 13, 2013
1 parent be709eb commit f7ae139
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7083e05072b88d503d257b6f012ce56367f3ac97
refs/heads/master: b8efb17b3d687695b81485f606fc4e6c35a50f9a
1 change: 1 addition & 0 deletions trunk/drivers/gpu/drm/i915/i915_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
mutex_init(&dev_priv->dpio_lock);

mutex_init(&dev_priv->rps.hw_lock);
mutex_init(&dev_priv->modeset_restore_lock);

if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev))
dev_priv->num_pipe = 3;
Expand Down
13 changes: 8 additions & 5 deletions trunk/drivers/gpu/drm/i915/i915_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ static int i915_drm_freeze(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;

/* ignore lid events during suspend */
mutex_lock(&dev_priv->modeset_restore_lock);
dev_priv->modeset_restore = MODESET_SUSPENDED;
mutex_unlock(&dev_priv->modeset_restore_lock);

intel_set_power_well(dev, true);

drm_kms_helper_poll_disable(dev);
Expand All @@ -496,9 +501,6 @@ static int i915_drm_freeze(struct drm_device *dev)

intel_opregion_fini(dev);

/* Modeset on resume, not lid events */
dev_priv->modeset_on_lid = 0;

console_lock();
intel_fbdev_set_suspend(dev, 1);
console_unlock();
Expand Down Expand Up @@ -574,8 +576,6 @@ static int __i915_drm_thaw(struct drm_device *dev)

intel_opregion_init(dev);

dev_priv->modeset_on_lid = 0;

/*
* The console lock can be pretty contented on resume due
* to all the printk activity. Try to keep it out of the hot
Expand All @@ -588,6 +588,9 @@ static int __i915_drm_thaw(struct drm_device *dev)
schedule_work(&dev_priv->console_resume_work);
}

mutex_lock(&dev_priv->modeset_restore_lock);
dev_priv->modeset_restore = MODESET_DONE;
mutex_unlock(&dev_priv->modeset_restore_lock);
return error;
}

Expand Down
10 changes: 8 additions & 2 deletions trunk/drivers/gpu/drm/i915/i915_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,12 @@ struct i915_gpu_error {
unsigned int stop_rings;
};

enum modeset_restore {
MODESET_ON_LID_OPEN,
MODESET_DONE,
MODESET_SUSPENDED,
};

typedef struct drm_i915_private {
struct drm_device *dev;
struct kmem_cache *slab;
Expand Down Expand Up @@ -967,8 +973,8 @@ typedef struct drm_i915_private {

unsigned long quirks;

/* Register state */
bool modeset_on_lid;
enum modeset_restore modeset_restore;
struct mutex modeset_restore_lock;

struct i915_gtt gtt;

Expand Down
33 changes: 20 additions & 13 deletions trunk/drivers/gpu/drm/i915/intel_lvds.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,13 +547,14 @@ static const struct dmi_system_id intel_no_modeset_on_lid[] = {
};

/*
* Lid events. Note the use of 'modeset_on_lid':
* - we set it on lid close, and reset it on open
* Lid events. Note the use of 'modeset':
* - we set it to MODESET_ON_LID_OPEN on lid close,
* and set it to MODESET_DONE on open
* - we use it as a "only once" bit (ie we ignore
* duplicate events where it was already properly
* set/reset)
* - the suspend/resume paths will also set it to
* zero, since they restore the mode ("lid open").
* duplicate events where it was already properly set)
* - the suspend/resume paths will set it to
* MODESET_SUSPENDED and ignore the lid open event,
* because they restore the mode ("lid open").
*/
static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
void *unused)
Expand All @@ -567,6 +568,9 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
if (dev->switch_power_state != DRM_SWITCH_POWER_ON)
return NOTIFY_OK;

mutex_lock(&dev_priv->modeset_restore_lock);
if (dev_priv->modeset_restore == MODESET_SUSPENDED)
goto exit;
/*
* check and update the status of LVDS connector after receiving
* the LID nofication event.
Expand All @@ -575,21 +579,24 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,

/* Don't force modeset on machines where it causes a GPU lockup */
if (dmi_check_system(intel_no_modeset_on_lid))
return NOTIFY_OK;
goto exit;
if (!acpi_lid_open()) {
dev_priv->modeset_on_lid = 1;
return NOTIFY_OK;
/* do modeset on next lid open event */
dev_priv->modeset_restore = MODESET_ON_LID_OPEN;
goto exit;
}

if (!dev_priv->modeset_on_lid)
return NOTIFY_OK;

dev_priv->modeset_on_lid = 0;
if (dev_priv->modeset_restore == MODESET_DONE)
goto exit;

drm_modeset_lock_all(dev);
intel_modeset_setup_hw_state(dev, true);
drm_modeset_unlock_all(dev);

dev_priv->modeset_restore = MODESET_DONE;

exit:
mutex_unlock(&dev_priv->modeset_restore_lock);
return NOTIFY_OK;
}

Expand Down

0 comments on commit f7ae139

Please sign in to comment.