Skip to content

vregion: create the interim heap on the allocating core - #11552

Open
kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:202611-fat-fix-interim-heap-create
Open

kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:202611-fat-fix-interim-heap-create

Conversation

@kv2019i

@kv2019i kv2019i commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

vregion_set_interim() is called from pipeline_complete() on the pipeline core, also for the vregions of DP modules on other cores. It created the interim k_heap right away, so the heap metadata was written to cached memory on the pipeline core. The first interim allocation on the module's own core then read stale metadata and failed, although the heap was empty:

[core 0] vregion.interim_heap_init: creating interim heap: lifetime
used 6784, interim available 13696 at 0xa0212a80
[core 1] src_prepare: comp:0 0x1013 entry
[core 1] vregion.interim_alloc: interim alloc failed for 80 bytes
align 64
[core 1] module_adapter.module_prepare: comp:0 0x1013 error -12:
module specific prepare failed

Make vregion_set_interim() only mark the switch, and create the interim heap on the next allocation, as the comments already describe. The allocations after the switch are made on the module's own core, so the heap metadata is only accessed on that core.

Fixes: 10c8e6b ("lib: vregion: lazy interim heap creation from remaining lifetime space")

vregion_set_interim() is called from pipeline_complete() on the
pipeline core, also for the vregions of DP modules on other cores.
It created the interim k_heap right away, so the heap metadata was
written to cached memory on the pipeline core. The first interim
allocation on the module's own core then read stale metadata and
failed, although the heap was empty:

  [core 0] vregion.interim_heap_init: creating interim heap: lifetime
           used 6784, interim available 13696 at 0xa0212a80
  [core 1] src_prepare: comp:0 0x1013 entry
  [core 1] vregion.interim_alloc: interim alloc failed for 80 bytes
           align 64
  [core 1] module_adapter.module_prepare: comp:0 0x1013 error -12:
           module specific prepare failed

Make vregion_set_interim() only mark the switch, and create the
interim heap on the next allocation, as the comments already
describe. The allocations after the switch are made on the module's
own core, so the heap metadata is only accessed on that core.

Fixes: 10c8e6b ("lib: vregion: lazy interim heap creation from remaining lifetime space")
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.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

Existing single-core vregion tests cannot validate the cache-dependent fix; affected multicore hardware is needed to reproduce the cross-core DP prepare failure and confirm heap metadata stays on the allocating core.

No open issues 🎉

What changed in this PR

This PR defers vregion interim heap creation to the first allocation on the module’s core, avoiding stale cached heap metadata when the pipeline and module run on different cores.

Changes:

  • Adds a pending flag so vregion_set_interim() marks the transition without creating the heap.
  • Initializes the interim heap under the existing lock on the next allocation.
File Description
zephyr/​lib/​vregion.c Tracks the pending transition and moves interim heap initialization to the allocating core.

Review effort: Balanced

@intel-sofci

Copy link
Copy Markdown

PR 11552: test results

Run date: 2026-11-27 16:45 UTC

Tested commit: f69675fc028eac6db094de155a77e82bdcf52b18

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

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.

4 participants