Repository navigation
Bluetooth: hci_bcm4377: don't rebind while the firmware boots after a sleep - #4414
Conversation
… sleep After a deep sleep that cuts the controller's power, power_lost_work boots the firmware again, which takes about 2.5 s on BCM4387 (J414s). A command sent meanwhile, such as bluetoothd writing the class of device (0x0c24), times out after 2 s, before that boot is done, and bcm4377_hci_reset() queues a rebind. The rebind races the boot: its device_reprobe() can fail with -EBUSY, which leaves the function without a driver and hci0 gone until reboot: Bluetooth: hci0: command 0x0c24 tx timeout Bluetooth: hci0: controller not responding, rebinding the driver Bluetooth: hci0: firmware booted again after the sleep pci 0000:01:00.1: reprobe after command timeout failed: -16 Skip the rebind while power_lost_work is pending or running, and have a boot that fails ask for the rebind itself, so a controller that really does not come back is still recovered. Signed-off-by: Justin Pfister <git@jjrpf.com>
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: REQUEST_CHANGES at 278d6a8.
Failure: If firmware boot succeeds but the HCI event-mask command times out during hci_resume_dev(), the timeout callback sees power_lost_work still running and suppresses the rebind. hci_resume_sync() ignores the event-mask status and returns 0. The boot-failure fallback has already been passed, so nothing queues a rebind. The exact driver and HCI functions replayed this on GCC and Clang with one rebind on base d0684a0 and zero on this head.
Please preserve timeout recovery for commands issued after firmware boot while retaining the boot-time deferral. The offline controls passed for a healthy resume, a failed boot in workqueue context, and a failed boot under the PCI device lock.
The previous change skipped the rebind for any command timeout while power_lost_work was busy. That work also resumes the HCI core once the firmware is back, and hci_resume_sync() ignores the status of the commands it sends (the event mask, for one). A timeout there was then dropped: the boot had succeeded, so nothing asked for a rebind. Skip the rebind only while the work is queued or still booting the firmware, and let a timeout once the firmware is back rebind as before. A boot that fails still asks for the rebind itself. Signed-off-by: Justin Pfister <git@jjrpf.com>
|
@RyanTheTide thanks, you're right. Fixed in 2a109b4: the rebind is skipped only while I replayed
One gap I left: between the workqueue clearing the pending bit and the first line of the work, neither check is true, so a timeout landing in those few instructions rebinds as it did before this PR. Setting the flag at the The new commit is on top of 278d6a8 so the change is easy to read; I'll squash the two before merge if you prefer one commit. |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 2a109b4
Checked: GCC and Clang replays of the driver and HCI core both queue a rebind for a post-boot HCI event-mask timeout. Healthy boot, boot failure, pending work and in-boot timeout controls retain their expected behavior.
Follow-ups: The workqueue clears PENDING before entering the worker and the driver sets power_lost_booting inside the worker. A concurrent timeout in that short interval can still queue a rebind, as on the base.
|
Hardware verification at exact head
|
|
Second-family hardware verification at exact head
|
Update the recovery harness for the post-sleep boot guard. Check that a timeout keeps the reserved rebind work intact while the boot is queued or in progress, and that the existing recovery path runs once the boot completes. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
I reproduced the affected host check failure on
The follow-up changes only the host fixture. The driver blob is unchanged from the J413 deep-sleep and J316s s2idle rows. @RyanTheTide Please recheck the fixture and refresh your approval on the new head. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 313badb
Checked: Reproduced the recovery fixture's compile failure on 2a109b4 and ran the repaired exact bcm4377-state-wait fixture with GCC and Clang. The production recovery checks and all three existing negative controls passed. The new pending-work and firmware-boot assertions both defer rebind and the normal timeout still enqueues one. The only changed file is the fixture, and the driver source is byte-identical to the head tested on J413 and J316s.
What: After a sleep that cut the controller's power,
power_lost_workboots the firmware again, which takes about 2.5 s on the BCM4387 in a J414s. A command sent meanwhile, here bluetoothd writing the class of device (0x0c24), times out after 2 s, before that boot is done, andbcm4377_hci_reset()queues a rebind. The rebind races the boot: itsdevice_reprobe()can fail with-EBUSY, which leaves the function without a driver and hci0 gone until reboot (a manual bind getsEBUSYtoo):This skips the rebind while
power_lost_workis pending or running, and has a boot that fails ask for the rebind itself, so a controller that really doesn't come back is still recovered. The J493 resume guard and #2808 only cover the BCM4378; the BCM4387 and others take the plain rebind this changes. #4269's s2idle power-loss path queues the same work, so it is covered too.Tested: J414s M2 Pro (BCM4387,
0x5f72), OS firmware 13.5 / system firmware 27.2, on aurora/mainefef6707019e+ #4313 + #4411, deep sleep:btmgmt class). Both of those rebinds happened to succeed.d0684a0604a0, with Bluetooth: hci_bcm4377: restore private PCI windows and reboot firmware after power-loss sleep #4269):hci_bcm4377.obuilds clean (LLVM, arm64); tools/asahi bcm4377-completion, -resume (63 production controls), -sleep-config, -suspend-notifier and -id tests pass.Risk: two-way door · only a command timeout while
power_lost_workis pending or running, on any bcm4377 chip; the J493 guarded recovery (hdev->reset = bcm4377_hci_timeout) only reaches this through its non-epoch rebind. A boot that fails now rebinds from the work instead of from the timeout; from a PM callback (pci_locked) it doesn't, as before.