System information
- OS: Arch Linux
- Kernel version: 6.10.7-arch1-1 (though I’ve also tested with the LTS kernel (6.6.48) and linux-mainline (6.11rc5), see below)
- Model: AMD 13th gen (AMD Ryzen 7 7840U)
- BIOS/firmware version: Gnome settings and
dmidecode -t bios
report version 3.05
Problem description
I’ve been having trouble getting my laptop to hibernate consistently with the most recent stable kernel. The LTS kernel works fine, but the linux-mainline kernel (6.11 rc5, currently) seems to exhibit the same behavior as 6.10.
Kernel 6.10.x (faulty kernel)
In short, I can get hibernation to work (i.e. systemctl hibernate
), but only under certain conditions. From what I can gather from dmesg
, the hibernation process gets (nearly) 100% of the way there, but is then interupted by some kind of wakeup event/kernel misbehavior. At that point, the system will just wake up again. Suspending (i.e. systemctl suspend
) works absolutely fine, however.
So far, I’ve been able to narrow down this immediate wakeup after hibernation to two possibly related causes. Specially, hibernation works completely fine, unless…
- Bluetooth is turned on (i.e. I run
rfkill unblock bluetooth
) - The kernel listens to wakeup triggers from the
xhc0
device, whichlspci
tells me corresponds toUSB controller: Advanced Micro Devices, Inc. [AMD] Device 15b9
.
To be more specific, hibernation works 100% of the time just in case bluetooth is turned off, or, alternatively, if the xhc0
device is told to ignore wakeup triggers. In other words, if bluetooth is on, and xhc0
is told to ignore wakeup events, hibernation will still work. Hibernation will also always work if bluetooth is turned off.
With respect to bluetooth, I should add that I can reproduce the problem even when no bluetooth devices are connected. Hence, it’s not as if some rogue bluetooth device is secretly sending inputs, so preventing the system from shutting down completely.
The “USB controller”/xhc0
device in question can be told to ignore wakeup triggers by running echo "XHC0" | sudo tee /proc/acpi/wakeup
(actually, this acts as a toggle; to check the current value, simply run cat /proc/acpi/wakeup
).
From what I can see, xhc0
will in fact respond to wakeup triggers by default.
Similar problems have been reported here and here.
Other kernels
The LTS kernel does not exhibit the above behavior: that is, hibernation works fine. Unfortunately, with linux 6.11 rc5, my system will immediately wakeup from hibernation if the conditions outlined above apply.
Interesting information from dmesg
dmesg
contains some interesting information in case either of the conditions above obtains. All information provided here stems from the 6.10.7 kernel.
Because dmesg outputs a lot whenever hibernation, I had to put it in a gist. This log reflects what happens when bluetooth is turned on.
Given the fact that the problem is dependend on the hardware’s state, I’m betting that this a problem that sits below userspace. However, I’m not seeing any similar reports, except this thread. There, the conversation stopped after a question about the size of the swapfile. But as my logs indicate, the size of the swapfile is clearly not at fault here (a contention further corrabarated by the fact that hibernation will still work in some cases, e.g. by just simply turning my bluetooth off). FTR: I have 16GB of RAM, and a swapfile that can hold 28GB.
The above log also shows the kernel freaking out (see the call trace). I thought this happened exclusively in instances where hibernation failed, but I’ve now noticed similar logs in instances where hibernation does in fact work.
Finally, the dmesg
logs also suggest that the laptop gets really far in the hibernation process — the image gets written to swapfile, all CPUS go offline, etc. In fact, it kind of seems like the system actually hibernates briefly, and then is interupted somehow, though it is important to note that the light on the power button never turns off. The latter is a sign of hibernation working as expected.
Here’s a log of hibernation working fine (with bluetooth turned on, and the XHC0
wakeup trigger disabled):
succesful hibernation with bluetooth on, and XHC0 triggers off
[31151.152569] wlan0: deauthenticating from c0:06:c3:0b:84:e6 by local choice (Reason: 3=DEAUTH_LEAVING)
[31152.124764] PM: Image not found (code -16)
[31152.133232] PM: hibernation: hibernation entry
[31152.138200] Filesystems sync: 0.003 seconds
[31152.138360] Freezing user space processes
[31152.139907] Freezing user space processes completed (elapsed 0.001 seconds)
[31152.139912] OOM killer disabled.
[31152.140028] PM: hibernation: Marking nosave pages: [mem 0x00000000-0x00000fff]
[31152.140031] PM: hibernation: Marking nosave pages: [mem 0x0009f000-0x000fffff]
[31152.140034] PM: hibernation: Marking nosave pages: [mem 0x09b00000-0x09dfffff]
[31152.140044] PM: hibernation: Marking nosave pages: [mem 0x09f00000-0x09f3bfff]
[31152.140046] PM: hibernation: Marking nosave pages: [mem 0x49b60000-0x4bd5ffff]
[31152.140143] PM: hibernation: Marking nosave pages: [mem 0x4bd69000-0x4bd6cfff]
[31152.140144] PM: hibernation: Marking nosave pages: [mem 0x4bd6f000-0x4bd6ffff]
[31152.140145] PM: hibernation: Marking nosave pages: [mem 0x4bd78000-0x4bd78fff]
[31152.140147] PM: hibernation: Marking nosave pages: [mem 0x4bd7c000-0x4bd7cfff]
[31152.140148] PM: hibernation: Marking nosave pages: [mem 0x52ea8000-0x52ef6fff]
[31152.140150] PM: hibernation: Marking nosave pages: [mem 0x5491d000-0x5491dfff]
[31152.140151] PM: hibernation: Marking nosave pages: [mem 0x57f7f000-0x5affefff]
[31152.140301] PM: hibernation: Marking nosave pages: [mem 0x5b000000-0xffffffff]
[31152.141542] PM: hibernation: Basic memory bitmaps created
[31152.142493] PM: hibernation: Preallocating image memory
[31162.613944] PM: hibernation: Allocated 806025 pages for snapshot
[31162.613950] PM: hibernation: Allocated 3224100 kbytes in 10.47 seconds (307.93 MB/s)
[31162.613953] Freezing remaining freezable tasks
[31162.905110] Freezing remaining freezable tasks completed (elapsed 0.291 seconds)
[31162.906701] printk: Suspending console(s) (use no_console_suspend to debug)
[31162.912842] btusb 1-5:1.1: suspend error -16
[31162.912845] btusb 1-5:1.0: suspend error -16
[31163.544507] ACPI: EC: interrupt blocked
[31163.574013] ACPI: PM: Preparing to enter system sleep state S4
[31163.576404] ACPI: EC: event blocked
[31163.576405] ACPI: EC: EC stopped
[31163.576406] ACPI: PM: Saving platform NVS memory
[31163.579597] Disabling non-boot CPUs ...
[31163.581678] smpboot: CPU 1 is now offline
[31163.584064] smpboot: CPU 2 is now offline
[31163.586343] smpboot: CPU 3 is now offline
[31163.588661] smpboot: CPU 4 is now offline
[31163.590915] smpboot: CPU 5 is now offline
[31163.593218] smpboot: CPU 6 is now offline
[31163.595570] smpboot: CPU 7 is now offline
[31163.597884] smpboot: CPU 8 is now offline
[31163.599898] smpboot: CPU 9 is now offline
[31163.602027] smpboot: CPU 10 is now offline
[31163.604369] smpboot: CPU 11 is now offline
[31163.606564] smpboot: CPU 12 is now offline
[31163.608809] smpboot: CPU 13 is now offline
[31163.610943] smpboot: CPU 14 is now offline
[31163.611636] Spectre V2 : Update user space SMT mitigation: STIBP off
[31163.613181] smpboot: CPU 15 is now offline
[31163.614268] PM: hibernation: Creating image:
[31163.919251] PM: hibernation: Need to copy 1245557 pages
[31163.919256] PM: hibernation: Normal pages needed: 1245557 + 1024, available pages: 2373579
[31163.614756] ACPI: PM: Restoring platform NVS memory
[31163.615578] ACPI: EC: EC started
[31163.616274] LVT offset 0 assigned for vector 0x400
[31163.616883] Enabling non-boot CPUs ...
[31163.617053] smpboot: Booting Node 0 Processor 1 APIC 0x1
[31163.619807] ACPI: \_SB_.PLTF.C001: Found 3 idle states
[31163.619983] Spectre V2 : Update user space SMT mitigation: STIBP always-on
[31163.620002] CPU1 is up
[31163.620105] smpboot: Booting Node 0 Processor 2 APIC 0x2
[31163.622639] ACPI: \_SB_.PLTF.C002: Found 3 idle states
[31163.622796] CPU2 is up
[31163.622902] smpboot: Booting Node 0 Processor 3 APIC 0x3
[31163.625379] ACPI: \_SB_.PLTF.C003: Found 3 idle states
[31163.625542] CPU3 is up
[31163.625664] smpboot: Booting Node 0 Processor 4 APIC 0x4
[31163.628288] ACPI: \_SB_.PLTF.C004: Found 3 idle states
[31163.628431] CPU4 is up
[31163.628548] smpboot: Booting Node 0 Processor 5 APIC 0x5
[31163.631035] ACPI: \_SB_.PLTF.C005: Found 3 idle states
[31163.631222] CPU5 is up
[31163.631370] smpboot: Booting Node 0 Processor 6 APIC 0x6
[31163.633916] ACPI: \_SB_.PLTF.C006: Found 3 idle states
[31163.634124] CPU6 is up
[31163.634240] smpboot: Booting Node 0 Processor 7 APIC 0x7
[31163.636719] ACPI: \_SB_.PLTF.C007: Found 3 idle states
[31163.636932] CPU7 is up
[31163.637037] smpboot: Booting Node 0 Processor 8 APIC 0x8
[31163.639555] ACPI: \_SB_.PLTF.C008: Found 3 idle states
[31163.639791] CPU8 is up
[31163.639949] smpboot: Booting Node 0 Processor 9 APIC 0x9
[31163.642504] ACPI: \_SB_.PLTF.C009: Found 3 idle states
[31163.642749] CPU9 is up
[31163.642848] smpboot: Booting Node 0 Processor 10 APIC 0xa
[31163.645338] ACPI: \_SB_.PLTF.C00A: Found 3 idle states
[31163.645555] CPU10 is up
[31163.645668] smpboot: Booting Node 0 Processor 11 APIC 0xb
[31163.648124] ACPI: \_SB_.PLTF.C00B: Found 3 idle states
[31163.648404] CPU11 is up
[31163.648591] smpboot: Booting Node 0 Processor 12 APIC 0xc
[31163.651128] ACPI: \_SB_.PLTF.C00C: Found 3 idle states
[31163.651374] CPU12 is up
[31163.651471] smpboot: Booting Node 0 Processor 13 APIC 0xd
[31163.653954] ACPI: \_SB_.PLTF.C00D: Found 3 idle states
[31163.654264] CPU13 is up
[31163.654390] smpboot: Booting Node 0 Processor 14 APIC 0xe
[31163.656881] ACPI: \_SB_.PLTF.C00E: Found 3 idle states
[31163.657163] CPU14 is up
[31163.657281] smpboot: Booting Node 0 Processor 15 APIC 0xf
[31163.659772] ACPI: \_SB_.PLTF.C00F: Found 3 idle states
[31163.660128] CPU15 is up
[31163.663035] ACPI: PM: Waking up from system sleep state S4
[31163.668513] ACPI: EC: interrupt unblocked
[31163.804466] ACPI: EC: event unblocked
[31163.804482] usb usb1: root hub lost power or was reset
[31163.804483] usb usb3: root hub lost power or was reset
[31163.804486] usb usb2: root hub lost power or was reset
[31163.804487] usb usb4: root hub lost power or was reset
[31163.804844] usb usb5: root hub lost power or was reset
[31163.804847] usb usb6: root hub lost power or was reset
[31163.804939] usb usb7: root hub lost power or was reset
[31163.804941] usb usb8: root hub lost power or was reset
[31163.805141] [drm] PCIE GART of 512M enabled (table at 0x000000807FD00000).
[31163.805179] amdgpu 0000:c1:00.0: amdgpu: PSP is resuming...
[31163.818226] nvme nvme0: 16/0/0 default/read/poll queues
[31163.829479] amdgpu 0000:c1:00.0: amdgpu: reserve 0x4000000 from 0x8078000000 for PSP TMR
[31164.077736] usb 3-1: reset high-speed USB device number 2 using xhci_hcd
[31164.087764] usb 1-5: reset high-speed USB device number 3 using xhci_hcd
[31164.351041] usb 1-1: reset high-speed USB device number 11 using xhci_hcd
[31164.382805] amdgpu 0000:c1:00.0: amdgpu: RAS: optional ras ta ucode is not available
[31164.391264] amdgpu 0000:c1:00.0: amdgpu: RAP: optional rap ta ucode is not available
[31164.391267] amdgpu 0000:c1:00.0: amdgpu: SECUREDISPLAY: securedisplay ta ucode is not available
[31164.391270] amdgpu 0000:c1:00.0: amdgpu: SMU is resuming...
[31164.423038] amdgpu 0000:c1:00.0: amdgpu: SMU is resumed successfully!
[31164.425637] [drm] DMUB hardware initialized: version=0x08004000
[31164.575221] [drm] kiq ring mec 3 pipe 1 q 0
[31164.578590] amdgpu 0000:c1:00.0: [drm:jpeg_v4_0_hw_init [amdgpu]] JPEG decode initialized successfully.
[31164.579150] amdgpu 0000:c1:00.0: amdgpu: ring gfx_0.0.0 uses VM inv eng 0 on hub 0
[31164.579152] amdgpu 0000:c1:00.0: amdgpu: ring comp_1.0.0 uses VM inv eng 1 on hub 0
[31164.579153] amdgpu 0000:c1:00.0: amdgpu: ring comp_1.1.0 uses VM inv eng 4 on hub 0
[31164.579154] amdgpu 0000:c1:00.0: amdgpu: ring comp_1.2.0 uses VM inv eng 6 on hub 0
[31164.579155] amdgpu 0000:c1:00.0: amdgpu: ring comp_1.3.0 uses VM inv eng 7 on hub 0
[31164.579156] amdgpu 0000:c1:00.0: amdgpu: ring comp_1.0.1 uses VM inv eng 8 on hub 0
[31164.579157] amdgpu 0000:c1:00.0: amdgpu: ring comp_1.1.1 uses VM inv eng 9 on hub 0
[31164.579157] amdgpu 0000:c1:00.0: amdgpu: ring comp_1.2.1 uses VM inv eng 10 on hub 0
[31164.579159] amdgpu 0000:c1:00.0: amdgpu: ring comp_1.3.1 uses VM inv eng 11 on hub 0
[31164.579159] amdgpu 0000:c1:00.0: amdgpu: ring sdma0 uses VM inv eng 12 on hub 0
[31164.579160] amdgpu 0000:c1:00.0: amdgpu: ring vcn_unified_0 uses VM inv eng 0 on hub 8
[31164.579162] amdgpu 0000:c1:00.0: amdgpu: ring jpeg_dec uses VM inv eng 1 on hub 8
[31164.579163] amdgpu 0000:c1:00.0: amdgpu: ring mes_kiq_3.1.0 uses VM inv eng 13 on hub 0
[31164.582853] [drm] ring gfx_32775.1.1 was added
[31164.583512] [drm] ring compute_32775.2.2 was added
[31164.584137] [drm] ring sdma_32775.3.3 was added
[31164.584162] [drm] ring gfx_32775.1.1 ib test pass
[31164.584188] [drm] ring compute_32775.2.2 ib test pass
[31164.584296] [drm] ring sdma_32775.3.3 ib test pass
[31164.618047] usb 1-4: reset full-speed USB device number 2 using xhci_hcd
[31164.882079] usb 2-1: reset SuperSpeed Plus Gen 2x1 USB device number 5 using xhci_hcd
[31164.971854] usb 1-1.4: reset high-speed USB device number 12 using xhci_hcd
[31165.141760] usb 1-1.5: reset high-speed USB device number 13 using xhci_hcd
[31165.861591] usb 1-1.4.5: reset high-speed USB device number 14 using xhci_hcd
[31166.994680] mt7921e 0000:01:00.0: Message 00020007 (seq 4) timeout
[31166.994694] mt7921e 0000:01:00.0: PM: dpm_run_callback(): pci_pm_restore returns -110
[31166.994707] mt7921e 0000:01:00.0: PM: failed to restore async: error -110
... pretty sure this is the moment my laptop wakes up again
[31166.999473] PM: hibernation: Basic memory bitmaps freed
[31166.999719] OOM killer enabled.
[31166.999720] Restarting tasks ... done.
[31167.001208] Bluetooth: hci0: HW/SW Version: 0x008a008a, Build Time: 20240716163633
[31167.001912] PM: hibernation: hibernation exit
[31167.002283] usb 2-1.4: USB disconnect, device number 6
[31167.002287] r8152-cfgselector 2-1.4.3: USB disconnect, device number 7
[31167.077349] mt7921e 0000:01:00.0: HW/SW Version: 0x8a108a10, Build Time: 20240716163242a
[31167.354505] usb 2-1.4: new SuperSpeed Plus Gen 2x1 USB device number 8 using xhci_hcd
[31167.371486] usb 2-1.4: New USB device found, idVendor=0424, idProduct=7216, bcdDevice= 1.91
[31167.371491] usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[31167.371493] usb 2-1.4: Product: USB7216 Smart Hub
Hibernation setup
To hibernate, I simply use a swapfile at /swapfile
. Since systemd version v255, hibernating to said file works automagically, without fiddling with kernel parameters (see the Arch Wiki), provided that your initramfs generator also supports the relevant systemd mechanism.
Again, I would say that the problem lies not with how I’ve setup hibernation — I can get it to work reliably under certian conditions, and dmesg
suggests that something below userspace is at play.
Really curious to know if others are also seeing this issue!
Workaround
There is a pretty simple workaround for the issue, other than not using bluetooth at all
- Disable wakeups from
XHC0
:
$ echo "XHC0" | sudo tee /proc/acpi/wakeup
-
Run
sudo systemctl hibernate
to check if that indeed fixed your hibernation issue. -
Values in
/proc/acpi/wakeup
are not persistent across boots. To re-apply the workaround at every boot, run:
$ echo 'w /proc/acpi/wakeup - - - - XHC0' | sudo tee /etc/tmpfiles.d/disable-xhc0-wakeup.conf
The above creates a file that tells systemd to write the string XHC0
to /proc/acpi/wakeup
at boot.
When/if this issue gets fixed, simply delete /etc/tmpfiles.d/disable-xhc0-wakeup.conf
again.