[PATCH] i915 / PM: Fix crash while aborting hibernation (Re: [linux-pm] [regression] "drm/i915: implement new pm ops" disables irq on aborted s2disk)
On Thursday 04 February 2010, Zhenyu Wang wrote: > On 2010.02.03 23:44:41 +0100, Rafael J. Wysocki wrote: > > On Wednesday 03 February 2010, Alan Jenkins wrote: > > > Hi > > > > > > I found this regression on my EeePC 701 with modesetting enabled. When > > > I hibernate using s2disk, I can abort the hibernation by pressing the > > > backspace key. Doing so breaks X on 2.6.32-rc6 (but not 2.6.32). > > > > Yeah. > > > > To be honest, I knew that's going to happen, but didn't have the time to > > take > > care of it. > > > > The problem is that i915 does literally _nothing_ in its .thaw() callback, > > although it should at least reverse whatever .freeze() did to the hardware > > (and memory allocations and so on), so that the adapter is functional > > after creating the image. > > > > Fixing this requires some thought, though, because at the moment .freeze() > > thinks it's .suspend(), which is not the case as this report clearly shows. > > So, in fact i915_pci_suspend() has to be split into the .freeze() part and > > the poweroff part cleanly and that's not so simple (at least to me). > > > > Right, I think that'll be more clean, stuff in i915_save/restore_state() need > to be splited too, especially isolate stuff for mode setting and other device > state, as what my original purpose for this is to remove extra mode setting > cycle in old behavior so not waste time for hibernate. We can't really do that, because we'll need to restore the saved state at the resume-from-hibernation stage. The appended patch fixes the issue for me, although it's been only tested a little. It sort of defeats the purpose of commit cbda12d77ea590082edb6d30bd342a67ebc459e0, but I don't see any less invasive way to fix this except maybe for reverting that commit entirely. Note that the drm_irq_[un]install() thing may be unnecessary, but I wasn't sure about that and surely wouldn't suggest doing that for 2.6.33. Also it looks like some things from the freeze and thaw parts may be moved to the "low-level" suspend and resume parts, respectively, but that would require some i915_gem_* surgery I was too scared to do. Alan, please test, i915 guys, please review. Rafael --- Subject: i915 / PM: Fix crash while aborting hibernation From: Rafael J. Wysocki Commit cbda12d77ea590082edb6d30bd342a67ebc459e0 (drm/i915: implement new pm ops for i915) introduced the problem that if s2disk hibernation is aborted, the system will crash, because i915_pm_freeze() does nothing, while it should at least reverse some operations carried out by i915_suspend(). Fix this issue by splitting the i915 suspend into a freeze part a suspend part, where the latter is not executed before creating a hibernation image, and the i915 resume into a "low-level" resume part and a thaw part, where the former is not executed after the image has been created. Signed-off-by: Rafael J. Wysocki --- drivers/gpu/drm/i915/i915_drv.c | 168 1 file changed, 101 insertions(+), 67 deletions(-) Index: linux-2.6/drivers/gpu/drm/i915/i915_drv.c === --- linux-2.6.orig/drivers/gpu/drm/i915/i915_drv.c +++ linux-2.6/drivers/gpu/drm/i915/i915_drv.c @@ -175,78 +175,100 @@ const static struct pci_device_id pciidl MODULE_DEVICE_TABLE(pci, pciidlist); #endif -static int i915_suspend(struct drm_device *dev, pm_message_t state) +static int i915_drm_freeze(struct drm_device *dev) { - struct drm_i915_private *dev_priv = dev->dev_private; - - if (!dev || !dev_priv) { - DRM_ERROR("dev: %p, dev_priv: %p\n", dev, dev_priv); - DRM_ERROR("DRM not initialized, aborting suspend.\n"); - return -ENODEV; - } - - if (state.event == PM_EVENT_PRETHAW) - return 0; - pci_save_state(dev->pdev); /* If KMS is active, we do the leavevt stuff here */ if (drm_core_check_feature(dev, DRIVER_MODESET)) { - if (i915_gem_idle(dev)) + int error = i915_gem_idle(dev); + if (error) { dev_err(&dev->pdev->dev, - "GEM idle failed, resume may fail\n"); + "GEM idle failed, resume might fail\n"); + return error; + } drm_irq_uninstall(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); + /* Modeset on resume, not lid events */ + dev_priv->modeset_on_lid = 0; +} + +static int i915_suspend(struct drm_device *dev, pm_message_t state) +{ + int error; + + if (!dev || !dev->dev_private) { + DRM_ERROR("dev: %p\n", dev); + DRM_ERROR("DRM not initialized, aborting suspend.\n"); + return -E
Re: [PATCH] i915 / PM: Fix crash while aborting hibernation (Re: [linux-pm] [regression] "drm/i915: implement new pm ops" disables irq on aborted s2disk)
On Monday 08 February 2010, Alan Jenkins wrote: > Rafael J. Wysocki wrote: > > On Thursday 04 February 2010, Zhenyu Wang wrote: > > > >> On 2010.02.03 23:44:41 +0100, Rafael J. Wysocki wrote: > >> > >>> On Wednesday 03 February 2010, Alan Jenkins wrote: > >>> > Hi > > I found this regression on my EeePC 701 with modesetting enabled. When > I hibernate using s2disk, I can abort the hibernation by pressing the > backspace key. Doing so breaks X on 2.6.32-rc6 (but not 2.6.32). > > >>> Yeah. > >>> > >>> To be honest, I knew that's going to happen, but didn't have the time to > >>> take > >>> care of it. > >>> > >>> The problem is that i915 does literally _nothing_ in its .thaw() callback, > >>> although it should at least reverse whatever .freeze() did to the hardware > >>> (and memory allocations and so on), so that the adapter is functional > >>> after creating the image. > >>> > >>> Fixing this requires some thought, though, because at the moment .freeze() > >>> thinks it's .suspend(), which is not the case as this report clearly > >>> shows. > >>> So, in fact i915_pci_suspend() has to be split into the .freeze() part and > >>> the poweroff part cleanly and that's not so simple (at least to me). > >>> > >>> > >> Right, I think that'll be more clean, stuff in i915_save/restore_state() > >> need > >> to be splited too, especially isolate stuff for mode setting and other > >> device > >> state, as what my original purpose for this is to remove extra mode > >> setting > >> cycle in old behavior so not waste time for hibernate. > >> > > > > We can't really do that, because we'll need to restore the saved state at > > the > > resume-from-hibernation stage. > > > > The appended patch fixes the issue for me, although it's been only tested > > a little. It sort of defeats the purpose of commit > > cbda12d77ea590082edb6d30bd342a67ebc459e0, but I don't see any less invasive > > way to fix this except maybe for reverting that commit entirely. > > > > Note that the drm_irq_[un]install() thing may be unnecessary, but I wasn't > > sure > > about that and surely wouldn't suggest doing that for 2.6.33. Also it > > looks like > > some things from the freeze and thaw parts may be moved to the "low-level" > > suspend and resume parts, respectively, but that would require some > > i915_gem_* surgery I was too scared to do. > > > > Alan, please test, i915 guys, please review. > > > > Rafael > > > > The patch works very nicely on my eeepc. Great, thanks for testing. > Thanks > (and thanks again for all your hard work this cycle, and specifically > for pointing me to the s2disk hang-fix) You're welcome. :-) Rafael -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com -- ___ Dri-devel mailing list Dri-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dri-devel
Re: [PATCH] i915 / PM: Fix crash while aborting hibernation (Re: [linux-pm] [regression] "drm/i915: implement new pm ops" disables irq on aborted s2disk)
Rafael J. Wysocki wrote: > On Thursday 04 February 2010, Zhenyu Wang wrote: > >> On 2010.02.03 23:44:41 +0100, Rafael J. Wysocki wrote: >> >>> On Wednesday 03 February 2010, Alan Jenkins wrote: >>> Hi I found this regression on my EeePC 701 with modesetting enabled. When I hibernate using s2disk, I can abort the hibernation by pressing the backspace key. Doing so breaks X on 2.6.32-rc6 (but not 2.6.32). >>> Yeah. >>> >>> To be honest, I knew that's going to happen, but didn't have the time to >>> take >>> care of it. >>> >>> The problem is that i915 does literally _nothing_ in its .thaw() callback, >>> although it should at least reverse whatever .freeze() did to the hardware >>> (and memory allocations and so on), so that the adapter is functional >>> after creating the image. >>> >>> Fixing this requires some thought, though, because at the moment .freeze() >>> thinks it's .suspend(), which is not the case as this report clearly shows. >>> So, in fact i915_pci_suspend() has to be split into the .freeze() part and >>> the poweroff part cleanly and that's not so simple (at least to me). >>> >>> >> Right, I think that'll be more clean, stuff in i915_save/restore_state() need >> to be splited too, especially isolate stuff for mode setting and other device >> state, as what my original purpose for this is to remove extra mode setting >> cycle in old behavior so not waste time for hibernate. >> > > We can't really do that, because we'll need to restore the saved state at the > resume-from-hibernation stage. > > The appended patch fixes the issue for me, although it's been only tested > a little. It sort of defeats the purpose of commit > cbda12d77ea590082edb6d30bd342a67ebc459e0, but I don't see any less invasive > way to fix this except maybe for reverting that commit entirely. > > Note that the drm_irq_[un]install() thing may be unnecessary, but I wasn't > sure > about that and surely wouldn't suggest doing that for 2.6.33. Also it looks > like > some things from the freeze and thaw parts may be moved to the "low-level" > suspend and resume parts, respectively, but that would require some > i915_gem_* surgery I was too scared to do. > > Alan, please test, i915 guys, please review. > > Rafael > The patch works very nicely on my eeepc. Thanks (and thanks again for all your hard work this cycle, and specifically for pointing me to the s2disk hang-fix) Alan -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com -- ___ Dri-devel mailing list Dri-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dri-devel
Re: [PATCH] i915 / PM: Fix crash while aborting hibernation (Re: [linux-pm] [regression] "drm/i915: implement new pm ops" disables irq on aborted s2disk)
On Sun, 7 Feb 2010 21:48:24 +0100, "Rafael J. Wysocki" wrote: > On Thursday 04 February 2010, Zhenyu Wang wrote: > > On 2010.02.03 23:44:41 +0100, Rafael J. Wysocki wrote: > > > On Wednesday 03 February 2010, Alan Jenkins wrote: > > > > Hi > > > > > > > > I found this regression on my EeePC 701 with modesetting enabled. When > > > > I hibernate using s2disk, I can abort the hibernation by pressing the > > > > backspace key. Doing so breaks X on 2.6.32-rc6 (but not 2.6.32). > > > > > > Yeah. > > > > > > To be honest, I knew that's going to happen, but didn't have the time to > > > take > > > care of it. > > > > > > The problem is that i915 does literally _nothing_ in its .thaw() callback, > > > although it should at least reverse whatever .freeze() did to the hardware > > > (and memory allocations and so on), so that the adapter is functional > > > after creating the image. > > > > > > Fixing this requires some thought, though, because at the moment .freeze() > > > thinks it's .suspend(), which is not the case as this report clearly > > > shows. > > > So, in fact i915_pci_suspend() has to be split into the .freeze() part and > > > the poweroff part cleanly and that's not so simple (at least to me). > > > > > > > Right, I think that'll be more clean, stuff in i915_save/restore_state() > > need > > to be splited too, especially isolate stuff for mode setting and other > > device > > state, as what my original purpose for this is to remove extra mode setting > > cycle in old behavior so not waste time for hibernate. > > We can't really do that, because we'll need to restore the saved state at the > resume-from-hibernation stage. > > The appended patch fixes the issue for me, although it's been only tested > a little. It sort of defeats the purpose of commit > cbda12d77ea590082edb6d30bd342a67ebc459e0, but I don't see any less invasive > way to fix this except maybe for reverting that commit entirely. > > Note that the drm_irq_[un]install() thing may be unnecessary, but I wasn't > sure > about that and surely wouldn't suggest doing that for 2.6.33. Also it looks > like > some things from the freeze and thaw parts may be moved to the "low-level" > suspend and resume parts, respectively, but that would require some > i915_gem_* surgery I was too scared to do. > > Alan, please test, i915 guys, please review. > > Rafael Applied to for-linus. Thanks! pgpya6h1omM6W.pgp Description: PGP signature -- SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev-- ___ Dri-devel mailing list Dri-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dri-devel