Conversation
432e806 to
5e6799a
Compare
Previous CI status & isolation test (resolved)Note for reviewers on CI status: All checks exercising the code in this PR are 100% green:
Isolating the
|
5e6799a to
40c0ac2
Compare
|
Verified on live hardware: MacBookPro18,1 with the BCM4387 ( Test: held an active LE discovery scan open (
The BlueZ (Didn't deliberately re-run the un-patched path under scan — a successful repro would leave the controller needing a driver rebind I can't sudo. The clean patched cycle on the right hardware is the evidence that matters anyway.) |
|
Validated head Reproduced bug — P2: power-off submission is not a completion barrier At I reproduced this using the installed BlueZ 5.87-2 CLI, the unchanged candidate helper, a private two-adapter D-Bus service, and an inert rfkill logger. Both fake adapters begin Powered=true. The default setter completes after 50ms and the secondary after 1000ms; the fake property changes only in the completion callback, immediately before the reply.
All four bounded experiments completed without harness errors. This demonstrates a missing completion barrier in the new implementation, not a newly reproduced kernel hang or worse hardware behavior than baseline. The included test checks command presence and misses this asynchronous case. Before merging, observe bounded completion or Powered=false for each intended controller, explicitly handle failure/timeouts, and add delayed-secondary-controller coverage. Waiting for the current piped process alone is insufficient. Verified pass
Remaining coverage gaps No live radio/rfkill operations were performed. Physical shutdown, DMA draining, active discovery/audio, lockup prevention, recovery and reboot persistence remain unverified; phone testing is paused. No full broad suite was rerun for this two-file change; ShellCheck is unavailable locally. GitHub reports MERGEABLE / BLOCKED with REVIEW_REQUIRED. Verdict: FAIL — I do not recommend merging this head until the completion-ordering defect is addressed. No source correction was applied during this review. |
40c0ac2 to
448068a
Compare
|
Thanks @malik-na for the sharp review and the reproducible test case! The asynchronous completion race on secondary controllers is completely valid, and I've addressed all three requirements: Summary of Updates
Branch has been rebased cleanly onto latest |
On Apple Silicon Macs (BCM4377/BCM4388 driven by hci_bcm4377), calling rfkill block bluetooth directly while discovery or connection is active causes HCI command timeouts (-110) followed by 10 transfer and completion ring destruction timeouts. The controller is left in an unrecoverable state where bluetoothctl power on fails until an unbind/bind or reboot. Gracefully powering off controllers through BlueZ first stops discovery and drains DMA queues cleanly, preventing driver timeouts while preserving the rfkill soft block for reboot persistence. Enforce a bounded completion barrier via wait_unpowered to ensure all controllers (including secondary controllers submitted asynchronously) reach Powered: no before applying the rfkill block. If any controller fails to power down before the deadline, log a warning to stderr, apply the rfkill block as a safety fallback, and return non-zero status. Upstream kernel report: AsahiLinux/linux#609
98208ba to
38189e9
Compare
Summary
Powers down Bluetooth adapters through BlueZ before applying
rfkill block bluetooth.This resolves an issue on Apple Silicon Macs where toggling Bluetooth off via the menu/bar wedged the Broadcom PCIe controller (
hci_bcm4377), causing 10 transfer ring destruction timeouts, leaving the controller dead, and preventing Bluetooth from turning back on without a manual driver rebind or reboot.Upstream kernel bug report: AsahiLinux/linux#609
The Problem on Apple Silicon Macs
On Apple Silicon MacBooks (M-series running
hci_bcm4377with Broadcom BCM4377/BCM4378/BCM4387/BCM4388 chips), callingrfkill block bluetoothwhile the radio is actively scanning or exchanging data triggers a driver/DMA hang:discoveryRetryinPanel.qml), keeping LE inquiry DMA queues active.omarchy-bluetooth-power off, which previously ranrfkill block bluetoothdirectly without asking BlueZ to power down first.hci_rfkill_set_blockimmediately attempts an uncoordinated power-down (hci_dev_do_poweroff). Because the Broadcom PCIe hardware has active DMA transfers in flight, it times out on HCI opcodes (command 0x0c01 tx timeout,-110).bcm4377_hci_close) then attempts to destroy the 6 transfer rings and 4 completion rings. Because the controller firmware is locked up, every ring destruction times out (1s each, stalling kernel workqueues for 10 seconds):closepath, the kernel core marks the device closed without triggering an automatic device reset.omarchy-bluetooth-power on),rfkill unblock bluetoothsucceeds, butbluetoothctl power onfails completely:echo 0000:01:00.1 > .../unbind && .../bind) or a full system reboot can recover the device.Solution
power_off()helper inbin/omarchy-bluetooth-power:controllers()) and requests a cleanpower offthrough BlueZ before cutting radio power.timeout 2s bluetoothctl power offfor the default controller.timeout 2sguards so D-Bus hiccups can never block the script.rfkill block bluetoothafterward, preserving Omarchy's design where the soft block persists state across reboots viasystemd-rfkill.test/shell.d/bluetooth-test.sh:power offto be absent to verifying that controllers are cleanly powered down before the rfkill block.By stopping discovery and draining DMA queues via BlueZ before
rfkill blockis applied, the kernel driver powers off the device cleanly with zero timeouts and zero ring destruction failures.Verification
Tested on an Apple MacBook Pro (14-inch, M2 Pro,
Mac14,9) running Omarchy on Linux 7.1.6-asahi with Broadcom BCM4388 (hci_bcm4377):omarchy-bluetooth-power offreproduced the exact 10-ring teardown failure indmesg, leavinghci0in a state whereomarchy-bluetooth-power onreturnedorg.bluez.Error.Failed (0x03).omarchy-bluetooth-power offandomarchy-bluetooth-power oncycles while actively connected to Sennheiser MOMENTUM 4 headphones and scanning:dmesgconfirmed zero HCI command timeouts and zero transfer ring destruction failures.omarchy-bluetooth-power onpowered on immediately, and headphones reconnected automatically without intervention.bash test/shell.d/bluetooth-test.shpasses all 47 assertions.