All of lore.kernel.org
 help / color / mirror / Atom feed
* [Regression] Linux v5.10 breaks AR3011 fw loading
@ 2021-02-09 11:40 Florian Albrechtskirchinger
  2021-02-09 11:40 ` [PATCH] Bluetooth: btusb: Fallback to 16 bit ROM version lookup Florian Albrechtskirchinger
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Albrechtskirchinger @ 2021-02-09 11:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel

Hey everyone,

Linux v5.10 broke firmware loading for my AR3011 Bluetooth USB adapter.
A git bisect identified the following commit as the culprit:

> commit b40f58b973865ee98ead884d2bdc7880b896ddb8
> Author: Rocky Liao <rjliao@codeaurora.org>
> Date:   Tue Sep 29 12:23:51 2020 +0800
>
>     Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855 support
>   
>     This patch add support for WCN6855 i.e. patch and nvm download
>     support.

The accompanying patch describes the issue further and attempts to offer
a fix based on my superficial understanding, which may or may not be
adequate.

Regards,
Florian


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Bluetooth: btusb: Fallback to 16 bit ROM version lookup
  2021-02-09 11:40 [Regression] Linux v5.10 breaks AR3011 fw loading Florian Albrechtskirchinger
@ 2021-02-09 11:40 ` Florian Albrechtskirchinger
  2021-02-09 13:42   ` Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Albrechtskirchinger @ 2021-02-09 11:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Fallback to 16 bit ROM version lookup
  2021-02-09 11:40 ` [PATCH] Bluetooth: btusb: Fallback to 16 bit ROM version lookup Florian Albrechtskirchinger
@ 2021-02-09 13:42   ` Marcel Holtmann
  2021-02-10 10:37     ` Florian Albrechtskirchinger
  0 siblings, 1 reply; 4+ messages in thread
From: Marcel Holtmann @ 2021-02-09 13:42 UTC (permalink / raw)
  To: Florian Albrechtskirchinger; +Cc: linux-bluetooth

Hi Florian,

> 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

please use correct comment style.

> +		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);

Regards

Marcel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Fallback to 16 bit ROM version lookup
  2021-02-09 13:42   ` Marcel Holtmann
@ 2021-02-10 10:37     ` Florian Albrechtskirchinger
  0 siblings, 0 replies; 4+ messages in thread
From: Florian Albrechtskirchinger @ 2021-02-10 10:37 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

On Tue, Feb 9, 2021 at 2:42 PM Marcel Holtmann <marcel@holtmann.org> wrote:
>
> Hi Florian,
>
> > 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
>
> please use correct comment style.
Noted for next time. I would've expected checkpatch.pl to catch issues
like that?
A proper fix by Hui Wang has already been committed to bluetooth-next.

> > +             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);
>
> Regards
>
> Marcel

- Florian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-10 10:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09 11:40 [Regression] Linux v5.10 breaks AR3011 fw loading Florian Albrechtskirchinger
2021-02-09 11:40 ` [PATCH] Bluetooth: btusb: Fallback to 16 bit ROM version lookup Florian Albrechtskirchinger
2021-02-09 13:42   ` Marcel Holtmann
2021-02-10 10:37     ` Florian Albrechtskirchinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.