Skip to content

Commit 32868e1

Browse files
jhovoldVudentz
authored andcommitted
Bluetooth: qca: fix invalid device address check
Qualcomm Bluetooth controllers may not have been provisioned with a valid device address and instead end up using the default address 00:00:00:00:5a:ad. This was previously believed to be due to lack of persistent storage for the address but it may also be due to integrators opting to not use the on-chip OTP memory and instead store the address elsewhere (e.g. in storage managed by secure world firmware). According to Qualcomm, at least WCN6750, WCN6855 and WCN7850 have on-chip OTP storage for the address. As the device type alone cannot be used to determine when the address is valid, instead read back the address during setup() and only set the HCI_QUIRK_USE_BDADDR_PROPERTY flag when needed. This specifically makes sure that controllers that have been provisioned with an address do not start as unconfigured. Reported-by: Janaki Ramaiah Thota <[email protected]> Link: https://lore.kernel.org/r/[email protected]/ Fixes: 5971752 ("Bluetooth: hci_qca: Set HCI_QUIRK_USE_BDADDR_PROPERTY for wcn3990") Fixes: e668eb1 ("Bluetooth: hci_core: Don't stop BT if the BD address missing in dts") Fixes: 6945795 ("Bluetooth: fix use-bdaddr-property quirk") Cc: [email protected] # 6.5 Cc: Matthias Kaehlcke <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Reported-by: Janaki Ramaiah Thota <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent a9a830a commit 32868e1

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

drivers/bluetooth/btqca.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#define VERSION "0.1"
1717

18+
#define QCA_BDADDR_DEFAULT (&(bdaddr_t) {{ 0xad, 0x5a, 0x00, 0x00, 0x00, 0x00 }})
19+
1820
int qca_read_soc_version(struct hci_dev *hdev, struct qca_btsoc_version *ver,
1921
enum qca_btsoc_type soc_type)
2022
{
@@ -612,6 +614,38 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
612614
}
613615
EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome);
614616

617+
static int qca_check_bdaddr(struct hci_dev *hdev)
618+
{
619+
struct hci_rp_read_bd_addr *bda;
620+
struct sk_buff *skb;
621+
int err;
622+
623+
if (bacmp(&hdev->public_addr, BDADDR_ANY))
624+
return 0;
625+
626+
skb = __hci_cmd_sync(hdev, HCI_OP_READ_BD_ADDR, 0, NULL,
627+
HCI_INIT_TIMEOUT);
628+
if (IS_ERR(skb)) {
629+
err = PTR_ERR(skb);
630+
bt_dev_err(hdev, "Failed to read device address (%d)", err);
631+
return err;
632+
}
633+
634+
if (skb->len != sizeof(*bda)) {
635+
bt_dev_err(hdev, "Device address length mismatch");
636+
kfree_skb(skb);
637+
return -EIO;
638+
}
639+
640+
bda = (struct hci_rp_read_bd_addr *)skb->data;
641+
if (!bacmp(&bda->bdaddr, QCA_BDADDR_DEFAULT))
642+
set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
643+
644+
kfree_skb(skb);
645+
646+
return 0;
647+
}
648+
615649
static void qca_generate_hsp_nvm_name(char *fwname, size_t max_size,
616650
struct qca_btsoc_version ver, u8 rom_ver, u16 bid)
617651
{
@@ -818,6 +852,10 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
818852
break;
819853
}
820854

855+
err = qca_check_bdaddr(hdev);
856+
if (err)
857+
return err;
858+
821859
bt_dev_info(hdev, "QCA setup on UART is completed");
822860

823861
return 0;

drivers/bluetooth/hci_qca.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,8 +1905,6 @@ static int qca_setup(struct hci_uart *hu)
19051905
case QCA_WCN6750:
19061906
case QCA_WCN6855:
19071907
case QCA_WCN7850:
1908-
set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
1909-
19101908
qcadev = serdev_device_get_drvdata(hu->serdev);
19111909
if (qcadev->bdaddr_property_broken)
19121910
set_bit(HCI_QUIRK_BDADDR_PROPERTY_BROKEN, &hdev->quirks);

0 commit comments

Comments
 (0)