Skip to content

Commit aae6b81

Browse files
committed
Bluetooth: HCI: Invert LE State quirk to be opt-out rather then opt-in
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: bluez/bluez#584 Fixes: 2209158 ("Bluetooth: Adding driver and quirk defs for multi-role LE") Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 9c5af2d commit aae6b81

File tree

10 files changed

+16
-32
lines changed

10 files changed

+16
-32
lines changed

drivers/bluetooth/btintel.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,9 +2945,6 @@ static int btintel_setup_combined(struct hci_dev *hdev)
29452945
INTEL_ROM_LEGACY_NO_WBS_SUPPORT))
29462946
set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED,
29472947
&hdev->quirks);
2948-
if (ver.hw_variant == 0x08 && ver.fw_variant == 0x22)
2949-
set_bit(HCI_QUIRK_VALID_LE_STATES,
2950-
&hdev->quirks);
29512948

29522949
err = btintel_legacy_rom_setup(hdev, &ver);
29532950
break;
@@ -2956,7 +2953,6 @@ static int btintel_setup_combined(struct hci_dev *hdev)
29562953
case 0x12: /* ThP */
29572954
case 0x13: /* HrP */
29582955
case 0x14: /* CcP */
2959-
set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
29602956
fallthrough;
29612957
case 0x0c: /* WsP */
29622958
/* Apply the device specific HCI quirks
@@ -3048,9 +3044,6 @@ static int btintel_setup_combined(struct hci_dev *hdev)
30483044
/* These variants don't seem to support LE Coded PHY */
30493045
set_bit(HCI_QUIRK_BROKEN_LE_CODED, &hdev->quirks);
30503046

3051-
/* Set Valid LE States quirk */
3052-
set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
3053-
30543047
/* Setup MSFT Extension support */
30553048
btintel_set_msft_opcode(hdev, ver.hw_variant);
30563049

@@ -3076,9 +3069,6 @@ static int btintel_setup_combined(struct hci_dev *hdev)
30763069
*/
30773070
set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
30783071

3079-
/* Apply LE States quirk from solar onwards */
3080-
set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
3081-
30823072
/* Setup MSFT Extension support */
30833073
btintel_set_msft_opcode(hdev,
30843074
INTEL_HW_VARIANT(ver_tlv.cnvi_bt));

drivers/bluetooth/btintel_pcie.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,9 +1180,6 @@ static int btintel_pcie_setup(struct hci_dev *hdev)
11801180
*/
11811181
set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
11821182

1183-
/* Apply LE States quirk from solar onwards */
1184-
set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
1185-
11861183
/* Setup MSFT Extension support */
11871184
btintel_set_msft_opcode(hdev,
11881185
INTEL_HW_VARIANT(ver_tlv.cnvi_bt));

drivers/bluetooth/btmtksdio.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,9 +1148,6 @@ static int btmtksdio_setup(struct hci_dev *hdev)
11481148
}
11491149
}
11501150

1151-
/* Valid LE States quirk for MediaTek 7921 */
1152-
set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
1153-
11541151
break;
11551152
case 0x7663:
11561153
case 0x7668:

drivers/bluetooth/btrtl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,6 @@ void btrtl_set_quirks(struct hci_dev *hdev, struct btrtl_device_info *btrtl_dev)
12871287
case CHIP_ID_8852C:
12881288
case CHIP_ID_8851B:
12891289
case CHIP_ID_8852BT:
1290-
set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
12911290
set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
12921291

12931292
/* RTL8852C needs to transmit mSBC data continuously without

drivers/bluetooth/btusb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3956,8 +3956,8 @@ static int btusb_probe(struct usb_interface *intf,
39563956
if (id->driver_info & BTUSB_WIDEBAND_SPEECH)
39573957
set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
39583958

3959-
if (id->driver_info & BTUSB_VALID_LE_STATES)
3960-
set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
3959+
if (!(id->driver_info & BTUSB_VALID_LE_STATES))
3960+
set_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks);
39613961

39623962
if (id->driver_info & BTUSB_DIGIANSWER) {
39633963
data->cmdreq_type = USB_TYPE_VENDOR;

drivers/bluetooth/hci_qca.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,8 +2474,8 @@ static int qca_serdev_probe(struct serdev_device *serdev)
24742474
set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED,
24752475
&hdev->quirks);
24762476

2477-
if (data->capabilities & QCA_CAP_VALID_LE_STATES)
2478-
set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
2477+
if (!(data->capabilities & QCA_CAP_VALID_LE_STATES))
2478+
set_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks);
24792479
}
24802480

24812481
return 0;

drivers/bluetooth/hci_vhci.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,6 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode)
425425
if (opcode & 0x80)
426426
set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
427427

428-
set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
429-
430428
if (hci_register_dev(hdev) < 0) {
431429
BT_ERR("Can't register HCI device");
432430
hci_free_dev(hdev);

include/net/bluetooth/hci.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,17 @@ enum {
206206
*/
207207
HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED,
208208

209-
/* When this quirk is set, the controller has validated that
210-
* LE states reported through the HCI_LE_READ_SUPPORTED_STATES are
211-
* valid. This mechanism is necessary as many controllers have
212-
* been seen has having trouble initiating a connectable
213-
* advertisement despite the state combination being reported as
214-
* supported.
209+
/* When this quirk is set, the LE states reported through the
210+
* HCI_LE_READ_SUPPORTED_STATES are invalid/broken.
211+
*
212+
* This mechanism is necessary as many controllers have been seen has
213+
* having trouble initiating a connectable advertisement despite the
214+
* state combination being reported as supported.
215+
*
216+
* This quirk can be set before hci_register_dev is called or
217+
* during the hdev->setup vendor callback.
215218
*/
216-
HCI_QUIRK_VALID_LE_STATES,
219+
HCI_QUIRK_BROKEN_LE_STATES,
217220

218221
/* When this quirk is set, then erroneous data reporting
219222
* is ignored. This is mainly due to the fact that the HCI

include/net/bluetooth/hci_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ extern struct mutex hci_cb_list_lock;
825825
} while (0)
826826

827827
#define hci_dev_le_state_simultaneous(hdev) \
828-
(test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && \
828+
(!test_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks) && \
829829
(hdev->le_states[4] & 0x08) && /* Central */ \
830830
(hdev->le_states[4] & 0x40) && /* Peripheral */ \
831831
(hdev->le_states[3] & 0x10)) /* Simultaneous */

net/bluetooth/hci_event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5920,7 +5920,7 @@ static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
59205920
* while we have an existing one in peripheral role.
59215921
*/
59225922
if (hdev->conn_hash.le_num_peripheral > 0 &&
5923-
(!test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) ||
5923+
(test_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks) ||
59245924
!(hdev->le_states[3] & 0x10)))
59255925
return NULL;
59265926

0 commit comments

Comments
 (0)