diff mbox series

[1/4] Bluetooth: Reset more state when cancelling a sync command

Message ID 20211109164113.65981-2-benjamin@sipsolutions.net (mailing list archive)
State Superseded
Headers show
Series Cancel sync commands if a TX failure occurs | expand

Checks

Context Check Description
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint success Gitlint PASS
tedd_an/buildkernel success Build Kernel PASS
tedd_an/testrunnersetup success Test Runner Setup PASS
tedd_an/testrunnerl2cap-tester success Total: 40, Passed: 40 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerbnep-tester success Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnermgmt-tester success Total: 492, Passed: 492 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnerrfcomm-tester success Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersco-tester success Total: 12, Passed: 12 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunnersmp-tester success Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0
tedd_an/testrunneruserchan-tester success Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0

Commit Message

Benjamin Berg Nov. 9, 2021, 4:41 p.m. UTC
From: Benjamin Berg <bberg@redhat.com>

Resetting the timers and cmd_cnt means that we assume the device will be
in a good state after the sync command finishes. Without this a chain of
synchronous commands might get stuck if one of them is cancelled.

Signed-off-by: Benjamin Berg <bberg@redhat.com>
---
 net/bluetooth/hci_request.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Luiz Augusto von Dentz Dec. 2, 2021, 11:52 p.m. UTC | #1
Hi Benjamin,

On Tue, Nov 9, 2021 at 2:35 PM Benjamin Berg <benjamin@sipsolutions.net> wrote:
>
> From: Benjamin Berg <bberg@redhat.com>
>
> Resetting the timers and cmd_cnt means that we assume the device will be
> in a good state after the sync command finishes. Without this a chain of
> synchronous commands might get stuck if one of them is cancelled.
>
> Signed-off-by: Benjamin Berg <bberg@redhat.com>
> ---
>  net/bluetooth/hci_request.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
> index 92611bfc0b9e..c948ee28bede 100644
> --- a/net/bluetooth/hci_request.c
> +++ b/net/bluetooth/hci_request.c
> @@ -122,6 +122,11 @@ void hci_req_sync_cancel(struct hci_dev *hdev, int err)
>         if (hdev->req_status == HCI_REQ_PEND) {
>                 hdev->req_result = err;
>                 hdev->req_status = HCI_REQ_CANCELED;
> +
> +               cancel_delayed_work_sync(&hdev->cmd_timer);
> +               cancel_delayed_work_sync(&hdev->ncmd_timer);
> +               atomic_set(&hdev->cmd_cnt, 1);
> +
>                 wake_up_interruptible(&hdev->req_wait_q);
>         }
>  }
> --
> 2.31.1

Are you going to provide updates on this set? Or you are waiting for
more feedback on how to proceed?
diff mbox series

Patch

diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 92611bfc0b9e..c948ee28bede 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -122,6 +122,11 @@  void hci_req_sync_cancel(struct hci_dev *hdev, int err)
 	if (hdev->req_status == HCI_REQ_PEND) {
 		hdev->req_result = err;
 		hdev->req_status = HCI_REQ_CANCELED;
+
+		cancel_delayed_work_sync(&hdev->cmd_timer);
+		cancel_delayed_work_sync(&hdev->ncmd_timer);
+		atomic_set(&hdev->cmd_cnt, 1);
+
 		wake_up_interruptible(&hdev->req_wait_q);
 	}
 }