Skip to contentSkip to conversation

btintel_pcie: hibernation intermittently aborted by -EBUSY from D3 entry timeout

DISCUSSION Sergey Lebedev 2 participants 3 messages Sep 8 – Sep 9 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

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/[email protected]/

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/[email protected]/

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: [email protected]

Sergey

Tested-by
#1 lore raw

Re: [PATCH v4] Bluetooth: btintel_pcie: fix stale cache in set_dxstate fallback check

Hello,

I reported the intermittent hibernation abort in <[email protected]>, and Sergey asked whether v4 alone fixes it on my hardware. It does not. Applying v4 together with Ravindra's "[PATCH v2] Bluetooth: btintel_pcie: fix PM flow for S0ix, S3 and S4" does. Details below, including a correction to my original report.

Hardware and software: Lenovo ThinkPad X9-15p (21VV004FHV), BIOS N4QET35W 1.14. Intel Panther Lake CNVi Bluetooth, 8086:e476 at 0000:00:14.7, firmware 42-26.26 (ibt-00a0-01a1-iml.sfi then ibt-00a0-01a1-pci.sfi, timestamp 2026.26 build 94250). Kernel 7.2.3-1-cachyos; drivers/bluetooth/btintel_pcie.{c,h} are byte-identical to upstream v7.2. Note this is a different generation from Sergey's Lunar Lake BE201 8086:a876.

First, a correction to my original report. I wrote that all three retries timed out "AND the poll also reported the controller was not in D3", and concluded the device genuinely did not reach D3. That inference was unfounded, for exactly the reason v4 exists: btintel_pcie_in_d3() reads data->boot_stage_cache, which on that path is only written by the alive interrupt handler, so after a missed interrupt it reports a value from before the transition. Sergey identified this. Please disregard that part of the report.

Results, using systemctl hibernate. The two patched arms are from a single boot on 7.2.3; the stock baseline is my original A/B test on 7.2.2, where the driver files are identical:

  stock, 7.2.2                   3 aborts in 10 cycles stock, module unloaded         0 aborts in 10 cycles v4 alone, 7.2.3                2 aborts in 5 cycles v4 + Ravindra's v2, 7.2.3      0 aborts in 10 cycles

The v4 arm reproduced the original failure unchanged: all three retry counts, then -EBUSY, with the image already written.

To find out why, I built v4 with one extra bt_dev_warn immediately after the patch's register re-read, printing retry, boot_stage and in_d3. On a failing cycle it gives:

  Bluetooth: hci0: INSTR: after re-read, retry 0, boot_stage
0x20db0001, in_d3 0
  Bluetooth: hci0: INSTR: after re-read, retry 1, boot_stage
0x20db0001, in_d3 0
  Bluetooth: hci0: INSTR: after re-read, retry 2, boot_stage
0x20db0001, in_d3 0

So the re-read is working and returning a live value: it is not 0x00000000 or 0xffffffff, MAC_ACCESS_ON (bit 16) and ALIVE (bit 23) are set, and none of DEVICE_WARNING, ABORT_HANDLER or DEVICE_HALTED is set. The controller is reachable. But D3_STATE_READY (bit 24) is clear, identically across all three retries roughly 600 ms apart.

What 0x20db0001 is becomes clear with dynamic debug enabled on btintel_pcie_msix_gp0_handler, which prints the boot stage per alive context:

  Alive context: rom            0x20db0001    ROM set, IML and OPFW clear Alive context: intel_reset1   0xa0db0003    ROM, IML set Alive context: intel_reset1   0xa0db000f    ROM, IML, OPFW set Alive context: intel_reset2   0xa0db0007    ROM, IML, OPFW set Alive context: hci_reset      0xa0db0047    ROM, IML, OPFW set Alive context: d0             0x61710007    ROM, IML, OPFW and
D3_STATE_READY set

The last row is the context in which the driver is waiting to leave D3, so it is also an example of D3_STATE_READY actually being set. The value seen at the failing D3 entry is byte-identical to the ROM-stage value. The controller has no firmware loaded at the moment .poweroff asks it to enter D3, and a ROM-stage controller does not complete the D3 handshake. That is a separate fault from the stale cache, which is why v4 alone cannot help here.

The reason it is in ROM is the driver's own .thaw callback, and the log ordering on a failing cycle shows it directly:

  PM: hibernation: Preallocating image memory
  PM: hibernation: Allocated 12776628 kbytes in 1.48 seconds (8632.85
MB/s)
  printk: Suspending console(s) (use no_console_suspend to debug)
  PM: hibernation: Normal pages needed: 3179962 + 1024, available
pages: 5078484
  btintel_pcie 0000:00:14.7: resetting
  btintel_pcie 0000:00:14.7: reset done
  Bluetooth: BT reprobe failed for BDF:0000:00:14.7
  PM: hibernation: Wrote 10837272 kbytes in 8.88 seconds (1220.41 MB/s)
  PM: Image size after compression: 3781433 kbytes
  PM: Image saving done
  printk: Suspending console(s) (use no_console_suspend to debug)
  Bluetooth: hci0: Timeout (200 ms) on alive interrupt for D3 entry,
retry count 0
  Bluetooth: hci0: Timeout (200 ms) on alive interrupt for D3 entry,
retry count 1
  Bluetooth: hci0: Timeout (200 ms) on alive interrupt for D3 entry,
retry count 2
  btintel_pcie 0000:00:14.7: PM: pci_pm_poweroff():
btintel_pcie_hibernate [btintel_pcie] returns -16
  btintel_pcie 0000:00:14.7: PM: dpm_run_callback():
pci_pm_poweroff.llvm.16961064922821440386 returns -16
  btintel_pcie 0000:00:14.7: PM: failed to hibernate async: error -16
  PM: hibernation: Wakeup event detected during hibernation, rolling back.

hibernation_snapshot() runs .freeze, creates the image, then runs .thaw. btintel_pcie_suspend_late() has just recorded pm_sx_event = PM_EVENT_FREEZE, and pm_ops has .thaw = btintel_pcie_resume, so the thaw takes this branch:

    if (data->pm_sx_event == PM_EVENT_FREEZE || data->pm_sx_event == PM_EVENT_HIBERNATE) { set_bit(BTINTEL_PCIE_CORE_HALTED, &data->flags); data->reset_type = BTINTEL_PCIE_IOSF_PRR_FLR; btintel_pcie_reset(data->hdev);
        return 0;
    }

The FLR drops the controller to ROM. No "Firmware loaded in ... usecs" line follows before the image write completes, so the firmware had not been reloaded by the time .poweroff asked a ROM-stage controller to enter D3 roughly nine seconds later. I have not established why the reload does not complete in that window; the freezer still being engaged during .thaw seems the likeliest reason, but I have not confirmed it. The "BT reprobe failed" line is not itself a failure marker, incidentally: it appears on every resume here, including ones that succeed. The comment above that branch justifies the reset by saying S4 erases the loaded firmware, which is true on .restore, after power was actually cut, but on .thaw no power has been lost and the image has not even been written yet.

Ravindra's v2 removes exactly this: .thaw gets its own callback taking a normal D0 transition, and the FLR stays on .restore and S3 resume, which matches what he described on-list on 2026-09-08. With both patches applied I get 10 consecutive clean hibernations where v4 alone gave 2 aborts in 5 in the same boot.

Caveats, so the numbers are not read as stronger than they are. Ten clean cycles against a roughly one-in-three prior failure rate is about a 2 percent outcome by chance; Fisher's exact test against my own controls (5 aborts in 15 before, 0 in 10 after) gives p ~= 0.06. It is consistent and it matches the mechanism, but it is not a large sample.

I could not observe the .thaw phase directly on a passing cycle. On a successful hibernation the restored ring buffer stops at the snapshot point, so everything after it, including the .thaw callback, the image write and the .poweroff D3 entry, is discarded. Worth flagging for anyone trying to test this: pm_test is not a way around that either. In hibernation_snapshot(), create_image() never runs on the TEST_DEVICES path, so in_suspend stays 0 and dpm_resume() is called with PMSG_RESTORE rather than PMSG_THAW, which means pm_test exercises .restore and says nothing about .thaw.

I am happy to run more cycles, or any other instrumentation that would help.

For the combination as tested, both patches applied together:

Assisted-by Claude:claude-opus-5

v4 is correct and worth keeping on its own account: the stale cache is real, and fixing it is what let the second fault become visible. I would rather not give it a bare Tested-by on this thread, though, since on this hardware v4 alone does not fix the reported bug.

Regards,
Ferenc Lengyel

#2 lore raw

Re: [PATCH v4] Bluetooth: btintel_pcie: fix stale cache in set_dxstate fallback check

Ferenc,

I owe you a plain acknowledgement: I told you my guess was that v4 alone would fix your hibernation, and it did not. You checked instead of taking my word for it, then instrumented the re-read and found the actual second fault - .thaw running an FLR that leaves the controller in ROM when .poweroff asks it for D3 nine seconds later. That is the mechanism, and it is not one I would have got to from this machine, where the failure is on s2idle and looks nothing like it.

The series went out yesterday with both patches:

https://lore.kernel.org/linux-bluetooth/[email protected]/

Your Tested-by is on 2/2 and deliberately not on 1/2, which is how you asked for it: a tag on patch N means the tree with 1..N applied, so 2/2 is the one that carries "the pair, tested". Your Assisted-by went with it, in your order. Your own caveat about ten cycles against a one-in-three rate - Fisher p ~ 0.06 - is quoted in the cover letter in your words rather than summarised away.

Nothing needed from you. If the maintainers ask for more cycles I will say so here rather than assume you are available.

Sergey