]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/6.6.26/bluetooth-add-quirk-for-broken-address-properties.patch
Linux 6.6.26
[thirdparty/kernel/stable-queue.git] / releases / 6.6.26 / bluetooth-add-quirk-for-broken-address-properties.patch
1 From 39646f29b100566451d37abc4cc8cdd583756dfe Mon Sep 17 00:00:00 2001
2 From: Johan Hovold <johan+linaro@kernel.org>
3 Date: Wed, 20 Mar 2024 08:55:53 +0100
4 Subject: Bluetooth: add quirk for broken address properties
5
6 From: Johan Hovold <johan+linaro@kernel.org>
7
8 commit 39646f29b100566451d37abc4cc8cdd583756dfe upstream.
9
10 Some Bluetooth controllers lack persistent storage for the device
11 address and instead one can be provided by the boot firmware using the
12 'local-bd-address' devicetree property.
13
14 The Bluetooth devicetree bindings clearly states that the address should
15 be specified in little-endian order, but due to a long-standing bug in
16 the Qualcomm driver which reversed the address some boot firmware has
17 been providing the address in big-endian order instead.
18
19 Add a new quirk that can be set on platforms with broken firmware and
20 use it to reverse the address when parsing the property so that the
21 underlying driver bug can be fixed.
22
23 Fixes: 5c0a1001c8be ("Bluetooth: hci_qca: Add helper to set device address")
24 Cc: stable@vger.kernel.org # 5.1
25 Reviewed-by: Douglas Anderson <dianders@chromium.org>
26 Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
27 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
28 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29 ---
30 include/net/bluetooth/hci.h | 9 +++++++++
31 net/bluetooth/hci_sync.c | 5 ++++-
32 2 files changed, 13 insertions(+), 1 deletion(-)
33
34 --- a/include/net/bluetooth/hci.h
35 +++ b/include/net/bluetooth/hci.h
36 @@ -176,6 +176,15 @@ enum {
37 */
38 HCI_QUIRK_USE_BDADDR_PROPERTY,
39
40 + /* When this quirk is set, the Bluetooth Device Address provided by
41 + * the 'local-bd-address' fwnode property is incorrectly specified in
42 + * big-endian order.
43 + *
44 + * This quirk can be set before hci_register_dev is called or
45 + * during the hdev->setup vendor callback.
46 + */
47 + HCI_QUIRK_BDADDR_PROPERTY_BROKEN,
48 +
49 /* When this quirk is set, the duplicate filtering during
50 * scanning is based on Bluetooth devices addresses. To allow
51 * RSSI based updates, restart scanning if needed.
52 --- a/net/bluetooth/hci_sync.c
53 +++ b/net/bluetooth/hci_sync.c
54 @@ -3292,7 +3292,10 @@ static void hci_dev_get_bd_addr_from_pro
55 if (ret < 0 || !bacmp(&ba, BDADDR_ANY))
56 return;
57
58 - bacpy(&hdev->public_addr, &ba);
59 + if (test_bit(HCI_QUIRK_BDADDR_PROPERTY_BROKEN, &hdev->quirks))
60 + baswap(&hdev->public_addr, &ba);
61 + else
62 + bacpy(&hdev->public_addr, &ba);
63 }
64
65 struct hci_init_stage {