[SOLVED] Using Linux QEMU/KVM causes s2idle hard freeze on Arch - Linux 6.10.8

Which Linux distro are you using?

Arch

Which release version?
7th September

Which kernel are you using?
6.10.8

Which BIOS version are you using?
03.05

Which Framework Laptop 13 model are you using? (AMD Ryzen™)

I’ve been trying to track this down… A s2idle suspend hard freezes my system when using QEMU with KVM acceleration.

Easy to repro… start qemu-system-x86_64 --accel kvm and try to suspend… Hard freeze… 10 second salute.

Nothing exotic… No extra kernel params.

How do you reproduce?

❯ uname -r
6.10.8-2-cachyos
❯ qemu-system-x86_64 --accel kvm

And then in another tab I ran a suspend sequence test and hit no problem.

❯ sudo ~/src/amd/scripts/amd_s2idle.py
Location of log file (default s2idle_report-2024-09-06.txt)? 
Debugging script for s2idle on AMD systems
💻 Framework Laptop 13 (AMD Ryzen 7040Series) (Laptop) running BIOS 3.5 (03.05) released 03/29/2024 and EC unknown
🐧 CachyOS
🐧 Kernel 6.10.8-2-cachyos
🔋 Battery BAT1 (NVT Framewo) is operating at 100.17% of design
Checking prerequisites for s2idle
✅ Logs are provided via systemd
✅ AMD Ryzen 5 7640U w/ Radeon 760M Graphics (family 19 model 74)
✅ SMT enabled
✅ LPS0 _DSM enabled
✅ ACPI FADT supports Low-power S0 idle
✅ HSMP driver `amd_hsmp` not detected (blocked: False)
✅ PMC driver `amd_pmc` loaded (Program 0 Firmware 76.82.0)
✅ USB4 driver `thunderbolt` bound to 0000:c3:00.5
✅ USB4 driver `thunderbolt` bound to 0000:c3:00.6
✅ GPU driver `amdgpu` bound to 0000:c1:00.0
✅ System is configured for s2idle
✅ NVME Sandisk Corp WD Black SN770 / PC SN740 256GB / PC SN560 (DRAM-less) NVMe SSD is configured for s2idle in BIOS
✅ GPIO driver `pinctrl_amd` available
How long should suspend cycles last in seconds (default 10)? 
How long to wait in between suspend cycles in seconds (default 4)? 
How many suspend cycles to run (default 1)? 
Started at 2024-09-06 23:36:00.277079 (cycle finish expected @ 2024-09-06 23:36:14.277092)
Results from last s2idle cycle
○ Suspend count: 1
○ Hardware sleep cycle count: 1
○ Wakeup triggered from IRQ 9: ACPI SCI
○ Woke up from IRQ 9: ACPI SCI
○ gpe0B increased from 146 to 160
✅ Userspace suspended for 0:00:12.503340
✅ In a hardware sleep state for 0:00:08.396301 (67.15%)
🔋 Battery BAT1 (NVT Framewo) is operating at 100.17% of design
1 Like

You’ve got no guests running? I’m guessing maybe there might be more to reproductio in steps

Curious, it’s not reproducible with that tool, but does happen with systemctl suspend

Here’s the tool output anyway.

Aha!

Some systemd change… this is the fix [SOLVED] System freezes after sleep since update / Newbie Corner / Arch Linux Forums
Not sure what side-effect this has on battery life.

Not hardware related at all, sorry!

3 Likes
1 Like

I think this really boils down to systemd exposed a kernel bug. There will be tension for a while until the kernel is fixed or systemd withdraws this change.

2 Likes

Do you think the workaround has any adverse effects?

FYI also needed

[Service]
Environment="SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=false"

in

/etc/systemd/system/systemd-hibernate.service.d/disable_freeze_user_session.conf

or hibernate has the same behavior.

1 Like

and


cp -rv /etc/systemd/system/systemd-suspend.service.d/ /etc/systemd/system/systemd-suspend-then-hibernate.service.d/

Annoying whackamole

On the systemd bug they say it should be fixed in 6.11. Can you upgrade to 6.11-rc7 and confirm?

Should get time later today UTC+1

6.11.0-rc7 still has the problem(without the workaround)

Can you share to the systemd ticket? They seem to think it would be fixed.

1 Like

The work around suggested by @David_Markey still works today :slight_smile:
Just to summarize it in a single place:

# as root
mkdir /etc/systemd/system/systemd-suspend.service.d \
      /etc/systemd/system/systemd-hibernate.service.d \
      /etc/systemd/system/systemd-suspend-then-hibernate.service.d \
      /etc/systemd/system/systemd-hybrid-sleep.service.d

cat <<EOF > /etc/systemd/system/systemd-suspend.service.d/disable_freeze_user_session.conf
[Service]
Environment="SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=false"
EOF

cp /etc/systemd/system/systemd-suspend.service.d/disable_freeze_user_session.conf /etc/systemd/system/systemd-hibernate.service.d/
cp /etc/systemd/system/systemd-suspend.service.d/disable_freeze_user_session.conf /etc/systemd/system/systemd-suspend-then-hibernate.service.d/
cp /etc/systemd/system/systemd-suspend.service.d/disable_freeze_user_session.conf /etc/systemd/system/systemd-hybrid-sleep.service.d/

This is a very annoying bug, that has plagued me for a long time, at times the suspend worked and at times it would freeze my system. I’m running VMs in Qemu using gnome-boxes and by the time I’ve noticed that that VM has something to do with the freezes… Anyway thanks to this thread I managed to apply the workaround and can now again suspend and hibernate my system. Thank you!

1 Like

You’re welcome.

From user session fails to resume from suspend when user is using NFS or KVM · Issue #33083 · systemd/systemd · GitHub

The fix is in 6.13 (which is still a RC right now), and in >=6.12.2 and >=6.11.11.

Doing a pacman -Syu and upgrading from 6.12.1 to 6.12.4 seems to have fixed the issue for me.

(Sorry about the screenshot, I couldn’t figure out how to copy-paste multiple comments on GitHub ^^")