Skip to content

telemetry: pause background refresh work during D0ix - #11542

Open
pfurtak2 wants to merge 1 commit into
thesofproject:mainfrom
pfurtak2:pfurtak/telemetry-d0ix-fix
Open

pfurtak2 wants to merge 1 commit into
thesofproject:mainfrom
pfurtak2:pfurtak/telemetry-d0ix-fix

Conversation

@pfurtak2

@pfurtak2 pfurtak2 commented Nov 26, 2026 •

Copy link
Copy Markdown

When extended telemetry (CONFIG_SOF_TELEMETRY_EXTENDED_WINDOW) is enabled,
telemetry_bg_dwork runs every 1 s on Zephyr's cooperative k_sys_work_q
(priority -1). During D0ix / D0i3 power gating this causes two issues:

  • Because cooperative threads cannot be preempted by ll_thread (priority -16),
    the background refresh can delay LL audio processing during low-power HDA RTD3
    playback, causing audio glitches.
  • The 1 s delayed work periodically wakes core 0 out of tickless D0i3 power
    gating even when the DSP is otherwise idle.

Changes

  • telemetry: pause background refresh work during D0ix
    • Notifies telemetry on D0ix state transitions from pm_runtime (with a no-op
      stub when CONFIG_SOF_TELEMETRY_EXTENDED_WINDOW is disabled).
    • Pauses the periodic cold-section refresh work when D0ix is allowed and
      resumes it on D0ix exit.
    • Lightweight hot-path staging flushes in telemetry_update() remain active.

Why not a lower-priority preemptible workqueue?

Moving telemetry_bg_dwork to a dedicated preemptible workqueue (lower priority
than ll_thread) has several drawbacks:

  • The 1 s periodic timer would still wake core 0 out of tickless D0i3 power
    gating every second (failing D0ix power-gating checks and increasing idle
    power).
  • telemetry_refresh_cold_sections() relies on cooperative execution to avoid
    same-core preemption while updating the shared staging buffers
    (tel_*_staging) and the window seqlock (telemetry_seq_begin/end), so
    making it preemptible would also require adding synchronization across
    telemetry writers.
  • A dedicated workqueue thread would require an extra thread stack in SRAM.

Pausing the periodic refresh during D0ix addresses both the LL audio starvation
and the periodic D0i3 wakeups with no additional locking or memory overhead.

@sofci

sofci commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

reply test this please to run this test once

@intel-sofci

intel-sofci commented Nov 26, 2026 •

Copy link
Copy Markdown

PR 11542: test results

Run date: 2026-11-26 17:09 UTC

Tested commit: 527aa3377efbf684892bb8e620b0f609ddc338d3

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

@pfurtak2
pfurtak2 marked this pull request as ready for review November 26, 2026 14:05
Copilot AI balanced review requested due to automatic review settings November 26, 2026 14:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Telemetry cancellation does not synchronize with a running handler, allowing concurrent collection to produce mixed snapshots and refresh work to rearm after cancellation.

3 open issues
What changed in this PR

This PR pauses extended telemetry’s background refresh during D0ix to reduce audio-processing delays and unnecessary DSP wakeups.

Changes:

  • Add D0ix notifications for runtime-idle policy-lock transitions.
  • Cancel background refresh on entry, publish a final cold-section snapshot, and resume periodic refresh on exit.
  • Guard background rescheduling while keeping lightweight hot-path telemetry updates active.
File Description
zephyr/​lib/​pm_runtime.c Emit local D0ix notifications when runtime-idle lock state changes.
src/​kernel/​debug/​telemetry/​telemetry.c Subscribe to D0ix events and pause or resume background refresh.
src/​include/​sof/​lib/​notifier.h Define the D0ix notification ID and transition states.

Review effort: Balanced

Comment thread src/kernel/debug/telemetry/telemetry.c Resolved
Comment thread zephyr/lib/pm_runtime.c Resolved
Comment thread zephyr/lib/pm_runtime.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Target-hardware validation is needed to confirm D0ix transitions quiesce queued or running refresh work, eliminate idle timer wakeups, resume refresh on exit, and preserve LL audio deadlines during HDA RTD3 playback.

1 open issue
2 resolved since last review

Review effort: Balanced

The periodic cold-section refresh runs on the cooperative system
workqueue, which cannot be preempted by ll_thread. During low-power
RTD3 playback this starves the LL audio thread and causes audio
glitches, while the 1000 ms timer also wakes core 0 from tickless
D0ix every second.

Notify telemetry on D0ix state transitions from pm_runtime to pause
the periodic refresh work when D0ix is allowed and resume it on D0ix
exit.

Signed-off-by: Pawel Furtak <pawel.furtak@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Static review cannot verify D0i3 power-gating, wakeup suppression, and low-latency audio guarantees across repeated transitions and secondary-core calls without target-hardware testing.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, btw do we have a method to switch on/off via IPC ?

@lgirdwood

Copy link
Copy Markdown
Member

Can you check the CI and ping if its good to merge. Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants