]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
Bluetooth: hci_sync: Add a new quirk to skip HCI_FLT_CLEAR_ALL
authorIsmael Ferreras Morezuelas <swyterzone@gmail.com>
Mon, 7 Mar 2022 20:04:44 +0000 (21:04 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 28 Mar 2022 08:03:20 +0000 (10:03 +0200)
commit 0eaecfb2e4814d51ab172df3823e35d7c488b6d2 upstream.

Some controllers have problems with being sent a command to clear
all filtering. While the HCI code does not unconditionally
send a clear-all anymore at BR/EDR setup (after the state machine
refactor), there might be more ways of hitting these codepaths
in the future as the kernel develops.

Cc: stable@vger.kernel.org
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Ismael Ferreras Morezuelas <swyterzone@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/net/bluetooth/hci.h
net/bluetooth/hci_sync.c

index 35c073d44ec5a868653e61562c9a6380d896d169..5cb095b09a9407bc8e23f4979a0dca68f12b94bc 100644 (file)
@@ -255,6 +255,16 @@ enum {
         * during the hdev->setup vendor callback.
         */
        HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
+
+       /* When this quirk is set, HCI_OP_SET_EVENT_FLT requests with
+        * HCI_FLT_CLEAR_ALL are ignored and event filtering is
+        * completely avoided. A subset of the CSR controller
+        * clones struggle with this and instantly lock up.
+        *
+        * Note that devices using this must (separately) disable
+        * runtime suspend, because event filtering takes place there.
+        */
+       HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL,
 };
 
 /* HCI device flags */
index ab9aa700b6b33c226c499abea500d01a0c52195b..5e93f37c2e04d5e0e4742d528a6f0b1c516b4bfe 100644 (file)
@@ -2806,6 +2806,9 @@ static int hci_set_event_filter_sync(struct hci_dev *hdev, u8 flt_type,
        if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED))
                return 0;
 
+       if (test_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks))
+               return 0;
+
        memset(&cp, 0, sizeof(cp));
        cp.flt_type = flt_type;
 
@@ -2826,6 +2829,13 @@ static int hci_clear_event_filter_sync(struct hci_dev *hdev)
        if (!hci_dev_test_flag(hdev, HCI_EVENT_FILTER_CONFIGURED))
                return 0;
 
+       /* In theory the state machine should not reach here unless
+        * a hci_set_event_filter_sync() call succeeds, but we do
+        * the check both for parity and as a future reminder.
+        */
+       if (test_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks))
+               return 0;
+
        return hci_set_event_filter_sync(hdev, HCI_FLT_CLEAR_ALL, 0x00,
                                         BDADDR_ANY, 0x00);
 }
@@ -4825,6 +4835,12 @@ static int hci_update_event_filter_sync(struct hci_dev *hdev)
        if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED))
                return 0;
 
+       /* Some fake CSR controllers lock up after setting this type of
+        * filter, so avoid sending the request altogether.
+        */
+       if (test_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks))
+               return 0;
+
        /* Always clear event filter when starting */
        hci_clear_event_filter_sync(hdev);