Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39D1D3AEF2D; Sat, 17 Oct 2026 17:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792258912; cv=none; b=qHkbGPydjLEm9pBij96gF4Hb4yjwVTnbG/oe2XLsYbqkFeKFWYVlr9/58NYo42gnD1ce4wgl2FphhK4iaFvzATiZD3zmFn9LF1cKA9bLj/Uqj2qboMZGtQ/jKwaxb7Q20EmLbm1LANBUAI79PahTMORkX8opVdi39YA42F9kBYU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792258912; c=relaxed/simple; bh=FIcHsobvnZBOzkWGAKhItK9Lev1lWnOBPmfJoAyyCEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xyv1S3+8d2GEjLcKG3IrNoJ03vCZ5a2BRk+pPgO0KCJLXZFP5rPJ1/W20MuP2y7VMG/tlySEiiHy85iAQ+ia7H2C8v9F3itx4XIVY1WBGthSuPliRmSH4n4Rp/LeyLd3BYoeyf+vlbMEzMnQ4nAsfnfGpSiZ1tPA16xI5X91HJk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WheUfCTI; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="WheUfCTI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88DAD1F000C4; Sat, 17 Oct 2026 17:41:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792258911; bh=t3ZeIXPz2dbLNF/5a9QbqPr7ga1UB318hPHIyWJuwII=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WheUfCTIxoOGeQy00kMm6VixUNvBmfkDmYCfSSzeVse7ZjKb92bxmiGDB6q7u8tn0 Cgdf2AYXCNkSK9QTwyqGuzJOWvfm881074W63oxIp9RFh849mkVJe6THRPUpck5paC MXDqaNEw4ehVC3Kw33pq5noqN2jJ5caA8IAafW08= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Heitor Alves de Siqueira , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.6 1040/1674] Bluetooth: hci_sync: Set HCI_CMD_DRAIN_WORKQUEUE during device close Date: Sat, 17 Oct 2026 17:55:12 +0200 Message-ID: <20261017160457.830288909@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Heitor Alves de Siqueira [ Upstream commit 525daaea459fc215f432de1b8debbd9144bf97b0 ] Since hci_dev_close_sync() can now be called during the reset path, we should also set HCI_CMD_DRAIN_WORKQUEUE. This avoids queuing timeouts while the hdev workqueue is being drained. Fixes: 877afadad2dc ("Bluetooth: When HCI work queue is drained, only queue chained work") Signed-off-by: Heitor Alves de Siqueira Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_sync.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 0648da9761258..ce665ef463a39 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -5361,6 +5361,12 @@ int hci_dev_close_sync(struct hci_dev *hdev) bt_dev_dbg(hdev, ""); + /* Set HCI_DRAIN_WORKQUEUE flag to prevent queuing work during + * reset/close. See hci_cmd_work() and handle_cmd_cnt_and_timer(). + */ + hci_dev_set_flag(hdev, HCI_CMD_DRAIN_WORKQUEUE); + synchronize_rcu(); + cancel_delayed_work(&hdev->power_off); cancel_delayed_work(&hdev->ncmd_timer); cancel_delayed_work(&hdev->le_scan_disable); @@ -5379,6 +5385,7 @@ int hci_dev_close_sync(struct hci_dev *hdev) if (!test_and_clear_bit(HCI_UP, &hdev->flags)) { cancel_delayed_work_sync(&hdev->cmd_timer); + hci_dev_clear_flag(hdev, HCI_CMD_DRAIN_WORKQUEUE); return err; } @@ -5479,6 +5486,7 @@ int hci_dev_close_sync(struct hci_dev *hdev) /* Clear flags */ hdev->flags &= BIT(HCI_RAW); hci_dev_clear_volatile_flags(hdev); + hci_dev_clear_flag(hdev, HCI_CMD_DRAIN_WORKQUEUE); memset(hdev->eir, 0, sizeof(hdev->eir)); memset(hdev->dev_class, 0, sizeof(hdev->dev_class)); -- 2.53.0