Skip to content

Commit 8377545

Browse files
Vudentzholtmann
authored andcommitted
Bluetooth: Fix handling of SUSPEND_DISCONNECTING
When SUSPEND_DISCONNECTING bit is set that means Disconnect is pending but the code was evaluating if the list is empty before calling hci_conn_del which does the actual cleanup and remove the connection from the list thus the bit is never cleared causing the suspend procedure to always timeout when there are connections to be disconnected: Suspend/Resume - Success 5 (Pairing - Legacy) - waiting done Set the system into Suspend via force_suspend = mgmt-tester: Suspend/Resume - Success 5 (Pairing -.. 17:03:13.200458 = mgmt-tester: Set the system into Suspend via force_suspend 17:03:13.205812 < HCI Command: Write Scan E.. (0x03|0x001a) plen 1 torvalds#122 [hci0] 17:03:13.213561 Scan enable: No Scans (0x00) > HCI Event: Command Complete (0x0e) plen 4 torvalds#123 [hci0] 17:03:13.214710 Write Scan Enable (0x03|0x001a) ncmd 1 Status: Success (0x00) < HCI Command: Disconnect (0x01|0x0006) plen 3 torvalds#124 [hci0] 17:03:13.215830 Handle: 42 Reason: Remote Device Terminated due to Power Off (0x15) > HCI Event: Command Status (0x0f) plen 4 torvalds#125 [hci0] 17:03:13.216602 Disconnect (0x01|0x0006) ncmd 1 Status: Success (0x00) > HCI Event: Disconnect Complete (0x05) plen 4 torvalds#126 [hci0] 17:03:13.217342 Status: Success (0x00) Handle: 42 Reason: Remote Device Terminated due to Power Off (0x15) @ MGMT Event: Device Disconn.. (0x000c) plen 8 {0x0002} [hci0] 17:03:13.217688 BR/EDR Address: 00:AA:01:01:00:00 (Intel Corporation) Reason: Connection terminated by local host for suspend (0x05) @ MGMT Event: Device Disconn.. (0x000c) plen 8 {0x0001} [hci0] 17:03:13.217688 BR/EDR Address: 00:AA:01:01:00:00 (Intel Corporation) Reason: Connection terminated by local host for suspend (0x05) Suspend/Resume - Success 5 (Pairing - Legacy) - test timed out = mgmt-tester: Suspend/Resume - Success 5 (Pairing -.. 17:03:13.939317 Suspend/Resume - Success 5 (Pairing - Legacy) - teardown = mgmt-tester: Suspend/Resume - Success 5 (Pairing -.. 17:03:13.947267 [ 13.284291] Bluetooth: hci0: Timed out waiting for suspend events [ 13.287324] Bluetooth: hci0: Suspend timeout bit: 6 Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent d16e6d1 commit 8377545

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

net/bluetooth/hci_event.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -2987,14 +2987,6 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
29872987

29882988
hci_disconn_cfm(conn, ev->reason);
29892989

2990-
/* The suspend notifier is waiting for all devices to disconnect so
2991-
* clear the bit from pending tasks and inform the wait queue.
2992-
*/
2993-
if (list_empty(&hdev->conn_hash.list) &&
2994-
test_and_clear_bit(SUSPEND_DISCONNECTING, hdev->suspend_tasks)) {
2995-
wake_up(&hdev->suspend_wait_q);
2996-
}
2997-
29982990
/* Re-enable advertising if necessary, since it might
29992991
* have been disabled by the connection. From the
30002992
* HCI_LE_Set_Advertise_Enable command description in
@@ -3012,6 +3004,14 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
30123004

30133005
hci_conn_del(conn);
30143006

3007+
/* The suspend notifier is waiting for all devices to disconnect so
3008+
* clear the bit from pending tasks and inform the wait queue.
3009+
*/
3010+
if (list_empty(&hdev->conn_hash.list) &&
3011+
test_and_clear_bit(SUSPEND_DISCONNECTING, hdev->suspend_tasks)) {
3012+
wake_up(&hdev->suspend_wait_q);
3013+
}
3014+
30153015
unlock:
30163016
hci_dev_unlock(hdev);
30173017
}

0 commit comments

Comments
 (0)