All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btintel_pcie: fix stale cache in set_dxstate fallback check
@ 2026-05-07 20:34 Vladimir V. Kondratyev
  2026-05-07 21:06 ` bluez.test.bot
                   ` (4 more replies)
  0 siblings, 5 replies; 23+ messages in thread
From: Vladimir V. Kondratyev @ 2026-05-07 20:34 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: Chandrashekar Devegowda, Kiran K, Paul Menzel, Arnd Bergmann,
	linux-bluetooth, linux-kernel, Vladimir V. Kondratyev

btintel_pcie_set_dxstate() falls back to checking the controller state via
btintel_pcie_in_d3/d0() when the alive interrupt is missed. However, these
helpers read boot_stage_cache, which is only updated by the interrupt
handler. As such, if the interrupt was missed, the cache is stale and the
fallback check always fails, exhausting all retries and returning -EBUSY,
causing suspend to abort.

The fix involves re-reading the hardware register before the fallback state
check, consistent with btintel_pcie_resume().

Fixes: e57362f4911b ("Bluetooth: btintel_pcie: Add support for _suspend() / _resume()")

Signed-off-by: Vladimir V. Kondratyev <vladimirkondratyev2@gmail.com>
---
 drivers/bluetooth/btintel_pcie.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index fda474406003..7fca8eea6e01 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -2778,9 +2778,13 @@ static int btintel_pcie_set_dxstate(struct btintel_pcie_data *data, u32 dxstate)
 					  BTINTEL_PCIE_MSIX_HW_INT_CAUSES_GP0);
 
 		/* A hardware bug may cause the alive interrupt to be missed.
-		 * Check if the controller reached the expected state and retry
-		 * the operation only if it hasn't.
+		 * Refresh boot_stage_cache from hardware since it is only
+		 * updated by the interrupt handler, then check if the
+		 * controller reached the expected state and retry the
+		 * operation only if it hasn't.
 		 */
+		data->boot_stage_cache = btintel_pcie_rd_reg32(data,
+							       BTINTEL_PCIE_CSR_BOOT_STAGE_REG);
 		if (dxstate == BTINTEL_PCIE_STATE_D0) {
 			if (btintel_pcie_in_d0(data))
 				return 0;
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread
* Re: btintel_pcie: hibernation intermittently aborted by -EBUSY from D3 entry timeout
@ 2026-09-08 17:43 Sergey Lebedev
  2026-09-09  0:45 ` [PATCH v4] Bluetooth: btintel_pcie: fix stale cache in set_dxstate fallback check Ferenc Lengyel
  0 siblings, 1 reply; 23+ messages in thread
From: Sergey Lebedev @ 2026-09-08 17:43 UTC (permalink / raw)
  To: Ferenc Lengyel
  Cc: Vladimir V . Kondratyev, Ravindra, Kiran K, Paul Menzel,
	linux-bluetooth

Ferenc,

Two patches already on this list address exactly your signature, and they
fix different halves of it. Both are reviewed and neither has been applied
yet, so testing them is useful rather than redundant.

Your path is btintel_pcie_hibernate() -> btintel_pcie_suspend_late(
PMSG_HIBERNATE) -> btintel_pcie_set_dxstate(D3_COLD). After each 200 ms
timeout that function does not give up blindly: it falls back to asking
whether the controller reached the state anyway, because the alive
interrupt is known to go missing. The fallback is btintel_pcie_in_d3(),
which reads data->boot_stage_cache and not the register.

And boot_stage_cache is refreshed in exactly one place on this path: the
alive interrupt handler. So the fallback that exists to survive a missed
interrupt is disabled by the very miss it exists for - it re-reads a value
last written before the transition, three times, and returns -EBUSY after
the image is already on disk.

  Vladimir V. Kondratyev, v4 - re-read BOOT_STAGE_REG before the fallback
  check, so a genuinely missed interrupt becomes survivable:
  https://lore.kernel.org/linux-bluetooth/20260903192245.135310-2-vladimirkondratyev2@gmail.com/

  Ravindra (Intel), v2 - move data->gp0_received = false out of the retry
  loop, so an interrupt that arrives late is not discarded by the next
  iteration:
  https://lore.kernel.org/linux-bluetooth/20260902042840.2432862-1-ravindra@intel.com/

I reproduced your exact three-retry signature deterministically on a
Surface Pro 11 (Lunar Lake, BE201 8086:a876) by dropping the alive
interrupt on demand, and measured the two patches per hunk: with only
Ravindra's, the missed-interrupt case still fails as unpatched; with only
Vladimir's, it passes. They do not interfere. I have also seen the failure
happen on its own, injection disabled, once in six s2idle cycles.

So my guess is Vladimir's patch alone will fix your hibernation, and it
would be worth knowing. If it does not, that is more interesting still:
it would mean your controller genuinely never reaches D3, which is a
different bug from this one and worth reporting as such.

If you do test it, a Tested-by would carry real weight. Everything above
is one machine, one controller, one firmware - which I have said in every
message I have sent on this - and yours is Panther Lake with 8086:e476, a
different generation. The two patches are being combined into a single
series, so there is a window in which a second machine can still be part
of it.

Your report: 22771256-6dcb-4ab9-ae77-3a88480e7d21@lengyelf.eu

Sergey


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2026-09-29 15:10 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 20:34 [PATCH] Bluetooth: btintel_pcie: fix stale cache in set_dxstate fallback check Vladimir V. Kondratyev
2026-05-07 21:06 ` bluez.test.bot
2026-09-01 20:37 ` [PATCH] " Vladimir V. Kondratyev
2026-09-01 22:36   ` bluez.test.bot
2026-09-02  5:35   ` [PATCH] " Paul Menzel
2026-09-02  7:24     ` Sergey Lebedev
2026-09-02  8:38       ` Paul Menzel
2026-09-02  9:30     ` Sergey Lebedev
2026-09-03 14:29 ` [PATCH v3] " Vladimir V. Kondratyev
2026-09-03 14:36   ` Paul Menzel
2026-09-03 14:47   ` [v3] " bluez.test.bot
2026-09-03 15:35 ` [PATCH v3] " Vladimir V. Kondratyev
2026-09-03 17:20   ` Sergey Lebedev
2026-09-03 18:40   ` [v3] " bluez.test.bot
2026-09-03 20:19     ` Paul Menzel
2026-09-03 19:22 ` [PATCH v4] " Vladimir V. Kondratyev
2026-09-03 19:53   ` Sergey Lebedev
2026-09-08 14:12     ` K, Kiran
2026-09-03 21:25   ` [v4] " bluez.test.bot
2026-09-09 12:36   ` [PATCH v4] " Sergey Lebedev
2026-09-29 15:10   ` patchwork-bot+bluetooth
  -- strict thread matches above, loose matches on Subject: below --
2026-09-08 17:43 btintel_pcie: hibernation intermittently aborted by -EBUSY from D3 entry timeout Sergey Lebedev
2026-09-09  0:45 ` [PATCH v4] Bluetooth: btintel_pcie: fix stale cache in set_dxstate fallback check Ferenc Lengyel
2026-09-09 17:49   ` Sergey Lebedev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.