ThinkPad T470p (w nvidia 940mx) sometimes gets stuck after sleep/hibernate

Hello! I recently installed this OS on my T470p laptop. I have a problem with the laptop coming out of sleep. After closing the lid of the laptop, after the laptop itself enters sleep mode, or if you press the “Sleep” button. Sometimes the laptop can lie down for 2-3 days and turn on and wake up normally, sometimes it does not wake up, instead I see a black screen, caps lock flashes and no reaction to any actions. To continue work, it is necessary to do a hot reboot of the laptop. Please help to solve this problem. I really like your OS build.
I have latest BIOS.
Installed and configured Optimus Manager.

Kernel: 6.7.5-arch1-1 arch: x86_64 bits: 64 compiler: gcc v: 13.2.1
Desktop: GNOME v: 45.4 Distro: EndeavourOS base: Arch Linux
Type: Laptop System: LENOVO product: 20J7S0DK00 v: ThinkPad T470p
Mobo: LENOVO model: 20J7S0DK00 v: SDK0J40697 WIN
serial: UEFI: LENOVO v: R0FET61W (1.41 )
date: 10/10/2023
ID-1: BAT0 charge: 56.6 Wh (80.9%) condition: 70.0/66.0 Wh (106.0%)
volts: 11.7 min: 11.1 model: LGC 45N1136 status: discharging
Info: quad core model: Intel Core i7-7820HQ bits: 64 type: MT MCP
arch: Kaby Lake rev: 9 cache: L1: 256 KiB L2: 1024 KiB L3: 8 MiB
Speed (MHz): avg: 812 high: 900 min/max: 800/3900 cores: 1: 800 2: 800
3: 800 4: 800 5: 800 6: 900 7: 800 8: 800 bogomips: 46419
Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
Device-1: Intel HD Graphics 630 vendor: Lenovo driver: i915 v: kernel
arch: Gen-9.5 bus-ID: 00:02.0
Device-2: NVIDIA GM108M [GeForce 940MX] vendor: Lenovo driver: N/A
arch: Maxwell bus-ID: 02:00.0
Device-3: Chicony Integrated Camera driver: uvcvideo type: USB
bus-ID: 1-8:3
Display: x11 server: X.Org v: 21.1.11 with: Xwayland v: 23.2.4 driver: X:
loaded: modesetting dri: iris gpu: i915 resolution: 1920x1080~60Hz
API: EGL v: 1.5 drivers: iris,swrast platforms:
active: gbm,x11,surfaceless,device inactive: wayland
API: OpenGL v: 4.6 compat-v: 4.5 vendor: intel mesa v: 24.0.1-arch1.1
glx-v: 1.4 direct-render: yes renderer: Mesa Intel HD Graphics 630 (KBL GT2)
Device-1: Intel CM238 HD Audio vendor: Lenovo driver: snd_hda_intel
v: kernel bus-ID: 00:1f.3
API: ALSA v: k6.7.5-arch1-1 status: kernel-api
Server-1: JACK v: 1.9.22 status: off
Server-2: PipeWire v: 1.0.3 status: active
Device-1: Intel Ethernet I219-LM vendor: Lenovo driver: e1000e v: kernel
port: N/A bus-ID: 00:1f.6
IF: enp0s31f6 state: down mac:
Device-2: Intel Wireless 8265 / 8275 driver: iwlwifi v: kernel
bus-ID: 03:00.0
IF: wlan0 state: up mac:
Device-1: Intel Bluetooth wireless interface driver: btusb v: 0.8 type: USB
bus-ID: 1-7:2
Report: btmgmt ID: hci0 rfk-id: 8 state: down bt-service: disabled
rfk-block: hardware: no software: no address: N/A
Local Storage: total: 1.4 TiB used: 201.27 GiB (14.1%)
ID-1: /dev/nvme0n1 vendor: Samsung model: MZVLW1T0HMLH-000L7
size: 953.87 GiB temp: 22.9 C
ID-2: /dev/sda vendor: Transcend model: TS512GMTS430S size: 476.94 GiB
ID-1: / size: 918.69 GiB used: 200.9 GiB (21.9%) fs: btrfs
dev: /dev/nvme0n1p2
ID-2: /home size: 918.69 GiB used: 200.9 GiB (21.9%) fs: btrfs
dev: /dev/nvme0n1p2
ID-3: /var/log size: 918.69 GiB used: 200.9 GiB (21.9%) fs: btrfs
dev: /dev/nvme0n1p2
ID-1: swap-1 type: partition size: 34.19 GiB used: 0 KiB (0.0%)
dev: /dev/nvme0n1p3
System Temperatures: cpu: 35.0 C pch: 31.5 C mobo: N/A
Fan Speeds (rpm): fan-1: 1541
Memory: total: 32 GiB note: est. available: 31.08 GiB used: 8.14 GiB (26.2%)
Processes: 341 Uptime: 5h 7m Init: systemd
Packages: 1391 Compilers: clang: 16.0.6 gcc: 13.2.1 Shell: Zsh v: 5.9
inxi: 3.3.33

Maybe this helps?

Edit: I see you have hybrid laptop and nvidia is showing N/A for drivers. So it is running on Intel.

Edit2: So this would have to do with the Intel integrated graphics.

I’m not using an nvidia video card. I only use Intel 630 all the time. Nvidia is always disabled using optimus manager.
Please tell me where to look.

Okay i was just going to ask if you even had the nvidia drivers installed?

Yes, drivers are installed correctly. Optimus manager + optimus-manager-qt + patched gdm (instruction on this site)

I’m not very familiar with Gnome and it’s settings with power managemnt and not sure what else to look for with Intel on hybrid laptop. :thinking:

Do you have the proper kernel parameters for sleep/hibernation?

according to the article, I have the required parameter resume=…

unit68a-system:~ adm04$ cat /proc/cmdline
initrd=\6651d0311cb4459e816ab1ec537bf0b0\6.7.5-arch1-1\initrd nvme_load=YES nowatchdog rw rootflags=subvol=/@ root=UUID=2b1b0aaa-588c-48b2-93c2-a7fddb7794ac resume=UUID=c5334fc2-cc4a-47a2-81ad-ada88bba44b4 nvidia-drm.modeset=1 systemd.machine_id=6651d0311cb4459e816ab1ec537bf0b0

UUID = swap partition created automatically (34 GB = 32 gb ram)
ID-1: swap-1 type: partition size: 34.19 GiB used: 0 KiB (0.0%)
dev: /dev/nvme0n1p3
Memory: total: 32 GiB note: est. available: 31.08 GiB used: 8.14 GiB (26.2%)

For what it’s worth, I’ve been seeing this behavior for a while on a T470p. The last kernel that works for me 100% is 6.4.15.