Sleep mode doesn't work

Bug #1810619 reported by Grentz
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

On my Dell XPS 13 laptop (9370), the sleep mode dosn't work anymore with linux-image-4.18.0-13.
The screen goes off correctly but any touch resume the laptop.

This is the log :
Jan 5 11:15:25 skeleton systemd[1]: Reached target Sleep.
Jan 5 11:15:25 skeleton systemd[1]: Starting Suspend...
Jan 5 11:15:25 skeleton systemd[1]: Starting Network Manager Script Dispatcher Service...
Jan 5 11:15:25 skeleton systemd-sleep[6229]: Suspending system...
Jan 5 11:15:25 skeleton kernel: [ 6176.006021] PM: suspend entry (s2idle)
an 5 11:15:25 skeleton dbus-daemon[1051]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Jan 5 11:15:25 skeleton systemd[1]: Started Network Manager Script Dispatcher Service.
Jan 5 11:15:25 skeleton nm-dispatcher: req:1 'down' [wlp2s0]: new request (1 scripts)
Jan 5 11:15:25 skeleton nm-dispatcher: req:1 'down' [wlp2s0]: start running ordered scripts...

[...]
Resume :

Jan 5 12:00:02 skeleton kernel: [ 6176.006023] PM: Syncing filesystems ... done.
Jan 5 12:00:02 skeleton kernel: [ 6176.016581] Freezing user space processes ... (elapsed 0.088 seconds) done.
Jan 5 12:00:02 skeleton kernel: [ 6176.104653] OOM killer disabled.
Jan 5 12:00:02 skeleton kernel: [ 6176.104654] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
Jan 5 12:00:02 skeleton kernel: [ 6176.106070] Suspending console(s) (use no_console_suspend to debug)
Jan 5 12:00:02 skeleton kernel: [ 8852.990035] OOM killer enabled.
Jan 5 12:00:02 skeleton kernel: [ 8852.990037] Restarting tasks ... done.
Jan 5 12:00:02 skeleton kernel: [ 8853.015639] r8152 2-1.2:1.0 enxe4b97acfa7e9: carrier on
Jan 5 12:00:02 skeleton kernel: [ 8853.084055] PM: suspend exit

With linux-image-4.18.0-10, it works correcly (but no with 4.18.0-11 and 4.18.0-12).
Thanks,

Tags: cosmic cscc
Revision history for this message
Grentz (mic.grentz) wrote :
Revision history for this message
Grentz (mic.grentz) wrote :
Revision history for this message
Grentz (mic.grentz) wrote :
affects: linux-meta (Ubuntu) → linux (Ubuntu)
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote : Status changed to Confirmed

This change was made by a bot.

Changed in linux (Ubuntu):
status: New → Confirmed
tags: added: cosmic
Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

This is because this change gets included:
commit 684bec1092b6991ff2a7751e8a763898576eb5c2
Author: Daniel Drake <email address hidden>
Date: Mon Oct 1 15:55:22 2018 -0700

    Input: i8042 - enable keyboard wakeups by default when s2idle is used

    Previously, on typical consumer laptops, pressing a key on the keyboard
    when the system is in suspend would cause it to wake up (default or
    unconditional behaviour). This happens because the EC generates a SCI
    interrupt in this scenario.

    That is no longer true on modern laptops based on Intel WhiskeyLake,
    including Acer Swift SF314-55G, Asus UX333FA, Asus UX433FN and Asus
    UX533FD. We confirmed with Asus EC engineers that the "Modern Standby"
    design has been modified so that the EC no longer generates a SCI
    in this case; the keyboard controller itself should be used for wakeup.

    In order to retain the standard behaviour of being able to use the
    keyboard to wake up the system, enable serio wakeups by default on
    platforms that are using s2idle.

This change makes the keyboard wakeup behavior in aligned with other major OS (i.e. Windows and macOS).

This can be changed to the "old" behavior by the following:
# echo disabled > /sys/bus/serio/devices/serio0/power/wakeup

Revision history for this message
Grentz (mic.grentz) wrote :

When I do some test, the screen goes off but the laptop doesn't seems to enter in sleep mode. The battery continue to discharge after enter in sleep mode : 39% when I stopped to work and 0% a few hours after (9 hours). Fans are stopped.

With :
sudo sh -c 'echo disabled > /sys/bus/serio/devices/serio0/power/wakeup'
Entering in sleep mode make a shutdown directly. I've no hibernation option on my kubuntu 18.10.

Thanks for explications

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

Your system needs this patch:
https://lists.ubuntu.com/archives/kernel-team/2018-November/096832.html

Should be available in next kernel release.

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

This test kernel includes the patch from #7:
https://people.canonical.com/~khfeng/lp1810619/

Revision history for this message
Grentz (mic.grentz) wrote :

When I do some test, the screen goes off but the laptop doesn't seems to enter in sleep mode. The battery continue to discharge after enter in sleep mode : 39% when I stopped to work and 0% a few hours after (9 hours). Fans are stopped.

With :
sudo sh -c 'echo disabled > /sys/bus/serio/devices/serio0/power/wakeup'
Entering in sleep mode make a shutdown directly. I've no hibernation option on my kubuntu 18.10.

Thanks for explications

Revision history for this message
Grentz (mic.grentz) wrote :

I've tested with https://people.canonical.com/~khfeng/lp1810619/

Bug still present :
- no really suspend mode (the battery continue to discharge like the laptop is in activity)
- resume by touch the keyboard
- sudo sh -c 'echo disabled > /sys/bus/serio/devices/serio0/power/wakeup' disabled the keyboard touch (not deep tested)

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

> - no really suspend mode (the battery continue to discharge like the laptop is in activity)
How much does it use during suspend?

> - resume by touch the keyboard
This is intended. Both macOS and Windows do this.

Revision history for this message
Grentz (mic.grentz) wrote :

> > - no really suspend mode (the battery continue to discharge like the laptop is in activity)
>How much does it use during suspend?

About 4 - 6 hours.

> > - resume by touch the keyboard
> This is intended. Both macOS and Windows do this.
With 4.18-10, I don't have this behavior. Is it right ?

I've read https://www.kernel.org/doc/Documentation/admin-guide/pm/sleep-states.rst
$ sudo sh -c 'echo mem > /sys/power/state'
$ sudo sh -c 'echo deep > /sys/power/mem_sleep'

With this two lines, my Dell XPS 13 9370 go in a sleep mode : no really battery discharge during 5 - 6 hours, resume only with power button or by opening the screen. The resume take just a more time than before.

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

> About 4 - 6 hours.
Do you mean a fully charged battery only lasts 4 ~ 6 hours?

> With 4.18-10, I don't have this behavior. Is it right ?
Yes, this is right. The default on keyboard wakeup changes.

Revision history for this message
Grentz (mic.grentz) wrote :

> Do you mean a fully charged battery only lasts 4 ~ 6 hours?

I will do some other tests next days but if a suspend my laptop at 1:00 with a battery loaded about 40%, when I try to resume at 7:00, the laptop refuse to resume (battery empty). I have to plug in the charger in order to resume (normal boot because a halt was certainly requested by the system on battery low).

With :
$ sudo sh -c 'echo mem > /sys/power/state'
$ sudo sh -c 'echo deep > /sys/power/mem_sleep'
the problem disappears.

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

Does that also happen to the test kernel I built?

Revision history for this message
Grentz (mic.grentz) wrote :

Yes, I've tested a few days ago and I believe the same behavior appears : no really sleep mode, battery in discharge. Just the screen black.

But I've non tested with
$ sudo sh -c 'echo mem > /sys/power/state'
$ sudo sh -c 'echo deep > /sys/power/mem_sleep'

I don't know the default value of this two files and it seems the kernel memories them.

Sorry for my English

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

This is weird. The patch in [1] should help a lot, it'll let s2idle decrease its power usage significantly, not as good as deep though.

Still surprising that the battery discharge that quick. May need some help from Dell though...

[1] https://lists.ubuntu.com/archives/kernel-team/2018-November/096832.html

Revision history for this message
Mario Limonciello (superm1) wrote :

>With :
>$ sudo sh -c 'echo mem > /sys/power/state'
>$ sudo sh -c 'echo deep > /sys/power/mem_sleep'
>the problem disappears.

This is changing how the system goes to sleep in a significant way. With this, the BIOS turns off all devices except RAM when going to sleep. With the way that it works by default the kernel is controlling all devices and putting them into their deepest sleep state.

This system "mem" will work on this system, but that can't be said for all systems.
You can change the default policy to this if you would like too using a modification to your kernel command line. It is better in my opinion to figure out the root cause of your problem though. It will lead to better runtime power consumption if we figure it out.

A few questions:
@Grentz:
1) Do you have anything plugged into notebook during sleep cycle with s2idle? Mouse, keyboard, USB key - anything like that.
2) Can you try to run powertop with --auto-tune and see if it improves things?
3) After running autotune wait a few moments and then can you please cat /sys/kernel/debug/pmc_core/pch_ip_power_gating_status and share results?

@Kai Heng:
4) Policy wise isn't TLP or something similar going to be needed to enact RTD3 for the rest of the devices that kernel policy isn't properly configured? I know the preload image has stuff like that.

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

Mario,

> 4) Policy wise isn't TLP or something similar going to be needed to enact RTD3 for the rest of the devices that kernel policy isn't properly

S2idle still calls all devices' suspend() callback, hence all PCIe devices will be put to D3.

It's a known issue that NVMe needs to stays at D0 and uses L1.2 and APST to save power - but somehow the test kernel I built doesn't work.

Revision history for this message
Grentz (mic.grentz) wrote :
Download full text (3.3 KiB)

@superm1

1) When I'm on battery, there is just an USB-C adapter with just a nano receiver for my cordless mouse. On AC, there is a USB-C all-in-one which is plugged in (output DVI, another nano USB receiver, ethernet)

2)
$ sudo powertop with --auto-tune
modprobe cpufreq_stats failed19 mesures préalables chargées
Impossible de charger à partir du fichier /var/cache/powertop/saved_parameters.powertop
File will be loaded after taking minimum number of measurement(s) with battery only
RAPL device for cpu 0
RAPL Using PowerCap Sysfs : Domain Mask f
RAPL device for cpu 0
RAPL Using PowerCap Sysfs : Domain Mask f
Devfreq not enabled
glob returned GLOB_ABORTED
Impossible de charger à partir du fichier /var/cache/powertop/saved_parameters.powertop
File will be loaded after taking minimum number of measurement(s) with battery only
To show power estimates do 344 measurement(s) connected to battery only
Sortie de PowerTOP

3) On battery
michel@skeleton:~$ sudo cat /sys/kernel/debug/pmc_core/pch_ip_power_gating_status
PCH IP: 0 - PMC State: On
PCH IP: 1 - OPI-DMI State: On
PCH IP: 2 - SPI / eSPI State: On
PCH IP: 3 - XHCI State: On
PCH IP: 4 - SPA State: Off
PCH IP: 5 - SPB State: On
PCH IP: 6 - SPC State: Off
PCH IP: 7 - GBE State: Off
PCH IP: 8 - SATA State: Off
PCH IP: 9 - HDA-PGD0 State: Off
PCH IP: 10 - HDA-PGD1 State: Off
PCH IP: 11 - HDA-PGD2 State: Off
PCH IP: 12 - HDA-PGD3 State: Off
PCH IP: 13 - RSVD State: Off
PCH IP: 14 - LPSS State: Off
PCH IP: 15 - LPC State: Off
PCH IP: 16 - SMB State: Off
PCH IP: 17 - ISH State: Off
PCH IP: 18 - P2SB State: Off
PCH IP: 19 - DFX State: Off
PCH IP: 20 - SCC State: Off
PCH IP: 21 - RSVD State: Off
PCH IP: 22 - FUSE State: On
PCH IP: 23 - CAMERA State: Off
PCH IP: 24 - RSVD State: Off
PCH IP: 25 - USB3-OTG State: Off
PCH IP: 26 - EXI State: Off
PCH IP: 27 - CSE State: Off
PCH IP: 28 - CSME_KVM State: Off
PCH IP: 29 - CSME_PMT State: Off
PCH IP: 30 - CSME_CLINK State: Off
PCH IP: 31 - CSME_PTIO State: Off
PCH IP: 32 - CSME_USBR State: Off
PCH IP: 33 - CSME_SUSRAM State: Off
PCH IP: 34 - CSME_SMT State: Off
PCH IP: 35 - RSVD State: Off
PCH IP: 36 - CSME_SMS2 State...

Read more...

Revision history for this message
Mario Limonciello (superm1) wrote :

Can you please test without your adapter plugged in prior to the sleep cycle? Due to the way suspend to idle works this may cause the PCH to remain in a higher power state burning a lot more battery.

Revision history for this message
Grentz (mic.grentz) wrote :

Same behavior. Without AC and without adapter :
michel@skeleton:~$ sudo powertop --auto-tune
modprobe cpufreq_stats failed23 mesures préalables chargées
Impossible de charger à partir du fichier /var/cache/powertop/saved_parameters.powertop
File will be loaded after taking minimum number of measurement(s) with battery only
RAPL device for cpu 0
RAPL Using PowerCap Sysfs : Domain Mask f
RAPL device for cpu 0
RAPL Using PowerCap Sysfs : Domain Mask f
Devfreq not enabled
glob returned GLOB_ABORTED
Impossible de charger à partir du fichier /var/cache/powertop/saved_parameters.powertop
File will be loaded after taking minimum number of measurement(s) with battery only
To show power estimates do 340 measurement(s) connected to battery only

Sometimes, the sleep function works... And sometimes not... Yesterday, I leave my computer at 0h00 (54%) and at 8h00, the battery was 0%...

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

What's the power consumption estimated by powertop?

Revision history for this message
Grentz (mic.grentz) wrote :

Powertop return consumption about 5,5W/h.

KDE doesn't said me the same autonomy... 2h actually in taskbar KDE but posertop said me 8h34 (with less than 4,5W/h) but sometimes posertop return 1h20.

Revision history for this message
Grentz (mic.grentz) wrote :

Today, with freshly installed 4.18.0-16-generic, it seems to be a better behavior.
With s2idle :
100% battery at 0h00
95% at 7:40

$ sudo cat /sys/power/mem_sleep
[s2idle] deep

Moving mouse (connected via bluetooth) resumes the laptop.

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

That's quite likely because the NVMe patches in #7 gets included.

Revision history for this message
Grentz (mic.grentz) wrote :

Nice job !
How can I known when this patch was applied ? Witch kernel version ? Witch ubuntu kernel version ?

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

Since Ubuntu-4.18.0-14.15.

Changed in linux (Ubuntu):
status: Confirmed → Fix Released
Brad Figg (brad-figg)
tags: added: cscc
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.