Skip to content

bluetooth: strip Broadcom vendor bits from legacy LE adv report type - #57

Open
josemiguelo wants to merge 1 commit into
t2linux:mainfrom
josemiguelo:bluetooth-bcm-adv-type
Open

bluetooth: strip Broadcom vendor bits from legacy LE adv report type#57
josemiguelo wants to merge 1 commit into
t2linux:mainfrom
josemiguelo:bluetooth-bcm-adv-type

Conversation

@josemiguelo

@josemiguelo josemiguelo commented Sep 4, 2026

Copy link
Copy Markdown

Bluetooth: LE auto-reconnect never fires on BCM4364 (ROM firmware) — strip vendor bits from adv report type

Hardware / software

  • MacBookPro16,1 (T2), Bluetooth BCM4364B3 "Trinidad Olympic" on hci_uart_bcm, ROM firmware (BCM (001.016.091) build 0115; no brcm/BCM.hcd exists for this model — t2linux only ships BT firmware for 15,4 / 16,3 / Air9,1)
  • Fedora 44, bluez 5.87. Reproduced on kernel-7.0.10-201.t2.fc44, 6.19.12-210.t2 and — with the
    stock module — on the current kernel-7.1.9-200.t2.fc44, so this is not an old-kernel artifact.
  • Peripherals: Logitech MX Master 3 (BLE HID), Keychron K15 Max (BLE HID)

TLDR

Issue: On T2 Macs where the BCM4364 runs ROM firmware (t2linux ships no .hcd for these models), the controller sets vendor bits in the Event_Type of legacy LE Advertising Reports (0x81/0xa1/…), so process_adv_report() discards ~95% of bonded peripherals' directed reconnect adverts — BLE devices stay disconnected on wake until a rare clean report slips through.

Fix: For Broadcom controllers only (hdev->manufacturer == 15), mask an out-of-range Event_Type to its low nibble before validation — reports that are valid today take the same path as before, and Broadcom controllers with real firmware never emit these types, so the quirk is inert everywhere else.

Only these two devices? No — the corruption happens on the local controller, so every bonded BLE peripheral is affected; the mouse and keyboard are just the two I own. BR/EDR devices are untouched (my Sony earbuds on the same machine reconnect fine — classic paging doesn't go through this path).

Long explanation

Symptom

Bonded LE HID devices don't reconnect when woken. dmesg fills with

Bluetooth: hci0: unknown advertising packet type: 0x81
Bluetooth: hci0: unknown advertising packet type: 0xa1
Bluetooth: hci0: unknown advertising packet type: 0x91

Tally over several boots (144 drops): 0xa1×35 0x81×35 0x91×17 0x11×8 0x21×6 0x90×4 0x80×4 0x14×4 0xa0×3 0x10×2 0xa2 0x93 0x24 0x23. The low nibble is always a valid legacy type (0–4); the upper nibble is 0x1/0x2/0x8/0x9/0xa vendor noise.

Root cause (btmon)

The controller reports the mouse's reconnect adverts with garbage high bits in Event_Type most of the time, and cleanly sometimes:

> HCI Event: LE Meta Event (0x3e) plen 12          2026-08-28 11:37:40
      LE Advertising Report (0x02)
        Event type: Reserved (0x81)                 <- dropped by process_adv_report()
        Address: E8:BB:F0:C3:98:2F (Static)
        Data length: 0

> HCI Event: LE Meta Event (0x3e) plen 12          2026-08-28 11:38:20
      LE Advertising Report (0x02)
        Event type: Connectable directed - ADV_DIRECT_IND (0x01)
        Address: E8:BB:F0:C3:98:2F (Static)
< HCI Command: LE Create Connection (0x08|0x000d)   +3 ms
> HCI Event: LE Enhanced Connection Complete       +70 ms, Status: Success
> HCI Event: Encryption Change                      Enabled with AES-CCM
kernel: logitech-hidpp-device ...: HID++ 4.5 device connected.

hci_le_adv_report_evt()process_adv_report() rejects any type > LE_ADV_SCAN_RSP, so the passive-scan auto-connect for bonded peripherals never triggers on the mangled reports. Reconnection only happens when a report slips through clean (~1 in 20). Every userspace path (bluetoothctl connect, L2CAP sockets) goes through the same scan-then-connect code, so no userspace workaround exists — a bluetoothctl connect loop only raises the odds.

Fix

Mask the type to its low nibble for Broadcom controllers (hdev->manufacturer == 15) when it is out of range, before validation. 2 lines of logic in net/bluetooth/hci_event.c; other vendors untouched.

This repo has carried the same shape of quirk before: 9001-Bluetooth-hci_event-Add-quirk-to-ignore-byte-in-LE-Extended-Adv-Report.patch patched the extended adv report path in this very file for T2 controllers. This is the legacy-report counterpart.

Scope / risk

  • Keyed on the local controller (hdev->manufacturer == 15), not on the peer device, and only for Event_Type > 0x04 — reports that were being discarded anyway. Valid reports (0x0–0x4) take the exact same path as before, so devices that work today are unaffected; the BR/EDR path is not involved.
  • Low nibbles ≥ 5 stay invalid and are still dropped.
  • Broadcom controllers with proper firmware never emit such types → inert there.
  • Worst case if the low nibble were ever wrong (never observed in 144 samples; the same mouse also emits the clean 0x01 for the same packet): a stray LE Create Connection that times out after a few seconds. No effect on established links.

@AdityaGarg8

Copy link
Copy Markdown
Member

I believe AI has been used here?

@turannul

turannul commented Sep 6, 2026

Copy link
Copy Markdown

All this to suppress noise on journal??

never had an issue with keyboard (Reddragon k530) or mouse (Logitech Pro X)

@josemiguelo

Copy link
Copy Markdown
Author

I believe AI has been used here?

Yes. Used it to test the solution and to redact the summary

@josemiguelo

Copy link
Copy Markdown
Author

All this to suppress noise on journal??

never had an issue with keyboard (Reddragon k530) or mouse (Logitech Pro X) - mbp15,4

I don't care about the noise on the journal. Logitech MX3 and Keychron keyboard were not reconnecting automatically. With this they reconnecting within 2 seconds even after waking up from suspend

@deqrocks

deqrocks commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Is this an AI novel for 5 lines of code? I was not able to figure out what is not working even after 3 times of reading. Could you describe your actual issue in just one sentence and describe the solution in a second sentence?
Is this only happening with the two described devices? If so, you will likely want to patch those drivers instead of this.
Also why you don't PR vs mainline kernel?

@josemiguelo
josemiguelo force-pushed the bluetooth-bcm-adv-type branch from fdc004d to 9dda525 Compare September 7, 2026 17:03
@josemiguelo

Copy link
Copy Markdown
Author

Is this an AI novel for 5 lines of code? I was not able to figure out what is not working even after 3 times of reading. Could you describe your actual issue in just one sentence and describe the solution in a second sentence? Is this only happening with the two described devices? If so, you will likely want to patch those drivers instead of this. Also why you don't PR vs mainline kernel?

Sorry for the inconvenience @deqrocks. I understand the summary may have had a lot of unnecessary text so I updated the PR description. Here's also more anwers to your questions:

Why not patch the peripherals' drivers? They never get the chance: the report is dropped in hci_event.c before the kernel knows which device it is or any peer driver (hidpp etc.) is involved. And the peers aren't at fault — btmon shows the same mouse packet arriving mangled 19 times and clean the 20th (reconnecting in 70 ms), so the packets are spec-valid on air and our controller corrupts them on the way up.

Why not mainline? I'll submit it upstream too. Posted here first because only ROM-firmware T2 controllers reproduce it, this repo already carries the extended-adv counterpart of this exact quirk (9001-…-LE-Extended-Adv-Report.patch), and t2linux users are the ones who can actually test it. If it lands mainline I'll drop it from here.

I hope this answers can be of any help now

T2 ROM-firmware controllers (BCM4364B3, no patchram) mangle the legacy
LE adv report Event_Type with vendor bits, so the kernel drops directed
reconnect adverts and bonded LE peripherals never auto-reconnect; mask
the type to its low nibble for Broadcom. Legacy counterpart of the 9001
extended-report quirk. Applies with git am on v7.1.9 and v7.2.3.
@josemiguelo
josemiguelo force-pushed the bluetooth-bcm-adv-type branch from 9dda525 to bc9942b Compare September 7, 2026 17:08
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.

4 participants