Intermittent failure to suspend Framework 13 AMD Ryzen

Running Debian/trixie on a Framework 13 AMD Ryzen 5 7640U.

Sometimes suspend works fine. Other times, it suspends then immediately resumes again with just a brief flash of the keyboard LED. When it resumes it’s always working properly again. Occasionally, just attempting it again will manage to make it suspend, but usually it remains in this un-suspendable state until a cold reboot, when maybe the next works just fine. I have found no particular pattern to the occasions when it does vs. does not work.

Peeking through dmesg reveals the following

[33380.692924] PM: suspend entry (s2idle)
[33380.696946] Filesystems sync: 0.004 seconds
[33380.697188] (NULL device *): firmware: direct-loading firmware mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin
[33380.697462] (NULL device *): firmware: direct-loading firmware mediatek/WIFI_RAM_CODE_MT7922_1.bin
[33380.697503] (NULL device *): firmware: direct-loading firmware regulatory.db.p7s
[33380.697505] (NULL device *): firmware: direct-loading firmware regulatory.db
[33380.697695] (NULL device *): firmware: direct-loading firmware mediatek/BT_RAM_CODE_MT7922_1_1_hdr.bin
[33380.698489] Freezing user space processes
[33380.720249] Freezing user space processes completed (elapsed 0.021 seconds)
[33380.720259] OOM killer disabled.
[33380.720262] Freezing remaining freezable tasks
[33380.721692] Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
[33380.721700] printk: Suspending console(s) (use no_console_suspend to debug)
[33381.295100] ACPI: EC: interrupt blocked
[33381.570391] amd_pmc AMDI0009:00: Last suspend didn't reach deepest state
[33381.845211] ACPI: EC: interrupt unblocked
[33382.029593] [drm] PCIE GART of 512M enabled (table at 0x000000801FD00000).
[33382.029633] amdgpu 0000:c1:00.0: amdgpu: SMU is resuming...
[33382.031657] amdgpu 0000:c1:00.0: amdgpu: SMU is resumed successfully!

Critically, the line towards the end of “Last suspend didn’t reach deepest state” would be my guess as some indication of what the trouble is, but beyond that I have no clue.

Anyone any ideas?

Hah - wow, and just after I wrote that I managed to make it suspend correctly. This was during the same session, without having rebooted inbetween. This time the messages are:

[34137.910376] Freezing user space processes
[34137.917759] Freezing user space processes completed (elapsed 0.007 seconds)
[34137.917768] OOM killer disabled.
[34137.917771] Freezing remaining freezable tasks
[34137.919068] Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
[34137.919072] printk: Suspending console(s) (use no_console_suspend to debug)
[34138.489532] ACPI: EC: interrupt blocked
[36379.313944] ACPI: EC: interrupt unblocked
[36379.507573] nvme nvme0: 16/0/0 default/read/poll queues

And in particular, the last message before suspend was the “ACPI: EC: interrupt blocked”, and much later (by timestamps) the “ACPI: EC: interrupt unblocked” with no complaint about not reaching deepest state inbetween.

This does suggest that’s where the problem lies, though doesn’t point at what might fix it.

https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/amd_s2idle.py run this

And if you haven’t already, update your Linux firmware from upstream. Debian refuses to update it.

Also, if running Debian, you may need a newer kernel as well: https://wiki.debian.org/HowToUpgradeKernel
(go for the testing kernel)

Yeah and if we’re talking about gaps, make sure you upgrade power profiles daemon to a current version too. This will allow PMF and AMD Pstate to be configured properly.

After a combination of an accidental quirk followed up by much further experimentation, I have narrowed it down. It turns out that if I have a Firefox tab open to with the YouTube video player inside it, the laptop doesn’t stay in suspend mode; it resumes again immediately. If I close that tab (just that tab; the rest of the browser can remain) then suspend reliably works. A slightly non-ideal circumstance, but perhaps I can find an improvement by one of the other suggestions lower down. I’ll keep reading.