Bug 95061

Summary: Laptop will not shutdown after suspend to disk (regression)
Product: Drivers Reporter: Dirk Griesbach (spamthis)
Component: Video(DRI - Intel)Assignee: Imre Deak (imre.deak)
Status: CLOSED CODE_FIX    
Severity: normal CC: aaron.lu, intel-gfx-bugs, lenb, mikko.rapeli, rjw, rui.zhang, spamthis
Priority: P1    
Hardware: Intel   
OS: Linux   
Kernel Version: 3.19 / 4.0-rc4 Subsystem:
Regression: Yes Bisected commit-id:
Attachments: dmesg output
i915_hibernate_quirk.patch

Description Dirk Griesbach 2015-03-18 12:12:14 UTC
Created attachment 171081 [details]
dmesg output

Hi,

Since kernel 3.19 (including 3.19.1) the system (Laptop FSC S7110) will not correctly shut down when suspending to disk (echo disk > /sys/power/state). The power-LED is still on and the fan keeps whirling. However, the hibernation image is created successfully. After pulling the plug and powering the system on, it will boot into the hibernated image without problems. I didn't ran into this problem with a former kernel as far as I can remember but 4.0-rc4 has the same issue. Suspend to RAM, shutdown and reboot all work as expected.

cat /sys/power/disk
[platform] shutdown reboot suspend

Regards,
Dirk
Comment 1 Aaron Lu 2015-03-19 05:22:34 UTC
Since this is a regression, can you please do a git bisect to find out the offending commit? Thanks.
Comment 2 Zhang Rui 2015-03-23 04:23:03 UTC
As this is a regression,
CC Rafael to see if he has any quick ideas about which patch may introduces this problem.

Dirk,
please make sure your kernel is built with CONFIG_PM_DEBUG=y, and then run "echo core > /sys/pm_pm_test; echo disk > /sys/power/state" in a console,
does the system come back after around 10 seconds?
Comment 3 Dirk Griesbach 2015-03-23 12:36:43 UTC
(In reply to Aaron Lu from comment #1)
> Since this is a regression, can you please do a git bisect to find out the
> offending commit? Thanks.

I finally found the time to do it:
da2bc1b9db3351addd293e5b82757efe1f77ed1d is the first bad commit
commit da2bc1b9db3351addd293e5b82757efe1f77ed1d
Author: Imre Deak <imre.deak@intel.com>
Date:   Thu Oct 23 19:23:26 2014 +0300

    drm/i915: add poweroff_late handler
    
    The suspend_late handler saves some registers and powers off the device,
    so it doesn't have a big overhead. Calling it at S4 poweroff_late time
    makes the power off handling identical to the S3 suspend and S4 freeze
    handling, so do this for consistency.
    
    Signed-off-by: Imre Deak <imre.deak@intel.com>
    Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

:040000 040000 367eee899c6c2b2a669e2e46f68529dad0e1f7a3 78c7571e2b18dc0fb77161b8a3e32288bd4cbee8 M      drivers

After I had reverted the commit on v3.19.2 the system powered down correctly.

(In reply to Zhang Rui from comment #2)
> Dirk,
> please make sure your kernel is built with CONFIG_PM_DEBUG=y, and then run
> "echo core > /sys/pm_pm_test; echo disk > /sys/power/state" in a console,
> does the system come back after around 10 seconds?

This did work without obvious problems.

Regards,
Dirk
Comment 4 Dirk Griesbach 2015-03-23 13:37:55 UTC
(In reply to Dirk Griesbach from comment #3)
> commit da2bc1b9db3351addd293e5b82757efe1f77ed1d
> Author: Imre Deak <imre.deak@intel.com>
> Date:   Thu Oct 23 19:23:26 2014 +0300
> 
>     drm/i915: add poweroff_late handler

The system in question contains an Intel GMA950 / 945GM

# lspci
00:00.0 Host bridge: Intel Corporation Mobile 945GM/PM/GMS, 943/940GML and 945GT Express Memory Controller Hub (rev 03)
00:02.0 VGA compatible controller: Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller (rev 03)
00:02.1 Display controller: Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller (rev 03)
Comment 6 Dirk Griesbach 2015-03-24 11:44:19 UTC
(In reply to Jani Nikula from comment #5)
> Please try
> http://mid.gmane.org/1426518839-25709-1-git-send-email-imre.deak@intel.com

After adjusting for vendor id (0x10cf - Fujitsu Limited. is not defined in pci_ids.h) and gen3 the machine did power down properly with this patch.

Is there a current patch/branch this code can be added to? Simply adding exceptions seems to get messy fast as pointed out by https://lkml.org/lkml/2015/3/18/133 in particular if more platforms/vendors need this workaround. Until then, I'm just posting the (Fujitsu only) code snipped:

	 * power down the device properly. Platforms where this was seen:
	 * Lenovo Thinkpad X301, X61s
	 * Lenovo Thinkpad X301, X61s, X41
         * Fujitsu Lifebook S7110
 	 */
        if (!(hibernation &&
              /* Fujitsu Limited. not defined in pci_ids.h */
              drm_dev->pdev->subsystem_vendor == 0x10cf &&
              IS_GEN3(dev_priv)))
                pci_set_power_state(drm_dev->pdev, PCI_D3hot);

Regards,
Dirk
Comment 7 Dirk Griesbach 2015-05-13 07:26:58 UTC
Created attachment 176591 [details]
i915_hibernate_quirk.patch

This patch can be applied on top of 4.0.2 and 4.1-rc3. It fixes the hibernate issue for me and based on information provided by https://bugzilla.kernel.org/show_bug.cgi?id=94241 should also fix the issue for known problematic Acer gen5 and Thinkpads.
Comment 8 Mikko Rapeli 2015-07-15 06:15:47 UTC
*** Bug 99941 has been marked as a duplicate of this bug. ***
Comment 9 Jani Nikula 2015-10-07 11:09:59 UTC
Presumed fixed by

commit 54875571bbfde00fc63741715c531cbb5246c3b2
Author: Imre Deak <imre.deak@intel.com>
Date:   Tue Jun 30 17:06:47 2015 +0300

    drm/i915: apply the PCI_D0/D3 hibernation workaround everywhere on pre GEN6

If the problem persists with that, please file a bug at the freedesktop.org bugzilla [1], referencing this bug. Thank you.

[1] https://bugs.freedesktop.org/enter_bug.cgi?product=DRI&component=DRM/Intel
Comment 10 Dirk Griesbach 2015-12-21 19:25:26 UTC
(In reply to Jani Nikula from comment #9)
> Presumed fixed by
> 
> commit 54875571bbfde00fc63741715c531cbb5246c3b2
> Author: Imre Deak <imre.deak@intel.com>
> Date:   Tue Jun 30 17:06:47 2015 +0300
> 
>     drm/i915: apply the PCI_D0/D3 hibernation workaround everywhere on pre
> GEN6

This fixes the bug and hit mainline, hence closing it.

Dirk