PC lags, then freezes and crashes after waking up from sleep

Greetings,

Been a while, I’ll try to be concise because I write a lot. My PC has been struggling the past weeks. It’s brand new, built by me 3~ weeks ago, and so far it’s great, it runs heavy games and everything else in general very well except when it wakes up from a sleep. It’s random, no matter the duration, but the cursor will lag hard, specially when opening or closing anything like a Konsole window or Brave tab. Things begin to crash, like Desktop Effects and Konsole if it’s open, even if it’s idle. Two or three white blurry lines blink/flicker horizontally across the screen too, and then after a while of using it like that it freezes completely (except audio, that keeps going on just fine) and only a hard reboot might fix it, not always, sometimes I gotta let all this happen 2-3 times in a row like that after rebooting for it to finally work fine (luckily, this has only happened twice, it’d lag after rebooting, and also after installing updates too, prompting me to reboot again or wait until it freezes and crashes again).

I went into full detail about everything in Fedora’s forums here. I give more context, some logs and photos of how the blurry lines look like.

TL;DR, tested these things so far:

  1. Disabled “Dim the Screen Automatically,” “Turn Off the Screen,” and “Screen Locking” one by one.
  2. Disabled “Use Graphics Acceleration when available” in my Brave browser.
  3. Disabled the AMD iGPU and tried 1 & 2 the same way again.
  4. At some point I thought it was SDDM and GDM conflicting with the Login Screen, but I nuked GDM, then disabled SDDM too, but it still happens.
  5. Happens on both GNOME and KDE Plasma 6.

I also encountered this today after running journalctl -b -1 | grep -iE “nvidia|powerdevil|kwin|resume”, which is why I’m here, in case the GPU/driver are the culprits:

The logs after running journalctl --user-unit plasma-kwin_wayland --boot 0 are these:

nvidia-bug-report.log (9.1 KB)


System Info (Fedora 43)

Kernel: 6.17.7-300.fc43.x86_64
Desktop: KDE Plasma 6.5.2 (KWin / Wayland)
GPU: NVIDIA GeForce RTX 5080 — driver 580.95.05 (proprietary)
CPU: AMD Ryzen 7 9800X3D (16 threads @ 5.27 GHz)
Memory: 64 GB DDR5
Swap: 8 GB
Disk: Btrfs, 1.82 TB total (37 % used)
Displays: Dual 4K HDR @ 60 Hz (scaled to 1080p)
Packages: 2647 (rpm) + 75 (flatpak)
Uptime when issue occurs: after resume from suspend (Sleep / mem)

I am a novice software engineer, I can understand some things, but not really much when it comes to Linux, graphics, OS or low-level stuff like these that much yet, but if there is anything I can do or test to further help narrow this down, I will do it and report results.

Update:

I don’t usually like to trust AI, but it led me to this:

"See that last line?

435 MHz, [N/A], P8

That means your GPU’s stuck in P8, which is the lowest bloody power state. It’s basically idling like a half-asleep pensioner, even when the desktop’s trying to render. That’s exactly why KWin keeps whining about “main thread hanging temporarily” — the compositor’s waiting on a GPU that refuses to wake the hell up."

After it told me to run nvidia-smi --query-gpu=clocks.current.graphics,clocks.applications.graphics,pstate --format=csv while the PC was lagging.

It told me to run these, which I trusted because I did a quick google search to confirm what the parameters do:

sudo nvidia-smi -pm 1
sudo nvidia-smi -lgc 2100,2700

If I understand, P0 - P8 are power modes for the GPU, P0 - P2 being full throttle, for gaming/rendering, and P5+ for being idle, or asleep (P8). My GPU would stay in P8 after waking up, at random. The command woke it up (I think it also capped my MHz at 2700 instead of the Max 3090, but I fixed that and still the same); it feels snappier, does not lag when moving the cursor anymore, but it still lags when opening or closing apps like Konsole, browser tabs, etc, even when CPU/GPU usage stays below 5%, same for I/O R/W stuff. It still hasn’t froze, spawned white blurry lines and crashed, it seems it isn’t going to anymore. I rebooted and it got fixed this time, I don’t have to wait for it to crash, I can maybe run the first command (sudo nvidia-smi -pm 1) and reboot whenever it happens, while I see if I can find how to solve the other half of this.

Another update:

While lagging at 100%, it was at P8 - 435MHz. Ran the commands and then it’d show P5 - 2130MHz~, but with lag at 50%. I rebooted and now it shows P0 - 2640 MHz. I’m a little confused, thought P0 was for full gaming/rendering, temperature is at its normal 39C, GPU usage at 0-5%, so, maybe the command is wrong and this whole thing can be fixed by setting it to P0 - 2640 MHz right next time.

Neveremind, I think this is all wrong. Being idle at the desktop should be on P8 with a low MHz like 400. Right now the GPU boosts up to P0 3090MHz when rendering something just fine, so. The commands did partially fix the issue, I will try just the persistence mode (sudo nvidia-smi -pm 1) one next time, it was maybe the caps I already removed by resetting them to their default values.

TL;DR:

Probable temporary solution for now: sudo nvidia-smi -pm 1 while it’s lagging, and reboot if opening/closing apps or browser tabs still lags the PC. Don’t have to wait for it to crash anymore for now, will keep testing.

What are you kernel parameters?

I don’t use Kwin, nor Wayland but my Xorg session would freeze or lag often after wakeup.

Try adding nvidia.NVreg_PreserveVideoMemoryAllocations=0 to your kernel parameters.

Also if wakeup fails, try adding a pre- and post condition in /usr/lib/systemd/system-sleep/

case “$1” in pre) /usr/bin/nvidia-sleep.sh “suspend” ;; post) /usr/bin/nvidia-sleep.sh “resume” ;; esac

Nvm, nothing worked, it still lagged again. I am out of options. There’s also a weird bug now where everything in my browser is treated like text-edit mode, I can put my blinking caret anywhere I want like buttons, text that shouldn’t be edited, or a new page’s background, it’s so weird and persistent. AI says it is because of Kwin’s event loop getting delayed, desync, the UI thinks it’s in “text-edit mode” globally, but I don’t know anymore, I think I will have to boot into a different distro and see if this happens there too.

UPDATE: It’s way worse in Kubuntu somehow. I installed it in a partition, booted it up, let it fall asleep after 15 minutes of gaming, woke it up instantly frozen like this:

Rebooted and this time I clicked “Sleep” myself to test it again. Woke it up, both screen were black, the cursor was visible, but wouldn’t move at all. I finally said “nah, dawg, the electric bill and planet Earth can wait” and gave up. Sorry. I tried @minksven suggestions too, but I think they are exclusive for X11, they didn’t work or allowed me to do them unless I was in X11 instead of Wayland. X11 got removed by Fedora a few months ago.

Ok, actual last try: while checking options in my BIOS, I saw one that said something about waking up being handled by either BIOS or the OS I think, it was set on BIOS, I will test OS… Didn’t fix it, but I discovered that I can suspend it while its lagging instead of waiting for it to crash and then rebooting to get it back to normal, which is a much better temporal alternative.