tl;dr
I tried to add an nvidia-hybrid-sleep service but there was no luck.
After investigating the systemd files installed by nvidia driver,
I found that the systemd-hybrid-sleep.service
doesn’t depend on either
nvidia-suspend.service
or nvidia-hibernate.service
like systemd-suspend and systemd-hibernate do.
Those two nvidia services execute the /usr/bin/nvidia-sleep.sh
script before suspend/hibernate. Without dependencies, the script won’t run at all throughout the hybrid sleep power cycle. So I add a custom systemd file to imitate the behaviour of nvidia-hibernate.service
.
$ sudo nano /etc/systemd/system/nvidia-hybrid-sleep.service
[Unit]
Description=NVIDIA system hybrid-suspend service
Before=systemd-hybrid-sleep.service
[Service]
Type=oneshot
ExecStart=/usr/bin/logger -t hibernate -s "nvidia-hybrid-sleep.service"
ExecStart=/usr/bin/nvidia-sleep.sh "hibernate"
[Install]
WantedBy=systemd-hybrid-sleep.service
As well as a drop-in for nvidia-resume.service
to let it be depended on system-hybrid-sleep.service
.
$ sudo mkdir /etc/systemd/system/nvidia-resume.service.d
$ sudo nano /etc/systemd/system/nvidia-resume.service.d/override.conf
[Unit]
After=systemd-hybrid-sleep.service
[Install]
WantedBy=systemd-hybrid-sleep.service
Then reload systemctl and enable those services.
$ sudo systemctl daemon-reload
$ sudo systemctl enable nvidia-resume.service
$ sudo systemctl enable nvidia-hybrid-sleep.service
After all of this work, the nvidia-sleep.sh
is properly run both before hybrid sleep and after resume like it would do during a normal hibernation.
The bad news is the script itself isn’t working as intended, as it would taint the kernel.
kernel: ------------[ cut here ]------------
kernel: WARNING: CPU: 11 PID: 10889 at /var/lib/dkms/nvidia/550.67/build/nvidia/nv.c:4522 nv_set_system_power_state+0x2e9/0x460 [nvidia]
kernel: Modules linked in: tls rfcomm ccm nvidia_uvm(POE) snd_ctl_led snd_soc_skl_hda_dsp snd_soc_intel_hda_dsp_common snd_soc_hdac_hdmi snd_sof_probes snd_hda_codec_hdmi snd_hda_codec_re>
kernel: intel_rapl_msr nls_iso8859_1 dell_smm_hwmon mac80211 snd_pcm libarc4 i915 snd_seq_midi snd_seq_midi_event uvcvideo intel_cstate dell_wmi snd_rawmidi videobuf2_vmalloc btusb btrtl>
kernel: x_tables autofs4 usbhid hid_sensor_custom hid_sensor_hub intel_ishtp_hid nvme hid_generic nvme_core spi_intel_pci i2c_i801 crc32_pclmul spi_intel i2c_smbus nvme_common ucsi_acpi >
kernel: CPU: 11 PID: 10889 Comm: nvidia-sleep.sh Tainted: P W OE 6.5.0-35-generic #35~22.04.1-Ubuntu
kernel: Hardware name: Dell Inc. Inspiron 7590/0JKGD4, BIOS 1.22.0 09/12/2023
kernel: RIP: 0010:nv_set_system_power_state+0x2e9/0x460 [nvidia]
kernel: Code: 48 8b 75 d0 84 c0 0f 84 6e ff ff ff 48 8b 3d 06 99 cd 00 e8 b9 17 14 c9 e9 5d ff ff ff 4c 89 f7 e8 fc 4b e1 c9 e9 50 ff ff ff <0f> 0b e9 34 fe ff ff 48 8b 3d e1 98 cd 00 4c >
kernel: RSP: 0018:ffffae3051ca3d18 EFLAGS: 00010206
kernel: RAX: 0000000000000011 RBX: 0000000000000002 RCX: 0000000000000000
kernel: RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
kernel: RBP: ffffae3051ca3d50 R08: 0000000000000000 R09: 0000000000000000
kernel: R10: 0000000000000000 R11: 0000000000000000 R12: ffff98e9db2f7000
kernel: R13: 0000000000000000 R14: 0000000000000006 R15: 0000000000000007
kernel: FS: 00007e5d6cb82740(0000) GS:ffff98ed2d6c0000(0000) knlGS:0000000000000000
kernel: CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
kernel: CR2: 0000641a83b7f008 CR3: 0000000158056002 CR4: 00000000003706e0
kernel: Call Trace:
kernel: <TASK>
kernel: ? show_regs+0x6d/0x80
kernel: ? __warn+0x89/0x160
kernel: ? nv_set_system_power_state+0x2e9/0x460 [nvidia]
kernel: ? report_bug+0x17e/0x1b0
kernel: ? handle_bug+0x46/0x90
kernel: ? exc_invalid_op+0x18/0x80
kernel: ? asm_exc_invalid_op+0x1b/0x20
kernel: ? nv_set_system_power_state+0x2e9/0x460 [nvidia]
kernel: ? nv_set_system_power_state+0x11c/0x460 [nvidia]
kernel: ? __check_object_size.part.0+0x3a/0x150
kernel: nv_procfs_write_suspend+0x106/0x1c0 [nvidia]
kernel: proc_reg_write+0x69/0xb0
kernel: vfs_write+0xff/0x440
kernel: ksys_write+0x73/0x100
kernel: __x64_sys_write+0x19/0x30
kernel: x64_sys_call+0x1d63/0x20b0
kernel: do_syscall_64+0x55/0x90
kernel: ? exit_to_user_mode_prepare+0x30/0xb0
kernel: ? syscall_exit_to_user_mode+0x37/0x60
kernel: ? do_syscall_64+0x61/0x90
kernel: ? do_syscall_64+0x61/0x90
kernel: entry_SYSCALL_64_after_hwframe+0x73/0xdd
kernel: RIP: 0033:0x7e5d6c914887
kernel: Code: 10 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 48 89 >
kernel: RSP: 002b:00007ffda2ac5528 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
kernel: RAX: ffffffffffffffda RBX: 0000000000000007 RCX: 00007e5d6c914887
kernel: RDX: 0000000000000007 RSI: 0000641a83b7f100 RDI: 0000000000000001
kernel: RBP: 0000641a83b7f100 R08: 0000000000000000 R09: 0000641a83b7f100
kernel: R10: 0000000000000077 R11: 0000000000000246 R12: 0000000000000007
kernel: R13: 00007e5d6ca1b780 R14: 00007e5d6ca17600 R15: 00007e5d6ca16a00
kernel: </TASK>
kernel: ---[ end trace 0000000000000000 ]---
gdm3[1378]: GLib: Source ID 82 was not found when attempting to remove it
systemd[1]: systemd-hybrid-sleep.service: Deactivated successfully.
systemd[1]: Finished Hybrid Suspend+Hibernate.
systemd[1]: systemd-hybrid-sleep.service: Consumed 2.665s CPU time.
systemd[1]: Reached target Hybrid Suspend+Hibernate.
systemd[1]: Stopped target Sleep.
/usr/libexec/gdm-x-session[2348]: (II) systemd-logind: got resume for 13:69
systemd[1]: Starting NVIDIA system resume actions...
systemd[1]: Stopped target Hybrid Suspend+Hibernate.
suspend[10913]: nvidia-resume.service
logger[10913]: <13>Jun 13 05:38:46 suspend: nvidia-resume.service
/usr/libexec/gdm-x-session[2348]: (II) systemd-logind: got resume for 13:72
systemd[1]: nvidia-resume.service: Deactivated successfully.
systemd[1]: Finished NVIDIA system resume actions.
/usr/libexec/gdm-x-session[2348]: (II) systemd-logind: got resume for 13:67
/usr/libexec/gdm-x-session[2348]: (II) systemd-logind: got resume for 13:65
/usr/libexec/gdm-x-session[2348]: (II) systemd-logind: got resume for 13:70
/usr/libexec/gdm-x-session[2348]: (II) systemd-logind: got resume for 13:71
/usr/libexec/gdm-x-session[2348]: (II) systemd-logind: got resume for 226:0
/usr/libexec/gdm-x-session[2348]: (II) AIGLX: Resuming AIGLX clients after VT switch
/usr/libexec/gdm-x-session[2348]: (II) modeset(0): EDID vendor "AUO", prod id 9453
/usr/libexec/gdm-x-session[2348]: (II) modeset(0): Printing DDC gathered Modelines:
/usr/libexec/gdm-x-session[2348]: (II) modeset(0): Modeline "1920x1080"x0.0 141.00 1920 2028 2076 2100 1080 1090 1100 1118 +hsync -vsync (67.1 kHz eP)
/usr/libexec/gdm-x-session[2348]: (II) modeset(0): Modeline "1920x1080"x0.0 112.80 1920 2028 2076 2100 1080 1090 1100 1118 +hsync -vsync (53.7 kHz e)
systemd-logind[925]: Operation 'sleep' finished.
kernel: rfkill: input handler disabled
ModemManager[977]: <info> [sleep-monitor-systemd] system is resuming
NetworkManager[894]: <info> [1718228326.8459] manager: sleep: wake requested (sleeping: yes enabled: yes)
NetworkManager[894]: <info> [1718228326.8461] device (wlp61s0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
/usr/libexec/gdm-x-session[2348]: (II) modeset(0): EDID vendor "AUO", prod id 9453
/usr/libexec/gdm-x-session[2348]: (II) modeset(0): Printing DDC gathered Modelines:
/usr/libexec/gdm-x-session[2348]: (II) modeset(0): Modeline "1920x1080"x0.0 141.00 1920 2028 2076 2100 1080 1090 1100 1118 +hsync -vsync (67.1 kHz eP)
/usr/libexec/gdm-x-session[2348]: (II) modeset(0): Modeline "1920x1080"x0.0 112.80 1920 2028 2076 2100 1080 1090 1100 1118 +hsync -vsync (53.7 kHz e)
kernel: iwlwifi 0000:3d:00.0: WRT: Invalid buffer destination
/usr/libexec/gdm-x-session[2348]: (WW) NVIDIA(GPU-0): Failed to enter interactive mode.
/usr/libexec/gdm-x-session[2348]: (EE) NVIDIA(GPU-0): Failed to query object info.
/usr/libexec/gdm-x-session[2348]: (EE) NVIDIA(GPU-0): Failed to query object info.
kernel: workqueue: set_brightness_delayed hogged CPU for >10000us 8 times, consider switching to WQ_UNBOUND
/usr/libexec/gdm-x-session[2348]: (EE) NVIDIA(GPU-0): Failed to query object info.
I’ve also tried “suspend” as the parameter of the nvidia-sleep.sh
script and enabled “NVreg_PreserveVideoMemoryAllocations” as other solutions suggested, but that gives a similar outcome. I hope someone in Nvidia would help to fix this compatibility issue.