2021-11-10 00:06:34

by Benjamin Berg

[permalink] [raw]
Subject: [PATCH 1/4] Bluetooth: Reset more state when cancelling a sync command

From: Benjamin Berg <[email protected]>

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 <[email protected]>
---
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


2021-12-02 23:53:09

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 1/4] Bluetooth: Reset more state when cancelling a sync command

Hi Benjamin,

On Tue, Nov 9, 2021 at 2:35 PM Benjamin Berg <[email protected]> wrote:
>
> From: Benjamin Berg <[email protected]>
>
> 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 <[email protected]>
> ---
> 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?

--
Luiz Augusto von Dentz