Skip to content

Commit

Permalink
article: how i fixed hibernation on my nixos machine
Browse files Browse the repository at this point in the history
  • Loading branch information
hmajid2301 committed May 27, 2024
1 parent 22bf536 commit 3c900c0
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,3 @@ It wasn't the most elegant solution, but as I said earlier it works well enough

## Appendix
- [My Hugo Blog](https://gitlab.com/hmajid2301/blog)
- [Example source code](https://gitlab.com/hmajid2301/blog/-/tree/main/content/posts/2024-05-26-how-to-add-hugo-revealjs-to-a-hugo-site/source_code)
Empty file.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Submodule ananke deleted from 33fbda
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
title: "How I Fixed Hibernate on My NixOS Machine"
date: 2024-05-27
canonicalURL: https://haseebmajid.dev/posts/2024-05-27-how-i-fixed-hibernation-on-my-nixos-machine
tags:
- hibernate
- drivers
- nixos
cover:
image: images/cover.png
---


{{< notice type="info" title="tl:dr;" >}}
Wi-Fi drivers were stopping the PC from suspending. I am using an Ethernet cable to connect my PC. So didn't need the
Wi-Fi drivers. By adding them to a blocklist. I think you only need the 2nd one in the list.

```nix
{
boot.blacklistedKernelModules = [
"ath12k_pci"
"ath12k"
];
}
```
{{< /notice >}}


Recently, I upgraded my PC to an am5 machine with an X670E Gigabyte motherboard. However, when I did this hibernate
was left broken, alongside suspend. This gave me an idea, it wasn't to do with my hibernate setup being broken by something
else going on.

So I started debugging, looking at the systemd logs which we can use `journalctl` service. Specifically, the `journal -f`
command to tail all the logs. Then in another terminal I ran `systemctl hibernate`

```bash
Apr 22 06:06:53 workstation kernel: ath12k_pci 0000:0f:00.0: failed to suspend core: -95
22 06:06:53 workstation kernel: ath12k_pci 0000:0f:00.0: PM: pci_pm_freeze(): ath12k_pci_pm_suspend+0x0/0x50 [ath12k] returns -95
22 06:06:53 workstation kernel: ath12k_pci 0000:0f:00.0: PM: dpm_run_callback(): pci_pm_freeze+0x0/0xc0 returns -95
22 06:06:53 workstation kernel: ath12k_pci 0000:0f:00.0: PM: failed to freeze async: error -95
22 06:06:53 workstation kernel: nvme nvme1: Shutdown timeout set to 10 seconds
22 06:06:53 workstation kernel: nvme nvme1: 8/0/0 default/read/poll queues
22 06:06:53 workstation kernel: nvme nvme1: Ignoring bogus Namespace Identifiers
22 06:06:53 workstation kernel: PM: hibernation: Basic memory bitmaps freed
22 06:06:53 workstation kernel: OOM killer enabled.
22 06:06:53 workstation kernel: Restarting tasks ... done.
22 06:06:53 workstation kernel: PM: hibernation: hibernation exit
22 06:06:53 workstation systemd-sleep[11861]: Failed to put system to sleep. System resumed again: Operation not supported
22 06:06:53 workstation systemd[1]: systemd-hibernate.service: Main process exited, code=exited, status=1/FAILURE
22 06:06:53 workstation systemd[1]: systemd-hibernate.service: Failed with result 'exit-code'.
22 06:06:53 workstation systemd[1]: Failed to start System Hibernate.
22 06:06:53 workstation systemd[1]: Dependency failed for System Hibernation.
22 06:06:53 workstation systemd[1]: hibernate.target: Job hibernate.target/start failed with result 'dependency'.
```

These logs provide us with a bunch of useful information, we can see that the hibernate job failed.

```bash
22 06:06:53 workstation kernel: PM: hibernation: Basic memory bitmaps freed
22 06:06:53 workstation kernel: OOM killer enabled.
22 06:06:53 workstation kernel: Restarting tasks ... done.
22 06:06:53 workstation kernel: PM: hibernation: hibernation exit
22 06:06:53 workstation systemd-sleep[11861]: Failed to put system to sleep. System resumed again: Operation not supported
22 06:06:53 workstation systemd[1]: systemd-hibernate.service: Main process exited, code=exited, status=1/FAILURE
22 06:06:53 workstation systemd[1]: systemd-hibernate.service: Failed with result 'exit-code'.
22 06:06:53 workstation systemd[1]: Failed to start System Hibernate.
22 06:06:53 workstation systemd[1]: Dependency failed for System Hibernation.
22 06:06:53 workstation systemd[1]: hibernate.target: Job hibernate.target/start failed with result 'dependency'.
```

However, I could not find an exact reason within the job itself. After trying numerous random things, I looked closer
at the logs above and noticed the mention of the Wi-Fi drivers `ath12k_pci` failing to suspend.

```bash
Apr 22 06:06:53 workstation kernel: ath12k_pci 0000:0f:00.0: failed to suspend core: -95
22 06:06:53 workstation kernel: ath12k_pci 0000:0f:00.0: PM: pci_pm_freeze(): ath12k_pci_pm_suspend+0x0/0x50 [ath12k] returns -95
22 06:06:53 workstation kernel: ath12k_pci 0000:0f:00.0: PM: dpm_run_callback(): pci_pm_freeze+0x0/0xc0 returns -95
22 06:06:53 workstation kernel: ath12k_pci 0000:0f:00.0: PM: failed to freeze async: error -95
```

This then gave me the idea to try to add the drivers to the blocklist and see if that resolves the issue. Like so:


```nix
{
boot.blacklistedKernelModules = [
"ath12k_pci"
"ath12k"
];
}
```

That's it! Hibernate and suspend are now working. Of course, the downside now for my desktop I cannot use the Wi-Fi
built into my motherboard. But that's an issue for another day, currently I have it connected via an Ethernet cable.
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ buildExpired = false
enableEmoji = true
ignorefiles = ["content/slides"]

[[module.mounts]]
source = "content/posts"
target = "content/posts"
excludeFiles = "source_code/*"


[markup.highlight]
noclasses = false

Expand Down

0 comments on commit 3c900c0

Please sign in to comment.