Bluetooth: Broadcom controllers of the Apple T2 Macs
Subsystems (3)
cover Bluetooth: Broadcom controllers of the Apple T2 Macs
Hello everyone,
This series is for the Broadcom Bluetooth controllers of the Apple T2 Macs, the BCM4364 over UART (hci_bcm) and the BCM4377 over PCIe (hci_bcm4377).
1 raise ACL priority on Apple Broadcom controllers 2 clear vendor bits in LE advertising report types 3 Revert "Bluetooth: hci_event: strip Broadcom vendor bits from
legacy adv report type"
4 set the strict duplicate filter quirk on Apple Broadcom controllers
Patch 2 and 3 belong together. Commit 88397423671f ("Bluetooth:hci_event: strip Broadcom vendor bits from legacy adv report type") in bluetooth-next masks the event type of legacy LE Advertising Reports for every controller with manufacturer 15. The controllers known to set these bits are the ones of the T2 Macs. Aditya Garg asked about this on the list:
https://lore.kernel.org/linux-bluetooth/[email protected]/
Masking the type to its low nibble goes back to a t2linux patch by Jose Miguel Ochoa. Patch 2 clears the bits in the two drivers of these controllers before the event reaches the core, and patch 3 reverts the check in hci_event.c. Patch 2 comes first, so every commit in between keeps the reports.
Patch 1 builds on a vendor command the Android Broadcom vendor library uses, 0xfc57, to keep A2DP from dropping out while WLAN runs on 2.4 GHz. Patch 4 sets the strict duplicate filter quirk in both drivers, so a discovery reports changed advertisement data before its next cycle.
The KaiT2en community, about 280 members, runs these patches with its kernels. Users reported them working on the MacBookPro15,1, 15,2, 15,3, 15,4, 16,1, 16,4, MacBookAir9,1 and iMac20,1, and nobody reported a regression.
Andre Eikmeyer (4):
Bluetooth: btbcm: raise ACL priority on Apple Broadcom controllers
Bluetooth: btbcm: clear vendor bits in LE advertising report types Revert "Bluetooth: hci_event: strip Broadcom vendor bits from legacy
adv report type"
Bluetooth: set the strict duplicate filter quirk on Apple Broadcom
controllers
drivers/bluetooth/Kconfig | 1 + drivers/bluetooth/btbcm.c | 102 ++++++++++++++++++++++++++++++++ drivers/bluetooth/btbcm.h | 12 ++++ drivers/bluetooth/hci_bcm.c | 28 ++++++++- drivers/bluetooth/hci_bcm4377.c | 9 +++ net/bluetooth/hci_event.c | 11 ---- 6 files changed, 149 insertions(+), 14 deletions(-)
base-commit: 3f425f95ba3923d605f6a8b382e8fcdc59d479db
PATCH 1/4 Bluetooth: btbcm: raise ACL priority on Apple Broadcom controllers
On the MacBookPro15,1 (BCM4364B0 over UART) A2DP audio drops out as soon as WLAN runs on 2.4 GHz with traffic. The host keeps the eight ACL buffers of the controller filled, but the controller holds single ACL packets for 160-200 ms, so the sink runs dry.
Sending the Broadcom vendor command 0xfc57 (HCI_BRCM_SET_ACL_PRIORITY, handle and priority, as used by the Android Broadcom vendor library) with priority high for the audio link stops the dropouts. Setting it back to normal brings them back right away. The BCM4377 of the MacBookAir9,1 accepts the command as well.
Raise the priority for every BR/EDR ACL link once its Connection Complete event arrives. This covers audio as well as HID links. hci_bcm does this on Apple machines only, hci_bcm4377 always, since it only runs on Apple machines. The PCIe driver receives events in hard interrupt context, so the command is queued from a work item.
--- drivers/bluetooth/Kconfig | 1 + drivers/bluetooth/btbcm.c | 72 +++++++++++++++++++++++++++++++++ drivers/bluetooth/btbcm.h | 7 ++++ drivers/bluetooth/hci_bcm.c | 18 ++++++++- drivers/bluetooth/hci_bcm4377.c | 3 ++ 5 files changed, 99 insertions(+), 2 deletions(-)
drivers/bluetooth/Kconfig +1 -0
@@ -318,6 +318,7 @@ config BT_HCIBCM4377 tristate "HCI BCM4377/4378/4387/4388 PCIe driver" depends on PCI select FW_LOADER + select BT_BCM help Support for Broadcom BCM4377/4378/4387/4388 Bluetooth chipsets attached via PCIe. These are usually found in Apple machines.
drivers/bluetooth/btbcm.c +72 -0
78 lines not on this page · raw message
drivers/bluetooth/btbcm.h +7 -0
@@ -59,6 +59,8 @@ int btbcm_read_pcm_int_params(struct hci_dev *hdev,int btbcm_write_pcm_int_params (struct hci_dev *hdev,const struct bcm_set_pcm_int_params *params); +void btbcm_set_acl_priority_on_connect (struct hci_dev *hdev,struct sk_buff *skb); +int btbcm_setup_patchram (struct hci_dev *hdev);int btbcm_setup_apple (struct hci_dev *hdev);
@@ -94,6 +96,11 @@ static inline int btbcm_patchram(struct hci_dev *hdev, const struct firmware *fwreturn -EOPNOTSUPP ; } +static inline void btbcm_set_acl_priority_on_connect (struct hci_dev *hdev, +struct sk_buff *skb) +{ +} +static inline int btbcm_setup_patchram (struct hci_dev *hdev) {return 0 ;
drivers/bluetooth/hci_bcm.c +16 -2
@@ -147,6 +147,7 @@ struct bcm_device {bool drive_rts_on_open;bool no_uart_clock_set;bool use_autobaud_mode; +bool acl_priority;u8 pcm_int_params[5 ];u32 max_autobaud_speed; };
@@ -680,10 +681,21 @@ static int bcm_setup(struct hci_uart *hu) .lsize = 0, \ .maxlen = BCM_TYPE52_SIZE +static int bcm_recv_event(struct hci_dev *hdev, struct sk_buff *skb) +{ +struct hci_uart *hu =hci_get_drvdata (hdev); +struct bcm_data *bcm = hu->priv; + +if (bcm->dev && bcm->dev->acl_priority) +btbcm_set_acl_priority_on_connect (hdev, skb); + +return hci_recv_frame (hdev, skb); +} +static const struct h4_recv_pkt bcm_recv_pkts[] = { {H4_RECV_ACL , .recv = hci_recv_frame }, {H4_RECV_SCO , .recv = hci_recv_frame }, - {H4_RECV_EVENT , .recv = hci_recv_frame }, + {H4_RECV_EVENT , .recv = bcm_recv_event }, {H4_RECV_ISO , .recv = hci_recv_frame }, {BCM_RECV_LM_DIAG , .recv = hci_recv_diag }, {BCM_RECV_NULL , .recv = hci_recv_diag },
@@ -1086,8 +1098,10 @@ static int bcm_get_resources(struct bcm_device *dev) dev->name =dev_name (dev->dev); -if (x86_apple_machine && !bcm_apple_get_resources (dev)) +if (x86_apple_machine && !bcm_apple_get_resources (dev)) { + dev->acl_priority = true;return 0 ; + } dev->txco_clk =bcm_get_txco (dev->dev);if (IS_ERR (dev->txco_clk))
drivers/bluetooth/hci_bcm4377.c +3 -0
@@ -22,6 +22,8 @@#include <net/bluetooth/bluetooth.h> #include <net/bluetooth/hci_core.h> +#include "btbcm.h" +enum bcm4377_chip {BCM4377 =0 ,BCM4378 ,
@@ -689,6 +691,7 @@ static void bcm4377_handle_event(struct bcm4377_data *bcm4377,memcpy (skb_put (skb, len), payload, len);hci_skb_pkt_type (skb) = type; +btbcm_set_acl_priority_on_connect (bcm4377->hdev, skb);hci_recv_frame (bcm4377->hdev, skb); out:
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1201944/
---Test result---
Test Summary:
CheckPatch PASS 17.29 seconds VerifyFixes PASS 0.13 seconds VerifySignedoff PASS 0.13 seconds GitLint FAIL 5.05 seconds SubjectPrefix PASS 0.54 seconds BuildKernel PASS 31.31 seconds CheckAllWarning PASS 35.69 seconds CheckSparse WARNING 38.56 seconds BuildKernel32 PASS 33.61 seconds CheckKernelLLVM PASS 35.67 seconds TestRunnerSetup PASS 734.75 seconds TestRunner_l2cap-tester FAIL 10.66 seconds TestRunner_iso-tester PASS 10.73 seconds TestRunner_bnep-tester PASS 3.20 seconds TestRunner_mgmt-tester PASS 89.37 seconds TestRunner_rfcomm-tester PASS 4.51 seconds TestRunner_sco-tester PASS 5.75 seconds TestRunner_ioctl-tester PASS 4.71 seconds TestRunner_mesh-tester PASS 5.59 seconds TestRunner_smp-tester PASS 4.41 seconds TestRunner_userchan-tester PASS 3.26 seconds TestRunner_6lowpan-tester PASS 4.57 seconds IncrementalBuild PASS 36.66 seconds
Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[3/4] Revert "Bluetooth: hci_event: strip Broadcom vendor bits from legacy adv report type"
1: T1 Title exceeds max length (91>80): "[3/4] Revert "Bluetooth: hci_event: strip Broadcom vendor bits from legacy adv report type"" [4/4] Bluetooth: set the strict duplicate filter quirk on Apple Broadcom controllers
1: T1 Title exceeds max length (84>80): "[4/4] Bluetooth: set the strict duplicate filter quirk on Apple Broadcom controllers"
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
##############################
Test: TestRunner_l2cap-tester - FAIL
Desc: Run l2cap-tester with test-runner
Output:
Sanitizer errors:
==37==ERROR: AddressSanitizer: heap-use-after-free on address 0x7b96372e33d0 at pc 0x562d946f9e8e bp 0x7fffafeca460 sp 0x7fffafeca450 READ of size 4 at 0x7b96372e33d0 thread T0
#0 0x562d946f9e8d in timeout_callback src/shared/timeout-mainloop.c:33
#1 0x562d946fab75 in timeout_callback src/shared/mainloop.c:270
#2 0x562d946fbaa6 in mainloop_run src/shared/mainloop.c:124
#3 0x562d946fe3fa in mainloop_run_with_signal src/shared/mainloop-notify.c:196
#4 0x562d9470364b in tester_run src/shared/tester.c:1223
#5 0x562d9462d17d in main tools/l2cap-tester.c:3918
#6 0x7f56381c3600 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:59
#7 0x7f56381c3717 in __libc_start_main_impl ../csu/libc-start.c:360
#8 0x562d94633c84 in _start (/home/runner/work/bluetooth-next/bluetooth-next/src/bluez/tools/l2cap-tester+0x16cc84) (BuildId: 91c9d49e9766c394468e27ffa29b05e7d348169f)0x7b96372e33d0 is located 0 bytes inside of 40-byte region [0x7b96372e33d0,0x7b96372e33f8) freed by thread T0 here:
#0 0x7f5638b013ff in free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:51
#1 0x562d946fa36a in timeout_destroy src/shared/mainloop.c:251previously allocated by thread T0 here:
#0 0x7f5638b0260f in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:67
#1 0x562d946e42d5 in util_malloc src/shared/util.c:46SUMMARY: AddressSanitizer: heap-use-after-free src/shared/timeout-mainloop.c:33 in timeout_callback No test result found
https://github.com/bluez/bluetooth-next/pull/1065
---
Regards,
Linux Bluetooth
kernel test robot
build botRe: [PATCH 1/4] Bluetooth: btbcm: raise ACL priority on Apple Broadcom controllers
In reply to Andre Eikmeyerkernel test robot noticed the following build warnings:
Hi Andre,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 3f425f95ba3923d605f6a8b382e8fcdc59d479db]
url: https://github.com/intel-lab-lkp/linux/commits/Andre-Eikmeyer/Bluetooth-btbcm-raise-ACL-priority-on-Apple-Broadcom-controllers/20261104-161558 base: 3f425f95ba3923d605f6a8b382e8fcdc59d479db patch link: https://lore.kernel.org/r/20261104151601.70493-2-dev%40deq.rocks patch subject: [PATCH 1/4] Bluetooth: btbcm: raise ACL priority on Apple Broadcom controllers config: sh-allyesconfig (https://download.01.org/0day-ci/archive/20261105/[email protected]/config) compiler: sh4-linux-gcc (GCC) 16.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261105/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> Warning: drivers/bluetooth/hci_bcm.c:152 struct member 'acl_priority' not described in 'bcm_device' >> Warning: drivers/bluetooth/hci_bcm.c:152 struct member 'acl_priority' not described in 'bcm_device'
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
PATCH 2/4 Bluetooth: btbcm: clear vendor bits in LE advertising report types
In reply to Andre EikmeyerThe BCM4364B0 of the MacBookPro15,1 (UART) and the BCM4377 of the MacBookAir9,1 (PCIe) set bits 4, 5 and 7 of the event type in LE Advertising Report events. btmon on the 15,1 shows types 0x10, 0x13, 0x14, 0x20, 0x23, 0x24, 0x93 and 0xa0 next to plain 0x00, 0x03 and 0x04, the same advertiser shows up as 0x13, 0x23 and 0x03. The kernel log of the 9,1 lists 0x10 to 0x24 and 0x80, 0x83, 0x90, 0x93, 0xa0, 0xa3. process_adv_report() drops every type above 0x04 with "Unknown advertising packet type", so most advertisements never reach the host. An AirDrop sender was reported as 0x23, 0x23 and 0x13 and only the fourth report, 0x03, reached BlueZ 32 s after the first one.
Add btbcm_fixup_le_adv_report(), which clears the bits above the type, and call it from hci_bcm on Apple machines and from hci_bcm4377 before the event goes to the core.
--- drivers/bluetooth/btbcm.c | 30 ++++++++++++++++++++++++++++++ drivers/bluetooth/btbcm.h | 5 +++++ drivers/bluetooth/hci_bcm.c | 5 +++++ drivers/bluetooth/hci_bcm4377.c | 1 + 4 files changed, 41 insertions(+)
drivers/bluetooth/btbcm.c +30 -0
@@ -282,6 +282,36 @@ void btbcm_set_acl_priority_on_connect(struct hci_dev *hdev, struct sk_buff *skb }EXPORT_SYMBOL_GPL (btbcm_set_acl_priority_on_connect); +/* The BCM4364 and BCM4377 of the T2 Macs set bits above the event type of LE +* Advertising Reports, 0x13 and 0x23 for ADV_NONCONN_IND for example. The +* core drops reports of unknown types, so clear them. +*/ +void btbcm_fixup_le_adv_report (struct sk_buff *skb) +{ +struct hci_event_hdr *hdr = (void *)skb->data; +struct hci_ev_le_advertising_info *info; +u8 *p, *end; +u8 num; + +if (hci_skb_pkt_type (skb) !=HCI_EVENT_PKT || + skb->len <HCI_EVENT_HDR_SIZE +2 || hdr->evt !=HCI_EV_LE_META ) +return ; + + p = skb->data +HCI_EVENT_HDR_SIZE ; +if (p[0 ] !=HCI_EV_LE_ADVERTISING_REPORT ) +return ; + + num = p[1 ]; + p +=2 ; + end = skb->data + skb->len; +while (num-- && p +sizeof (*info) +1 <= end) { + info = (void *)p; + info->type &=0x0f ; + p +=sizeof (*info) + info->length +1 ; + } +} +EXPORT_SYMBOL_GPL (btbcm_fixup_le_adv_report); +int btbcm_patchram (struct hci_dev *hdev,const struct firmware *fw) {const struct hci_command_hdr *cmd;
drivers/bluetooth/btbcm.h +5 -0
@@ -60,6 +60,7 @@ int btbcm_write_pcm_int_params(struct hci_dev *hdev, const struct bcm_set_pcm_int_params *params);void btbcm_set_acl_priority_on_connect (struct hci_dev *hdev,struct sk_buff *skb); +void btbcm_fixup_le_adv_report (struct sk_buff *skb);int btbcm_setup_patchram (struct hci_dev *hdev);int btbcm_setup_apple (struct hci_dev *hdev);
@@ -101,6 +102,10 @@ static inline void btbcm_set_acl_priority_on_connect(struct hci_dev *hdev, { } +static inline void btbcm_fixup_le_adv_report (struct sk_buff *skb) +{ +} +static inline int btbcm_setup_patchram (struct hci_dev *hdev) {return 0 ;
drivers/bluetooth/hci_bcm.c +5 -0
@@ -148,6 +148,7 @@ struct bcm_device {bool no_uart_clock_set;bool use_autobaud_mode;bool acl_priority; +bool adv_type_fixup;u8 pcm_int_params[5 ];u32 max_autobaud_speed; };
@@ -686,6 +687,9 @@ static int bcm_recv_event(struct hci_dev *hdev, struct sk_buff *skb)struct hci_uart *hu =hci_get_drvdata (hdev);struct bcm_data *bcm = hu->priv; +if (bcm->dev && bcm->dev->adv_type_fixup) +btbcm_fixup_le_adv_report (skb); +if (bcm->dev && bcm->dev->acl_priority)btbcm_set_acl_priority_on_connect (hdev, skb);
@@ -1100,6 +1104,7 @@ static int bcm_get_resources(struct bcm_device *dev)if (x86_apple_machine && !bcm_apple_get_resources (dev)) { dev->acl_priority = true; + dev->adv_type_fixup = true;return 0 ; }
drivers/bluetooth/hci_bcm4377.c +1 -0
@@ -691,6 +691,7 @@ static void bcm4377_handle_event(struct bcm4377_data *bcm4377,memcpy (skb_put (skb, len), payload, len);hci_skb_pkt_type (skb) = type; +btbcm_fixup_le_adv_report (skb);btbcm_set_acl_priority_on_connect (bcm4377->hdev, skb);hci_recv_frame (bcm4377->hdev, skb);
Luiz Augusto von Dentz
maintainerRe: [PATCH 2/4] Bluetooth: btbcm: clear vendor bits in LE advertising report types
Hi Andre,
Quoted 54 lines · Andre Eikmeyer
The BCM4364B0 of the MacBookPro15,1 (UART) and the BCM4377 of the MacBookAir9,1 (PCIe) set bits 4, 5 and 7 of the event type in LE Advertising Report events. btmon on the 15,1 shows types
0x10,0x13,0x14,0x20,0x23,0x24,0x93and0xa0next to plain0x00,0x03and0x04, the same advertiser shows up as0x13,0x23and0x03. The kernel log of the 9,1 lists0x10to0x24and0x80,0x83,0x90,0x93,0xa0,0xa3.process_adv_report()drops every type above0x04with "Unknown advertising packet type", so most advertisements never reach the host. An AirDrop sender was reported as0x23,0x23and0x13and only the fourth report,0x03, reached BlueZ 32 s after the first one.Add
btbcm_fixup_le_adv_report(), which clears the bits above the type, and call it fromhci_bcmon Apple machines and fromhci_bcm4377before the event goes to the core.Suggested-by Jose Miguel Ochoa <[email protected]>Tested-by Yossef Osman <[email protected]>Tested-by Aditya Garg <[email protected]>Signed-off-by Andre Eikmeyer <[email protected]>--- drivers/bluetooth/btbcm.c | 30 ++++++++++++++++++++++++++++++ drivers/bluetooth/btbcm.h | 5 +++++ drivers/bluetooth/hci_bcm.c | 5 +++++ drivers/bluetooth/hci_bcm4377.c | 1 + 4 files changed, 41 insertions(+)drivers/bluetooth/btbcm.c +19
-0@@ -282,6 +282,36 @@ void btbcm_set_acl_priority_on_connect(struct hci_dev *hdev, struct sk_buff *skb }EXPORT_SYMBOL_GPL (btbcm_set_acl_priority_on_connect); +/* The BCM4364 and BCM4377 of the T2 Macs set bits above the event type of LE +* Advertising Reports, 0x13 and 0x23 for ADV_NONCONN_IND for example. The +* core drops reports of unknown types, so clear them. +*/ +void btbcm_fixup_le_adv_report (struct sk_buff *skb) +{ +struct hci_event_hdr *hdr = (void *)skb->data; +struct hci_ev_le_advertising_info *info; +u8 *p, *end; +u8 num; + +if (hci_skb_pkt_type (skb) !=HCI_EVENT_PKT || + skb->len <HCI_EVENT_HDR_SIZE +2 || hdr->evt !=HCI_EV_LE_META ) +return ; + + p = skb->data +HCI_EVENT_HDR_SIZE ; +if (p[0 ] !=HCI_EV_LE_ADVERTISING_REPORT ) +return ; +
drivers/bluetooth/btbcm.c void btbcm_set_acl_priority_on_connect(struct hci_dev *hdev, struct sk_buff *skb · line 313
Quoted 10 lines
drivers/bluetooth/btbcm.c +10
-0+ num = p[1 ]; + p +=2 ; + end = skb->data + skb->len; +while (num-- && p +sizeof (*info) +1 <= end) { + info = (void *)p; + info->type &=0x0f ; + p +=sizeof (*info) + info->length +1 ; + } +} +EXPORT_SYMBOL_GPL (btbcm_fixup_le_adv_report);
I don't think I agree with this being cleaner then doing at hci_event.though; not only is it more code but it also walks the packet which is inefficient and may have security implications as well.
Quoted 68 lines
drivers/bluetooth/btbcm.c +0
-0int btbcm_patchram (struct hci_dev *hdev,const struct firmware *fw) {const struct hci_command_hdr *cmd;drivers/bluetooth/btbcm.h +5
-0@@ -60,6 +60,7 @@ int btbcm_write_pcm_int_params(struct hci_dev *hdev, const struct bcm_set_pcm_int_params *params);void btbcm_set_acl_priority_on_connect (struct hci_dev *hdev,struct sk_buff *skb); +void btbcm_fixup_le_adv_report (struct sk_buff *skb);int btbcm_setup_patchram (struct hci_dev *hdev);int btbcm_setup_apple (struct hci_dev *hdev);@@ -101,6 +102,10 @@ static inline void btbcm_set_acl_priority_on_connect(struct hci_dev *hdev, { } +static inline void btbcm_fixup_le_adv_report (struct sk_buff *skb) +{ +} +static inline int btbcm_setup_patchram (struct hci_dev *hdev) {return 0 ;drivers/bluetooth/hci_bcm.c +5
-0@@ -148,6 +148,7 @@ struct bcm_device {bool no_uart_clock_set;bool use_autobaud_mode;bool acl_priority; +bool adv_type_fixup;u8 pcm_int_params[5 ];u32 max_autobaud_speed; };@@ -686,6 +687,9 @@ static int bcm_recv_event(struct hci_dev *hdev, struct sk_buff *skb)struct hci_uart *hu =hci_get_drvdata (hdev);struct bcm_data *bcm = hu->priv; +if (bcm->dev && bcm->dev->adv_type_fixup) +btbcm_fixup_le_adv_report (skb); +if (bcm->dev && bcm->dev->acl_priority)btbcm_set_acl_priority_on_connect (hdev, skb);@@ -1100,6 +1104,7 @@ static int bcm_get_resources(struct bcm_device *dev)if (x86_apple_machine && !bcm_apple_get_resources (dev)) { dev->acl_priority = true; + dev->adv_type_fixup = true;return 0 ; }drivers/bluetooth/hci_bcm4377.c +1
-0@@ -691,6 +691,7 @@ static void bcm4377_handle_event(struct bcm4377_data *bcm4377,memcpy (skb_put (skb, len), payload, len);hci_skb_pkt_type (skb) = type; +btbcm_fixup_le_adv_report (skb);btbcm_set_acl_priority_on_connect (bcm4377->hdev, skb);hci_recv_frame (bcm4377->hdev, skb);
Signature · 1 line
Luiz Augusto von Dentz
Re: [PATCH 2/4] Bluetooth: btbcm: clear vendor bits in LE advertising report types
Quoted 67 lines · Luiz Augusto von Dentz
Hi Andre,
Quoted 62 lines · Andre Eikmeyer
The BCM4364B0 of the MacBookPro15,1 (UART) and the BCM4377 of the MacBookAir9,1 (PCIe) set bits 4, 5 and 7 of the event type in LE Advertising Report events. btmon on the 15,1 shows types
0x10,0x13,0x14,0x20,0x23,0x24,0x93and0xa0next to plain0x00,0x03and0x04, the same advertiser shows up as0x13,0x23and0x03. The kernel log of the 9,1 lists0x10to0x24and0x80,0x83,0x90,0x93,0xa0,0xa3.process_adv_report()drops every type above0x04with "Unknown advertising packet type", so most advertisements never reach the host. An AirDrop sender was reported as0x23,0x23and0x13and only the fourth report,0x03, reached BlueZ 32 s after the first one.Add
btbcm_fixup_le_adv_report(), which clears the bits above the type, and call it fromhci_bcmon Apple machines and fromhci_bcm4377before the event goes to the core.Suggested-by Jose Miguel Ochoa <[email protected]>Tested-by Yossef Osman <[email protected]>Tested-by Aditya Garg <[email protected]>Signed-off-by Andre Eikmeyer <[email protected]>---
drivers/bluetooth/btbcm.c | 30 ++++++++++++++++++++++++++++++ drivers/bluetooth/btbcm.h | 5 +++++ drivers/bluetooth/hci_bcm.c | 5 +++++ drivers/bluetooth/hci_bcm4377.c | 1 + 4 files changed, 41 insertions(+)drivers/bluetooth/btbcm.c +26
-0@@ -282,6 +282,36 @@ void btbcm_set_acl_priority_on_connect(struct hci_dev *hdev, struct sk_buff *skb }EXPORT_SYMBOL_GPL (btbcm_set_acl_priority_on_connect); +/* The BCM4364 and BCM4377 of the T2 Macs set bits above the event type of LE +* Advertising Reports, 0x13 and 0x23 for ADV_NONCONN_IND for example. The +* core drops reports of unknown types, so clear them. +*/ +void btbcm_fixup_le_adv_report (struct sk_buff *skb) +{ +struct hci_event_hdr *hdr = (void *)skb->data; +struct hci_ev_le_advertising_info *info; +u8 *p, *end; +u8 num; + +if (hci_skb_pkt_type (skb) !=HCI_EVENT_PKT || + skb->len <HCI_EVENT_HDR_SIZE +2 || hdr->evt !=HCI_EV_LE_META ) +return ; + + p = skb->data +HCI_EVENT_HDR_SIZE ; +if (p[0 ] !=HCI_EV_LE_ADVERTISING_REPORT ) +return ; + + num = p[1 ]; + p +=2 ; + end = skb->data + skb->len; +while (num-- && p +sizeof (*info) +1 <= end) { + info = (void *)p; + info->type &=0x0f ; + p +=sizeof (*info) + info->length +1 ;
Quoted 8 lines
drivers/bluetooth/btbcm.c void btbcm_set_acl_priority_on_connect(struct hci_dev *hdev, struct sk_buff *skb · line 313
Quoted 3 lines
drivers/bluetooth/btbcm.c +3
-0+ } +} +EXPORT_SYMBOL_GPL (btbcm_fixup_le_adv_report);I don't think I agree with this being cleaner then doing at hci_event.though; not only is it more code but it also walks the packet which is inefficient and may have security implications as well.
The hci_event patch makes it apply for all Broadcom chips. The author who sent that patch themselves use a T2 Mac. I doubt all Broadcom chips need this because there have been no bug reports from normal PCs.
Re: [PATCH 2/4] Bluetooth: btbcm: clear vendor bits in LE advertising report types
In reply to Luiz Augusto von DentzQuoted 4 lines · On Wed, 4 Nov 2026 10:24:47 -0500 Luiz Augusto von Dentz…
I don't think I agree with this being cleaner then doing at hci_event.though; not only is it more code but it also walks the packet which is inefficient and may have security implications as well.
You are right, the driver should not parse the event a second time.
What I would like to keep is limiting the mask to the controllers that set these bits, as hci_bcm4377 already does with HCI_QUIRK_FIXUP_LE_EXT_ADV_REPORT_PHY:
- add HCI_QUIRK_FIXUP_LE_ADV_REPORT_TYPE
- set it in hci_bcm on Apple machines and in hci_bcm4377
- test the quirk in hci_le_adv_report_evt() instead of the manufacturer, keeping the mask from 88397423671f
That drops patch 2 and replaces the revert in patch 3. Would that work for you? Then I would send a v2 along these lines, with patch 1 and 4 unchanged.
Thanks,
Andre
Luiz Augusto von Dentz
maintainerRe: [PATCH 2/4] Bluetooth: btbcm: clear vendor bits in LE advertising report types
Hi Andre,
Quoted 15 lines · André Eikmeyer
Quoted 4 lines · On Wed, 4 Nov 2026 10:24:47 -0500 Luiz Augusto von Dentz…
I don't think I agree with this being cleaner then doing at hci_event.though; not only is it more code but it also walks the packet which is inefficient and may have security implications as well.
You are right, the driver should not parse the event a second time.
What I would like to keep is limiting the mask to the controllers that set these bits, as
hci_bcm4377already does withHCI_QUIRK_FIXUP_LE_EXT_ADV_REPORT_PHY:
Quoted 8 lines
- add
HCI_QUIRK_FIXUP_LE_ADV_REPORT_TYPE
- set it inhci_bcmon Apple machines and inhci_bcm4377
- test the quirk inhci_le_adv_report_evt()instead of the manufacturer, keeping the mask from88397423671fThat drops patch 2 and replaces the revert in patch 3. Would that work for you? Then I would send a v2 along these lines, with patch 1 and 4 unchanged.
Yes that would work. That said, I don't think it is worth adding a quirk for this. Masking the reserved bits shouldn't cause any side effects afaik, well except if those bits are later adopted by Bluetooth SIG. Then these controllers would become non-compliant—though they already are, as the bits are reserved and not in use. In that case we would probably require a quirk to avoid a conflict. So, is that what you are trying to fix?
Signature · 1 line
Luiz Augusto von Dentz
Re: [PATCH 2/4] Bluetooth: btbcm: clear vendor bits in LE advertising report types
Quoted 7 lines · On Wed, 4 Nov 2026 11:29:11 -0500 Luiz Augusto von Dentz…
Yes that would work. That said, I don't think it is worth adding a quirk for this. Masking the reserved bits shouldn't cause any side effects afaik, well except if those bits are later adopted by Bluetooth SIG. Then these controllers would become non-compliant—though they already are, as the bits are reserved and not in use. In that case we would probably require a quirk to avoid a conflict. So, is that what you are trying to fix?
No, nothing concrete beyond the scope, and I agree it is harmless as long as the bits stay reserved. We only put it in the drivers because our downstream ships driver modules through DKMS and not bluetooth.ko, which let many users test it quickly. Let's keep 88397423671f as it is then. I'll drop patch 2 and 3 and send a v2 with patch 1 and 4.
kernel test robot
build botRe: [PATCH 2/4] Bluetooth: btbcm: clear vendor bits in LE advertising report types
In reply to Andre Eikmeyerkernel test robot noticed the following build warnings:
Hi Andre,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 3f425f95ba3923d605f6a8b382e8fcdc59d479db]
url: https://github.com/intel-lab-lkp/linux/commits/Andre-Eikmeyer/Bluetooth-btbcm-raise-ACL-priority-on-Apple-Broadcom-controllers/20261104-161558 base: 3f425f95ba3923d605f6a8b382e8fcdc59d479db patch link: https://lore.kernel.org/r/20261104151601.70493-3-dev%40deq.rocks patch subject: [PATCH 2/4] Bluetooth: btbcm: clear vendor bits in LE advertising report types config: sh-allyesconfig (https://download.01.org/0day-ci/archive/20261105/[email protected]/config) compiler: sh4-linux-gcc (GCC) 16.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261105/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
Warning: drivers/bluetooth/hci_bcm.c:153 struct member 'acl_priority' not described in 'bcm_device'
>> Warning: drivers/bluetooth/hci_bcm.c:153 struct member 'adv_type_fixup' not described in 'bcm_device' Warning: drivers/bluetooth/hci_bcm.c:153 struct member 'acl_priority' not described in 'bcm_device' >> Warning: drivers/bluetooth/hci_bcm.c:153 struct member 'adv_type_fixup' not described in 'bcm_device'
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
PATCH 3/4 Revert "Bluetooth: hci_event: strip Broadcom vendor bits from legacy adv report type"
In reply to Andre EikmeyerThis reverts commit 88397423671f2b54119a6162a1834d207dcf1a81.
The commit clears the upper bits of the legacy LE Advertising Report event type for every controller with manufacturer 15, Broadcom. The reports of these bits, in its own commit message and here, all come from the Broadcom controllers of the Apple T2 Macs.
The previous patch clears the bits in hci_bcm on Apple machines and in hci_bcm4377, the drivers of these controllers, before the event reaches the core. That makes the check in hci_le_adv_report_evt() redundant for them.
--- net/bluetooth/hci_event.c | 11 ----------- 1 file changed, 11 deletions(-)
net/bluetooth/hci_event.c +0 -11
@@ -6683,17 +6683,6 @@ static void hci_le_adv_report_evt(struct hci_dev *hdev, void *data,hci_store_wake_reason (hdev, &info->bdaddr, info->bdaddr_type); -/* Broadcom ROM firmware (BCM4364B3 on Apple T2 Macs, no -* patchram) sets vendor bits in the legacy Event_Type. -*/ -if (hdev->manufacturer ==15 && info->type >LE_ADV_SCAN_RSP ) { -/* 0x0f masks out upper vendor bits (0x10, 0x20, 0x80), -* extracting the standard legacy advertising type -* (0x00-0x04) stored in the low nibble (bits 0-3). -*/ - info->type &=0x0f ; - } -if (info->length <=max_adv_len (hdev)) { rssi = info->data[info->length]; process_adv_report(hdev, info->type, &info->bdaddr,
PATCH 4/4 Bluetooth: set the strict duplicate filter quirk on Apple Broadcom controllers
In reply to Andre Eikmeyerbtbcm_finalize() sets HCI_QUIRK_STRICT_DUPLICATE_FILTER, but bcm_setup() returns before it when no patch file was loaded. The MacBookPro15,1 has none for its BCM4364B0 ("BCM: firmware Patch file not found"). hci_bcm4377 does not use btbcm_finalize() and never sets the quirk. A service discovery then scans with "Filter duplicates: Enabled", and the controller reports an address once per discovery cycle of about 10.7 s. A Mac that changed its advertisement data on the same address was reported 6 s after the change, at the next cycle.
Set the quirk in hci_bcm on that path and in hci_bcm4377.
--- drivers/bluetooth/hci_bcm.c | 5 ++++- drivers/bluetooth/hci_bcm4377.c | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/bluetooth/hci_bcm.c +4 -1
@@ -597,8 +597,11 @@ static int bcm_setup(struct hci_uart *hu)if (err)return err; -if (!fw_load_done) +if (!fw_load_done) { +/* btbcm_finalize() sets this after loading a patch file */ +hci_set_quirk (hu->hdev,HCI_QUIRK_STRICT_DUPLICATE_FILTER );return 0 ; + }/* Init speed if any */ if (bcm->dev && bcm->dev->init_speed)
drivers/bluetooth/hci_bcm4377.c +5 -0
@@ -2392,6 +2392,11 @@ static int bcm4377_probe(struct pci_dev *pdev, const struct pci_device_id *id) hdev->set_bdaddr = bcm4377_hci_set_bdaddr; hdev->setup = bcm4377_hci_setup; +/* The controller reports an address once per scan with duplicate +* filtering, also after its advertisement data changed. +*/ +hci_set_quirk (hdev,HCI_QUIRK_STRICT_DUPLICATE_FILTER ); +if (bcm4377->hw->broken_mws_transport_config)hci_set_quirk (hdev,HCI_QUIRK_BROKEN_MWS_TRANSPORT_CONFIG );if (bcm4377->hw->broken_ext_scan)