summaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
diff options
context:
space:
mode:
authorJian-Hong Pan <jian-hong@endlessm.com>2019-06-25 04:30:51 -0400
committerMarcel Holtmann <marcel@holtmann.org>2019-07-06 06:32:50 -0400
commit7af3f558aca74f2ee47b173f1c27f6bb9a5b5561 (patch)
treeaa560c8fe725702f772da427c407e98afffcf3fb /drivers/bluetooth
parent6322f377bc4a0e3dac040c1c6d01761514f42187 (diff)
Bluetooth: btrtl: HCI reset on close for Realtek BT chip
Realtek RTL8822BE BT chip on ASUS X420FA cannot be turned on correctly after on-off several times. Bluetooth daemon sets BT mode failed when this issue happens. Scanning must be active while turning off for this bug to be hit. bluetoothd[1576]: Failed to set mode: Failed (0x03) If BT is turned off, then turned on again, it works correctly again. According to the vendor driver, the HCI_QUIRK_RESET_ON_CLOSE flag is set during probing. So, this patch makes Realtek's BT reset on close to fix this issue. Link: https://bugzilla.kernel.org/show_bug.cgi?id=203429 Signed-off-by: Jian-Hong Pan <jian-hong@endlessm.com> Reviewed-by: Daniel Drake <drake@endlessm.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r--drivers/bluetooth/btrtl.c20
-rw-r--r--drivers/bluetooth/btrtl.h6
-rw-r--r--drivers/bluetooth/btusb.c1
3 files changed, 27 insertions, 0 deletions
diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index 208feef63de4..d04b443cad1f 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -637,6 +637,26 @@ int btrtl_setup_realtek(struct hci_dev *hdev)
637} 637}
638EXPORT_SYMBOL_GPL(btrtl_setup_realtek); 638EXPORT_SYMBOL_GPL(btrtl_setup_realtek);
639 639
640int btrtl_shutdown_realtek(struct hci_dev *hdev)
641{
642 struct sk_buff *skb;
643 int ret;
644
645 /* According to the vendor driver, BT must be reset on close to avoid
646 * firmware crash.
647 */
648 skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
649 if (IS_ERR(skb)) {
650 ret = PTR_ERR(skb);
651 bt_dev_err(hdev, "HCI reset during shutdown failed");
652 return ret;
653 }
654 kfree_skb(skb);
655
656 return 0;
657}
658EXPORT_SYMBOL_GPL(btrtl_shutdown_realtek);
659
640static unsigned int btrtl_convert_baudrate(u32 device_baudrate) 660static unsigned int btrtl_convert_baudrate(u32 device_baudrate)
641{ 661{
642 switch (device_baudrate) { 662 switch (device_baudrate) {
diff --git a/drivers/bluetooth/btrtl.h b/drivers/bluetooth/btrtl.h
index f1676144fce8..10ad40c3e42c 100644
--- a/drivers/bluetooth/btrtl.h
+++ b/drivers/bluetooth/btrtl.h
@@ -55,6 +55,7 @@ void btrtl_free(struct btrtl_device_info *btrtl_dev);
55int btrtl_download_firmware(struct hci_dev *hdev, 55int btrtl_download_firmware(struct hci_dev *hdev,
56 struct btrtl_device_info *btrtl_dev); 56 struct btrtl_device_info *btrtl_dev);
57int btrtl_setup_realtek(struct hci_dev *hdev); 57int btrtl_setup_realtek(struct hci_dev *hdev);
58int btrtl_shutdown_realtek(struct hci_dev *hdev);
58int btrtl_get_uart_settings(struct hci_dev *hdev, 59int btrtl_get_uart_settings(struct hci_dev *hdev,
59 struct btrtl_device_info *btrtl_dev, 60 struct btrtl_device_info *btrtl_dev,
60 unsigned int *controller_baudrate, 61 unsigned int *controller_baudrate,
@@ -83,6 +84,11 @@ static inline int btrtl_setup_realtek(struct hci_dev *hdev)
83 return -EOPNOTSUPP; 84 return -EOPNOTSUPP;
84} 85}
85 86
87static inline int btrtl_shutdown_realtek(struct hci_dev *hdev)
88{
89 return -EOPNOTSUPP;
90}
91
86static inline int btrtl_get_uart_settings(struct hci_dev *hdev, 92static inline int btrtl_get_uart_settings(struct hci_dev *hdev,
87 struct btrtl_device_info *btrtl_dev, 93 struct btrtl_device_info *btrtl_dev,
88 unsigned int *controller_baudrate, 94 unsigned int *controller_baudrate,
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 50aed5259c2b..342e1de6bcba 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3184,6 +3184,7 @@ static int btusb_probe(struct usb_interface *intf,
3184#ifdef CONFIG_BT_HCIBTUSB_RTL 3184#ifdef CONFIG_BT_HCIBTUSB_RTL
3185 if (id->driver_info & BTUSB_REALTEK) { 3185 if (id->driver_info & BTUSB_REALTEK) {
3186 hdev->setup = btrtl_setup_realtek; 3186 hdev->setup = btrtl_setup_realtek;
3187 hdev->shutdown = btrtl_shutdown_realtek;
3187 3188
3188 /* Realtek devices lose their updated firmware over suspend, 3189 /* Realtek devices lose their updated firmware over suspend,
3189 * but the USB hub doesn't notice any status change. 3190 * but the USB hub doesn't notice any status change.