]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: HCI: Invert LE State quirk to be opt-out rather then opt-in
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 12 Aug 2024 14:43:48 +0000 (10:43 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Aug 2024 15:35:55 +0000 (17:35 +0200)
[ Upstream commit aae6b81260fd9a7224f7eb4fc440d625852245bb ]

This inverts the LE State quirk so by default we assume the controllers
would report valid states rather than invalid which is how quirks
normally behave, also this would result in HCI command failing it the LE
States are really broken thus exposing the controllers that are really
broken in this respect.

Link: https://github.com/bluez/bluez/issues/584
Fixes: 220915857e29 ("Bluetooth: Adding driver and quirk defs for multi-role LE")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/bluetooth/btintel.c
drivers/bluetooth/btintel_pcie.c
drivers/bluetooth/btmtksdio.c
drivers/bluetooth/btrtl.c
drivers/bluetooth/btusb.c
drivers/bluetooth/hci_qca.c
drivers/bluetooth/hci_vhci.c
include/net/bluetooth/hci.h
include/net/bluetooth/hci_core.h
net/bluetooth/hci_event.c

index 93900c37349c1c351b9abb94f646d787195026ab..c084dc88d3d9125d72310c1c05b977a2d92c3e92 100644 (file)
@@ -2876,9 +2876,6 @@ static int btintel_setup_combined(struct hci_dev *hdev)
                                               INTEL_ROM_LEGACY_NO_WBS_SUPPORT))
                                set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED,
                                        &hdev->quirks);
-                       if (ver.hw_variant == 0x08 && ver.fw_variant == 0x22)
-                               set_bit(HCI_QUIRK_VALID_LE_STATES,
-                                       &hdev->quirks);
 
                        err = btintel_legacy_rom_setup(hdev, &ver);
                        break;
@@ -2887,7 +2884,6 @@ static int btintel_setup_combined(struct hci_dev *hdev)
                case 0x12:      /* ThP */
                case 0x13:      /* HrP */
                case 0x14:      /* CcP */
-                       set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
                        fallthrough;
                case 0x0c:      /* WsP */
                        /* Apply the device specific HCI quirks
@@ -2979,9 +2975,6 @@ static int btintel_setup_combined(struct hci_dev *hdev)
                /* These variants don't seem to support LE Coded PHY */
                set_bit(HCI_QUIRK_BROKEN_LE_CODED, &hdev->quirks);
 
-               /* Set Valid LE States quirk */
-               set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
-
                /* Setup MSFT Extension support */
                btintel_set_msft_opcode(hdev, ver.hw_variant);
 
@@ -3003,9 +2996,6 @@ static int btintel_setup_combined(struct hci_dev *hdev)
                 */
                set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
 
-               /* Apply LE States quirk from solar onwards */
-               set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
-
                /* Setup MSFT Extension support */
                btintel_set_msft_opcode(hdev,
                                        INTEL_HW_VARIANT(ver_tlv.cnvi_bt));
index b8120b98a2395e323d87a9c63c02f623de4c0267..1fd3b7073ab90ddf1f9f14f8007bacc95d40c1d9 100644 (file)
@@ -1182,9 +1182,6 @@ static int btintel_pcie_setup(struct hci_dev *hdev)
                 */
                set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
 
-               /* Apply LE States quirk from solar onwards */
-               set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
-
                /* Setup MSFT Extension support */
                btintel_set_msft_opcode(hdev,
                                        INTEL_HW_VARIANT(ver_tlv.cnvi_bt));
index 8ded9ef8089a2fdbb697b253e70aee7a95e36392..bc4700ed3b782cbf653a233fb5f0678fcf8f8e46 100644 (file)
@@ -1144,9 +1144,6 @@ static int btmtksdio_setup(struct hci_dev *hdev)
                        }
                }
 
-               /* Valid LE States quirk for MediaTek 7921 */
-               set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
-
                break;
        case 0x7663:
        case 0x7668:
index 4f1e37b4f7802daceffc1ea46bd943215fcba4bd..bfcb41a57655f3e48939d4b3bbe2778c3ef88e62 100644 (file)
@@ -1287,7 +1287,6 @@ void btrtl_set_quirks(struct hci_dev *hdev, struct btrtl_device_info *btrtl_dev)
        case CHIP_ID_8852C:
        case CHIP_ID_8851B:
        case CHIP_ID_8852BT:
-               set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
                set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
 
                /* RTL8852C needs to transmit mSBC data continuously without
index 789c492df6fa2f1c857d4f443c3c9caceeef3b0a..0927f51867c26ac6107f7bc6cd560cacc8748e0a 100644 (file)
@@ -4545,8 +4545,8 @@ static int btusb_probe(struct usb_interface *intf,
        if (id->driver_info & BTUSB_WIDEBAND_SPEECH)
                set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
 
-       if (id->driver_info & BTUSB_VALID_LE_STATES)
-               set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
+       if (!(id->driver_info & BTUSB_VALID_LE_STATES))
+               set_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks);
 
        if (id->driver_info & BTUSB_DIGIANSWER) {
                data->cmdreq_type = USB_TYPE_VENDOR;
index 9a0bc86f9aace53282742b381f08bf3ac93e230b..34c36f0f781eacf05e25747785aa9e4528d41e1e 100644 (file)
@@ -2408,8 +2408,8 @@ static int qca_serdev_probe(struct serdev_device *serdev)
                        set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED,
                                &hdev->quirks);
 
-               if (data->capabilities & QCA_CAP_VALID_LE_STATES)
-                       set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
+               if (!(data->capabilities & QCA_CAP_VALID_LE_STATES))
+                       set_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks);
        }
 
        return 0;
index 28750a40f0ed52aab23f519e47bdd886d46780bd..b652d68f0ee1466291d64d4b7092fed60cca74e1 100644 (file)
@@ -425,8 +425,6 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode)
        if (opcode & 0x80)
                set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
 
-       set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
-
        if (hci_register_dev(hdev) < 0) {
                BT_ERR("Can't register HCI device");
                hci_free_dev(hdev);
index e372a88e8c3f6a9a640f791ad4ddcf9be25a7947..d1d073089f384e20eeb269ab2d5192f6c18d6939 100644 (file)
@@ -206,14 +206,17 @@ enum {
         */
        HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED,
 
-       /* When this quirk is set, the controller has validated that
-        * LE states reported through the HCI_LE_READ_SUPPORTED_STATES are
-        * valid.  This mechanism is necessary as many controllers have
-        * been seen has having trouble initiating a connectable
-        * advertisement despite the state combination being reported as
-        * supported.
+       /* When this quirk is set, the LE states reported through the
+        * HCI_LE_READ_SUPPORTED_STATES are invalid/broken.
+        *
+        * This mechanism is necessary as many controllers have been seen has
+        * having trouble initiating a connectable advertisement despite the
+        * state combination being reported as supported.
+        *
+        * This quirk can be set before hci_register_dev is called or
+        * during the hdev->setup vendor callback.
         */
-       HCI_QUIRK_VALID_LE_STATES,
+       HCI_QUIRK_BROKEN_LE_STATES,
 
        /* When this quirk is set, then erroneous data reporting
         * is ignored. This is mainly due to the fact that the HCI
index b15f51ae3bfd989beea743ca2d447b3f71cd5fd0..c97ff64c9189f0a5aec445568920344c46cb0a2a 100644 (file)
@@ -826,7 +826,7 @@ extern struct mutex hci_cb_list_lock;
        } while (0)
 
 #define hci_dev_le_state_simultaneous(hdev) \
-       (test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && \
+       (!test_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks) && \
         (hdev->le_states[4] & 0x08) && /* Central */ \
         (hdev->le_states[4] & 0x40) && /* Peripheral */ \
         (hdev->le_states[3] & 0x10))   /* Simultaneous */
index a78f6d706cd43edbe495c0e1865a4372a3f25b6b..59d9086db75fee86d41138d8ef9e2583366bdc96 100644 (file)
@@ -5921,7 +5921,7 @@ static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
         * while we have an existing one in peripheral role.
         */
        if (hdev->conn_hash.le_num_peripheral > 0 &&
-           (!test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) ||
+           (test_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks) ||
             !(hdev->le_states[3] & 0x10)))
                return NULL;