Skip to content

Bluetooth: hci_bcm4377: Add hardware reset recovery and post-init restoration - #7

Merged
RyanTheTide merged 1 commit into
aurora-silicon:aurora-wipfrom
JJRPF:aurora-fix/bcm4377-hardware-reset-recovery
Oct 8, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:aurora-wipfrom
JJRPF:aurora-fix/bcm4377-hardware-reset-recovery

Conversation

@JJRPF

@JJRPF JJRPF commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Problem

On Apple Silicon Macs using Broadcom PCIe Bluetooth controllers (bcm4377, bcm4378, bcm4387, bcm4388 driven by hci_bcm4377), stopping the radio or cycling rfkill during heavy traffic (such as active LE scanning, discovery, or audio streaming) causes transfer and completion ring destruction commands to time out in bcm4377_hci_close().

When ring destruction fails, the controller hardware is left in an unrecoverable state:

  1. The firmware rings remain allocated and desynchronized.
  2. Subsequent bcm4377_hci_open() calls fail immediately when attempting to recreate transfer rings (bcm4377_create_ring fails).
  3. The controller is completely wedged until an unbind/bind of the PCIe driver via sysfs or a full machine reboot.

Solution

  1. Hardware Reset Recovery (bcm4377_pci_reset):

    • Track teardown failures in bcm4377_hci_close() and set needs_reset = true.
    • On the next open (or if ring creation fails), execute a PCIe Function-Level Reset (pci_reset_function).
    • Re-initialize PCI config space, restore MSI vectors, reset ring states, reboot firmware (bcm4377_boot), and re-establish the Real-Time Interface (bcm4377_setup_rti).
  2. Synchronous Post-Init Hook (hdev->post_init):

    • Because hardware reset wipes internal SRAM, the silicon loses its calibration, regulatory PTB tables, and programmed MAC address, reverting to Broadcom's ROM placeholder (43:88:C0:00:76:93).
    • Implement bcm4377_hci_post_init (executed synchronously inside hci_dev_open_sync() under hdev->req_lock immediately after HCI_OP_RESET):
      • Reloads beamforming and calibration blobs via send_calibration.
      • Reloads regulatory PTB tables via send_ptb.
      • Restores the device's authentic BD_ADDR into the silicon registers via vendor opcode 0xfc01 (bcm4377_hci_set_bdaddr), and updates hdev->bdaddr.

Testing & Verification

  • Tested on an Apple MacBook Pro 14" (M2 Pro, Mac14,9) with Broadcom BCM4388 on Linux 7.1.13-3-1-ARCH.
  • Verified fault recovery under active LE discovery and advertising:
    • Abrupt ring destruction teardown failure captured.
    • Driver automatically performed PCIe FLR reset.
    • Firmware rebooted cleanly and RTI synchronized.
    • post_init reloaded calibration, PTB, and restored factory MAC (6C:7E:67:CA:E2:2E).
    • Class of Device (0x006c010c) and device name restored.
    • Paired Bluetooth devices (Sennheiser MOMENTUM 4, Dell wireless keyboard/mouse) connect cleanly without key drops.

AI Disclosure & Attribution

In compliance with Documentation/process/coding-assistants.rst:

  • Assisted-by: Antigravity:gemini-3.8-flash
  • This code was developed with AI assistance (Google Antigravity / Gemini 3.8 Flash) and has been human-reviewed, compiled, and tested on bare-metal Apple Silicon hardware.

Assisted-by: Antigravity:gemini-3.8-flash
Signed-off-by: Justin Pfister [email protected]

…toration

When Bluetooth is stopped during heavy traffic (such as active LE
scanning or discovery), transfer ring destruction commands to the
Broadcom PCIe controller can time out and fail. Subsequent opens
fail because rings cannot be created, leaving the device wedged.

Implement hardware reset recovery using PCI Function-Level Reset (FLR)
to re-initialize the PCIe controller and restart the firmware.
Introduce a synchronous hdev->post_init hook to reload calibration
data, regulatory PTB tables, and restore the device BD_ADDR after
hardware reset, ensuring the controller is fully restored to operational
state.

Assisted-by: Antigravity:gemini-3.8-flash
Signed-off-by: Justin Pfister <[email protected]>
chriskearney added a commit to chriskearney/aurora-linux that referenced this pull request Oct 2, 2026
Kernel 7.1.12.aurora2-11.21 from custom/sep df7cb9b: 11.20 plus
hci_bcm4377 hardware reset recovery (aurora-silicon/linux#7, Justin
Pfister). A Broadcom PCIe radio wedged by an rfkill cycle under heavy
traffic is reset on the next open, and its calibration and address are
restored. Other packages are unchanged.

Boot-tested in maclab (m1air, job j1002-074408-6d57): 25 rfkill cycles
under LE discovery with the address unchanged and discovery working,
the 11.20 release checks, and no omarchy-m-test regressions against
11.19. The M1 Air's BCM4378 did not wedge on 11.19 either, so the
recovery path itself is the author's M2 Pro (BCM4388) result.

Signed-off-by: Chris Kearney <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FwdG63dRaMrRbYrUBkSa1i
@chriskearney

Copy link
Copy Markdown
Contributor

Shipped in the aurora-sep 11.21 test release (omacom/linux-aurora#7), thanks. Regression check on an M1 Air (J313, BCM4378) in our lab: 25 rfkill block/unblock cycles during active LE discovery (btmgmt find -l). hci0 powered back on each time, the BD address was unchanged (10:B5:… before and after), discovery still found 119 devices, and there was no oops. omarchy-m-test showed no regressions.

That BCM4378 didn't wedge under the same stress on the previous kernel either, so the recovery path itself never ran there. The FLR and post_init restore is still your BCM4388 result. If you have a reliable reproducer for M1 Pro/Max (BCM4387), it would cover the remaining generation.

cb2206 pushed a commit to cb2206/linux that referenced this pull request Oct 5, 2026
…io-speaker-lock

ASoC: macaudio: speaker-lock race fixes from aurora-wip (needs review)
@RyanTheTide
RyanTheTide merged commit e6c5b30 into aurora-silicon:aurora-wip Oct 8, 2026
RyanTheTide added a commit that referenced this pull request Oct 8, 2026
Preserve the original review commits and retain subsequent published repairs where superseded.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide added a commit that referenced this pull request Oct 8, 2026
[follow-up to #7] Bluetooth: hci_bcm4377: stop recovery when the PCI reset fails

Original contributor commits are preserved. Conflict resolutions retain the audited shared driver APIs and their integrated review fixes.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide added a commit that referenced this pull request Oct 17, 2026
Bring the 7.2.10 assembly to the tree of the canonical top-up #7
assembly, stacked on top-up #6a 40a2ec8 so that it is a
fast-forward of that publish head. The second parent is that canonical
assembly; the tree is identical to it.

Ported from aurora-wip, each commit with cherry-pick -x and its
original author:
- #306: aurora_j700_defconfig, regenerated for 7.2.10 with savedefconfig
  from the published 7.2.10 J700 configuration (900-config-tooling);
- #354 (j700/clamshell-mic-v4), 3 commits: the LPAI pointer published
  after its frames, the spin_lock_irqsave() Rust helpers, and the mics
  reported unplugged with the lid closed (070-audio);
- #355 (j700/tipd-hpd-pulse-v2), 9 commits: the CD321x DisplayPort
  hotplug decisions, their trace events and KUnit tests (170-usb), and
  the apple-dcp selftests that compile them (200-dcp);
- #356 (fix/rust-dmabuf-xarray-20261018): the dma_buf stub gated on
  built-in DRM and the xarray KUnit values allocated before xa_lock
  (210-gpu, with the Fixes: tags of the 7.2.10 base); its dma-resv
  backport is already in asahi-wip;
- #357 (fix/sep-followups-20261018), 7 commits: dma_wmb()/dma_rmb() for
  Rust, the SEP shared buffers ordered against the mailbox, the hwrng
  and sleep glue and its tests, and the trusted-keys built-in source
  fixes (100-sep).

Our own 7.2-native commits, not on aurora-wip (100-sep): the Rust
system_dfl_wq wrapper, and the SEP, Asahi DRM and binder work moved
off the deprecated system_wq. Their AOP change is not carried: the
070-audio AOP driver already registers its services on its own
ordered queue.

Adaptations, each with a [ryan: ...] note in its commit:
- the AOP lid tests go after the parser tests, where 7.2.10 has the
  name tests (context only);
- trusted_key_core_done goes next to 7.2.10's
  trusted_key_source_migratable (context only);
- the defconfig is regenerated, not picked; its note lists the 62
  lines that differ from the 7.1 file, none of them a J700 setting.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide added a commit that referenced this pull request Oct 18, 2026
…d GPU

Bring the 7.2.10 assembly to the tree of the canonical top-up #7a
assembly, stacked on top-up #7 29ea847 so that it is a
fast-forward of that publish head. The second parent is that canonical
assembly; the tree is identical to it.

Ported from aurora-wip with cherry-pick -x and its original author:
- #359 (fix/tipd-mux-ceiling-time-20261018): a held Type-C mux is
  retried for two minutes from its first failure rather than for 16
  retries, with its KUnit tests (170-usb) and the apple-dcp selftests
  that check it (200-dcp), split by topic.

Our own 7.2-native commits, not on aurora-wip: the Rust system_dfl_wq
wrapper in the topics that need it, the T8140 AOP audio jack, mic
array and speaker work moved off the deprecated system_wq (070-audio),
and the Asahi command retirement and G17 background work moved off
the deprecated system_wq and system_unbound_wq (210-gpu). No Rust
driver we carry uses a deprecated system queue any more.

No commit needed an adaptation.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
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