Skip to content

Commit f419863

Browse files
apusakaVudentz
authored andcommitted
Bluetooth: Cancel sync command before suspend and power off
Some of the sync commands might take a long time to complete, e.g. LE Create Connection when the peer device isn't responding might take 20 seconds before it times out. If suspend command is issued during this time, it will need to wait for completion since both commands are using the same sync lock. This patch cancel any running sync commands before attempting to suspend or adapter power off. Signed-off-by: Archie Pusaka <[email protected]> Reviewed-by: Ying Hsu <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 7948fe1 commit f419863

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

net/bluetooth/hci_core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,6 +2803,9 @@ int hci_suspend_dev(struct hci_dev *hdev)
28032803
if (mgmt_powering_down(hdev))
28042804
return 0;
28052805

2806+
/* Cancel potentially blocking sync operation before suspend */
2807+
__hci_cmd_sync_cancel(hdev, -EHOSTDOWN);
2808+
28062809
hci_req_sync_lock(hdev);
28072810
ret = hci_suspend_sync(hdev);
28082811
hci_req_sync_unlock(hdev);

net/bluetooth/mgmt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,10 @@ static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data,
13991399
goto failed;
14001400
}
14011401

1402+
/* Cancel potentially blocking sync operation before power off */
1403+
if (cp->val == 0x00)
1404+
__hci_cmd_sync_cancel(hdev, -EHOSTDOWN);
1405+
14021406
err = hci_cmd_sync_queue(hdev, set_powered_sync, cmd,
14031407
mgmt_set_powered_complete);
14041408

0 commit comments

Comments
 (0)