Trigger reset if firmware status is abnormal when
Subsystems (2)
cover Trigger reset if firmware status is abnormal when
When the device unexpectedly restarts during previous firmware download process, it can cause mt79xx firmware status to be abnormal in the next attempt. In this case, a reset should be performed to ensure everything starts afresh.
These changes include:
1. Optimizing the handling after the download function retry is exhausted, a reset should be performed.
2. Another download firmware command also needs to check status , and if an unexpected status occurs, trigger a reset.
3. Adding a flag "BTMTK_FIRMWARE_DL_RETRY": if download firmware process enters the reset mechanism, this flag will be set. After a successful setup, the flag will be cleared. If the flag is already set, no further reset attempts will be made to avoid endless reset retries.
Chris Lu (3):
Bluetooth: btmtk: improve mt79xx firmware setup retry flow
Bluetooth: btmtk: add status check in mt79xx firmware setup
Bluetooth: btmtk: Add reset mechanism if downloading firmware failed
drivers/bluetooth/btmtk.c | 21 +++++++++++++++++++-- drivers/bluetooth/btmtk.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-)
Signature · 1 line
2.45.2
PATCH 1/3 Bluetooth: btmtk: improve mt79xx firmware setup retry flow
If retries are exhausted, driver should not do futher operation. During mt79xx firmware download process, if the retry count reaches0, driver will return an -EIO error and release the firmware resources.
--- drivers/bluetooth/btmtk.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/bluetooth/btmtk.c +6 -0
@@ -205,6 +205,12 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname, } } +/* If retry exhausted goto err_release_fw */ +if (retry ==0 ) { + err = -EIO ; + goto err_release_fw; + } + fw_ptr += section_offset; wmt_params.op =BTMTK_WMT_PATCH_DWNLD ; wmt_params.status =NULL ;
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=1050104
---Test result---
Test Summary:
CheckPatch PENDING 0.34 seconds GitLint PENDING 0.29 seconds SubjectPrefix PASS 0.35 seconds BuildKernel PASS 28.39 seconds CheckAllWarning PASS 29.50 seconds CheckSparse WARNING 33.43 seconds BuildKernel32 PASS 26.24 seconds TestRunnerSetup PASS 569.51 seconds TestRunner_l2cap-tester PASS 29.22 seconds TestRunner_iso-tester FAIL 85.43 seconds TestRunner_bnep-tester PASS 6.51 seconds TestRunner_mgmt-tester FAIL 115.40 seconds TestRunner_rfcomm-tester PASS 9.87 seconds TestRunner_sco-tester FAIL 14.96 seconds TestRunner_ioctl-tester PASS 10.51 seconds TestRunner_mesh-tester FAIL 12.47 seconds TestRunner_smp-tester PASS 8.77 seconds TestRunner_userchan-tester PASS 6.84 seconds IncrementalBuild PENDING 0.76 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:drivers/bluetooth/btmtk.c:1507:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1508:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1509:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1510:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1511:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1511:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1512:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1513:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1514:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1515:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1516:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1517:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1507:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1508:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1509:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1510:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1511:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1511:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1512:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1513:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1514:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1515:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1516:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1517:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1507:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1508:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1509:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1510:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1511:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1511:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1512:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1513:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1514:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1515:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1516:1: error: bad constant expressiondrivers/bluetooth/btmtk.c:1517:1: error: bad constant expression
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
BUG: KASAN: slab-use-after-free in le_read_features_complete+0x7e/0x2b0
Total: 141, Passed: 141 (100.0%), Failed: 0, Not Run: 0
##############################
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.108 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 2.624 seconds Mesh - Send cancel - 2 Timed out 1.992 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
PATCH 2/3 Bluetooth: btmtk: add status check in mt79xx firmware setup
In reply to Chris LuTo prevent abnormal controller states, it is necessary to check status in another part of the mt79xx firmware setup. During this process, receiving the 'BTMTK_WMT_PATCH_PROGRESS' status is unexpected. If this occurs, it should be treated as an error, and driver must be prevented from continuing execution.
--- drivers/bluetooth/btmtk.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/bluetooth/btmtk.c +8 -2
@@ -213,7 +213,6 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname, fw_ptr += section_offset; wmt_params.op =BTMTK_WMT_PATCH_DWNLD ; - wmt_params.status =NULL ;while (dl_size >0 ) { dlen =min_t (int,250 , dl_size);
@@ -231,7 +230,14 @@ int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname, wmt_params.data = fw_ptr; err =wmt_cmd_sync (hdev, &wmt_params); -if (err <0 ) { +/* Status BTMTK_WMT_PATCH_PROGRESS indicates firmware is +* in process of being downloaded, which is not expected to +* occur here. +*/ +if (status ==BTMTK_WMT_PATCH_PROGRESS ) { + err = -EIO ; + goto err_release_fw; + }else if (err <0 ) {bt_dev_err (hdev,"Failed to send wmt patch dwnld (%d)" , err); goto err_release_fw;
Signature · 1 line
2.45.2
PATCH 3/3 Bluetooth: btmtk: Add reset mechanism if downloading firmware failed
In reply to Chris LuAdd a new flag 'BTMTK_FIRMWARE_DL_RETRY'.
If an error occurs during mt79xx firmware download process, this flag will be set and cleared after a reset. If the flag is already set and firmware still cannot be loaded successfully after a reset, no further reset attempts will be made. In other words, if there is a problem during firmware download, only one reset will be attempted.
--- drivers/bluetooth/btmtk.c | 6 ++++++ drivers/bluetooth/btmtk.h | 1 + 2 files changed, 7 insertions(+)
drivers/bluetooth/btmtk.c +6 -0
@@ -1344,6 +1344,9 @@ int btmtk_usb_setup(struct hci_dev *hdev) err =btmtk_setup_firmware_79xx (hdev, fw_bin_name, btmtk_usb_hci_wmt_sync);if (err <0 ) { +/* retry once if setup firmware error */ +if (!test_and_set_bit (BTMTK_FIRMWARE_DL_RETRY , &btmtk_data->flags)) +btmtk_reset_sync (hdev);bt_dev_err (hdev,"Failed to set up firmware (%d)" , err);return err; }
@@ -1371,6 +1374,9 @@ int btmtk_usb_setup(struct hci_dev *hdev)hci_set_msft_opcode (hdev,0xFD30 );hci_set_aosp_capable (hdev); +/* Clear BTMTK_FIRMWARE_DL_RETRY if setup successfully */ +test_and_clear_bit (BTMTK_FIRMWARE_DL_RETRY , &btmtk_data->flags); +/* Set up ISO interface after protocol enabled */ if (test_bit (BTMTK_ISOPKT_OVER_INTR , &btmtk_data->flags)) {if (!btmtk_usb_isointf_init (hdev))
drivers/bluetooth/btmtk.h +1 -0
@@ -147,6 +147,7 @@ enum {BTMTK_HW_RESET_ACTIVE ,BTMTK_ISOPKT_OVER_INTR ,BTMTK_ISOPKT_RUNNING , + BTMTK_FIRMWARE_DL_RETRY, };typedef int (*btmtk_reset_sync_func_t )(struct hci_dev *,void *);
Signature · 1 line
2.45.2
This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 16 lines · On Tue, 3 Feb 2026 14:25:07 +0800 you wrote:
When the device unexpectedly restarts during previous firmware download process, it can cause mt79xx firmware status to be abnormal in the next attempt. In this case, a reset should be performed to ensure everything starts afresh.
These changes include:
1. Optimizing the handling after the download function retry is exhausted, a reset should be performed.
2. Another download firmware command also needs to check status , and if an unexpected status occurs, trigger a reset.
3. Adding a flag "BTMTK_FIRMWARE_DL_RETRY": if download firmware process enters the reset mechanism, this flag will be set. After a successful setup, the flag will be cleared. If the flag is already set, no further reset attempts will be made to avoid endless reset retries.
Quoted 1 line
[...]
Here is the summary with links:
- [v1,1/3] Bluetooth: btmtk: improve mt79xx firmware setup retry flow
https://git.kernel.org/bluetooth/bluetooth-next/c/9cc9fc9bff32
- [v1,2/3] Bluetooth: btmtk: add status check in mt79xx firmware setup
https://git.kernel.org/bluetooth/bluetooth-next/c/458b6d8b0108 - [v1,3/3] Bluetooth: btmtk: Add reset mechanism if downloading firmware failed https://git.kernel.org/bluetooth/bluetooth-next/c/73130272a121
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html