From: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: marcel@holtmann.org
Subject: [PATCH] Bluetooth: btusb: Fallback to 16 bit ROM version lookup
Date: Tue, 9 Feb 2021 12:40:24 +0100 [thread overview]
Message-ID: <20210209114024.2910-2-falbrechtskirchinger@gmail.com> (raw)
In-Reply-To: <20210209114024.2910-1-falbrechtskirchinger@gmail.com>
Commit b40f58b97386 ("Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855
support") changes ROM version lookup from 16 bit to 32 bit. Previously, the
upper 16 bit of the version number were ignored. This breaks setups, where the
upper 16 bits are non-zero, but are now assumed to be zero.
An example of such a device would be
0cf3:3008 Qualcomm Atheros Communications Bluetooth (AR3011)
with ROM version 0x1020200 and this corresponding entry in the device table:
{ 0x00000200, 28, 4, 16 }, /* Rome 2.0 */
This patch adds a potential second round of lookups that mimics the old
behavior, should no version have been matched by comparing the full 32 bits.
During this second round only the lower 16 bits are compared, but only where
the upper 16 bits are defined zero in the lookup table.
Fixes: b40f58b97386 ("Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855
support")
Signed-off-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
---
drivers/bluetooth/btusb.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 03b83aa91277..d8c4c6474f14 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -4054,6 +4054,7 @@ static int btusb_setup_qca(struct hci_dev *hdev)
const struct qca_device_info *info = NULL;
struct qca_version ver;
u32 ver_rom;
+ u16 ver_rom_low;
u8 status;
int i, err;
@@ -4065,8 +4066,22 @@ static int btusb_setup_qca(struct hci_dev *hdev)
ver_rom = le32_to_cpu(ver.rom_version);
for (i = 0; i < ARRAY_SIZE(qca_devices_table); i++) {
- if (ver_rom == qca_devices_table[i].rom_version)
+ if (ver_rom == qca_devices_table[i].rom_version) {
info = &qca_devices_table[i];
+ break;
+ }
+ }
+ if (!info) {
+ // If we don't find an exact version match, try with
+ // the lower half, but only where the upper half is 0
+ ver_rom_low = ver_rom & 0xffff;
+ for (i = 0; i < ARRAY_SIZE(qca_devices_table); i++) {
+ if (!(qca_devices_table[i].rom_version & 0xffff0000) &&
+ ver_rom_low == qca_devices_table[i].rom_version) {
+ info = &qca_devices_table[i];
+ break;
+ }
+ }
}
if (!info) {
bt_dev_err(hdev, "don't support firmware rome 0x%x", ver_rom);
--
2.30.0
next prev parent reply other threads:[~2021-02-09 11:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 11:40 [Regression] Linux v5.10 breaks AR3011 fw loading Florian Albrechtskirchinger
2021-02-09 11:40 ` Florian Albrechtskirchinger [this message]
2021-02-09 13:42 ` [PATCH] Bluetooth: btusb: Fallback to 16 bit ROM version lookup Marcel Holtmann
2021-02-10 10:37 ` Florian Albrechtskirchinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210209114024.2910-2-falbrechtskirchinger@gmail.com \
--to=falbrechtskirchinger@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marcel@holtmann.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox