summaryrefslogtreecommitdiff
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorArchie Pusaka <apusaka@chromium.org>2023-04-20 20:23:36 +0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2023-04-23 22:06:55 -0700
commitf419863588217f76eaf754e1dfce21ea7fcb026d (patch)
treee03c79cf12a69f5b31edbd8eddf5688d6141b2d2 /net/bluetooth/mgmt.c
parent7948fe1c92d92313eea5453f83deb7f0141355e8 (diff)
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 <apusaka@chromium.org> Reviewed-by: Ying Hsu <yinghsu@chromium.org> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 5f8c144c84b8..13c745876b39 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1399,6 +1399,10 @@ static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data,
goto failed;
}
+ /* Cancel potentially blocking sync operation before power off */
+ if (cp->val == 0x00)
+ __hci_cmd_sync_cancel(hdev, -EHOSTDOWN);
+
err = hci_cmd_sync_queue(hdev, set_powered_sync, cmd,
mgmt_set_powered_complete);