Live data from Hacker News

I helped fix sleep-wake hangs on Linux with AMD GPUs

nyanpasu64.gitlab.io

201–210 of 218 posts

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#201

Update: I upgraded to an Intel Arc B570 GPU... and ran into the exact same problem on an independent driver: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/4288

Oh hey, another Intel Arc user! I got the LE B580 and so far it's been a pretty good experience for me, though I don't really use suspend. Also I got curious about your blog (haven't heard about Zola, recently migrated my own blog over to a newer version of Grav, which is a flat file CMS with no DB) and saw your post about looking for a new job. Hope things work out for you, stay safe!

All the non-scalped B580s were out of stock by the time I decided to buy a GPU :( Thanks for the moral support!

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#202
post #177
post #167

Earlier quoted context omitted.

Maybe I should have clarified more - I'm using a desktop PC, not a laptop The system seems to go into sleep state just fine, it just freezes when waking up again

Yes, my problem was with an Aorus ATX motherboard too. > The system seems to go into sleep state just fine, it just freezes when waking up again The behavior differs per device. Some sleep but freeze on wakeup, some immediately wakeup after sleeping, and some (like mine) will go to sleep 98% of the way, but the fans keep spinning. That was a dead giveaway for me that the bug was triggered. I suspect that on some syst…

Yiikes, on my B550M DS3H, previously when I woke my PC from sleep immediately after it slept (eg. by pressing the keyboard or case power button), it would "wake" after 0.5 seconds asleep and turn on the power light but not respond to user input, and not even shut down if I held the power button for 4 seconds! I had to pull power at the wall. This behavior occurred on both Windows and Linux, and was fixed at some point in a BIOS update.

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#203
post #159

Props to you for this. I am not clever/experienced enough to solve my own issues with sleep-wake hangs on Linux at work. I’ve instead opted to work around it. I use Firefox, Obsidian, and Tmux with Neovim for all my work. Tmux has resurrect and a plugin that saves my entire terminal state automatically every few minutes. I also have a command that automatically sets up my i3wm/regolith windows exactly how I like. Bas…

Could you link to your i3wm/regolith window setup code? I'd like to set up something similar!

Here we go:

https://github.com/lkdm/dotfiles/blob/main/bin/executable_wk...

Hope it helps you out

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#204

I have a problem similar to what OP faced but with an NVIDIA GPU (RTX 4080). When I wake the computer from suspend, the computer will usually wake up, show me the timestamp changing on the lock screen. But sometimes randomly, the timestamp will not change the the screen will freeze on the old timestamp. After this, it is either REISUB or hard reset. @nyanpasu64, do you think enabling nvidia-suspend/nvidia-resume serv…

I would try both nvidia-suspend enabled and disabled; https://forums.developer.nvidia.com/t/fixed-suspend-resume-i... suggests turning it off, but I'd try with it both on and off.

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#205
post #192

Earlier quoted context omitted.

> two problems ... overcommit Is there any other sensible way to do this though? It would be quite inefficient to constantly call mmap for additional small(ish) pieces of memory. In effect overcommit just means that until the page is actually written to it hasn't really been allocated. (Aside: I believe a malloc implementation that zero'd out blocks on allocation would fail abruptly rather than later in case that hap…

A potential workaround would be to still allow giant mmaps but not hang a program when it runs out of pages and instead send a signal to it. Obviously, neither Chrome nor Firefox actually use this much memory in practice.

Rather than a workaround I think that would just be an overall better approach. Receive an actionable error when the allocation happens "for real", whether that's at an arbitrary point in user code or when malloc zeros out the block ahead of time.

However I think you'd need per-thread signal handlers for that to work sensibly. Which the kernel supports (see man 2 clone) but would require updates to (at least) posix and glibc.

It would probably also be nice to have a way to allocate pages without writing to them. Currently we have mlock but that prevents swapping which isn't desirable in this context.

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#206
post #168
post #107

Earlier quoted context omitted.

This is not my experience. My M1 Pro MacBook has very strange issues with sound over HDMI. I usually need to reboot it when I connect it to my TV or media won't play if the sound is output over HDMI.

That's annoying but could also be caused by the monitor or TV HDMI implementation.

I don't think so. In that state, video will jump and stutter wildly, run very fast, and audio will be very broken. It's not just the sound that's affected.

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#207
post #83
post #52

Earlier quoted context omitted.

Because they own the now hardware, and MacOS iOS run exclusively on their hardware Source: I work on windows power management and I know system engineers at apple.

That's the often repeated argument. But as a counter point you have the Google Pixel. Google owns the hardware, even the SoC, and the software. And yet, battery is still poorer than third party Android phone manufacturers. And let's not even compare to Apple. So controlling the entire stack isn't enough. There has to be a desire to do better, as well as technical competency.

It's mostly unrelated to the platform "mastering" sleep/wakeup, those work really well on Linux as used in Android.

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#208
post #176
post #162

Earlier quoted context omitted.

Wow, thanks for this tip! I've been dealing with suspend issues with an X570 Aorus Master as well. Running `echo GPP0 >> /proc/acpi/wakeup` into a systemd unit at boot solved the issue for me... except the first sleep after a boot would always wake back up immediately. I applied your udev rule and that issue seems to be resolved as well!

This is more so for your future unit file use: did you use `Type=oneshot` and `RemainAfterExit=yes`? I remember there being some strange interaction with the wakeup behaviour being toggled otherwise. But this could be due to me being on NixOS.

I just did `ExecStart` with `multi-user.target`. That implies the unit is `simple`, so it very well could be sequencing incorrectly at boot and failing. That's a good point; I'll have to keep that in mind!

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#209
Has anyone tried the AMD suspend/resume patches that Alibaba? https://lists.freedesktop.org/archives/amd-gfx/2025-January/...

"We have tried to solve these issues case by case, but found that may not be the right way. Especially about the unbalanced irq reference count, there will be new issues appear once we fixed the current known issues. After analyzing related source code, we found that there may be some fundamental implementation flaws behind these resource tracking issues.

So we try to fix those issues by two enhancements/refinements to current device management state machines."

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#210
post #208
post #176

Earlier quoted context omitted.

This is more so for your future unit file use: did you use `Type=oneshot` and `RemainAfterExit=yes`? I remember there being some strange interaction with the wakeup behaviour being toggled otherwise. But this could be due to me being on NixOS.

I just did `ExecStart` with `multi-user.target`. That implies the unit is `simple`, so it very well could be sequencing incorrectly at boot and failing. That's a good point; I'll have to keep that in mind!

Apologies for the confusion, I don't mean it was failing to run.

If you don't add "RemainAfterExit", the service will run at every boot, because after a reboot it is considered "inactive. This will execute your shell code, which effectively toggles wakeup.

"RemainAfterExit" is meant for unit files that change the state of your system. After running once, the service will be considered "active", until you manually deactivate it, which will execute whatever you might have set in "ExecStop".

"Type=Oneshot" is necessary for "RemainAfterExit".

In this case I still would prefer doing it via udev though. I've made it my rule of thumb to evade shell scripting wherever feasible, because it usually ends up being more brittle, and more prone to footgunning :)

Post reply on HN