diff mbox series

Bluetooth: btusb: Fix failing to init controllers with operation firmware

Message ID 20210430230501.603111-1-luiz.dentz@gmail.com (mailing list archive)
State New, archived
Headers show
Series Bluetooth: btusb: Fix failing to init controllers with operation firmware | expand

Commit Message

Luiz Augusto von Dentz April 30, 2021, 11:05 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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 <luiz.von.dentz@intel.com>
---
 drivers/bluetooth/btusb.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

bluez.test.bot@gmail.com May 1, 2021, 2:17 a.m. UTC | #1
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
Marcel Holtmann May 7, 2021, 8:29 a.m. UTC | #2
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 <luiz.von.dentz@intel.com>
> ---
> drivers/bluetooth/btusb.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel
youling 257 May 11, 2021, 4:26 a.m. UTC | #3
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
Luiz Augusto von Dentz May 11, 2021, 7:01 a.m. UTC | #4
Hi,

On Mon, May 10, 2021 at 9:27 PM youling257 <youling257@gmail.com> 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.
Marcel Holtmann May 13, 2021, 3:16 p.m. UTC | #5
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
Luiz Augusto von Dentz May 13, 2021, 8:29 p.m. UTC | #6
Hi Marcel,

On Thu, May 13, 2021 at 8:16 AM Marcel Holtmann <marcel@holtmann.org> 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.
diff mbox series

Patch

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;