Skip to content

Commit ed2a2ef

Browse files
svenpeter42Vudentz
authored andcommitted
Bluetooth: Add quirk to ignore reserved PHY bits in LE Extended Adv Report
Some Broadcom controllers found on Apple Silicon machines abuse the reserved bits inside the PHY fields of LE Extended Advertising Report events for additional flags. Add a quirk to drop these and correctly extract the Primary/Secondary_PHY field. The following excerpt from a btmon trace shows a report received with "Reserved" for "Primary PHY" on a 4388 controller: > HCI Event: LE Meta Event (0x3e) plen 26 LE Extended Advertising Report (0x0d) Num reports: 1 Entry 0 Event type: 0x2515 Props: 0x0015 Connectable Directed Use legacy advertising PDUs Data status: Complete Reserved (0x2500) Legacy PDU Type: Reserved (0x2515) Address type: Random (0x01) Address: 00:00:00:00:00:00 (Static) Primary PHY: Reserved Secondary PHY: No packets SID: no ADI field (0xff) TX power: 127 dBm RSSI: -60 dBm (0xc4) Periodic advertising interval: 0.00 msec (0x0000) Direct address type: Public (0x00) Direct address: 00:00:00:00:00:00 (Apple, Inc.) Data length: 0x00 Cc: stable@vger.kernel.org Fixes: 2e7ed5f ("Bluetooth: hci_sync: Use advertised PHYs on hci_le_ext_create_conn_sync") Reported-by: Janne Grunau <j@jannau.net> Closes: https://lore.kernel.org/all/Zjz0atzRhFykROM9@robin Tested-by: Janne Grunau <j@jannau.net> Signed-off-by: Sven Peter <sven@svenpeter.dev> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent dc6be0b commit ed2a2ef

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

drivers/bluetooth/hci_bcm4377.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,10 @@ struct bcm4377_data;
495495
* extended scanning
496496
* broken_mws_transport_config: Set to true if the chip erroneously claims to
497497
* support MWS Transport Configuration
498+
* broken_le_ext_adv_report_phy: Set to true if this chip stuffs flags inside
499+
* reserved bits of Primary/Secondary_PHY inside
500+
* LE Extended Advertising Report events which
501+
* have to be ignored
498502
* send_calibration: Optional callback to send calibration data
499503
* send_ptb: Callback to send "PTB" regulatory/calibration data
500504
*/
@@ -513,6 +517,7 @@ struct bcm4377_hw {
513517
unsigned long broken_ext_scan : 1;
514518
unsigned long broken_mws_transport_config : 1;
515519
unsigned long broken_le_coded : 1;
520+
unsigned long broken_le_ext_adv_report_phy : 1;
516521

517522
int (*send_calibration)(struct bcm4377_data *bcm4377);
518523
int (*send_ptb)(struct bcm4377_data *bcm4377,
@@ -2373,6 +2378,8 @@ static int bcm4377_probe(struct pci_dev *pdev, const struct pci_device_id *id)
23732378
set_bit(HCI_QUIRK_BROKEN_EXT_SCAN, &hdev->quirks);
23742379
if (bcm4377->hw->broken_le_coded)
23752380
set_bit(HCI_QUIRK_BROKEN_LE_CODED, &hdev->quirks);
2381+
if (bcm4377->hw->broken_le_ext_adv_report_phy)
2382+
set_bit(HCI_QUIRK_FIXUP_LE_EXT_ADV_REPORT_PHY, &hdev->quirks);
23762383

23772384
pci_set_drvdata(pdev, bcm4377);
23782385
hci_set_drvdata(hdev, bcm4377);
@@ -2477,6 +2484,7 @@ static const struct bcm4377_hw bcm4377_hw_variants[] = {
24772484
.clear_pciecfg_subsystem_ctrl_bit19 = true,
24782485
.broken_mws_transport_config = true,
24792486
.broken_le_coded = true,
2487+
.broken_le_ext_adv_report_phy = true,
24802488
.send_calibration = bcm4387_send_calibration,
24812489
.send_ptb = bcm4378_send_ptb,
24822490
},

include/net/bluetooth/hci.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,17 @@ enum {
324324
* claim to support it.
325325
*/
326326
HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE,
327+
328+
/*
329+
* When this quirk is set, the reserved bits of Primary/Secondary_PHY
330+
* inside the LE Extended Advertising Report events are discarded.
331+
* This is required for some Apple/Broadcom controllers which
332+
* abuse these reserved bits for unrelated flags.
333+
*
334+
* This quirk can be set before hci_register_dev is called or
335+
* during the hdev->setup vendor callback.
336+
*/
337+
HCI_QUIRK_FIXUP_LE_EXT_ADV_REPORT_PHY,
327338
};
328339

329340
/* HCI device flags */

net/bluetooth/hci_event.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6311,6 +6311,13 @@ static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, void *data,
63116311

63126312
evt_type = __le16_to_cpu(info->type) & LE_EXT_ADV_EVT_TYPE_MASK;
63136313
legacy_evt_type = ext_evt_type_to_legacy(hdev, evt_type);
6314+
6315+
if (test_bit(HCI_QUIRK_FIXUP_LE_EXT_ADV_REPORT_PHY,
6316+
&hdev->quirks)) {
6317+
info->primary_phy &= 0x1f;
6318+
info->secondary_phy &= 0x1f;
6319+
}
6320+
63146321
if (legacy_evt_type != LE_ADV_INVALID) {
63156322
process_adv_report(hdev, legacy_evt_type, &info->bdaddr,
63166323
info->bdaddr_type, NULL, 0,

0 commit comments

Comments
 (0)