bluetooth: strip Broadcom vendor bits from legacy LE adv report type - #57
Open
josemiguelo wants to merge 1 commit into
Open
bluetooth: strip Broadcom vendor bits from legacy LE adv report type#57josemiguelo wants to merge 1 commit into
josemiguelo wants to merge 1 commit into
Conversation
Broadcom controllers running ROM firmware on T2 Macs (no patchram available, e.g. BCM4364B3 on MacBookPro16,1 via hci_uart_bcm) set vendor bits 0x10/0x20/0x80 in the legacy LE Advertising Report Event_Type, so ADV_DIRECT_IND arrives as 0x81/0x91/0xa1 and process_adv_report() drops it as unknown. Directed advertising is exactly what bonded LE HID peripherals use to reconnect, so the passive-scan auto-connect never fires and mice and keyboards only reconnect when a report happens through clean, roughly 1 in 20. Every userspace path goes through the same scan-then-connect code, so there is no workaround outside the kernel. The real type is always in the low nibble; mask it for Broadcom controllers when it is out of range. This repo already carries the extended-report counterpart of the same quirk in 9001-Bluetooth-hci_event-Add-quirk-to-ignore-byte-in-LE-Extended-Adv-Report.patch. Applies cleanly with git am on v7.1.9 and v7.2.3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bluetooth: LE auto-reconnect never fires on BCM4364 (ROM firmware) — strip vendor bits from adv report type
Hardware / software
hci_uart_bcm, ROM firmware (BCM (001.016.091) build 0115; nobrcm/BCM.hcdexists for this model — t2linux only ships BT firmware for 15,4 / 16,3 / Air9,1)kernel-7.0.10-201.t2.fc44,6.19.12-210.t2and — with thestock module — on the current
kernel-7.1.9-200.t2.fc44, so this is not an old-kernel artifact.Symptom
Bonded LE HID devices don't reconnect when woken.
dmesgfills withTally over several boots (144 drops):
0xa1×350x81×350x91×170x11×80x21×60x90×40x80×40x14×40xa0×30x10×20xa20x930x240x23. The low nibble is always a valid legacy type (0–4); the upper nibble is0x1/0x2/0x8/0x9/0xavendor noise.Root cause (btmon)
The controller reports the mouse's reconnect adverts with garbage high bits in
Event_Typemost of the time, and cleanly sometimes: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 — abluetoothctl connectloop 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 innet/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.patchpatched the extended adv report path in this very file for T2 controllers. This is the legacy-report counterpart.Scope / risk
hdev->manufacturer == 15), not on the peer device, and only forEvent_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.0x01for the same packet): a strayLE Create Connectionthat times out after a few seconds. No effect on established links.Verification
Built the patched
bluetoothmodule via DKMS (sources byte-identical to the stock module — all 3818 text symbols match in size; only the quirk differs).On 7.0.10-201.t2, after reboot:
journalctl -k -b | grep -c "unknown advertising packet type"→ 0 (was 39 in the previous half-day)Re-confirmed on 7.1.9-200.t2 (2026-09-02): after the kernel upgrade the DKMS package was dropped and the machine ran the stock module again — the MX Master 3 and Keychron K15 Max immediately stopped auto-reconnecting. Rebuilding the patched module for 7.1.9 restored reliable reconnect. The bug is present in current kernels.
Patch file:
9002-Bluetooth-hci_event-strip-Broadcom-vendor-bits-from-adv-type.patch(git format-patch, Signed-off-by).Applies cleanly with
git amonv7.1.9and onv7.2.2(theKVERthis repo'smaincurrently targets).How to confirm this on your own machine
Nothing here changes anything on your system. You need at least one bonded BLE peripheral (mouse,
keyboard) for the bug to be observable at all — the mangled reports only appear when a paired device
is advertising to reconnect.
1. Count the dropped reports.
Non-zero means your controller is emitting advertising types the kernel discards.
2. Look at what is being dropped.
The signature is that every value has a valid legacy type in the low nibble (
0x0-0x4) and vendornoise in the high nibble (
0x1/0x2/0x8/0x9/0xa). Mine, over several boots and 144 drops:3. Confirm the controller is Broadcom running ROM firmware.
Affected machines show a
BCM (...)build string with no patchram ever loaded — there is no"Patch file" /
.hcdline, because t2linux ships BT firmware for only a few models. Mine reportsBCM (001.016.091) build 0115on a BCM4364B3.4. Watch it happen live.
Let a bonded BLE mouse or keyboard sleep, then wake it, and watch for:
Reserved (0x8x/0x9x/0xax)is the bug. Keep watching and the same device will occasionally emit aclean
Connectable directed - ADV_DIRECT_IND (0x01)and reconnect within ~70 ms. That contrast — samedevice, same packet, sometimes clean — is what shows this is a report-parsing problem and not a link
or pairing problem.
5. The user-visible symptom: bonded LE HID devices do not reconnect when woken. They sit
disconnected until you retry by hand enough times for a clean report to land.
Verify the fix before it is merged
You do not need to rebuild a kernel — the
bluetoothmodule can be rebuilt on its own via DKMS,which also survives kernel updates. Requires
dkms,kernel-develfor your running kernel,gitand
patch, and Secure Boot off (the default on T2 Macs).Create
/usr/src/bluetooth-t2adv-1.0/containing this PR's.patchfile plus two others:dkms.conffetch-src.sh(make it executable)Then:
Only
net/bluetoothis fetched, at the tag matching your running kernel, so this keeps workingacross kernel updates for as long as the patch applies.
Verify after installing
Confirm you are actually running the rebuilt module:
Then:
and let each bonded LE peripheral sleep and wake it: it should reconnect on its own within a second
or two, every time, with no manual retries.
On my machine the current boot reports 0 dropped advertising reports, against 39 over a
comparable half-day on the stock module.
To go back at any time: