Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: btmtk: Add reset mechanism if downloading firmware failed

Add 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.

Signed-off-by: Chris Lu <chris.lu@mediatek.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Chris Lu and committed by
Luiz Augusto von Dentz
679621a7 b27a306e

+7
+6
drivers/bluetooth/btmtk.c
··· 1344 1344 err = btmtk_setup_firmware_79xx(hdev, fw_bin_name, 1345 1345 btmtk_usb_hci_wmt_sync); 1346 1346 if (err < 0) { 1347 + /* retry once if setup firmware error */ 1348 + if (!test_and_set_bit(BTMTK_FIRMWARE_DL_RETRY, &btmtk_data->flags)) 1349 + btmtk_reset_sync(hdev); 1347 1350 bt_dev_err(hdev, "Failed to set up firmware (%d)", err); 1348 1351 return err; 1349 1352 } ··· 1373 1370 1374 1371 hci_set_msft_opcode(hdev, 0xFD30); 1375 1372 hci_set_aosp_capable(hdev); 1373 + 1374 + /* Clear BTMTK_FIRMWARE_DL_RETRY if setup successfully */ 1375 + test_and_clear_bit(BTMTK_FIRMWARE_DL_RETRY, &btmtk_data->flags); 1376 1376 1377 1377 /* Set up ISO interface after protocol enabled */ 1378 1378 if (test_bit(BTMTK_ISOPKT_OVER_INTR, &btmtk_data->flags)) {
+1
drivers/bluetooth/btmtk.h
··· 147 147 BTMTK_HW_RESET_ACTIVE, 148 148 BTMTK_ISOPKT_OVER_INTR, 149 149 BTMTK_ISOPKT_RUNNING, 150 + BTMTK_FIRMWARE_DL_RETRY, 150 151 }; 151 152 152 153 typedef int (*btmtk_reset_sync_func_t)(struct hci_dev *, void *);