Skip to content

Commit f37515d

Browse files
nukeletgregkh
authored andcommitted
Bluetooth: Add new quirk for broken read key length on ATS2851
[ Upstream commit 48201a3 ] The ATS2851 controller erroneously reports support for the "Read Encryption Key Length" HCI command. This makes it unable to connect to any devices, since this command is issued by the kernel during the connection process in response to an "Encryption Change" HCI event. Add a new quirk (HCI_QUIRK_BROKEN_ENC_KEY_SIZE) to hint that the command is unsupported, preventing it from interrupting the connection process. This is the error log from btmon before this patch: > HCI Event: Encryption Change (0x08) plen 4 Status: Success (0x00) Handle: 2048 Address: ... Encryption: Enabled with E0 (0x01) < HCI Command: Read Encryption Key Size (0x05|0x0008) plen 2 Handle: 2048 Address: ... > HCI Event: Command Status (0x0f) plen 4 Read Encryption Key Size (0x05|0x0008) ncmd 1 Status: Unknown HCI Command (0x01) Signed-off-by: Vinicius Peixoto <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 591a048 commit f37515d

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

drivers/bluetooth/btusb.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4483,6 +4483,7 @@ static int btusb_probe(struct usb_interface *intf,
44834483
set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
44844484
set_bit(HCI_QUIRK_BROKEN_SET_RPA_TIMEOUT, &hdev->quirks);
44854485
set_bit(HCI_QUIRK_BROKEN_EXT_SCAN, &hdev->quirks);
4486+
set_bit(HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE, &hdev->quirks);
44864487
}
44874488

44884489
if (!reset)

include/net/bluetooth/hci.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,14 @@ enum {
339339
* during the hdev->setup vendor callback.
340340
*/
341341
HCI_QUIRK_BROKEN_LE_CODED,
342+
343+
/*
344+
* When this quirk is set, the HCI_OP_READ_ENC_KEY_SIZE command is
345+
* skipped during an HCI_EV_ENCRYPT_CHANGE event. This is required
346+
* for Actions Semiconductor ATS2851 based controllers, which erroneously
347+
* claim to support it.
348+
*/
349+
HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE,
342350
};
343351

344352
/* HCI device flags */

net/bluetooth/hci_event.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3679,7 +3679,8 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, void *data,
36793679
* controller really supports it. If it doesn't, assume
36803680
* the default size (16).
36813681
*/
3682-
if (!(hdev->commands[20] & 0x10)) {
3682+
if (!(hdev->commands[20] & 0x10) ||
3683+
test_bit(HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE, &hdev->quirks)) {
36833684
conn->enc_key_size = HCI_LINK_KEY_SIZE;
36843685
goto notify;
36853686
}

0 commit comments

Comments
 (0)