Skip to content

Commit bb2500a

Browse files
rjliao-qcaholtmann
authored andcommitted
Bluetooth: hci_qca: Retry btsoc initialize when it fails
This patch adds the retry of btsoc initialization when it fails. There are reports that the btsoc initialization may fail on some platforms but the repro ratio is very low. The symptoms is the firmware downloading failed due to the UART write timed out. The failure may be caused by UART, platform HW or the btsoc itself but it's very difficlut to root cause, given the repro ratio is very low. Add a retry for the btsoc initialization can work around most of the failures and make Bluetooth finally works. Signed-off-by: Rocky Liao <[email protected]> Reviewed-by: Matthias Kaehlcke <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 5559904 commit bb2500a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

drivers/bluetooth/hci_qca.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
/* Controller debug log header */
5656
#define QCA_DEBUG_HANDLE 0x2EDC
5757

58+
/* max retry count when init fails */
59+
#define MAX_INIT_RETRIES 3
60+
5861
/* Controller dump header */
5962
#define QCA_SSR_DUMP_HANDLE 0x0108
6063
#define QCA_DUMP_PACKET_SIZE 255
@@ -1539,6 +1542,7 @@ static int qca_setup(struct hci_uart *hu)
15391542
struct hci_dev *hdev = hu->hdev;
15401543
struct qca_data *qca = hu->priv;
15411544
unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200;
1545+
unsigned int retries = 0;
15421546
enum qca_btsoc_type soc_type = qca_soc_type(hu);
15431547
const char *firmware_name = qca_get_firmware_name(hu);
15441548
int ret;
@@ -1559,6 +1563,7 @@ static int qca_setup(struct hci_uart *hu)
15591563
bt_dev_info(hdev, "setting up %s",
15601564
qca_is_wcn399x(soc_type) ? "wcn399x" : "ROME");
15611565

1566+
retry:
15621567
ret = qca_power_on(hdev);
15631568
if (ret)
15641569
return ret;
@@ -1613,6 +1618,20 @@ static int qca_setup(struct hci_uart *hu)
16131618
* patch/nvm-config is found, so run with original fw/config.
16141619
*/
16151620
ret = 0;
1621+
} else {
1622+
if (retries < MAX_INIT_RETRIES) {
1623+
qca_power_shutdown(hu);
1624+
if (hu->serdev) {
1625+
serdev_device_close(hu->serdev);
1626+
ret = serdev_device_open(hu->serdev);
1627+
if (ret) {
1628+
bt_dev_err(hdev, "failed to open port");
1629+
return ret;
1630+
}
1631+
}
1632+
retries++;
1633+
goto retry;
1634+
}
16161635
}
16171636

16181637
/* Setup bdaddr */

0 commit comments

Comments
 (0)