Skip to content

Commit cbda12d

Browse files
zhenywanholt
authored andcommitted
drm/i915: implement new pm ops for i915
One problem in i915 hibernate with current legacy pci pm ops is that after we do freeze, we'll be forced to do resume once again, which re-init some resources and do modesetting again, that is unnecessary for hibernate. This patch trys to bypass that. We can't resolve this within legacy pm framework, but can do it easily with new pm ops. Suspend (S3) process has also been kept without change. Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com> Signed-off-by: Eric Anholt <eric@anholt.net>
1 parent 11ba159 commit cbda12d

1 file changed

Lines changed: 47 additions & 6 deletions

File tree

‎drivers/gpu/drm/i915/i915_drv.c‎

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,52 @@ i915_pci_resume(struct pci_dev *pdev)
284284
return i915_resume(dev);
285285
}
286286

287+
static int
288+
i915_pm_suspend(struct device *dev)
289+
{
290+
return i915_pci_suspend(to_pci_dev(dev), PMSG_SUSPEND);
291+
}
292+
293+
static int
294+
i915_pm_resume(struct device *dev)
295+
{
296+
return i915_pci_resume(to_pci_dev(dev));
297+
}
298+
299+
static int
300+
i915_pm_freeze(struct device *dev)
301+
{
302+
return i915_pci_suspend(to_pci_dev(dev), PMSG_FREEZE);
303+
}
304+
305+
static int
306+
i915_pm_thaw(struct device *dev)
307+
{
308+
/* thaw during hibernate, do nothing! */
309+
return 0;
310+
}
311+
312+
static int
313+
i915_pm_poweroff(struct device *dev)
314+
{
315+
return i915_pci_suspend(to_pci_dev(dev), PMSG_HIBERNATE);
316+
}
317+
318+
static int
319+
i915_pm_restore(struct device *dev)
320+
{
321+
return i915_pci_resume(to_pci_dev(dev));
322+
}
323+
324+
const struct dev_pm_ops i915_pm_ops = {
325+
.suspend = i915_pm_suspend,
326+
.resume = i915_pm_resume,
327+
.freeze = i915_pm_freeze,
328+
.thaw = i915_pm_thaw,
329+
.poweroff = i915_pm_poweroff,
330+
.restore = i915_pm_restore,
331+
};
332+
287333
static struct vm_operations_struct i915_gem_vm_ops = {
288334
.fault = i915_gem_fault,
289335
.open = drm_gem_vm_open,
@@ -303,8 +349,6 @@ static struct drm_driver driver = {
303349
.lastclose = i915_driver_lastclose,
304350
.preclose = i915_driver_preclose,
305351
.postclose = i915_driver_postclose,
306-
.suspend = i915_suspend,
307-
.resume = i915_resume,
308352
.device_is_agp = i915_driver_device_is_agp,
309353
.enable_vblank = i915_enable_vblank,
310354
.disable_vblank = i915_disable_vblank,
@@ -344,10 +388,7 @@ static struct drm_driver driver = {
344388
.id_table = pciidlist,
345389
.probe = i915_pci_probe,
346390
.remove = i915_pci_remove,
347-
#ifdef CONFIG_PM
348-
.resume = i915_pci_resume,
349-
.suspend = i915_pci_suspend,
350-
#endif
391+
.driver.pm = &i915_pm_ops,
351392
},
352393

353394
.name = DRIVER_NAME,

0 commit comments

Comments
 (0)