Skip to content

Refine ASUS suspend fixes: RTC ACPI alarm, DDR5 spd5118 blacklist, and conditional S3 - #9816

Closed
gladimdim wants to merge 3 commits into
omacom:quattrofrom
gladimdim:fix/asus-rog-deep-sleep
Closed

gladimdim wants to merge 3 commits into
omacom:quattrofrom
gladimdim:fix/asus-rog-deep-sleep

Conversation

@gladimdim

@gladimdim gladimdim commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On modern ASUS laptops (ROG, TUF, ZenBook, ExpertBook), sleep and wake behavior require several firmware-level workarounds under Linux:

  1. RTC Alarm Deadlock / Wake Failures: ASUS motherboards route the RTC CMOS alarm through ACPI Fixed Event handlers rather than legacy IRQ 8. Without rtc_cmos.use_acpi_alarm=1, timer wakeups either fail to fire or hang during suspend entry/exit.
  2. DDR5 SMBus Suspend/Resume Freezes: On systems with DDR5 memory (such as ASUS ROG Strix G834JZ), spd5118 encounters firmware write-protection during async resume (spd5118 ... returns -6 / ENXIO), locking the SMBus and freezing suspend transitions.
  3. Broken Lid-Open Wake in ACPI S3 (deep):
    • While modern ASUS UEFI firmware often still advertises ACPI S3 (deep) in /sys/power/mem_sleep, ASUS dropped ACPI S3 GPE wake routing for the lid switch (LID0 lacks _PRW and is absent from /proc/acpi/wakeup) in favor of Microsoft Modern Standby (s2idle).
    • Forcing MemorySleepMode=deep or mem_sleep_default=deep on these machines means opening the lid cannot wake the laptop at all.
    • Furthermore, resuming discrete NVIDIA GPUs from S3 on these hybrid platforms frequently fails ACPI D-notifier transitions (status=0x11), producing black screens.

Solution

  1. Added install/hardware/asus/fix-deep-sleep.sh and wired it into install/hardware/all.sh.
  2. RTC Alarm: Always configures rtc_cmos.use_acpi_alarm=1 via /etc/limine-entry-tool.d/asus-rtc-alarm.conf on all ASUS systems.
  3. DDR5 Fix: Blacklists spd5118 via /etc/modprobe.d/spd5118.conf if the module/driver is present, eliminating SMBus bus locks and suspend/resume freezes.
  4. Conditional S3 Deep Sleep:
    • Only configures MemorySleepMode=deep and mem_sleep_default=deep if both grep -qw "deep" /sys/power/mem_sleep and grep -qi "LID" /proc/acpi/wakeup are satisfied.
    • If the lid switch lacks ACPI S3 wake capability (as on modern ROG Strix and other Modern Standby-first ASUS laptops), defaults to s2idle where lid-open wake is fully functional, and cleans up any stale S3 overrides that break lid-open wake.

Update 2026-09-06: the system-sleep hooks were never executable

A critical-battery suspend-then-hibernate on this ROG Strix G834JZ (upowerd at 1 %, so systemd-sleep skipped the suspend leg and hibernated directly) ended with a 10 s power-button hold. Two separate defects were involved; the second commit here fixes the one in this PR's scope.

  1. Sleep hooks installed 644. default/systemd/system-sleep/keyboard-backlight and force-igpu were committed as 644 and omarchy-hibernation-setup / omarchy-toggle-hybrid-gpu copied them with cp -p, so systemd-sleep silently skipped both (/usr/lib/systemd/system-sleep/keyboard-backlight was -rw-r--r-- on this machine). keyboard-backlight exists precisely to stop the ASUS keyboard controller from blocking S4 power-off (hibernation setup installs keyboard-backlight system-sleep hook non-executable, so it never runs #7618). Since this PR was opened, quattro (feb0557) made both installers install the hooks root-owned 0755, so the installer edits were dropped when rebasing. What remains: the hooks are executable in the repo, and migration 1788695343 makes existing root-owned 644 copies executable. Upstream's 1788662350 only replaces copies a user could write, and cp -p from the root-owned packaged source produced root-owned 644 copies, so those were left inert.
  2. Resume from the hibernation image is discarded on hybrid NVIDIA laptops because install/hardware/nvidia.sh early-loads nvidia in the initramfs (nv_pmops_freeze returns -5 → PM: hibernation: resume failed (-5)). That is Hibernation resume fails on hybrid Intel+NVIDIA laptops — nvidia.sh's early-KMS module bundling races the resume hook #8352 / Hibernate resume fails (nv_pmops_freeze → -EIO) on single-NVIDIA-GPU desktops — initramfs nvidia load blocks the resume hook #10039 and is fixed generically by Stop early-loading the NVIDIA driver on hybrid GPU machines so hibernation can resume #8263; this PR intentionally does not duplicate it. Together they make battery sleep survivable on ROG Strix hybrids.

Update 2026-10-02: scope keyboard-backlight to ASUS and restore it on resume (#12657)

Making the old hook copies executable would have spread #12657: the hook zeroed the first *kbd_backlight* LED of any vendor before hibernate and never restored it, so a ThinkPad's keyboard stayed dark after resume and, once systemd-backlight saved the 0, after reboots too. The third commit:

  • only touches asus*::kbd_backlight* LEDs, the ones with the S4 hang;
  • saves their brightness in /run (part of the hibernation image) and restores it on post;
  • makes the migration replace installed copies that still match a shipped version (both fingerprints), while keeping customized copies;
  • adds tests for suspend vs hibernate, non-ASUS LEDs, restore, suspend-then-hibernate, and the migration, and updates the compound-sleep check in system-sleep-ownership-migration-test.sh to the new interface.

Tested on the ROG Strix G834JZ (asus::kbd_backlight): running the hook as root, pre hibernate saved brightness 2 and set the LED to 0, and post hibernate restored 2 and removed the state. That was the hook run by hand, not a full hibernate cycle. system-sleep-hooks-test.sh and system-sleep-ownership-migration-test.sh pass. ./test/shell has 9 other failing files that fail identically on quattro (environment-dependent).

Fixes #12657
Fixes #7618

@gladimdim
gladimdim force-pushed the fix/asus-rog-deep-sleep branch from 3bfeb5b to 139fb29 Compare September 2, 2026 18:46
@gladimdim gladimdim changed the title Configure S3 deep sleep on ASUS ROG when supported by firmware Configure S3 deep sleep and RTC ACPI alarm on ASUS laptops when supported by firmware Sep 2, 2026
@gladimdim
gladimdim force-pushed the fix/asus-rog-deep-sleep branch from 139fb29 to 3ac6854 Compare September 4, 2026 08:49
@gladimdim gladimdim changed the title Configure S3 deep sleep and RTC ACPI alarm on ASUS laptops when supported by firmware Refine ASUS suspend fixes: RTC ACPI alarm, DDR5 spd5118 blacklist, and conditional S3 Sep 4, 2026
@gladimdim
gladimdim force-pushed the fix/asus-rog-deep-sleep branch from 3ac6854 to 3c7c5ab Compare September 6, 2026 11:51
gladimdim and others added 2 commits October 2, 2026 17:32
…d conditional S3

- Route RTC alarm via ACPI Fixed Event handlers (rtc_cmos.use_acpi_alarm=1)
  on all ASUS motherboards to prevent RTC alarm wake hangs.
- Blacklist spd5118 DDR5 SPD temperature sensor driver to avoid async resume
  failures and SMBus lockups on DDR5 systems.
- Only configure S3 (deep) sleep if firmware exposes "deep" in
  /sys/power/mem_sleep AND the lid switch is registered as an ACPI wakeup device
  in /proc/acpi/wakeup. Modern ASUS laptops (such as ROG Strix) drop S3 GPE wake
  routing for the lid switch in favor of Modern Standby (s2idle), leaving
  lid-open wake completely broken in S3 deep sleep, and cause black screens
  due to failed ACPI D-notifier transitions on discrete NVIDIA GPUs.
- Clean up any stale deep sleep drop-ins when S3 lid wake is unsupported so
  systemd and the kernel default to s2idle.
… them

omarchy-hibernation-setup and omarchy-toggle-hybrid-gpu used to copy
keyboard-backlight and force-igpu into /usr/lib/systemd/system-sleep with
cp -p from files committed as 644. systemd-sleep only executes files with
the executable bit, so both hooks were silently skipped: the keyboard LEDs
stayed lit into S4, which keyboard-backlight exists to prevent on ASUS
keyboards, and force-igpu never detached the dGPU before hibernate.

Seen on an ASUS ROG Strix G834JZ, where a critical-battery
suspend-then-hibernate went straight to hibernate and the machine had to be
power-cycled: /usr/lib/systemd/system-sleep/keyboard-backlight was
-rw-r--r--.

The installers now install the hooks 0755, and migration 1788662350
replaces copies a user could write. It leaves root-owned copies alone,
which is what cp -p from the root-owned packaged source produced, so those
stay 644. Add a migration that makes them executable, mark the hooks
executable in the repo, and cover both with a shell test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@gladimdim
gladimdim force-pushed the fix/asus-rog-deep-sleep branch from 3c7c5ab to 9e6d565 Compare October 2, 2026 14:48
@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 1/5

[High risk] Modifies system sleep hooks and adds hardware-specific kernel parameters.

The PR does not appear safe to merge while the outstanding ASUS sleep-selection and deployment defects remain.

Findings

  1. P1 Existing ASUS systems miss fixes ▶
  2. P1 Boot settings remain unchanged ▶
  3. P1 Disabled lid wake selects deep ▶
  4. P1 Desktop sleep override removed ▶
  5. P2 Brightness can remain off ▶
  6. P2 Blacklist affects unaffected machines ▶
  7. P2 Production repair path untested ▶

Summary

The PR adds ASUS sleep configuration and makes installed system-sleep hooks executable. The latest changes narrow keyboard-backlight handling to ASUS LEDs, save and restore their brightness around hibernation, and replace recognized legacy hooks during migration.

  • A failed brightness save can leave an ASUS keyboard dark after resume.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Hibernate pre-hook] --> B[Save ASUS LED brightness]
  B --> C[Set brightness to zero]
  C --> D[Hibernate]
  D --> E[Post-hook restores brightness]
  F[Update migration] --> G[Replace recognized legacy hook]
  G --> H[Make installed hooks executable]
Loading

Reviews (2) · Last reviewed commit: "Scope the keyboard-backlight sleep hook ..."

Comment thread install/hardware/all.sh
run_logged "$OMARCHY_INSTALL/hardware/asus/fix-asus-ptl-b9406-display.sh"
run_logged "$OMARCHY_INSTALL/hardware/asus/fix-asus-ptl-b9406-touchpad.sh"
run_logged "$OMARCHY_INSTALL/hardware/asus/fix-z13-touchpad.sh"
run_logged "$OMARCHY_INSTALL/hardware/asus/fix-deep-sleep.sh"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Existing ASUS systems miss fixes
On an existing ASUS installation, a normal omarchy update runs migrations but does not rerun the hardware stage. This script is only called from that stage, while the new migration only repairs hook permissions. Updating therefore does not apply the RTC alarm, spd5118, or sleep-mode fixes to existing machines.

Knowledge Base Used:

Comment on lines +38 to +41
# ASUS motherboards route RTC alarm via ACPI Fixed Event handlers
KERNEL_CMDLINE[default]+=" rtc_cmos.use_acpi_alarm=1"
EOF

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Boot settings remain unchanged
Writing these Limine fragments does not regenerate the boot entries, and the hardware stage does not run limine-mkinitcpio afterward. After a standalone hardware rerun, the RTC parameter remains absent from the boot entry, and a removed stale mem_sleep_default=deep setting can remain active until an unrelated rebuild.

Knowledge Base Used: Hardware, devices, and power


# 3. Check for ACPI S3 deep sleep support AND lid wake capability
has_s3=$(grep -qw "deep" /sys/power/mem_sleep 2>/dev/null && echo true || echo false)
has_lid_s3_wake=$(grep -qi "LID" /proc/acpi/wakeup 2>/dev/null && echo true || echo false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Disabled lid wake selects deep
If LID0 appears in /proc/acpi/wakeup with status *disabled, this grep still reports working lid wake. The script then forces deep, leaving that laptop unable to wake when its lid is opened.


# 3. Check for ACPI S3 deep sleep support AND lid wake capability
has_s3=$(grep -qw "deep" /sys/power/mem_sleep 2>/dev/null && echo true || echo false)
has_lid_s3_wake=$(grep -qi "LID" /proc/acpi/wakeup 2>/dev/null && echo true || echo false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Desktop sleep override removed
If an ASUS desktop has working S3 and an existing 10-mem-sleep-deep.conf override, it has no lid entry for this check to find. The script therefore deletes the override and changes the desktop's sleep mode, although lid-open wake is not relevant to that machine.

Knowledge Base Used: Hardware, devices, and power

Comment on lines +43 to +49
if lsmod | grep -qw "spd5118" 2>/dev/null || modinfo spd5118 >/dev/null 2>&1; then
mkdir -p /etc/modprobe.d
cat > /etc/modprobe.d/spd5118.conf <<'EOF'
# Prevent spd5118 async resume failures and SMBus lockups on DDR5 systems
blacklist spd5118
EOF
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Blacklist affects unaffected machines
modinfo spd5118 shows that the kernel ships the driver, not that this ASUS machine has the SMBus suspend defect. On unaffected ASUS systems with DDR5, this check still blacklists the driver, unnecessarily removing DIMM temperature telemetry.

Knowledge Base Used: Hardware, devices, and power

Comment on lines +30 to +35
mkdir -p "$tmp_dir/system-sleep"
install -m644 "$hooks_dir/keyboard-backlight" "$tmp_dir/system-sleep/keyboard-backlight"
install -m644 /dev/null "$tmp_dir/system-sleep/unrelated"

OMARCHY_SYSTEM_SLEEP_DIR="$tmp_dir/system-sleep" bash -euo pipefail "$ROOT/migrations/1788695343.sh" >/dev/null ||
fail "migration completes on a 644 hook"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Production repair path untested
The test creates a user-owned hook, so it exercises only the direct chmod branch. The migration's intended repair of a root-owned, nonexecutable hook uses sudo chmod instead. Without a test for that path, the actual upgrade repair could regress unnoticed.

Knowledge Base Used: Migration framework

The hook zeroed the first *kbd_backlight* LED before hibernate and had no
post branch, so on non-ASUS laptops (tpacpi::kbd_backlight on a ThinkPad)
the keyboard stayed dark after resume, and systemd-backlight then saved
the 0 so it stayed dark after reboots too (omacom#12657).

Only touch asus*::kbd_backlight* LEDs, which are the ones with the S4
hang, save their brightness in /run (part of the hibernation image), and
put it back on post. The migration now replaces installed copies that
still match a shipped version, so making old copies executable no longer
spreads the bug.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment on lines +18 to +19
cat "$led/brightness" >"$state_dir/${led##*/}"
echo 0 >"$led/brightness"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Brightness can remain off

If saving an ASUS keyboard’s brightness fails—for example, because /run is full—the hook still sets the LED to 0 and exits successfully. It then has no valid brightness to restore on resume, so the keyboard can remain dark. Save the prior value successfully before turning the LED off.

Knowledge Base Used: Hardware, devices, and power

@gladimdim

Copy link
Copy Markdown
Contributor Author

Closing this. The sleep-hook fixes moved to #14066, and re-checking the ASUS sleep configuration against the review left nothing in it that should merge:

  • spd5118 blacklist. The journal on the G834JZ (kernel 7.1.11) does show spd5118_resume returns -6 / failed to resume async: error -6 on both DIMMs, but both times the system kept running for hours afterwards. What failed was the DIMM temperature sensor, not suspend or the SMBus, so blacklisting it, and on every ASUS machine since modinfo always succeeds, isn't justified.
  • rtc_cmos.use_acpi_alarm=1. rtc-cmos already enables the ACPI alarm by itself on Intel firmware from 2015 on and AMD from 2021 on (use_acpi_alarm_quirks()), and deliberately doesn't where the FADT sets FIXED_RTC. Forcing it changes nothing on current ASUS machines and overrides that check on the rest.
  • Conditional S3. Omarchy has never set deep sleep on ASUS: nothing in quattro's history writes MemorySleepMode=deep, 10-mem-sleep-deep.conf or mem-sleep.conf. The lid-wake breakage that motivated this came from local overrides on my machine. That leaves a script that would force deep on some ASUS machines with no evidence it helps, and delete files Omarchy never created (Greptile's points 3 and 4). Fixing the deployment gaps (points 1 and 2) would only spread that further.

Thanks to the reviewers. If S3 on a specific ASUS model turns out to need a fix, it'll come as a narrow PR with logs from that machine.

@gladimdim gladimdim closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant