You are not logged in.

#1 2024-06-05 19:08:46

teescdf
Member
Registered: 2024-06-05
Posts: 3

[SOLVED] Script to fix laptop NVMe/sleep issue

Hi all,

I'm trying to fix an issue with my MacBook in which the NVMe will not wake from sleep properly.

I've tried to implement the fix outlined on various other forums for different distros, and also here. I had this working previously on the same device under Kubuntu, using a cronjob that ran @reboot. The specific fix is to run the command echo 0 > /sys/bus/pci/devices/0000\:01\:00.0/d3cold_allowed as root. Said file's content seems to get changed back to "1" every restart.

Now that the laptop in question has Arch on it, I have attempted to use systemd to solve the same problem. To that end, I created a file named nvmefix.service in /etc/systemd/system with the following contents:

[Unit]
Description=Script to fix NVMe resume/sleep issues

[Service]
ExecStart=/usr/bin/d3cold_allowed

[Install]
WantedBy=multi-user.target

And a file named d3cold_allowed in /usr/bin containing the following:

echo 0 > /sys/bus/pci/devices/0000\:01\:00.0/d3cold_allowed

This file has had a chmod 755 done to it. And I have run sudo systemctl start nvmefix and sudo systemctl enable nvmefix commands without any apparent errors.

Checking the /sys/bus/pci/devices/0000\:01\:00.0/d3cold_allowed file after logon, it still shows up as containing  a "1". If I run the command manually, then it works fine.

Can anyone see what I'm doing wrong here?

Thanks,

Ben

Last edited by teescdf (2024-06-20 08:41:16)

Offline

#2 2024-06-05 20:36:48

seth
Member
Registered: 2012-09-03
Posts: 59,897

Re: [SOLVED] Script to fix laptop NVMe/sleep issue

Some power management daemon might still write the file?
If it's only relevant for resuming from S3, write it before the S3:
https://wiki.archlinux.org/title/Power_ … stem-sleep

Offline

#3 2024-06-06 08:32:22

teescdf
Member
Registered: 2024-06-05
Posts: 3

Re: [SOLVED] Script to fix laptop NVMe/sleep issue

Thank for the quick response. There's some really informative stuff in the link you shared, so thanks for that, much appreciated!

As it happens, I fixed things...I had simply forgotten to include "#!/bin/sh" at the start of the script file. Added that and all appears to be working properly!

Offline

#4 2024-06-06 15:06:13

seth
Member
Registered: 2012-09-03
Posts: 59,897

Re: [SOLVED] Script to fix laptop NVMe/sleep issue

\o/
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

#5 2024-06-06 15:08:38

teescdf
Member
Registered: 2024-06-05
Posts: 3

Re: [SOLVED] Script to fix laptop NVMe/sleep issue

Done, thanks for the prompt!

And... given the error I made, and for anyone looking for the (complete and working) solution for this issue, do the following:

Create a  file named nvmefix.service in /etc/systemd/system with the following contents:

[Unit]
Description=Script to fix NVMe resume/sleep issues

[Service]
ExecStart=/usr/bin/d3cold_allowed

[Install]
WantedBy=multi-user.target

Now create a file named d3cold_allowed in /usr/bin containing the following

#!/bin/sh
echo 0 > /sys/bus/pci/devices/0000\:01\:00.0/d3cold_allowed

Now run the following command to make the script executable:

chmod 755 /usr/bin/d3cold_allowed

Finally, run the following 2 commands:

sudo systemctl start nvmefix
sudo systemctl enable nvmefix

After a reboot, you should be able to read the contents of the d3cold_allowed file with the following command, and check that it does, in fact contain a "0":

cat /sys/bus/pci/devices/0000\:01\:00.0/d3cold_allowed

Last edited by teescdf (2024-06-20 08:48:54)

Offline

#6 2024-10-15 16:33:40

werefkin
Member
Registered: 2023-11-21
Posts: 38

Re: [SOLVED] Script to fix laptop NVMe/sleep issue

teescdf wrote:

Done, thanks for the prompt!

And... given the error I made, and for anyone looking for the (complete and working) solution for this issue, do the following:

Create a  file named nvmefix.service in /etc/systemd/system with the following contents:

[Unit]
Description=Script to fix NVMe resume/sleep issues

[Service]
ExecStart=/usr/bin/d3cold_allowed

[Install]
WantedBy=multi-user.target

Now create a file named d3cold_allowed in /usr/bin containing the following

#!/bin/sh
echo 0 > /sys/bus/pci/devices/0000\:01\:00.0/d3cold_allowed

Now run the following command to make the script executable:

chmod 755 /usr/bin/d3cold_allowed

Finally, run the following 2 commands:

sudo systemctl start nvmefix
sudo systemctl enable nvmefix

After a reboot, you should be able to read the contents of the d3cold_allowed file with the following command, and check that it does, in fact contain a "0":

cat /sys/bus/pci/devices/0000\:01\:00.0/d3cold_allowed

Hi, did you do anything else to make suspend work? I have 0 returned, so it works, but the laptop cannot wake up from suspend -- nothing happens, just black screen.
thanks!

Offline

Board footer

Powered by FluxBB