I'm on Ubuntu 22.04. Sleep has always worked before. But after some recent update, it does not anymore, and instead causes the computer to freeze, so it needs a hard reset then, which is very annoying (also because it automatically tries to go into sleep mode after a while).
I'm not exactly sure which recent update that was, and since when this happens, as I only infrequently use this computer (a few times per week on average, but varies a lot). Maybe since the last 2-3 weeks or so.
I have an Nvidia graphics card. I suspect this is related because at some point I think I had the same problem once after I had some bad graphics driver.
I guess I could try to check through my install log (/var/log/dpkg?) to see what was recently updated and randomly try older Linux kernels or Nvidia drivers and try various combinations but that seems quite annoying to do?
Can I somehow do this more cleverly?
Can I somehow easily know the exact versions of the Linux kernel and the Nvidia drivers from e.g. last month?
Can I also maybe debug this somehow, to find out about the actual problem?
Right now this is what is running (where it is not working, i.e. where sleep freezes): Linux kernel 5.15.0-105-generic and Nvidia driver 545.29.06.
Recent log for Nvidia driver (grepping for (status installed|remove) linux-modules-nvidia- in dpkg.log):
2024-03-28 10:19:58 status installed linux-modules-nvidia-545-5.15.0-101-generic:amd64 5.15.0-101.111+1
2024-03-28 10:20:00 status installed linux-modules-nvidia-545-5.15.0-97-generic:amd64 5.15.0-97.107+1
2024-03-28 10:20:00 status installed linux-modules-nvidia-545-generic:amd64 5.15.0-101.111+1
2024-03-28 10:20:49 status installed linux-modules-nvidia-545-5.15.0-94-generic:amd64 5.15.0-94.104+1
2024-03-28 10:20:49 remove linux-modules-nvidia-545-5.15.0-94-generic:amd64 5.15.0-94.104+1 <none>
2024-04-22 13:32:00 status installed linux-modules-nvidia-545-5.15.0-101-generic:amd64 5.15.0-101.111+2
2024-04-22 13:32:03 status installed linux-modules-nvidia-545-5.15.0-105-generic:amd64 5.15.0-105.115+1
2024-04-22 13:32:04 status installed linux-modules-nvidia-545-generic:amd64 5.15.0-105.115+1
2024-04-24 00:26:51 status installed linux-modules-nvidia-545-5.15.0-101-generic:amd64 5.15.0-101.111+2
2024-04-24 00:26:51 remove linux-modules-nvidia-545-5.15.0-101-generic:amd64 5.15.0-101.111+2 <none>
2024-04-24 00:26:54 status installed linux-modules-nvidia-545-5.15.0-97-generic:amd64 5.15.0-97.107+1
2024-04-24 00:26:54 remove linux-modules-nvidia-545-5.15.0-97-generic:amd64 5.15.0-97.107+1 <none>
Edit I also tried Linux kernel 5.15.0-102-generic with linux-modules-nvidia-5.15.0-102-generic (still same driver version 545.29.06) and that also does not work.
Edit Linux kernel 5.15.0-101-generic with linux-modules-nvidia-5.15.0-101-generic (still same driver version 545.29.06) and that also does not work. I'm not really sure if I really was using any older kernel though before that, considering the dpkg log (see below). Was I? I'm wondering whether the problem is maybe something else.
Edit I'm now suspecting my new USB keyboard. After I disconnected it, sleep works again and does not freeze the computer? This is again with the latest kernel I have installed. dmesg log when connecting the USB keyboard:
[ 119.060978] usb 1-2: new full-speed USB device number 3 using xhci_hcd
[ 119.231581] usb 1-2: New USB device found, idVendor=3434, idProduct=0331, bcdDevice= 1.02
[ 119.231587] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 119.231590] usb 1-2: Product: Keychron V3
[ 119.231591] usb 1-2: Manufacturer: Keychron
[ 119.393845] input: Keychron Keychron V3 as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/0000:03:08.0/0000:06:00.1/usb1/1-2/1-2:1.0/0003:3434:0331.0006/input/input22
[ 119.453210] hid-generic 0003:3434:0331.0006: input,hidraw5: USB HID v1.11 Keyboard [Keychron Keychron V3] on usb-0000:06:00.1-2/input0
[ 119.456765] hid-generic 0003:3434:0331.0007: hiddev3,hidraw6: USB HID v1.11 Device [Keychron Keychron V3] on usb-0000:06:00.1-2/input1
[ 119.461933] input: Keychron Keychron V3 Mouse as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/0000:03:08.0/0000:06:00.1/usb1/1-2/1-2:1.2/0003:3434:0331.0008/input/input23
[ 119.462054] input: Keychron Keychron V3 System Control as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/0000:03:08.0/0000:06:00.1/usb1/1-2/1-2:1.2/0003:3434:0331.0008/input/input24
[ 119.521156] input: Keychron Keychron V3 Consumer Control as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/0000:03:08.0/0000:06:00.1/usb1/1-2/1-2:1.2/0003:3434:0331.0008/input/input25
[ 119.521237] input: Keychron Keychron V3 Keyboard as /devices/pci0000:00/0000:00:01.2/0000:02:00.0/0000:03:08.0/0000:06:00.1/usb1/1-2/1-2:1.2/0003:3434:0331.0008/input/input26
[ 119.521482] hid-generic 0003:3434:0331.0008: input,hidraw7: USB HID v1.11 Mouse [Keychron Keychron V3] on usb-0000:06:00.1-2/input2
Edit Yes, confirmed. When my nice new Keychron USB keyboard is not connected, all is fine, sleep mode works. When it is connected, the computer freezes once I try to go into sleep mode. How can that be?
(Also, again I would stress the question: how can I debug such an issue? This trial-and-error game I was playing now for the last few hours seems extremely inefficient.)
Edit I was searching a bit through the Internet for similar reports but did not really find so much. Some links:
- forum.manjaro.org: Black Screen/Freeze on Sleep (Nov 2021) (no answer):
I noticed that when I unplug the bluetooth receiver for my wireless keyboard, suddenly everything starts working again.
Edit Ok, the kernel version might be relevant as well. It also seems to freeze now without the keyboard with the latest kernel 5.15.0-105-generic, but it seems to work fine without the keyboard with the kernel 5.15.0-102-generic. But kernel 5.15.0-102-generic with the keyboard always freezes.
Edit Hm ok, the first sleep worked fine, the second does not anymore. I'm totally confused now. It seems to be somewhat non-deterministic as well? (But remember, as said, 2 weeks ago or so, sleep always worked fine, for many years. So sth definitely changed.)
Edit Ok, now I installed a completely new kernel 6.5.0-28-lowlatency, and so far, sleep mode seems to work, even when the keyboard is connected. But I'm not really sure whether it is all resolved now and will continue to work... I don't really think this question here is resolved. Many questions are unanswered here (e.g. how to debug this more systematically), so I will leave the question open, until I hopefully find some answers.
Edit Ok, I got the problem again, now with Linux kernel 6.5.0-28-lowlatency. Sleep (suspend) seems to work fine when the USB keyboard is not attached but it freezes when the USB keyboard is attached. When I said it worked in my previous comment, this was also true. I tried it a couple of times. But now the problem is back, and again seems related to this keyboard. But this also shows that it's somewhat non-deterministic (or depending on some other factor which I don't understand yet).