Skip to content

Commit 61a9c6e

Browse files
NeerajSanjayKaleVudentz
authored andcommitted
Bluetooth: btnxpuart: Revert baudrate change in nxp_shutdown
This reverts the change baudrate logic in nxp_shutdown. Earlier, when the driver was removed, it restored the controller baudrate to fw_init_baudrate, so that on re-loading the driver, things work fine. However, if the driver was removed while hci0 interface is down, the change baudrate vendor command could not be sent by the driver. When the driver was re-loaded, host and controller baudrate would be mismatched and hci initialization would fail. The only way to recover would be to reboot the system. This issue was fixed by moving the restore baudrate logic from nxp_serdev_remove() to nxp_shutdown(). This fix however caused another issue with the command "hciconfig hci0 reset", which makes hci0 DOWN and UP immediately. Running "bluetoothctl power off" and "bluetoothctl power on" in a tight loop works fine. To maintain support for "hciconfig reset" command, the above mentioned fix is reverted. Fixes: 6fca678 ("Bluetooth: btnxpuart: Move vendor specific initialization to .post_init") Signed-off-by: Neeraj Sanjay Kale <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent c174cd0 commit 61a9c6e

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

drivers/bluetooth/btnxpuart.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,9 +1445,6 @@ static int nxp_shutdown(struct hci_dev *hdev)
14451445
/* HCI_NXP_IND_RESET command may not returns any response */
14461446
if (!IS_ERR(skb))
14471447
kfree_skb(skb);
1448-
} else if (nxpdev->current_baudrate != nxpdev->fw_init_baudrate) {
1449-
nxpdev->new_baudrate = nxpdev->fw_init_baudrate;
1450-
nxp_set_baudrate_cmd(hdev, NULL);
14511448
}
14521449

14531450
return 0;
@@ -1799,13 +1796,15 @@ static void nxp_serdev_remove(struct serdev_device *serdev)
17991796
clear_bit(BTNXPUART_FW_DOWNLOADING, &nxpdev->tx_state);
18001797
wake_up_interruptible(&nxpdev->check_boot_sign_wait_q);
18011798
wake_up_interruptible(&nxpdev->fw_dnld_done_wait_q);
1802-
}
1803-
1804-
if (test_bit(HCI_RUNNING, &hdev->flags)) {
1805-
/* Ensure shutdown callback is executed before unregistering, so
1806-
* that baudrate is reset to initial value.
1799+
} else {
1800+
/* Restore FW baudrate to fw_init_baudrate if changed.
1801+
* This will ensure FW baudrate is in sync with
1802+
* driver baudrate in case this driver is re-inserted.
18071803
*/
1808-
nxp_shutdown(hdev);
1804+
if (nxpdev->current_baudrate != nxpdev->fw_init_baudrate) {
1805+
nxpdev->new_baudrate = nxpdev->fw_init_baudrate;
1806+
nxp_set_baudrate_cmd(hdev, NULL);
1807+
}
18091808
}
18101809

18111810
ps_cleanup(nxpdev);

0 commit comments

Comments
 (0)