Skip to content

Opt-in: keep AMD xHCI controllers awake to avoid dead USB after resume - #7641

Closed
VECTORG99 wants to merge 2 commits into
omacom:devfrom
VECTORG99:feat/amd-xhci-wakeup
Closed

VECTORG99 wants to merge 2 commits into
omacom:devfrom
VECTORG99:feat/amd-xhci-wakeup

Conversation

@VECTORG99

Copy link
Copy Markdown

Opt-in udev rule behind omarchy toggle amd-xhci-wakeup; keeps AMD xHCI controllers awake so the broken suspend→resume path (Bugzilla 221073, Ubuntu 2158539) never runs; off by default honoring #6671 (dhh: default-on raises laptop power draw; he asked to document instead — docs side lives in #7631); class-based match (0x0c0330 + vendor 0x1022) avoids device-ID whack-a-mole; sibling of #7044 (same power/control=on + d3cold_allowed=0 for the Intel TB3 xHCI).

Copilot AI balanced review requested due to automatic review settings August 20, 2026 21:13

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed. The opt-in gating is correct — nothing enables this without an explicit toggle — but the mechanism does not appear to fix the bug the PR names, and your own docs PR #7631 says so.

The rule does not address the failure mode. ATTR{power/control}="on" disables runtime power management. It does not stop a full system suspend from running the xHCI driver's suspend/resume callbacks — the controller still goes down and still comes back up through the path that breaks. d3cold_allowed="0" blocks D3cold specifically, but the device can still enter D3hot and still traverses resume. Neither setting touches MSI/MSI-X handling, which is what #7631 identifies as the root cause ("the controller fails to redeliver its MSI/MSI-X interrupts after waking"), and #7631 goes on to say that keeping USB controllers powered "does not fully avoid the broken resume path on long sleeps". So the comment in the rule at install/config/hardware/amd/fix-xhci-resume.sh:19 — "Keep them awake so the broken suspend->resume cycle never runs" — is not accurate, and neither is the command summary's promise to avoid the dead-USB bug. The two PRs tell a user two different stories about the same bug, and by #7631's own account this one is the weaker.

The mechanism reads as borrowed from #7044, but that PR fixes a genuinely different failure: an Intel TB3 controller that runtime-suspends into D3cold after an unplug and never re-enumerates. power/control=on is exactly the right fix there. It is not the same bug.

Detection gate and rule disagree on scope. Line 15 gates on eight hardcoded device IDs while the rule matches by PCI class and claims in its comment to cover "all current and future AMD xHCI device IDs". All eight are real AMD xHCI parts, but the list omits many — 1022:145c (Family 17h), 1022:149c (Matisse), 1022:1557 (Turin), 1022:15d4/15d5 (FireFlight), and the entire 1022:43xx chipset series. On one of those the toggle sets the flag, notifies "enabled", writes no rule, and exits 0.

Reported state can diverge from actual state, in both directions. omarchy-toggle writes the flag and fires the notification before the rule is applied, and nothing in the script checks a result, so an unlisted ID, a declined sudo password, or a failed tee all leave "enabled" on screen with no rule installed. In the other direction, disabling deletes the rule file and reloads, but never writes power/control back to auto or d3cold_allowed back to 1 — the controllers stay awake until reboot while the toggle says disabled. 5783da8 is titled "make toggle reversible"; it removes the rule but does not revert the live devices.

The menu entry is not hardware-gated. bin/omarchy-menu:214 adds "AMD xHCI Wake" unconditionally, while show_hardware_menu a few lines below gates its entries on omarchy-hw-* helpers (:236, :240, :244, :248). An Intel user sees the entry, selects it, gets "AMD xHCI wake fix enabled", and nothing happens.

Two smaller ones. exit 0 at line 12 is in a sourced install script; AGENTS.md says to avoid exit there unless you mean to abort the install. It happens to be contained today because run_logged sources leaves in a separate bash -c and migrations run under bash $file, so this is not a live failure — but it does swallow rm/udevadm failures in the disable branch, and return 0 or a plain if/else would satisfy the rule. And migrations/1787260348.sh is a permanent no-op: nothing creates the flag before it runs, so on every existing install it prints a line about a feature the user has not opted into and then does nothing.

Base branch. This targets dev, which last moved on 2026-08-12; quattro is the default branch and is where everything is landing. On quattro none of the three wiring points in this PR exist any more — install/config/hardware/ is gone (system files ship as tracked files under etc/), bin/omarchy-menu is now a thin IPC wrapper, and the menu is declarative in default/omarchy/omarchy-menu.jsonc. GitHub reports this mergeable into dev; a merge into quattro conflicts in eight files. Worth noting that the JSONC menu has a native "when" guard, which would fix the gating problem above in one field. Your docs PR #7631 already targets quattro.

On #7631. It should land separately, and it can land first. It is self-contained, it names the actual root cause, and it is close to what was asked for on #6671. If this PR lands as written, #7631's text and this toggle contradict each other and the manual would need an edit in the same change.

What was checked. The CLI suite on a disposable VM: ./test/cli does not exist on this branch, so I ran test/omarchy-cli-test.sh, which passed, and confirmed the new command routes (omarchy toggle amd xhci wakeup, and the hyphenated form quoted in your comment, both resolve). The actual suspend/resume behaviour needs affected AMD hardware and cannot be reproduced on a VM — nothing here confirms or refutes that the rule helps on your machine, only that the reasoning about what the two sysfs attributes do points away from it.

A second opinion from codex at xhigh reasoning reviewed the diff independently and reached the same conclusion on the mechanism, the ID gate, the state divergence and the menu gating; its independence is not currently guaranteed, so read that as agreement rather than confirmation. It added one thing on its own: a fresh install never invokes sudo for this feature, because the disabled path only shells out when the rule file already exists.

Nothing was pushed to your branch — the open questions here are yours and the maintainer's to settle, not something a reviewer should patch around. Waiting on you for the mechanism question and the base branch; waiting on the maintainer for whether a menu toggle is wanted at all, given the ask on #6671 was to document instead.

@VECTORG99

Copy link
Copy Markdown
Author

Thank you for this incredibly detailed and instructive review!

You are entirely correct on all counts. The fundamental flaw here was conflating runtime power management (power/control="on") with system suspend callbacks. As you rightly pointed out, forcing the device awake at runtime does nothing to prevent the broken MSI/MSI-X redelivery path during a full system resume. The true fix is the kernel quirk (xhci_hcd.quirks=0x40) documented in #7631.

Additionally, the insights regarding the quattro branch architecture (moving system files to etc/ and transitioning to a declarative JSONC menu) are highly appreciated and good to know for future reference.

Given that #7631 accurately identifies the root cause and provides the actual working fix, I am closing this PR to avoid shipping a placebo mechanism. We will let the documentation PR stand as the definitive solution for this bug.

Thanks again for taking the time to write such a comprehensive technical teardown!

@VECTORG99 VECTORG99 closed this Aug 21, 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

Development

Successfully merging this pull request may close these issues.

3 participants