diff mbox series

[SRU,Noble] Bluetooth: hci_sync: fix HCI_CMD_DRAIN_WORKQUEUE fix

Message ID 20260923074417.55765-1-krzysztof.adamski@canonical.com
State New
Headers show
Series [SRU,Noble] Bluetooth: hci_sync: fix HCI_CMD_DRAIN_WORKQUEUE fix | expand

Commit Message

Krzysztof Adamski Sept. 23, 2026, 7:44 a.m. UTC
BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2167919

The commit fd719dc6e35c ("Bluetooth: hci_sync: Set
HCI_CMD_DRAIN_WORKQUEUE during device close") introduced a regression
that breaks hci_cmd_timeout(). This was disovered on the Ventuno Q
platform, where this prevents the QCA2066 Bluetooth card from probing,
as its initialization relies on a timeout-triggered reset.

The regression was caused by an incorrect rebase of upstream commit
47330cc875b3 with the same name. The original change intended to set the
HCI_CMD_DRAIN_WORKQUEUE flag only during hci_dev_close_sync() and clear
it before completion. Instead, the flag was mistakenly added to
hci_dev_open_sync() at rebase.

As a result, command timeout handling was permanently cancelled upon
device bring-up rather than temporarily during device closure. Fix this
by moving the flag handling to hci_dev_close_sync().

Signed-off-by: Krzysztof Adamski <krzysztof.adamski@canonical.com>
---
 net/bluetooth/hci_sync.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Edoardo Canepa Sept. 23, 2026, 9:20 a.m. UTC | #1
Rejected for the following reasons:

The submission is missing a cover letter, the PATCH indication on the 
subject,
and even if it proposes a SAUCE patch it should at least have a 
reference to upstream
discussion to keep track of the possible code evolution.

On 9/23/26 09:44, Krzysztof Adamski via kernel-team wrote:
> BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2167919
>
> The commit fd719dc6e35c ("Bluetooth: hci_sync: Set
> HCI_CMD_DRAIN_WORKQUEUE during device close") introduced a regression
> that breaks hci_cmd_timeout(). This was disovered on the Ventuno Q
> platform, where this prevents the QCA2066 Bluetooth card from probing,
> as its initialization relies on a timeout-triggered reset.
>
> The regression was caused by an incorrect rebase of upstream commit
> 47330cc875b3 with the same name. The original change intended to set the
> HCI_CMD_DRAIN_WORKQUEUE flag only during hci_dev_close_sync() and clear
> it before completion. Instead, the flag was mistakenly added to
> hci_dev_open_sync() at rebase.
>
> As a result, command timeout handling was permanently cancelled upon
> device bring-up rather than temporarily during device closure. Fix this
> by moving the flag handling to hci_dev_close_sync().
>
> Signed-off-by: Krzysztof Adamski <krzysztof.adamski@canonical.com>
> ---
>   net/bluetooth/hci_sync.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
> index 88675037f21f..5f60b95390e2 100644
> --- a/net/bluetooth/hci_sync.c
> +++ b/net/bluetooth/hci_sync.c
> @@ -5049,12 +5049,6 @@ int hci_dev_open_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();
> -
>   	if (hci_dev_test_flag(hdev, HCI_UNREGISTER)) {
>   		ret = -ENODEV;
>   		goto done;
> @@ -5206,6 +5200,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);
diff mbox series

Patch

diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 88675037f21f..5f60b95390e2 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -5049,12 +5049,6 @@  int hci_dev_open_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();
-
 	if (hci_dev_test_flag(hdev, HCI_UNREGISTER)) {
 		ret = -ENODEV;
 		goto done;
@@ -5206,6 +5200,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);