Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surface Book with Performance Base: NVMe SSD breaks suspend (s2idle) #123

Closed
kitakar5525 opened this issue Mar 31, 2018 · 9 comments

Comments

Projects
None yet
3 participants
@kitakar5525
Copy link

commented Mar 31, 2018

s2idle (S0ix state), formerly called as Suspend-to-Freeze. Actually, some devices with Linux seem to go well with Connected Standby (Modern Standby) when s2idle is selected as a suspend mode (not traditional Suspend-to-Ram which is not supported even in Windows, though).

For example:

But my PC fails to resume from s2idle always when I attempt to resume for the second time (oddly, first time resume is ok).

Tested environment

  1. Surface Book with Performance Base i7/512GB/16GB/dGPU
  2. Arch Linux with this repo's kernel (4.15.12-1) and .conf files
    (Also tested on Ubuntu 17.10.1 Live USB with stock kernel and same result)
  3. SSD model: THNSN5512GPU7 TOSHIBA
  4. wifi model: Marvell Technology Group Ltd. 88W8897 [AVASTAR] 802.11ac Wireless

How to reproduce

1. Make sure s2idle is selected as a suspend mode:

$ cat /sys/power/mem_sleep
[s2idle]

(deep will also appears if a device is support traditional Suspend-to-Ram, but Surface is not.)

2. First s2idle, can correctly resume from this state (you can go to s2idle in the ordinary way: systemctl suspend and can resume by lid-open)

3. Second s2idle, and never to resume again

When no_console_suspend and ignore_loglevel kernel parameter is set, after second resume from s2idle on console, I get messages like this:

no_console_suspend-log

It says

pci 0000:03:00.0: Refused to change power state, currently in D3
nvme 0000:02:00.0: Refused to change power state, currently in D3

(pci 0000:03:00.0 is wifi device)

And don't respond to any input anymore.

Workaround?

pre/*)
  echo 1 > "/sys/bus/pci/devices/0000:03:00.0/remove"
post/*)
  echo 1 > /sys/bus/pci/rescan

in your /lib/systemd/system-sleep/hibernate.sh can resolve wifi one.

But nvme will not go the same way. If I do, error storm occurs.

So, I need to set pcie_port_pm=off kernel parameter to resume from s2idle for second time and more. However, this may consume more power(?) It consumes 4-5% per hour on s2idle.

Can anyone reproduce this issue? How to change power state of nvme from D3 state?

@kitakar5525 kitakar5525 changed the title Surface Book with Performance Base: nvme and wifi is preventing from resuming from s2idle, saying `nvme 0000:02:00.0: Refused to change power state, currently in D3` Surface Book with Performance Base: nvme and wifi is preventing PC from resuming from s2idle Mar 31, 2018

@kitakar5525

This comment has been minimized.

Copy link
Author

commented Apr 1, 2018

Hi! I can now correctly resume from s2idle more than first time with these commands!:

echo 0 > "/sys/bus/pci/devices/0000:02:00.0/d3cold_allowed" # nvme
echo 0 > "/sys/bus/pci/devices/0000:03:00.0/d3cold_allowed" # wifi

Now no need to set pcie_port_pm=off kernel parameter and echo 1 > "/sys/bus/pci/devices/0000:03:00.0/remove", echo 1 > /sys/bus/pci/rescan in /lib/systemd/system-sleep/hibernate.sh.

Can anyone confirm this?

@mlabieniec

This comment has been minimized.

Copy link

commented Apr 1, 2018

@kitakar5525 where are you putting these commands? ... in hibernate.sh -> pre/post ?

@kitakar5525

This comment has been minimized.

Copy link
Author

commented Apr 1, 2018

I put in hibernate.sh -> pre.

@jakeday

This comment has been minimized.

Copy link
Owner

commented Apr 1, 2018

@kitakar5525 I'll add it to the script, but I may want to set this in the kernel in the future. Thanks!

@mlabieniec

This comment has been minimized.

Copy link

commented Apr 1, 2018

it doesn't seem to work for me ... well in general systemctl suspend doesn't seem to work with or without it...i get a hissing/popping sound on the speakers then no wifi etc when it comes back up a few seconds later. Then my display starts wiggin out (surface book 2 15")

@jakeday

This comment has been minimized.

Copy link
Owner

commented Apr 1, 2018

Updated scripts and added patch to kernel.

@jakeday jakeday closed this Apr 1, 2018

@kitakar5525

This comment has been minimized.

Copy link
Author

commented Apr 2, 2018

@mlabieniec Setting no_console_suspend, ignore_loglevel and systemd.unit=multi-user.target (system will boot to console) kernel parameters and attempting to suspend may provide you interesting information in console while your display is still readable.

Because you are using SB2, maybe there are another issues preventing you from suspending the system. I think the cause can differ by models.

@jakeday Just for your information, I noticed disabling d3cold only for nvme is enough (at least for my Performance Base) to resume from s2idle.

echo 0 > "/sys/bus/pci/devices/0000:02:00.0/d3cold_allowed" # for SB Performance Base nvme for s2idle suspend

Then, I see this message pci 0000:03:00.0: Refused to change power state, currently in D3 in dmesg again each time it resumes, but wifi is still usable each resume from s2idle suspend.

Also see this message nvme 0000:02:00.0: invalid power transition (from state 4 to 3) each resume.

I don't know how harmful these messages are, though.

EDIT:
(I forgot to mention that echo 1 > /sys/bus/pci/devices/0000\:02\:00.0/reset in your hibernate hook did not work for this issue.)

@kitakar5525 kitakar5525 changed the title Surface Book with Performance Base: nvme and wifi is preventing PC from resuming from s2idle Surface Book with Performance Base: nvme is preventing PC from resuming from s2idle Apr 2, 2018

@kitakar5525 kitakar5525 changed the title Surface Book with Performance Base: nvme is preventing PC from resuming from s2idle Surface Book with Performance Base: NVMe SSD breaks suspend (s2idle) Feb 18, 2019

@kitakar5525

This comment has been minimized.

Copy link
Author

commented Feb 18, 2019

Sorry to comment on an old closed issue, but I want to share my update.

I wrote my findings here:

summary

I made two patches to fix suspend by kernel side. These patches fix resume from suspend by not allow that NVMe disk to enter D3 state and then, improve power consumption when we disable D3 state on the NVMe during suspend.

@kitakar5525

This comment has been minimized.

Copy link
Author

commented Feb 18, 2019

Just sharing the findings, I don't make a PR because I'm not sure I'm doing the right thing🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.