Bluetooth: btmtk: Trigger reset on firmware download failure
Subsystems (2)
PATCH 1/1 Bluetooth: btmtk: Trigger reset on firmware download failure
Initiate reset flow if MT79xx series BT failed to download firmware when doing setup.
If driver is not able to get event after reset in the first section of btmtk_usb_setup, the protocol is deemed unuable and driver will return to prevent from repeatedly executing resets.
--- drivers/bluetooth/btmtk.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/bluetooth/btmtk.c +9 -2
@@ -1333,7 +1333,7 @@ int btmtk_usb_setup(struct hci_dev *hdev) btmtk_usb_hci_wmt_sync);if (err <0 ) {bt_dev_err (hdev,"Failed to set up firmware (%d)" , err); -return err; + goto reset_fw; }/* It's Device EndPoint Reset Option Register */
@@ -1353,7 +1353,7 @@ int btmtk_usb_setup(struct hci_dev *hdev) err =btmtk_usb_hci_wmt_sync (hdev, &wmt_params);if (err <0 ) {bt_dev_err (hdev,"Failed to send wmt func ctrl (%d)" , err); -return err; + goto reset_fw; }hci_set_msft_opcode (hdev,0xFD30 );
@@ -1444,6 +1444,13 @@ int btmtk_usb_setup(struct hci_dev *hdev) }kfree_skb (skb); +reset_fw: +if (btmtk_data->reset_sync) { +bt_dev_err (hdev,"Mediatek do firmware reset" ); +btmtk_reset_sync (hdev); +return err; + } + done: rettime =ktime_get (); delta =ktime_sub (rettime, calltime);
Signature · 1 line
2.45.2
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=1031700
---Test result---
Test Summary:
CheckPatch PENDING 0.39 seconds GitLint PENDING 0.42 seconds SubjectPrefix PASS 0.09 seconds BuildKernel PASS 25.46 seconds CheckAllWarning PASS 27.76 seconds CheckSparse PASS 31.06 seconds BuildKernel32 PASS 24.82 seconds TestRunnerSetup PASS 551.53 seconds TestRunner_l2cap-tester PASS 24.20 seconds TestRunner_iso-tester PASS 88.35 seconds TestRunner_bnep-tester PASS 6.15 seconds TestRunner_mgmt-tester FAIL 114.62 seconds TestRunner_rfcomm-tester PASS 9.50 seconds TestRunner_sco-tester FAIL 14.31 seconds TestRunner_ioctl-tester PASS 10.33 seconds TestRunner_mesh-tester FAIL 11.41 seconds TestRunner_smp-tester PASS 8.48 seconds TestRunner_userchan-tester PASS 6.58 seconds IncrementalBuild PENDING 0.97 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner Output:
Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.102 seconds
##############################
Test: TestRunner_sco-tester - FAIL
Desc: Run sco-tester with test-runner
Output:
WARNING: possible circular locking dependency detected
BUG: sleeping function called from invalid context at net/core/sock.c:3782
Total: 30, Passed: 30 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 1.816 seconds Mesh - Send cancel - 2 Timed out 1.999 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz
maintainerHi Chris,
Quoted 35 lines · Chris Lu
Initiate reset flow if MT79xx series BT failed to download firmware when doing setup.
If driver is not able to get event after reset in the first section ofbtmtk_usb_setup, the protocol is deemed unuable and driver will return to prevent from repeatedly executing resets.Signed-off-by Chris Lu <[email protected]>--- drivers/bluetooth/btmtk.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/bluetooth/btmtk.c +2
-2@@ -1333,7 +1333,7 @@ int btmtk_usb_setup(struct hci_dev *hdev) btmtk_usb_hci_wmt_sync);if (err <0 ) {bt_dev_err (hdev,"Failed to set up firmware (%d)" , err); -return err; + goto reset_fw; }/* It's Device EndPoint Reset Option Register */ @@ -1353,7 +1353,7 @@ int btmtk_usb_setup(struct hci_dev *hdev) err =btmtk_usb_hci_wmt_sync (hdev, &wmt_params);if (err <0 ) {bt_dev_err (hdev,"Failed to send wmt func ctrl (%d)" , err); -return err; + goto reset_fw; }hci_set_msft_opcode (hdev,0xFD30 );
drivers/bluetooth/btmtk.c int btmtk_usb_setup(struct hci_dev *hdev) · line 1449
Quoted 6 lines
drivers/bluetooth/btmtk.c +3
-0@@ -1444,6 +1444,13 @@ int btmtk_usb_setup(struct hci_dev *hdev) }kfree_skb (skb); +reset_fw: +if (btmtk_data->reset_sync) { +bt_dev_err (hdev,"Mediatek do firmware reset" );
This message is a bit cryptic to me, why do we need to print that you will be doing a reset?
drivers/bluetooth/btmtk.c int btmtk_usb_setup(struct hci_dev *hdev) · line 1450
Quoted 1 line
drivers/bluetooth/btmtk.c +1
-0+btmtk_reset_sync (hdev);
This seems to be doing a hard reset, which I assume you are doing as an attempt to recover by retrying to setup, but if it fails we may go into a loop condition trying to setup so we better limit the number of attempts.
Quoted 9 lines
drivers/bluetooth/btmtk.c +3
-1+return err; + } + done: rettime =ktime_get (); delta =ktime_sub (rettime, calltime); --2.45.2
Signature · 1 line
Luiz Augusto von Dentz
Hi Luiz,
Thanks for your review and response.
Quoted 53 lines · Luiz Augusto von Dentz
External email : Please do not click links or open attachments until you have verified the sender or the content.
Hi Chris,
Quoted 44 lines · Chris Lu
Initiate reset flow if MT79xx series BT failed to download firmware when
doing setup.
If driver is not able to get event after reset in the first section ofbtmtk_usb_setup, the protocol is deemed unuable and driver will return to
prevent from repeatedly executing resets.Signed-off-by Chris Lu <[email protected]>---
drivers/bluetooth/btmtk.c | 11 +++++++++--1 file changed, 9 insertions(+), 2 deletions(-)drivers/bluetooth/btmtk.c +0
-0@@ -1333,7 +1333,7 @@ int btmtk_usb_setup(struct hci_dev *hdev)
btmtk_usb_hci_wmt_sync);
if (err < 0) {
bt_dev_err(hdev, "Failed to set up firmware (%d)", err);
- return err;
+ gotoreset_fw;
}/* It's Device EndPoint Reset Option Register */
drivers/bluetooth/btmtk.c +0
-0@@ -1353,7 +1353,7 @@ int btmtk_usb_setup(struct hci_dev *hdev) err = btmtk_usb_hci_wmt_sync(hdev, &wmt_params); if (err < 0) {
bt_dev_err(hdev, "Failed to send wmt func ctrl (%d)", err);
- return err;
+ gotoreset_fw;
}
hci_set_msft_opcode(hdev, 0xFD30);drivers/bluetooth/btmtk.c +0
-0@@ -1444,6 +1444,13 @@ int btmtk_usb_setup(struct hci_dev *hdev) } kfree_skb(skb);
Quoted 6 lines
drivers/bluetooth/btmtk.c int btmtk_usb_setup(struct hci_dev *hdev) · line 1449
Quoted 3 lines
drivers/bluetooth/btmtk.c +3
-0+reset_fw: + if (btmtk_data->reset_sync) { + bt_dev_err(hdev, "Mediatek do firmware reset");This message is a bit cryptic to me, why do we need to print that you will be doing a reset?
Indeed, this log can only be interpreted by Mediatek engineers. I'll update v2 to remove this line.
Quoted 8 lines
drivers/bluetooth/btmtk.c int btmtk_usb_setup(struct hci_dev *hdev) · line 1450
Quoted 2 lines
drivers/bluetooth/btmtk.c +1
-0+ btmtk_reset_sync(hdev);This seems to be doing a hard reset, which I assume you are doing as an attempt to recover by retrying to setup, but if it fails we may go into a loop condition trying to setup so we better limit the number of
attempts.
We only perform reset once when firmware download failed or 'wmt ctrl' command failed.
Before downloading the firmware, driver will send pre-init commands to get information such as chip id, after the reset, if those command still can't work normally, it is considered a protocol issue that it can't be further used. We'll not enter the reset flow again to avoid an endless loop.
There is indeed a potential risk. If the pre-init commands are all fine but firmware download continues to have problem, it could cause a loop condition. Retry limit will be addressed in v2.
Quoted 12 lines
Quoted 10 lines
drivers/bluetooth/btmtk.c +3
-0+ return err; + } +done:
rettime =ktime_get();
delta =ktime_sub(rettime, calltime);
--
2.45.2
Quoted 2 lines
--
Luiz Augusto von Dentz
Thanks a lot!
Chris Lu