2021-04-30 23:07:19

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH] Bluetooth: btusb: Fix failing to init controllers with operation firmware

From: Luiz Augusto von Dentz <[email protected]>

Some firmware when operation don't may have broken versions leading to
error like the following:

[ 6.176482] Bluetooth: hci0: Firmware revision 0.0 build 121 week 7
2021
[ 6.177906] bluetooth hci0: Direct firmware load for
intel/ibt-20-0-0.sfi failed with error -2
[ 6.177910] Bluetooth: hci0: Failed to load Intel firmware file
intel/ibt-20-0-0.sfi (-2)

Since we load the firmware file just to check if its version had changed
comparing to the one already loaded we can just skip since the firmware
is already operation.

Signed-off-by: Luiz Augusto von Dentz <[email protected]>
---
drivers/bluetooth/btusb.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 90e7e9d35805..9b84ada0aac6 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2603,8 +2603,15 @@ static int btusb_intel_download_firmware_newgen(struct hci_dev *hdev,
btusb_setup_intel_newgen_get_fw_name(ver, fwname, sizeof(fwname), "sfi");
err = request_firmware(&fw, fwname, &hdev->dev);
if (err < 0) {
+ if (!test_bit(BTUSB_BOOTLOADER, &data->flags)) {
+ /* Firmware has already been loaded */
+ set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
+ return 0;
+ }
+
bt_dev_err(hdev, "Failed to load Intel firmware file %s (%d)",
fwname, err);
+
return err;
}

@@ -2754,12 +2761,24 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev,
err = btusb_setup_intel_new_get_fw_name(ver, params, fwname,
sizeof(fwname), "sfi");
if (err < 0) {
+ if (!test_bit(BTUSB_BOOTLOADER, &data->flags)) {
+ /* Firmware has already been loaded */
+ set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
+ return 0;
+ }
+
bt_dev_err(hdev, "Unsupported Intel firmware naming");
return -EINVAL;
}

err = request_firmware(&fw, fwname, &hdev->dev);
if (err < 0) {
+ if (!test_bit(BTUSB_BOOTLOADER, &data->flags)) {
+ /* Firmware has already been loaded */
+ set_bit(BTUSB_FIRMWARE_LOADED, &data->flags);
+ return 0;
+ }
+
bt_dev_err(hdev, "Failed to load Intel firmware file %s (%d)",
fwname, err);
return err;
--
2.30.2


2021-05-01 02:22:04

by bluez.test.bot

[permalink] [raw]
Subject: RE: Bluetooth: btusb: Fix failing to init controllers with operation firmware

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=475935

---Test result---

##############################
Test: CheckPatch - PASS


##############################
Test: CheckGitLint - FAIL
Bluetooth: btusb: Fix failing to init controllers with operation firmware
1: T1 Title exceeds max length (73>72): "Bluetooth: btusb: Fix failing to init controllers with operation firmware"


##############################
Test: CheckBuildK - PASS


##############################
Test: CheckTestRunner: Setup - PASS


##############################
Test: CheckTestRunner: l2cap-tester - PASS
Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0

##############################
Test: CheckTestRunner: bnep-tester - PASS
Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0

##############################
Test: CheckTestRunner: mgmt-tester - PASS
Total: 416, Passed: 403 (96.9%), Failed: 0, Not Run: 13

##############################
Test: CheckTestRunner: rfcomm-tester - PASS
Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0

##############################
Test: CheckTestRunner: sco-tester - PASS
Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0

##############################
Test: CheckTestRunner: smp-tester - PASS
Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0

##############################
Test: CheckTestRunner: userchan-tester - PASS
Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0



---
Regards,
Linux Bluetooth


Attachments:
l2cap-tester.log (43.20 kB)
bnep-tester.log (3.48 kB)
mgmt-tester.log (533.93 kB)
rfcomm-tester.log (11.40 kB)
sco-tester.log (9.68 kB)
smp-tester.log (11.55 kB)
userchan-tester.log (5.33 kB)
Download all attachments

2021-05-07 09:28:58

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: btusb: Fix failing to init controllers with operation firmware

Hi Luiz,

> Some firmware when operation don't may have broken versions leading to
> error like the following:
>
> [ 6.176482] Bluetooth: hci0: Firmware revision 0.0 build 121 week 7
> 2021
> [ 6.177906] bluetooth hci0: Direct firmware load for
> intel/ibt-20-0-0.sfi failed with error -2
> [ 6.177910] Bluetooth: hci0: Failed to load Intel firmware file
> intel/ibt-20-0-0.sfi (-2)
>
> Since we load the firmware file just to check if its version had changed
> comparing to the one already loaded we can just skip since the firmware
> is already operation.
>
> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
> ---
> drivers/bluetooth/btusb.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel

2021-05-11 04:29:17

by youling 257

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: btusb: Fix failing to init controllers with operation firmware

I test this patch no help. rmmod btusb, modprobe btusb.


[ 7.661739] Bluetooth: Core ver 2.22
[ 7.661762] NET: Registered protocol family 31
[ 7.661763] Bluetooth: HCI device and connection manager initialized
[ 7.661767] Bluetooth: HCI socket layer initialized
[ 7.661768] Bluetooth: L2CAP socket layer initialized
[ 7.661772] Bluetooth: SCO socket layer initialized
[ 7.686106] usbcore: registered new interface driver btusb
[ 7.689317] iwlwifi 0000:07:00.0: Detected Intel(R) Wi-Fi 6 AX200 160MHz, REV=0x340
[ 7.689789] Bluetooth: hci0: Firmware revision 0.0 build 118 week 15 2021
[ 7.694911] bluetooth hci0: Direct firmware load for intel/ibt-20-0-0.sfi failed with error -2

[ 230.746397] usbcore: registered new interface driver btusb
[ 230.750827] Bluetooth: hci0: Firmware revision 0.0 build 118 week 15 2021
[ 230.756450] bluetooth hci0: Direct firmware load for intel/ibt-20-0-0.sfi failed with error -2

2021-05-11 07:03:38

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: btusb: Fix failing to init controllers with operation firmware

Hi,

On Mon, May 10, 2021 at 9:27 PM youling257 <[email protected]> wrote:
>
> I test this patch no help. rmmod btusb, modprobe btusb.
>
>
> [ 7.661739] Bluetooth: Core ver 2.22
> [ 7.661762] NET: Registered protocol family 31
> [ 7.661763] Bluetooth: HCI device and connection manager initialized
> [ 7.661767] Bluetooth: HCI socket layer initialized
> [ 7.661768] Bluetooth: L2CAP socket layer initialized
> [ 7.661772] Bluetooth: SCO socket layer initialized
> [ 7.686106] usbcore: registered new interface driver btusb
> [ 7.689317] iwlwifi 0000:07:00.0: Detected Intel(R) Wi-Fi 6 AX200 160MHz, REV=0x340
> [ 7.689789] Bluetooth: hci0: Firmware revision 0.0 build 118 week 15 2021
> [ 7.694911] bluetooth hci0: Direct firmware load for intel/ibt-20-0-0.sfi failed with error -2
>
> [ 230.746397] usbcore: registered new interface driver btusb
> [ 230.750827] Bluetooth: hci0: Firmware revision 0.0 build 118 week 15 2021
> [ 230.756450] bluetooth hci0: Direct firmware load for intel/ibt-20-0-0.sfi failed with error -2

The error shall be ignored in this case since it comes from
request_firmware we can't prevent it, if you don't see another error
after that means it can be ignored, that said perhaps we detect it
sooner by either attempting to stat the file or perhaps check if
revision comes back as all 0.

--
Luiz Augusto von Dentz

2021-05-13 15:19:55

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: btusb: Fix failing to init controllers with operation firmware

Hi Luiz,

>> I test this patch no help. rmmod btusb, modprobe btusb.
>>
>>
>> [ 7.661739] Bluetooth: Core ver 2.22
>> [ 7.661762] NET: Registered protocol family 31
>> [ 7.661763] Bluetooth: HCI device and connection manager initialized
>> [ 7.661767] Bluetooth: HCI socket layer initialized
>> [ 7.661768] Bluetooth: L2CAP socket layer initialized
>> [ 7.661772] Bluetooth: SCO socket layer initialized
>> [ 7.686106] usbcore: registered new interface driver btusb
>> [ 7.689317] iwlwifi 0000:07:00.0: Detected Intel(R) Wi-Fi 6 AX200 160MHz, REV=0x340
>> [ 7.689789] Bluetooth: hci0: Firmware revision 0.0 build 118 week 15 2021
>> [ 7.694911] bluetooth hci0: Direct firmware load for intel/ibt-20-0-0.sfi failed with error -2
>>
>> [ 230.746397] usbcore: registered new interface driver btusb
>> [ 230.750827] Bluetooth: hci0: Firmware revision 0.0 build 118 week 15 2021
>> [ 230.756450] bluetooth hci0: Direct firmware load for intel/ibt-20-0-0.sfi failed with error -2
>
> The error shall be ignored in this case since it comes from
> request_firmware we can't prevent it, if you don't see another error
> after that means it can be ignored, that said perhaps we detect it
> sooner by either attempting to stat the file or perhaps check if
> revision comes back as all 0.

any reason you don’t use firmware_request_nowarn()?

Regards

Marcel


2021-05-14 00:16:14

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: btusb: Fix failing to init controllers with operation firmware

Hi Marcel,

On Thu, May 13, 2021 at 8:16 AM Marcel Holtmann <[email protected]> wrote:
>
> Hi Luiz,
>
> >> I test this patch no help. rmmod btusb, modprobe btusb.
> >>
> >>
> >> [ 7.661739] Bluetooth: Core ver 2.22
> >> [ 7.661762] NET: Registered protocol family 31
> >> [ 7.661763] Bluetooth: HCI device and connection manager initialized
> >> [ 7.661767] Bluetooth: HCI socket layer initialized
> >> [ 7.661768] Bluetooth: L2CAP socket layer initialized
> >> [ 7.661772] Bluetooth: SCO socket layer initialized
> >> [ 7.686106] usbcore: registered new interface driver btusb
> >> [ 7.689317] iwlwifi 0000:07:00.0: Detected Intel(R) Wi-Fi 6 AX200 160MHz, REV=0x340
> >> [ 7.689789] Bluetooth: hci0: Firmware revision 0.0 build 118 week 15 2021
> >> [ 7.694911] bluetooth hci0: Direct firmware load for intel/ibt-20-0-0.sfi failed with error -2
> >>
> >> [ 230.746397] usbcore: registered new interface driver btusb
> >> [ 230.750827] Bluetooth: hci0: Firmware revision 0.0 build 118 week 15 2021
> >> [ 230.756450] bluetooth hci0: Direct firmware load for intel/ibt-20-0-0.sfi failed with error -2
> >
> > The error shall be ignored in this case since it comes from
> > request_firmware we can't prevent it, if you don't see another error
> > after that means it can be ignored, that said perhaps we detect it
> > sooner by either attempting to stat the file or perhaps check if
> > revision comes back as all 0.
>
> any reason you don’t use firmware_request_nowarn()?

Yep, totally missed that one exists, I will send a patch making use of it.

--
Luiz Augusto von Dentz