Repository navigation
Recover Intel Bluetooth when an rfkill block interrupts the firmware load - #8022
ezitounioussama wants to merge 1 commit into
Conversation
…load omarchy-bluetooth-power keeps the off state in the rfkill soft block because that is the half systemd-rfkill restores across reboots. On Intel CNVi adapters that restore lands while btusb is still downloading the firmware: the device drops off the bus mid-transfer, the download fails with -19 (ENODEV) and hci0 is torn down, so the machine boots with no Bluetooth controller at all rather than one that is merely powered off. Bluetooth: hci0: Found device firmware: intel/ibt-0040-0041.sfi Bluetooth: hci0: Failed to send firmware data (-19) Bluetooth: hci0: FW download error recovery failed (-19) Turning Bluetooth back on cannot recover from that on its own: power_on() lifts the block and then waits for BlueZ to power an adapter that no longer exists, then falls back to a bluetoothctl power on with no controller to address. Watch for the unblock with a udev rule and reload btusb when it leaves no adapter behind. The recovery waits for an adapter first and does nothing when one shows up, so it stays inert on hardware without this problem, and it also does nothing while the block is still set, since a missing adapter is then the intended state.
|
Reviewed at 1317f4c. The diagnosis in the description is clear and the recovery script's guards hold up, but two things stop the fix from reaching the failure it describes. 1. The udev rule cannot fire once the adapter is gone. The rule at
The testing in the description covers the trigger with an adapter present and the reload branch run by hand, but not the two together. It would still fire on a machine that also has a platform Bluetooth switch (a ThinkPad's 2. Existing installs never get it. A smaller point: Related: #13085 (open) makes What was checked: the diff read against Second opinion: Codex Medium reviewed it separately and raised findings 1 and 2 as well. It may have read this review's working notes, so its agreement is not guaranteed to be independent. It also claimed the unit would only start on the first unblock. That didn't hold: on the VM it started on every unblock. It raised the second-controller point above too. Next: waiting on you for the trigger and a migration. |
|
#20378 is on Codex High checked the current base and ran For manual recovery, #13085 can reach the reload without a Bluetooth rfkill event and checks for a controller in BlueZ. If both changes land, the restart command's unblock could trigger this service too and both could try to reload |
The problem
Turning Bluetooth off and rebooting leaves an Intel CNVi machine with no Bluetooth adapter at all, not one that is merely powered off.
bluetoothctlreportsNo default controller available, and turning Bluetooth back on cannot recover it.Mechanism
omarchy-bluetooth-power offsets an rfkill soft block, and the reasoning in that script is sound: BlueZ never persistsPowered, while systemd-rfkill saves every switch under/var/lib/systemd/rfkilland restores it early on the next boot.The trouble is how early. On this adapter the restore lands while
btusbis still downloading the firmware. The device drops off the bus mid-transfer, the download fails with-19(ENODEV), andhci0is torn down completely:/sys/class/bluetooth/is then empty. That also defeats the recovery path inpower_on(): it lifts the block and waits for BlueZ to auto-power the adapter, then falls back tobluetoothctl power on. Both need a controller to exist, so both fail and the helper reports that the adapter did not come up.Evidence
Firmware load outcome per boot on one machine. The only failure is the boot where Bluetooth had been turned off beforehand:
btusbreloadReproduction
omarchy-bluetooth-power off(or use the bar widget).journalctl -b -k | grep hci0shows the-19failures.bluetoothctl listis empty.The change
A udev rule watches for the Bluetooth rfkill block being lifted and starts a oneshot unit that reloads
btusbif that left no adapter behind.It is deliberately inert outside the broken case. It waits for an adapter first and exits as soon as one appears, so hardware without this problem never reloads anything; and it exits when the block is still set, since a missing adapter is the intended state while Bluetooth is off.
bin/omarchy-bluetooth-recover— the recovery itselfbin/omarchy-hw-intel-bluetooth— detection, reading sysfs becauseusbutilsis not in the base install solsusbis usually absentdefault/udev/intel-bluetooth-recover.rules— the triggerinstall/hardware/intel/fix-bluetooth-rfkill-firmware.sh— installs the rule and unit, gated on the adapter being presentinstall/hardware/all.shTesting
Verified on Omarchy 4.0.0-1, kernel 7.1.8-arch1-3, Intel Raptor Lake PCH CNVi (
8087:0033, firmwareintel/ibt-0040-0041.sfi).The real failure, and that a
btusbreload fixes it. Reached by turning Bluetooth off and rebooting. The boot logged the-19failures above and left no adapter; reloadingbtusbrecovered it:That the script takes the reload branch and recovers the adapter.
btusbwas removed without touching rfkill, so no device event could make udev auto-load it — leaving the module unloaded and no adapter, which is the state the script has to act on:Exit status 0, no
-19errors. The controller in that run reportedFirmware already loaded, since it kept the firmware from the previous successful load — so this run proves the recovery mechanics, while the case above proves a reload repairs a genuinely failed download.That the guards keep it inert. With an adapter present the script exits in 2ms without reloading and logs nothing. With the block still set it exits without reloading, so turning Bluetooth off keeps working normally.
That the trigger fires. Unblocking Bluetooth starts the unit through the udev rule (
Starting Recover Bluetooth adapter after rfkill unblock→Finished).Detection.
omarchy-hw-intel-bluetoothreturns 0 on this hardware, matching8087:0033at device classe0. It reads sysfs deliberately: an earlier version usedlsusb -d 8087:, which exits 127 on a base install becauseusbutilsis not included — that would have silently disabled the fix.Note on timing
omarchy-bluetooth-powergives up afterPOWER_WAIT_SECONDS(2s) while the recovery waits 5s for an adapter before reloading, so the first toggle after a blocked boot can still report that the adapter did not come up, with the adapter appearing a few seconds later. Happy to align those.If you would rather keep this in one place, the reload could move into
power_on()instead. That needs a privileged path, though:rfkillworks unprivileged through the uaccess ACL on/dev/rfkill, butmodprobeandsystemctl restart bluetoothdo not, and the helper is called detached from the shell where a sudo prompt has nowhere to go. That is why this is a root-side unit driven by udev.