This fixes errors like bellow when LE Connection times out since that is actually not a controller error: Bluetooth: hci0: Opcode 0x200d failed: -110 Bluetooth: hci0: request failed to create LE connection: err -110 Instead the code shall properly detect if -ETIMEDOUT is returned and send HCI_OP_LE_CREATE_CONN_CANCEL to give up on the connection.
Unified · Split
| @@ -954,6 +954,7 @@ enum { · 953 unmodified lines | ||
| 954 | 954 | HCI_CONN_STK_ENCRYPT, |
| 955 | 955 | HCI_CONN_AUTH_INITIATOR, |
| 956 | 956 | HCI_CONN_DROP, |
| 957 | + HCI_CONN_CANCEL, | |
| 957 | 958 | HCI_CONN_PARAM_REMOVAL_PEND, |
| 958 | 959 | HCI_CONN_NEW_LINK_KEY, |
| 959 | 960 | HCI_CONN_SCANNING, |
| @@ -1233,6 +1233,8 @@ static void create_le_conn_complete(struct hci_dev *hdev, void *data, int err) · 1232 unmodified lines | ||
| 1233 | 1233 | { |
| 1234 | 1234 | struct hci_conn *conn = data; |
| 1235 | 1235 | |
| 1236 | + bt_dev_dbg(hdev, "err %d", err); | |
| 1237 | + | |
| 1236 | 1238 | hci_dev_lock(hdev); |
| 1237 | 1239 | |
| 1238 | 1240 | if (!err) { |
| @@ -1240,8 +1242,6 @@ static void create_le_conn_complete(struct hci_dev *hdev, void *data, int err) · 1 unmodified line | ||
| 1240 | 1242 | goto done; |
| 1241 | 1243 | } |
| 1242 | 1244 | |
| 1243 | − bt_dev_err(hdev, "request failed to create LE connection: err %d", err); | |
| 1244 | − | |
| 1245 | 1245 | /* Check if connection is still pending */ |
| 1246 | 1246 | if (conn != hci_lookup_le_connect(hdev)) |
| 1247 | 1247 | goto done; |
| @@ -2771,6 +2771,9 @@ int hci_abort_conn(struct hci_conn *conn, u8 reason) · 1523 unmodified lines | ||
| 2771 | 2771 | { |
| 2772 | 2772 | int r = 0; |
| 2773 | 2773 | |
| 2774 | + if (test_and_set_bit(HCI_CONN_CANCEL, &conn->flags)) | |
| 2775 | + return 0; | |
| 2776 | + | |
| 2774 | 2777 | switch (conn->state) { |
| 2775 | 2778 | case BT_CONNECTED: |
| 2776 | 2779 | case BT_CONFIG: |
| @@ -2881,16 +2881,6 @@ static void cs_le_create_conn(struct hci_dev *hdev, bdaddr_t *peer_addr, · 2880 unmodified lines | ||
| 2881 | 2881 | |
| 2882 | 2882 | conn->resp_addr_type = peer_addr_type; |
| 2883 | 2883 | bacpy(&conn->resp_addr, peer_addr); |
| 2884 | − | |
| 2885 | − /* We don't want the connection attempt to stick around | |
| 2886 | − * indefinitely since LE doesn't have a page timeout concept | |
| 2887 | − * like BR/EDR. Set a timer for any connection that doesn't use | |
| 2888 | − * the accept list for connecting. | |
| 2889 | − */ | |
| 2890 | − if (filter_policy == HCI_LE_USE_PEER_ADDR) | |
| 2891 | − queue_delayed_work(conn->hdev->workqueue, | |
| 2892 | − &conn->le_conn_timeout, | |
| 2893 | − conn->conn_timeout); | |
| 2894 | 2884 | } |
| 2895 | 2885 | |
| 2896 | 2886 | static void hci_cs_le_create_conn(struct hci_dev *hdev, u8 status) |
| @@ -5902,6 +5892,12 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status, · 3005 unmodified lines | ||
| 5902 | 5892 | if (status) |
| 5903 | 5893 | goto unlock; |
| 5904 | 5894 | |
| 5895 | + /* Drop the connection if it has been aborted */ | |
| 5896 | + if (test_bit(HCI_CONN_CANCEL, &conn->flags)) { | |
| 5897 | + hci_conn_drop(conn); | |
| 5898 | + goto unlock; | |
| 5899 | + } | |
| 5900 | + | |
| 5905 | 5901 | if (conn->dst_type == ADDR_LE_DEV_PUBLIC) |
| 5906 | 5902 | addr_type = BDADDR_LE_PUBLIC; |
| 5907 | 5903 | else |
| @@ -246,8 +246,9 @@ int __hci_cmd_sync_status_sk(struct hci_dev *hdev, u16 opcode, u32 plen, · 245 unmodified lines | ||
| 246 | 246 | |
| 247 | 247 | skb = __hci_cmd_sync_sk(hdev, opcode, plen, param, event, timeout, sk); |
| 248 | 248 | if (IS_ERR(skb)) { |
| 249 | − bt_dev_err(hdev, "Opcode 0x%4x failed: %ld", opcode, | |
| 250 | − PTR_ERR(skb)); | |
| 249 | + if (!event) | |
| 250 | + bt_dev_err(hdev, "Opcode 0x%4x failed: %ld", opcode, | |
| 251 | + PTR_ERR(skb)); | |
| 251 | 252 | return PTR_ERR(skb); |
| 252 | 253 | } |
| 253 | 254 | |
| @@ -5126,8 +5127,11 @@ static int hci_le_connect_cancel_sync(struct hci_dev *hdev, · 4872 unmodified lines | ||
| 5126 | 5127 | if (test_bit(HCI_CONN_SCANNING, &conn->flags)) |
| 5127 | 5128 | return 0; |
| 5128 | 5129 | |
| 5130 | + if (test_and_set_bit(HCI_CONN_CANCEL, &conn->flags)) | |
| 5131 | + return 0; | |
| 5132 | + | |
| 5129 | 5133 | return __hci_cmd_sync_status(hdev, HCI_OP_LE_CREATE_CONN_CANCEL, |
| 5130 | − 6, &conn->dst, HCI_CMD_TIMEOUT); | |
| 5134 | + 0, NULL, HCI_CMD_TIMEOUT); | |
| 5131 | 5135 | } |
| 5132 | 5136 | |
| 5133 | 5137 | static int hci_connect_cancel_sync(struct hci_dev *hdev, struct hci_conn *conn) |
| @@ -6102,6 +6106,9 @@ int hci_le_create_conn_sync(struct hci_dev *hdev, struct hci_conn *conn) · 968 unmodified lines | ||
| 6102 | 6106 | conn->conn_timeout, NULL); |
| 6103 | 6107 | |
| 6104 | 6108 | done: |
| 6109 | + if (err == -ETIMEDOUT) | |
| 6110 | + hci_le_connect_cancel_sync(hdev, conn); | |
| 6111 | + | |
| 6105 | 6112 | /* Re-enable advertising after the connection attempt is finished. */ |
| 6106 | 6113 | hci_resume_advertising_sync(hdev); |
| 6107 | 6114 | return err; |