Repository navigation
Conversation
|
Thanks @malik-na, this is a useful port. A few things need changing before merge:
For release (not the source merge): a real lid-close resume through the unit on both BCM4387 and BCM4388. |
Review of #21: - A wants link under /usr/lib/systemd/system/suspend.target.wants runs the unit after every suspend on installs and upgrades alike, as the audio watchdog's link does, so Macs that only update get it. System setup no longer enables it, so a Bluetooth detection failure can no longer stop the speaker and launcher setup after it. Turning it off is a mask. - The watch starts from this suspend's entry: the kernel counts suspend attempts in /sys/power/suspend_stats, and the command waits up to 10 s for journald to hold that entry before taking its cursor, so an earlier cycle's timeouts are never read as this one's. Without it, it watches a bounded window from now. Journal reads stay within this boot. - A suspend during the 20 s watch moves it to the newer resume and restarts the watch: systemd will not start the unit again while it runs. - Hibernation is dropped from the unit; Apple Silicon Macs don't hibernate. - The README, manual and messages say what was seen (an HCI command timeout) instead of claiming a confirmed wedge or a healthy controller. - Tests: a fixture journal that changes over time covers timeouts after an earlier cycle's entry, a lagging journal, an entry that never arrives, a second suspend during the watch, hci0 leaving on unbind and returning on bind (or not), and setup finishing after a Bluetooth detection failure.
|
Thanks @maralcbr. Changes in 1a499ff:
Tested:
No wedge occurred, so the rebind itself is covered only by the tests. Still needed for release: lid-close resumes on BCM4387 and BCM4388. |
|
Thanks @malik-na, this is really careful work. You covered all five of @maralcbr's points, and the logic holds up. Anchoring the watch on the It can't land as is, though, now that #26 has merged and moved main underneath it. Notes against 1a499ff: Blocking
Smaller
Hardware I can be one of the two test machines you still need. My MacBook Pro 14" M2 Max (J414c) has a BCM4388: Bluetooth at 01:00.1 is If you'd rather I push the rebase myself, I'm happy to. The branch is in this repo, so just say the word. |
Review of #21: - A wants link under /usr/lib/systemd/system/suspend.target.wants runs the unit after every suspend on installs and upgrades alike, as the audio watchdog's link does, so Macs that only update get it. System setup no longer enables it, so a Bluetooth detection failure can no longer stop the speaker and launcher setup after it. Turning it off is a mask. - The watch starts from this suspend's entry: the kernel counts suspend attempts in /sys/power/suspend_stats, and the command waits up to 10 s for journald to hold that entry before taking its cursor, so an earlier cycle's timeouts are never read as this one's. Without it, it watches a bounded window from now. Journal reads stay within this boot. - A suspend during the 20 s watch moves it to the newer resume and restarts the watch: systemd will not start the unit again while it runs. - Hibernation is dropped from the unit; Apple Silicon Macs don't hibernate. - The README, manual and messages say what was seen (an HCI command timeout) instead of claiming a confirmed wedge or a healthy controller. - Tests: a fixture journal that changes over time covers timeouts after an earlier cycle's entry, a lagging journal, an entry that never arrives, a second suspend during the watch, hci0 leaving on unbind and returning on bind (or not), and setup finishing after a Bluetooth detection failure.
1a499ff to
2e4c968
Compare
|
Thanks @scottjones, this is all fixed and the branch is rebased on Blocking
Smaller
Not yet run: I rebased and made these changes on macOS, which can't run the suites, so Hardware: yes please, and thank you. Your BCM4388 lid-close resume through the unit, plus the manual unbind/bind of 01:00.1 with Wi-Fi up, would cover that chip. BCM4387 still needs a tester. No need to push the rebase; it's done. |
|
Thanks for the rebase, @malik-na. Here are the BCM4388 results from my 14" M2 Max (J414c, Bluetooth Without the fix
With the fix I installed 4m27s sleep: hci0 hung again at resume, and the unit caught it. No timeouts after that. Wi-Fi reconnected normally and the speaker reconnected by itself. A second lid close (3m26s) did the same: timeouts at resume, rebind started at 17:28:05.99, controller back at 17:28:08.44, no timeouts after, Wi-Fi back within about a second. So the rebind works on BCM4388, and Wi-Fi on the same chip survives the reset. It's one wedged resume without the fix and two with it, so a small sample, and I haven't compared against the previous kernel. BCM4387 still needs a tester. |
maralcbr
left a comment
There was a problem hiding this comment.
Thanks @malik-na, and thanks @scottjones for the BCM4388 runs. All five of my earlier points are fixed at 2e4c968: the vendor wants link reaches upgrades, setup-system is back to main's, the watch is anchored on the suspend_stats count, the docs are softer, and the four tests are there. Scott's gate, test-stub and version points are fixed too. His two wedged lid-close resumes, each recovered in about 2.5 s with Wi-Fi still up, are good evidence for BCM4388.
One fix before merge:
omarchy-mac/README.md:15: 2e4c968 replaced "It enables resume recovery only for BCM4378, BCM4387 and BCM4388 on Apple Silicon; Intel/T2 Macs are excluded." That sentence described the Wi-Fi unit, whichomarchy-mac-setup-system:53-63still enables, so the setup contract no longer mentions it. Please put it back as "It enables Wi-Fi resume recovery only for …" and keep the Bluetooth sentence after it.
Non-blocking:
- The Wi-Fi and Bluetooth recovery units both start after
suspend.targetwith no ordering between them, and they act on the same chip. The Wi-Fi fix reloads brcmfmac, and on some PCIe core revisions brcmfmac's reset (brcmf_pcie_reset_device) uses a chip watchdog that resets every PCIe function, Bluetooth included. Scott's manual test showed Wi-Fi surviving a Bluetooth rebind, but not the reverse, and not both recoveries at once. @scottjones, could you runmodprobe -r brcmfmac_wcc brcmfmac && modprobe brcmfmacwhile an unbind/bind of0000:01:00.1is in flight? If that misbehaves, addAfter=omarchy-wifi-resume-fix.service. I'd rather not add that ordering without evidence, because it delays Bluetooth until Wi-Fi reconnects. - Fallback window (
omarchy-bluetooth-resume-fix:104-108,:125). When the journal never catches up to the kernel's suspend count (for example, this boot's early kernel lines were vacuumed), every resume waits 10 s, resetsstartedto that moment and reads--sinceit. That drops the first 10 s, and a clock step after resume (timesyncd) can empty the window. Taking a tail cursor when the script starts (journalctl -kqb -n 0 --show-cursor) and using it in place of--sincefixes both.omarchy-wifi-resume-fixuses a cursor for the same reason. A real wedge repeats its timeouts, so this is unlikely to miss one in practice. The test stub ignores the--sincevalue, so this path isn't covered. - Nit: README
:43says the fallback "watches a bounded window from its own start". On the count-mismatch path it starts 10 s later. The:116message says "watching from now" but uses the script's start time. - Nit:
omarchy-bluetooth-resume-fix:175"…${elapsed}s after resume":elapsedcounts watch passes since anchoring, not time since resume. Scott's log shows "0s after resume" for a timeout logged during device resume. Something like "after N s of watching" would be accurate. - Please post the native
omarchy-mac/test/allandtest/integration/allrun on the rebased branch when you have it. BCM4387 lid-close is still open for release, not for this merge.
maralcbr
left a comment
There was a problem hiding this comment.
Thanks @malik-na. aa747a8 fixes the README point, and Scott's BCM4388 lid-close runs are good evidence for the rebind.
One fix before merge:
- Version. Main has since released omarchy-mac 0.1.4 (2d0c5b2), and this branch also sets
omarchy-mac/versionandREADME.md:3to 0.1.4. GitHub reports no conflict because the two bumps are identical, so a merge would put the Bluetooth unit under the version that's already published, and nothing would ship it as an upgrade. Please rebase on main and make it 0.1.5. If #30 lands first, drop the bump instead, since it moves bumps into the release PR.
Still open from my last review, not blocking:
- The native
omarchy-mac/test/allandtest/integration/allrun on the rebased branch. CI is green on the merge ref, so a post after the rebase is enough. - The journal cursor in place of
--sincefor the fallback window (omarchy-bluetooth-resume-fix:104-108,:125). - BCM4387 lid-close is still needed before release.
Port omacom/omarchy-mac#498 into the hardware package, with controller-specific journal recovery and setup that preserves administrator choices. Co-authored-by: n0mahd <39080654+n0mahd@users.noreply.github.com>
On an M2 Pro (t6020, 14e4:5f72) the controller wedged across 2 of 7 suspends with the same HCI tx timeout signature before PM: suspend exit, and reloading hci_bcm4377 brought it back, as reported in the review of omacom/omarchy-mac#498. The source PR left BCM4388 out only because its one report then was the rfkill path; this adds it to the gate, the setup tests, the README and the manual. Co-authored-by: Oliver Lukschander <33756270+oliverlukschander@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #21: - A wants link under /usr/lib/systemd/system/suspend.target.wants runs the unit after every suspend on installs and upgrades alike, as the audio watchdog's link does, so Macs that only update get it. System setup no longer enables it, so a Bluetooth detection failure can no longer stop the speaker and launcher setup after it. Turning it off is a mask. - The watch starts from this suspend's entry: the kernel counts suspend attempts in /sys/power/suspend_stats, and the command waits up to 10 s for journald to hold that entry before taking its cursor, so an earlier cycle's timeouts are never read as this one's. Without it, it watches a bounded window from now. Journal reads stay within this boot. - A suspend during the 20 s watch moves it to the newer resume and restarts the watch: systemd will not start the unit again while it runs. - Hibernation is dropped from the unit; Apple Silicon Macs don't hibernate. - The README, manual and messages say what was seen (an HCI command timeout) instead of claiming a confirmed wedge or a healthy controller. - Tests: a fixture journal that changes over time covers timeouts after an earlier cycle's entry, a lagging journal, an entry that never arrives, a second suspend during the watch, hci0 leaving on unbind and returning on bind (or not), and setup finishing after a Bluetooth detection failure.
The runtime's omarchy-hw-platform names a Mac aarch64-apple, so the literal apple-silicon comparison skipped the fix there. Ask omarchy-hw-apple-silicon, as omarchy-mac-setup-system does, and stub it in the tests over an aarch64-apple detector.
2e4c968 replaced the sentence about the Wi-Fi resume unit, which omarchy-mac-setup-system still enables, rather than adding the Bluetooth one after it. Put it back, naming Wi-Fi, ahead of the Bluetooth sentence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main released 0.1.4 in 2d0c5b2, so the unit needs its own version to ship as an upgrade. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the journal never holds this suspend's entry, the watch read --since a time taken after the 10 s wait, dropping those seconds, and a clock step after resume could empty the window. It now reads after the kernel journal's tail as the service started, or as of the pass before a suspend during the watch, as omarchy-wifi-resume-fix does. The journal stub filters by cursor alone, so the tests cover that path: a timeout logged during the wait is read, and a second suspend with no entry reads from the pass before it. The rebind message counts seconds of watching, not since resume, and the fallback messages and README say where the window starts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aa747a8 to
d277aa9
Compare
|
Thanks @maralcbr. Rebased on Blocking
From your earlier review (
Tested natively at
BCM4387 lid-close is still needed for release. |
[Medium impact] The change affects Bluetooth recovery on a limited set of Apple Silicon Macs. The PR should not merge yet because journal cleanup can still prevent Bluetooth recovery after resume. Findings
SummaryAdds automatic Bluetooth recovery after suspend on supported Apple Silicon Macs.
|
| kernel=$(journalctl -kqb --no-pager -o cat 2>/dev/null) || return 2 | ||
| seen=$(grep -c 'PM: suspend entry' <<<"$kernel" || true) | ||
| if [[ -z $attempts ]] || (( seen >= attempts )); then | ||
| break | ||
| fi | ||
| if (( waited >= wait_journal )); then | ||
| echo "The journal has no entry for this suspend after ${wait_journal}s; watching from $mark_origin instead" | ||
| cursor=$mark |
There was a problem hiding this comment.
Journal cleanup breaks Bluetooth recovery
If journal cleanup removes an earlier suspend entry, anchor() sees fewer entries than the kernel's lifetime suspend count, even when the current entry is present. It waits 10 seconds and falls back to the service-start cursor. That skips timeouts logged during device resume, so Bluetooth can stay stuck despite the timeout being in the journal.
Track the current cycle without requiring all earlier suspend entries to remain, and add a test with an older entry removed.
Main is at 0.2.3 after omarchy-mac-pkgs#32, so this bumps to 0.2.4. The README keeps main's mpv and microphone wording beside the Bluetooth resume recovery text.
PRs that each bumped omarchy-mac/version kept colliding (#23 and #24 on 0.1.1, #21 and #28 on 0.1.3) or forgot to bump. Only a release reads the number, through the recipe's pkgver, so the release now sets it: in a pull request from release/omarchy-mac-<version> that changes only that file. A new gate fails any other pull request that touches the file. The README no longer repeats the number. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Port of omacom/omarchy-mac#498 by @n0mahd, with the recovery moved into
omarchy-mac/. Co-authored commit.After s2idle the Broadcom Bluetooth firmware can stop answering HCI commands (
hci0: command 0x0c01 tx timeout), and only rebindinghci_bcm4377brings it back.omarchy-bluetooth-resume-fix.service, a vendor unit ordered after the sleep targets, rebinds the Bluetooth PCI function (Wi-Fi on the same chip is not touched) when the kernel logs an HCI command timeout from that controller during the current suspend cycle. A timeout shows that a command failed, not that the controller is still stuck, so it can rebind a controller that would have recovered. A radio you turned off is left alone.Changes from the source PR:
lib/bluetooth-supported: the runtime'somarchy-hw-apple-siliconpredicate (omarchy-hw-platformreportsaarch64-apple) plus the PCI ID.suspend.target.wantslink, so installs and upgrades both get the unit andomarchy-mac-setup-systemis unchanged frommain. Onlysystemctl maskturns it off (disablecannot remove the link). The quattro migration is dropped.PM: suspend entrythe kernel counted in/sys/power/suspend_stats, reads only this boot, and restarts its 20 passes if the Mac suspends again. Without that entry it reads after a journal cursor taken at its start, not a--sincetime. Hibernate targets are dropped.14e4:5f72): @oliverlukschander saw the same wedge on an M2 Pro in the source PR's review.omarchy-macgoes to 0.1.5.Tested:
omarchy-mac/test/allandtest/integration/all(runtimee1b0e5e9) run natively on an M1 Air (J313, BCM4378) atd277aa9;electron-desktop-repair-test.shfails there onmaintoo. Before the rebase, the package installed without running setup was wanted bysuspend.targetand ran after threepm_test=devicessuspends. @scottjones's lid-close runs on an M2 Max covered BCM4388: two wedged resumes, each recovered in about 2.5 s with Wi-Fi up. Still needed before release: a lid-close resume through the unit on BCM4387.