Bluetooth: btintel: Fix broken LED quirk for legacy ROM devices
authorTedd Ho-Jeong An <tedd.an@intel.com>
Fri, 7 Jan 2022 00:34:54 +0000 (16:34 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 16 Jan 2022 08:12:43 +0000 (09:12 +0100)
commit 95655456e7cee858a23793f67025765b4c4c227b upstream.

This patch fixes the broken LED quirk for Intel legacy ROM devices.
To fix the LED issue that doesn't turn off immediately, the host sends
the SW RFKILL command while shutting down the interface and it puts the
devices in SW RFKILL state.

Once the device is in SW RFKILL state, it can only accept HCI_Reset to
exit from the SW RFKILL state. This patch checks the quirk for broken
LED and sends the HCI_Reset before sending the HCI_Intel_Read_Version
command.

The affected legacy ROM devices are
 - 8087:07dc
 - 8087:0a2a
 - 8087:0aa7

Fixes: ffcba827c0a1d ("Bluetooth: btintel: Fix the LED is not turning off immediately")
Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/bluetooth/btintel.c
drivers/bluetooth/btintel.h
drivers/bluetooth/btusb.c

index f1705b46fc8898bf1b03d1521ed809a82cdffc18..525be2e1fbb25d27f785c2953ebed63a31041552 100644 (file)
@@ -2193,8 +2193,15 @@ static int btintel_setup_combined(struct hci_dev *hdev)
         * As a workaround, send HCI Reset command first which will reset the
         * number of completed commands and allow normal command processing
         * from now on.
+        *
+        * Regarding the INTEL_BROKEN_SHUTDOWN_LED flag, these devices maybe
+        * in the SW_RFKILL ON state as a workaround of fixing LED issue during
+        * the shutdown() procedure, and once the device is in SW_RFKILL ON
+        * state, the only way to exit out of it is sending the HCI_Reset
+        * command.
         */
-       if (btintel_test_flag(hdev, INTEL_BROKEN_INITIAL_NCMD)) {
+       if (btintel_test_flag(hdev, INTEL_BROKEN_INITIAL_NCMD) ||
+           btintel_test_flag(hdev, INTEL_BROKEN_SHUTDOWN_LED)) {
                skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL,
                                     HCI_INIT_TIMEOUT);
                if (IS_ERR(skb)) {
@@ -2263,12 +2270,6 @@ static int btintel_setup_combined(struct hci_dev *hdev)
                                set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED,
                                        &hdev->quirks);
 
-                       /* These devices have an issue with LED which doesn't
-                        * go off immediately during shutdown. Set the flag
-                        * here to send the LED OFF command during shutdown.
-                        */
-                       btintel_set_flag(hdev, INTEL_BROKEN_LED);
-
                        err = btintel_legacy_rom_setup(hdev, &ver);
                        break;
                case 0x0b:      /* SfP */
@@ -2399,9 +2400,10 @@ static int btintel_shutdown_combined(struct hci_dev *hdev)
 
        /* Some platforms have an issue with BT LED when the interface is
         * down or BT radio is turned off, which takes 5 seconds to BT LED
-        * goes off. This command turns off the BT LED immediately.
+        * goes off. As a workaround, sends HCI_Intel_SW_RFKILL to put the
+        * device in the RFKILL ON state which turns off the BT LED immediately.
         */
-       if (btintel_test_flag(hdev, INTEL_BROKEN_LED)) {
+       if (btintel_test_flag(hdev, INTEL_BROKEN_SHUTDOWN_LED)) {
                skb = __hci_cmd_sync(hdev, 0xfc3f, 0, NULL, HCI_INIT_TIMEOUT);
                if (IS_ERR(skb)) {
                        ret = PTR_ERR(skb);
index aa64072bbe68d77b5c0dce0e99b8e147d50f587b..704e3b7bcb77c251dddacbe131d5f12ceed69924 100644 (file)
@@ -145,7 +145,7 @@ enum {
        INTEL_FIRMWARE_FAILED,
        INTEL_BOOTING,
        INTEL_BROKEN_INITIAL_NCMD,
-       INTEL_BROKEN_LED,
+       INTEL_BROKEN_SHUTDOWN_LED,
        INTEL_ROM_LEGACY,
 
        __INTEL_NUM_FLAGS,
index be385bb8aa2463bbee549d70a1da9e236fa9dc4f..754e25f35d7ae44a9da7a7dedd7ad5e2468eaed6 100644 (file)
@@ -59,6 +59,7 @@ static struct usb_driver btusb_driver;
 #define BTUSB_WIDEBAND_SPEECH  0x400000
 #define BTUSB_VALID_LE_STATES   0x800000
 #define BTUSB_QCA_WCN6855      0x1000000
+#define BTUSB_INTEL_BROKEN_SHUTDOWN_LED        0x2000000
 #define BTUSB_INTEL_BROKEN_INITIAL_NCMD 0x4000000
 
 static const struct usb_device_id btusb_table[] = {
@@ -380,10 +381,13 @@ static const struct usb_device_id blacklist_table[] = {
        { USB_DEVICE(0x8087, 0x0033), .driver_info = BTUSB_INTEL_COMBINED },
        { USB_DEVICE(0x8087, 0x07da), .driver_info = BTUSB_CSR },
        { USB_DEVICE(0x8087, 0x07dc), .driver_info = BTUSB_INTEL_COMBINED |
-                                                    BTUSB_INTEL_BROKEN_INITIAL_NCMD },
-       { USB_DEVICE(0x8087, 0x0a2a), .driver_info = BTUSB_INTEL_COMBINED },
+                                                    BTUSB_INTEL_BROKEN_INITIAL_NCMD |
+                                                    BTUSB_INTEL_BROKEN_SHUTDOWN_LED },
+       { USB_DEVICE(0x8087, 0x0a2a), .driver_info = BTUSB_INTEL_COMBINED |
+                                                    BTUSB_INTEL_BROKEN_SHUTDOWN_LED },
        { USB_DEVICE(0x8087, 0x0a2b), .driver_info = BTUSB_INTEL_COMBINED },
-       { USB_DEVICE(0x8087, 0x0aa7), .driver_info = BTUSB_INTEL_COMBINED },
+       { USB_DEVICE(0x8087, 0x0aa7), .driver_info = BTUSB_INTEL_COMBINED |
+                                                    BTUSB_INTEL_BROKEN_SHUTDOWN_LED },
        { USB_DEVICE(0x8087, 0x0aaa), .driver_info = BTUSB_INTEL_COMBINED },
 
        /* Other Intel Bluetooth devices */
@@ -3849,6 +3853,9 @@ static int btusb_probe(struct usb_interface *intf,
 
                if (id->driver_info & BTUSB_INTEL_BROKEN_INITIAL_NCMD)
                        btintel_set_flag(hdev, INTEL_BROKEN_INITIAL_NCMD);
+
+               if (id->driver_info & BTUSB_INTEL_BROKEN_SHUTDOWN_LED)
+                       btintel_set_flag(hdev, INTEL_BROKEN_SHUTDOWN_LED);
        }
 
        if (id->driver_info & BTUSB_MARVELL)