From patchwork Fri Dec 3 14:58:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 12655365 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93E75C433EF for ; Fri, 3 Dec 2021 14:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381641AbhLCPCj (ORCPT ); Fri, 3 Dec 2021 10:02:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245020AbhLCPCf (ORCPT ); Fri, 3 Dec 2021 10:02:35 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 300DAC061353 for ; Fri, 3 Dec 2021 06:59:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=hvWDrkt26pgfpjnKS6vgCC4J9GIM4uWh5a5u+N3cj/c=; t=1638543551; x=1639753151; b=wyw8Utitge3J+7Oe5GcOc0Y4wmjsTAmkZkvucIRF3Rgfpl4 4n++LlelyTJFM5PCGHwUJiXOuAM7339JVvE24DZ0dlyXr6dgB3TYOiBLX62MQNv64mrCOAz3ts85e M+I5V+6cEVAKOicTJ/sSJIGOPE8BMi8SlJFQc/fthw5tF4wGEyjkuYqzUvyyB2miUqSM+xcAM8QjR qfngOWQVhcgSDvLKdMPRXvQ8oA8w5dkFbLbLm9E+3BDsWGvedkXDf4/jPe2EXTxgIYNE6md21ZnTd A4EJ1tULXnHRmtwMhLum06wla6OzdwbJnHZAuiIx9tM2GfsanVCpqsrC1bSklSkw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.95) (envelope-from ) id 1mtA1k-006QDV-Kd; Fri, 03 Dec 2021 15:59:08 +0100 From: Benjamin Berg To: linux-bluetooth@vger.kernel.org Cc: Luiz Augusto von Dentz , Benjamin Berg Subject: [PATCH v2 1/4] Bluetooth: Reset more state when cancelling a sync command Date: Fri, 3 Dec 2021 15:58:59 +0100 Message-Id: <20211203145902.3223861-2-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211203145902.3223861-1-benjamin@sipsolutions.net> References: <20211203145902.3223861-1-benjamin@sipsolutions.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Benjamin Berg 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 --- 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 8b3205e4b23e..58d640a31bde 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -118,6 +118,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); } } From patchwork Fri Dec 3 14:59:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 12655367 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3BCAC433FE for ; Fri, 3 Dec 2021 14:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381638AbhLCPCk (ORCPT ); Fri, 3 Dec 2021 10:02:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381622AbhLCPCf (ORCPT ); Fri, 3 Dec 2021 10:02:35 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F78AC061751 for ; Fri, 3 Dec 2021 06:59:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=IIcDy0f1QPrDBuQZeQYfUX+PfDG6D7KTDR5HCwg2u4w=; t=1638543551; x=1639753151; b=gJt8AZy8fgfZH+T2sVaFRsRqzz3nrDgSZc2nHghH+PE4md/ nE8FprF4CBklTqap0zQtIB0n8fnQ7S3wGOEwNIQXIDxcj52aBDbpAFLRLDIBoeMY+x5DGjGDFxT+B p8TzN+MfAUNfI9hevfkHkGpPpnwR/vi7fQWIWOErfduUqg0chPeqfi/4j5/OpzweknN3QYuym1VSw yF2/TTub1itO5m4jrfVrXy8G602mcMYRO7z6g9PkpRGsS0+mdaa+8oNulsda0HftmHpsv6G8dKBBE JyuuGnTLGrwcY5T4E6U4FZJPzMK8zdF9REUPiI92WK52wBwhU6a6Xo9aDyDEepnA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.95) (envelope-from ) id 1mtA1l-006QDV-4K; Fri, 03 Dec 2021 15:59:09 +0100 From: Benjamin Berg To: linux-bluetooth@vger.kernel.org Cc: Luiz Augusto von Dentz , Benjamin Berg Subject: [PATCH v2 2/4] Bluetooth: Add hci_cmd_sync_cancel to public API Date: Fri, 3 Dec 2021 15:59:00 +0100 Message-Id: <20211203145902.3223861-3-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211203145902.3223861-1-benjamin@sipsolutions.net> References: <20211203145902.3223861-1-benjamin@sipsolutions.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Benjamin Berg After transfer errors it makes sense to cancel an ongoing synchronous command that cannot complete anymore. To permit this, export the old hci_req_sync_cancel function as hci_cmd_sync_cancel in the API. Signed-off-by: Benjamin Berg --- include/net/bluetooth/hci_sync.h | 1 + net/bluetooth/hci_request.c | 18 +----------------- net/bluetooth/hci_request.h | 1 - net/bluetooth/hci_sync.c | 17 +++++++++++++++++ 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/include/net/bluetooth/hci_sync.h b/include/net/bluetooth/hci_sync.h index 0336c1bc5d25..f4034bf8f1ce 100644 --- a/include/net/bluetooth/hci_sync.h +++ b/include/net/bluetooth/hci_sync.h @@ -37,6 +37,7 @@ int __hci_cmd_sync_status_sk(struct hci_dev *hdev, u16 opcode, u32 plen, void hci_cmd_sync_init(struct hci_dev *hdev); void hci_cmd_sync_clear(struct hci_dev *hdev); +void hci_cmd_sync_cancel(struct hci_dev *hdev, int err); int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, void *data, hci_cmd_sync_work_destroy_t destroy); diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 58d640a31bde..a2607db44404 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -111,22 +111,6 @@ void hci_req_sync_complete(struct hci_dev *hdev, u8 result, u16 opcode, } } -void hci_req_sync_cancel(struct hci_dev *hdev, int err) -{ - bt_dev_dbg(hdev, "err 0x%2.2x", 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); - } -} - /* Execute request and wait for completion. */ int __hci_req_sync(struct hci_dev *hdev, int (*func)(struct hci_request *req, unsigned long opt), @@ -2708,7 +2692,7 @@ void hci_request_setup(struct hci_dev *hdev) void hci_request_cancel_all(struct hci_dev *hdev) { - hci_req_sync_cancel(hdev, ENODEV); + hci_cmd_sync_cancel(hdev, ENODEV); cancel_work_sync(&hdev->discov_update); cancel_work_sync(&hdev->scan_update); diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h index 5f8e8846ec74..8d39e9416861 100644 --- a/net/bluetooth/hci_request.h +++ b/net/bluetooth/hci_request.h @@ -64,7 +64,6 @@ int hci_req_sync(struct hci_dev *hdev, int (*req)(struct hci_request *req, int __hci_req_sync(struct hci_dev *hdev, int (*func)(struct hci_request *req, unsigned long opt), unsigned long opt, u32 timeout, u8 *hci_status); -void hci_req_sync_cancel(struct hci_dev *hdev, int err); struct sk_buff *hci_prepare_cmd(struct hci_dev *hdev, u16 opcode, u32 plen, const void *param); diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index ad86caf41f91..7ac6c170ec49 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -335,6 +335,23 @@ void hci_cmd_sync_clear(struct hci_dev *hdev) } } +void hci_cmd_sync_cancel(struct hci_dev *hdev, int err) +{ + bt_dev_dbg(hdev, "err 0x%2.2x", 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); + } +} +EXPORT_SYMBOL(hci_cmd_sync_cancel); + int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, void *data, hci_cmd_sync_work_destroy_t destroy) { From patchwork Fri Dec 3 14:59:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 12655359 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31D70C433FE for ; Fri, 3 Dec 2021 14:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381630AbhLCPCg (ORCPT ); Fri, 3 Dec 2021 10:02:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381627AbhLCPCf (ORCPT ); Fri, 3 Dec 2021 10:02:35 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37557C061359 for ; Fri, 3 Dec 2021 06:59:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=vDsOiCXIJOBMs2DG8p+Cbmag+JNpQHQD0sNjbqaOyGU=; t=1638543551; x=1639753151; b=JqW8zOAqHbhmNfJYrWW7QjVV2eFt+mcllf6AHpEM8hcGof2 ++yyYBzXk1sR46cJusWaVOWp+EHIFqGmmgckUd3f7XBnsy6ksVCeVIYlkb0iDESb7Kvq7v9IVI6E5 zcIp6RngFN/6Y8TpIPp8EqZuS4bTzp4DqDX2/rlDl4rjP8dTkjy4F67ne9nrTmPZwTEbcm8oxNnfH IOYE9fMTb2EEdn/D+pVfgqR08yKkRf4RtfU5KyVxRKvUJLVjwM8iFTMQuvNXy4Qfv4WVZjz59mZLT 5rOvLrRBqsx/0vZ3BkAvfakIJ5osA7tdcqJFKinEtfFocFHiJFRBuSwoIomjulOg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.95) (envelope-from ) id 1mtA1l-006QDV-Ew; Fri, 03 Dec 2021 15:59:09 +0100 From: Benjamin Berg To: linux-bluetooth@vger.kernel.org Cc: Luiz Augusto von Dentz , Benjamin Berg Subject: [PATCH v2 3/4] Bluetooth: hci_core: Cancel sync command if sending a frame failed Date: Fri, 3 Dec 2021 15:59:01 +0100 Message-Id: <20211203145902.3223861-4-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211203145902.3223861-1-benjamin@sipsolutions.net> References: <20211203145902.3223861-1-benjamin@sipsolutions.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Benjamin Berg If sending a frame failed any sync command associated with it will never be completed. As such, cancel any such command immediately to avoid timing out. Signed-off-by: Benjamin Berg --- v2: * Pass error up and cancel sync command from hci_cmd_work --- net/bluetooth/hci_core.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index fdc0dcf8ee36..5cadecd31f66 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -2906,7 +2906,7 @@ int hci_unregister_cb(struct hci_cb *cb) } EXPORT_SYMBOL(hci_unregister_cb); -static void hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb) +static int hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb) { int err; @@ -2929,14 +2929,17 @@ static void hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb) if (!test_bit(HCI_RUNNING, &hdev->flags)) { kfree_skb(skb); - return; + return -EINVAL; } err = hdev->send(hdev, skb); if (err < 0) { bt_dev_err(hdev, "sending frame failed (%d)", err); kfree_skb(skb); + return err; } + + return 0; } /* Send HCI command */ @@ -3843,10 +3846,15 @@ static void hci_cmd_work(struct work_struct *work) hdev->sent_cmd = skb_clone(skb, GFP_KERNEL); if (hdev->sent_cmd) { + int res; if (hci_req_status_pend(hdev)) hci_dev_set_flag(hdev, HCI_CMD_PENDING); atomic_dec(&hdev->cmd_cnt); - hci_send_frame(hdev, skb); + + res = hci_send_frame(hdev, skb); + if (res < 0) + hci_cmd_sync_cancel(hdev, -res); + if (test_bit(HCI_RESET, &hdev->flags)) cancel_delayed_work(&hdev->cmd_timer); else From patchwork Fri Dec 3 14:59:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 12655363 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 044F7C433F5 for ; Fri, 3 Dec 2021 14:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381636AbhLCPCi (ORCPT ); Fri, 3 Dec 2021 10:02:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381628AbhLCPCf (ORCPT ); Fri, 3 Dec 2021 10:02:35 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C717C0611F7 for ; Fri, 3 Dec 2021 06:59:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=fS2yL2UnMGjTsNu363MYFfJS182LjOB/Q7ttvexi/FQ=; t=1638543551; x=1639753151; b=IFGY1UnpMmBxM+mD9tL0eyZiUyGLmffSjX1gMlK8YGrHCnR ckh6kDy9waBuYu6oQ543o13EJ/5XEPxBH6JCuSLdspwa8VvGyQqslI5KVeLteoP+eoeWNkmITLel9 K/c5dcV2crFtSRrT04cv5PHMUn4mwGmafqgszAr+zcieW4m0dOjX8CQ/HHtGz/pz5LK63YOJtD31n ZkJhy9HPsk4ngyl5asa9oFhp91FqLNbfdMpqE/2X1XhgF7YyYHba2JpAWafJ9Y9Wxx2T9kqGO9TQO zSknGgjDtNN5VjYw6ZiNV22cbfDb1U+2GXuSkoY2y7mpvfM7Gheh+cA6aIG+JCEQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.95) (envelope-from ) id 1mtA1l-006QDV-PM; Fri, 03 Dec 2021 15:59:10 +0100 From: Benjamin Berg To: linux-bluetooth@vger.kernel.org Cc: Luiz Augusto von Dentz , Benjamin Berg Subject: [PATCH v2 4/4] Bluetooth: btusb: Cancel sync commands for certain URB errors Date: Fri, 3 Dec 2021 15:59:02 +0100 Message-Id: <20211203145902.3223861-5-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211203145902.3223861-1-benjamin@sipsolutions.net> References: <20211203145902.3223861-1-benjamin@sipsolutions.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Benjamin Berg Cancel sync commands when transmission of URBs fail. This is done for both failures to send a command URB and also when the interrupt URB used to retrieve a response fails. This approach is sufficient to quickly deal with certain errors such as a device being disconnected while synchronous commands are done during initialization. Signed-off-by: Benjamin Berg --- v2: * Do not call handler in btusb_isoc_tx_complete. * Only call handler for command SKBs in btusb_tx_complete --- drivers/bluetooth/btusb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index ab169fc673ea..d9067a8fad60 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -933,6 +933,8 @@ static void btusb_intr_complete(struct urb *urb) if (err != -EPERM && err != -ENODEV) bt_dev_err(hdev, "urb %p failed to resubmit (%d)", urb, -err); + if (err != -EPERM) + hci_cmd_sync_cancel(hdev, -err); usb_unanchor_urb(urb); } } @@ -976,6 +978,8 @@ static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags) if (err != -EPERM && err != -ENODEV) bt_dev_err(hdev, "urb %p submission failed (%d)", urb, -err); + if (err != -EPERM) + hci_cmd_sync_cancel(hdev, -err); usb_unanchor_urb(urb); } @@ -1331,10 +1335,13 @@ static void btusb_tx_complete(struct urb *urb) if (!test_bit(HCI_RUNNING, &hdev->flags)) goto done; - if (!urb->status) + if (!urb->status) { hdev->stat.byte_tx += urb->transfer_buffer_length; - else + } else { + if (hci_skb_pkt_type(skb) == HCI_COMMAND_PKT) + hci_cmd_sync_cancel(hdev, -urb->status); hdev->stat.err_tx++; + } done: spin_lock_irqsave(&data->txlock, flags);