@@ -637,6 +637,7 @@ enum {
/* ---- HCI Error Codes ---- */
#define HCI_ERROR_UNKNOWN_CONN_ID 0x02
+#define HCI_ERROR_HARDWARE_FAILURE 0x03
#define HCI_ERROR_AUTH_FAILURE 0x05
#define HCI_ERROR_PIN_OR_KEY_MISSING 0x06
#define HCI_ERROR_MEMORY_EXCEEDED 0x07
@@ -2323,13 +2323,14 @@ static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
if (status) {
if (conn && conn->state == BT_CONNECT) {
- /* If the request failed with "Command Disallowed", the
+ /* If the request failed with a certain status, the
* card is either using all its available "slots" for
* attempting new connections, or it's currently
* doing an HCI Inquiry. In these cases we'll try to
* do the "Create Connection" request again later.
*/
- if (status == HCI_ERROR_COMMAND_DISALLOWED) {
+ if (status == HCI_ERROR_COMMAND_DISALLOWED ||
+ status == HCI_ERROR_HARDWARE_FAILURE) {
conn->state = BT_CONNECT2;
if (!hci_conn_hash_lookup_state(hdev, ACL_LINK, BT_CONNECT) &&
@@ -3254,7 +3255,26 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
done:
if (status) {
- hci_conn_failed(conn, status);
+ if (status == HCI_ERROR_REJ_LIMITED_RESOURCES) {
+ conn->state = BT_CONNECT2;
+
+ if (!hci_conn_hash_lookup_state(hdev, ACL_LINK, BT_CONNECT) &&
+ !test_bit(HCI_INQUIRY, &hdev->flags)) {
+ bt_dev_err(hdev,
+ "\"Connect Complete\" event with error "
+ "(0x%2.2x) indicating to try again, but "
+ "there's no concurrent \"Create "
+ "Connection\" nor an ongoing inquiry",
+ status);
+
+ hci_conn_failed(conn, status);
+ }
+
+ hci_dev_unlock(hdev);
+ return;
+ } else {
+ hci_conn_failed(conn, status);
+ }
} else if (ev->link_type == SCO_LINK) {
switch (conn->setting & SCO_AIRMODE_MASK) {
case SCO_AIRMODE_CVSD:
While some hardware seems to return "HCI Command Disallowed" errors when trying to connect to too many devices at once, other hardware (eg. the BCM4378 found in M1 macbooks) returns "HCI Hardware Failure" in this case. And the Marvell 88W8897 in various Microsoft Surface devices behaves different again: Here the "HCI Create Connection" succeeds, but later a "HCI Connection Complete" event with status "Rejected Limited Resources" comes in. Handle all these cases as expected by userspace and reuse the existing BT_CONNECT2 logic to try "HCI Create Connection" again after the ongoing connection attempts have been completed. Signed-off-by: Jonas Dreßler <verdre@v0yd.nl> --- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_event.c | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-)