linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Cancel sync command before suspend and power off
@ 2023-04-20 12:23 Archie Pusaka
  2023-04-20 13:13 ` bluez.test.bot
  2023-04-20 21:00 ` [PATCH] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Archie Pusaka @ 2023-04-20 12:23 UTC (permalink / raw)
  To: linux-bluetooth, Luiz Augusto von Dentz, Marcel Holtmann
  Cc: CrosBT Upstreaming, Archie Pusaka, Ying Hsu, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Johan Hedberg, Paolo Abeni,
	linux-kernel, netdev

From: Archie Pusaka <apusaka@chromium.org>

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>

---

 net/bluetooth/hci_core.c | 3 +++
 net/bluetooth/mgmt.c     | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 393b317ae68f6..a856b1051d355 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2803,6 +2803,9 @@ int hci_suspend_dev(struct hci_dev *hdev)
 	if (mgmt_powering_down(hdev))
 		return 0;
 
+	/* Cancel potentially blocking sync operation before suspend */
+	__hci_cmd_sync_cancel(hdev, -EHOSTDOWN);
+
 	hci_req_sync_lock(hdev);
 	ret = hci_suspend_sync(hdev);
 	hci_req_sync_unlock(hdev);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 5f8c144c84b88..13c745876b390 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);
 
-- 
2.40.0.634.g4ca3ef3211-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: Bluetooth: Cancel sync command before suspend and power off
  2023-04-20 12:23 [PATCH] Bluetooth: Cancel sync command before suspend and power off Archie Pusaka
@ 2023-04-20 13:13 ` bluez.test.bot
  2023-04-20 21:00 ` [PATCH] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2023-04-20 13:13 UTC (permalink / raw)
  To: linux-bluetooth, apusaka

[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=741724

---Test result---

Test Summary:
CheckPatch                    PASS      0.87 seconds
GitLint                       PASS      0.34 seconds
SubjectPrefix                 PASS      0.13 seconds
BuildKernel                   PASS      31.60 seconds
CheckAllWarning               PASS      35.22 seconds
CheckSparse                   PASS      39.70 seconds
CheckSmatch                   PASS      108.30 seconds
BuildKernel32                 PASS      30.72 seconds
TestRunnerSetup               PASS      441.03 seconds
TestRunner_l2cap-tester       PASS      16.96 seconds
TestRunner_iso-tester         PASS      20.94 seconds
TestRunner_bnep-tester        PASS      5.55 seconds
TestRunner_mgmt-tester        PASS      115.13 seconds
TestRunner_rfcomm-tester      PASS      8.92 seconds
TestRunner_sco-tester         PASS      8.20 seconds
TestRunner_ioctl-tester       PASS      9.50 seconds
TestRunner_mesh-tester        PASS      7.08 seconds
TestRunner_smp-tester         PASS      8.13 seconds
TestRunner_userchan-tester    PASS      5.84 seconds
IncrementalBuild              PASS      29.22 seconds



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Bluetooth: Cancel sync command before suspend and power off
  2023-04-20 12:23 [PATCH] Bluetooth: Cancel sync command before suspend and power off Archie Pusaka
  2023-04-20 13:13 ` bluez.test.bot
@ 2023-04-20 21:00 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2023-04-20 21:00 UTC (permalink / raw)
  To: Archie Pusaka
  Cc: linux-bluetooth, luiz.dentz, marcel,
	chromeos-bluetooth-upstreaming, apusaka, yinghsu, davem,
	edumazet, kuba, johan.hedberg, pabeni, linux-kernel, netdev

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu, 20 Apr 2023 20:23:36 +0800 you wrote:
> From: Archie Pusaka <apusaka@chromium.org>
> 
> 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.
> 
> [...]

Here is the summary with links:
  - Bluetooth: Cancel sync command before suspend and power off
    https://git.kernel.org/bluetooth/bluetooth-next/c/ef917d571667

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-20 21:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-20 12:23 [PATCH] Bluetooth: Cancel sync command before suspend and power off Archie Pusaka
2023-04-20 13:13 ` bluez.test.bot
2023-04-20 21:00 ` [PATCH] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).