* [PATCH v3] Bluetooth: hci_qca: Reset the in-band sleep state on power off
@ 2026-12-01 17:29 Birk Skyum via B4 Relay
2026-12-02 3:00 ` [v3] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Birk Skyum via B4 Relay @ 2026-12-01 17:29 UTC (permalink / raw)
To: Bartosz Golaszewski, Marcel Holtmann, Luiz Augusto von Dentz
Cc: Vladyslav Tymoshchuk, linux-bluetooth, linux-arm-msm, linux-pm,
linux-kernel, stable, Birk Skyum
From: Birk Skyum <birk.skyum@pm.me>
qca_power_off() cuts the power of the controller but leaves the host
side of the in-band sleep (IBS) protocol as it was. tx_ibs_state and
rx_ibs_state are initialised in qca_open() only, so a controller that
qca_setup() powers on again meets whatever state the last session ended
in.
If that state is HCI_IBS_TX_AWAKE, the host sends the frames after the
next setup without a wake indication. qca_hci_shutdown() stops both IBS
timers, but the pre-shutdown command it sends afterwards goes through
qca_enqueue() and arms tx_idle_timer again for 2 s, so a power on within
those 2 s finds the state at AWAKE. On a OnePlus Pad 3 (WCN7880) this
happens with a power off and on within 2 s, and at every boot of a board
without local-bd-address when user space sets the address right after
the controller registers. The controller comes back asleep, and the
first command after it has gone to sleep breaks the link:
Bluetooth: hci0: Frame reassembly failed (-84)
Bluetooth: hci0: Opcode 0x0c56 failed: -110
Bluetooth: hci0: crash the soc to collect controller dump
The timer left armed can also send HCI_IBS_SLEEP_IND in the middle of
the next setup.
If the state is HCI_IBS_TX_WAKING, the host is waiting for a wake
acknowledgment, and qca_hci_shutdown() has deleted the timer that
sends the wake indication again. The setup still works, because frames
bypass IBS while QCA_IBS_DISABLED is set. Once the flag is cleared,
qca_enqueue() puts every frame on tx_wait_q and nothing takes it off:
Bluetooth: hci0: QCA setup on UART is completed
Bluetooth: hci0: Opcode 0x0c03 failed: -110
A restore from hibernation gets there on a Lenovo Yoga Slim 7x
(WCN7850). The controller has been through a power cycle, while the
restored kernel holds the state from before the image was taken. Its
wake indications go unanswered, the commands behind them time out, and
the core closes the device and sets it up again. From then on
tx_ibs_state reads 1 in debugfs and Bluetooth stays dead until hci_uart
is reloaded.
When the controller loses power, cancel the IBS work, wait for the IBS
timers, drop what was queued and put both sides back to asleep, which
is where qca_open() starts. The timer callbacks take hci_ibs_lock, so
the timers are deleted outside of it. All callers of qca_power_off()
can sleep, and the work items do not call it.
Fixes: 3e4be65eb82c ("Bluetooth: hci_qca: Add poweroff support during hci down for wcn3990")
Cc: stable@vger.kernel.org
Co-developed-by: Vladyslav Tymoshchuk <tvlad744@gmail.com>
Signed-off-by: Vladyslav Tymoshchuk <tvlad744@gmail.com>
Signed-off-by: Birk Skyum <birk.skyum@pm.me>
---
Changes since v2:
- Rebased onto bluetooth-next (e0e943a9d) after the qca_serdev refactor
- Dropped Assisted-by: trailer per Bartosz Golaszewski's review
- No functional changes from v2
- v2: https://lore.kernel.org/r/20261014180201.57109-1-birk.skyum@pm.me
Changes since v1:
- Cancel both IBS work items and wait for both timers before the reset,
with the timers deleted outside hci_ibs_lock, and flush after that, as
the Sashiko review of v1 pointed out (Vladyslav)
- Describe the AWAKE trigger next to the WAKING one
- Add Fixes: and Cc: stable
- v1: https://lore.kernel.org/r/179163212446.46972.2306254853726299632@pm.me
Testing notes (carried from v2, identical code):
- Vladyslav tested this patch on a OnePlus Pad 3 (SM8750, WCN7880): in
five quick power cycles, four fail without it and none with it [1].
- On a Lenovo Yoga Slim 7x (X1E80100, WCN7850) with v7.3-rc7, debugfs
reads tx_ibs_state=2 and rx_ibs_state=1 after power off on stock and
0 and 0 with this patch.
- Compiled cleanly on arm64 against bluetooth-next with W=1.
[1] https://lore.kernel.org/r/20261014162025.3733-1-tvlad744@gmail.com
---
drivers/bluetooth/hci_qca.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index d51db761f..835874260 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -2265,12 +2265,25 @@ static void qca_power_off(struct hci_uart *hu)
bool sw_ctrl_state;
/* From this point we go into power off state. But serial port may
- * still be open, stop queueing the IBS data and flush all the buffered
- * data in skb's.
+ * still be open, stop queueing the IBS data.
*/
spin_lock_irqsave(&qca->hci_ibs_lock, flags);
set_bit(QCA_IBS_DISABLED, &qca->flags);
+ spin_unlock_irqrestore(&qca->hci_ibs_lock, flags);
+
+ /* The controller loses the IBS state with its power and comes back
+ * with both sides asleep, as qca_open() assumes. Stop the IBS work and
+ * timers, drop what they queued and start over from there.
+ */
+ cancel_work_sync(&qca->ws_awake_device);
+ cancel_work_sync(&qca->ws_awake_rx);
+ timer_delete_sync(&qca->wake_retrans_timer);
+ timer_delete_sync(&qca->tx_idle_timer);
+
+ spin_lock_irqsave(&qca->hci_ibs_lock, flags);
qca_flush(hu);
+ qca->tx_ibs_state = HCI_IBS_TX_ASLEEP;
+ qca->rx_ibs_state = HCI_IBS_RX_ASLEEP;
spin_unlock_irqrestore(&qca->hci_ibs_lock, flags);
/* Non-serdev device usually is powered by external power
---
base-commit: e0e943a9dbcd7675652e2900d09e8595f28f724e
change-id: 20261201-bluetooth-hci-qca-ibs-reset-18aebe477a00
Best regards,
--
Birk Skyum <birk.skyum@pm.me>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [v3] Bluetooth: hci_qca: Reset the in-band sleep state on power off
2026-12-01 17:29 [PATCH v3] Bluetooth: hci_qca: Reset the in-band sleep state on power off Birk Skyum via B4 Relay
@ 2026-12-02 3:00 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-12-02 3:00 UTC (permalink / raw)
To: linux-bluetooth, birk.skyum
[-- Attachment #1: Type: text/plain, Size: 1219 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1228449/
---Test result---
Test Summary:
CheckPatch PASS 0.55 seconds
VerifyFixes PASS 0.08 seconds
VerifySignedoff PASS 0.10 seconds
GitLint FAIL 0.23 seconds
SubjectPrefix PASS 0.07 seconds
BuildKernel PASS 23.40 seconds
CheckAllWarning PASS 26.92 seconds
CheckSparse PASS 28.88 seconds
BuildKernel32 PASS 23.70 seconds
CheckKernelLLVM PASS 26.04 seconds
TestRunnerSetup PASS 556.86 seconds
IncrementalBuild PASS 22.85 seconds
Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[v3] Bluetooth: hci_qca: Reset the in-band sleep state on power off
86: B2 Line has trailing whitespace: "-- "
https://github.com/bluez/bluetooth-next/pull/1271
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-02 3:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 17:29 [PATCH v3] Bluetooth: hci_qca: Reset the in-band sleep state on power off Birk Skyum via B4 Relay
2026-12-02 3:00 ` [v3] " bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox