From 67b790ecbeab3f5493dc8306e87e503e1bb7bcdc Mon Sep 17 00:00:00 2001 From: Paolo Sabatino Date: Sun, 29 Jan 2023 13:43:27 +0000 Subject: [PATCH] fix spreadtrum (sprd) bluetooth broken park link status --- drivers/bluetooth/hci_ldisc.c | 6 ++++++ include/net/bluetooth/hci.h | 6 ++++++ net/bluetooth/hci_sync.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c --- a/drivers/bluetooth/hci_ldisc.c (revision 58aa050aa57333b34b358234002121c59fb3af26) +++ b/drivers/bluetooth/hci_ldisc.c (revision bf8ab2f58b21494ffde96979431a3da931deb48b) @@ -658,6 +658,12 @@ hdev->setup = hci_uart_setup; SET_HCIDEV_DEV(hdev, hu->tty->dev); + // Set the broken Park link status quirk, specific for spreadtrum (sprd) + // bluetooth devices + if (hdev->manufacturer == 0xffff && hu->tty->driver && + strncmp(hu->tty->driver->name, "ttyBT", 5) == 0) + set_bit(HCI_QUIRK_BROKEN_PARK_LINK_STATUS, &hdev->quirks); + if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags)) set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h --- a/include/net/bluetooth/hci.h (revision 58aa050aa57333b34b358234002121c59fb3af26) +++ b/include/net/bluetooth/hci.h (revision bf8ab2f58b21494ffde96979431a3da931deb48b) @@ -309,6 +309,12 @@ /* HCI device quirks */ enum { + /* + * Device declares that support Park link status, but it really + * does not support it and fails to initialize + */ + HCI_QUIRK_BROKEN_PARK_LINK_STATUS, + /* When this quirk is set, the HCI Reset command is send when * closing the transport instead of when opening it. * diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c --- a/net/bluetooth/hci_sync.c (revision 58aa050aa57333b34b358234002121c59fb3af26) +++ b/net/bluetooth/hci_sync.c (revision bf8ab2f58b21494ffde96979431a3da931deb48b) @@ -3804,7 +3804,7 @@ link_policy |= HCI_LP_HOLD; if (lmp_sniff_capable(hdev)) link_policy |= HCI_LP_SNIFF; - if (lmp_park_capable(hdev)) + if (lmp_park_capable(hdev) && !test_bit(HCI_QUIRK_BROKEN_PARK_LINK_STATUS, &hdev->quirks)) link_policy |= HCI_LP_PARK; cp.policy = cpu_to_le16(link_policy); -- 2.34.1