Bluetooth: Notify suspend on le conn failed
authorAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
Mon, 1 Mar 2021 20:06:04 +0000 (12:06 -0800)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 2 Mar 2021 14:02:55 +0000 (15:02 +0100)
When suspending, Bluetooth disconnects all connected peers devices. If
an LE connection is started but isn't completed, we will see an LE
Create Connection Cancel instead of an HCI disconnect. This just adds
a check to see if an LE cancel was the last disconnected device and wake
the suspend thread when that is the case.

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Archie Pusaka <apusaka@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/hci_conn.c

index 6ffa89e3ba0a854d0ae63519b637e8f691a6bd06..468d31f3303d7a34471631e9d615f51e35c63b42 100644 (file)
@@ -772,6 +772,16 @@ void hci_le_conn_failed(struct hci_conn *conn, u8 status)
 
        hci_conn_del(conn);
 
+       /* The suspend notifier is waiting for all devices to disconnect and an
+        * LE connect cancel will result in an hci_le_conn_failed. Once the last
+        * connection is deleted, we should also wake the suspend queue to
+        * complete suspend operations.
+        */
+       if (list_empty(&hdev->conn_hash.list) &&
+           test_and_clear_bit(SUSPEND_DISCONNECTING, hdev->suspend_tasks)) {
+               wake_up(&hdev->suspend_wait_q);
+       }
+
        /* Since we may have temporarily stopped the background scanning in
         * favor of connection establishment, we should restart it.
         */