Repository navigation
Conversation
|
@harajend fyi - pls let me know if this helps. |
There was a problem hiding this comment.
🟡 Changes recommended
Region boundary handling still has edge-case bugs, and the new regression test does not detect the original leak.
3 open findings
What changed in this PR
Fixes vpage sizing and allocation tracking, including NVL-S support.
Changes:
- Prevents virtual-region size underflow.
- Cleans up partially mapped pages and fixes out-of-order frees.
- Adds an out-of-order free boot test.
| File | Description |
|---|---|
zephyr/lib/vpage.c |
Updates region sizing, cleanup, and allocation tracking. |
zephyr/test/vpage.c |
Adds an out-of-order free regression test. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
vpage_init() computed the vpage region size as an unsigned subtraction without checking that the image, virtual heap and library regions leave any L2 for vpages. On platforms with a small L2 (NVL-S: 2MB, with the default 0x140000 virtual heap and 0x100000 library region) this underflows into a ~4GB region whose end wraps the 32-bit address space. sys_mm_drv_map_region_safe() then rejects every mapping with -EINVAL, so every vpage_alloc() fails and vregion creation falls back to the heap. Check that the reserved areas fit before adding the region. If not, log an error and leave vpages disabled; vpage_alloc()/vpage_free() now fail cleanly with -ENODEV instead of dereferencing a missing region. Also fix vpages_free_and_unmap() moving velems[num_elems_in_use], which is one past the last in-use element, over the released slot. Freeing a non-last allocation left the last element outside the in-use count, so the next allocation overwrote its tracking entry and that allocation could never be freed, leaking its virtual and physical pages. Decrement the count first so the real last element is moved. Add a boot test that frees allocations out of order. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The vpage region assumed that the virtual heap and library regions are carved out of physical L2 in addition to the image. On NVL-S (2MB L2) they do not fit, so vpages were unavailable. Those regions are only virtual address space backed on demand, so they don't need to fit in L2. When they do not fit, place the vpage region right after the virtual heap and end it at the library base address (or the end of virtual memory), capped by the physical L2 left after the image. For the NVL-S CI layout this gives a 294 page region at 0xa023a000. Layouts where everything fits in L2 are unchanged. Also release pages already mapped by a failed multi-page map. The mm driver maps page by page and leaves earlier pages and their physical pages mapped on failure, which leaked physical L2 when it ran out. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
6115723 to
b6f127a
Compare
PR 11303: test resultsRun date: 2026-10-14 07:36 UTC Tested commit: b6f127a467cf69bff8316170c8910770bd21d50c |
Tested commit This issue is not fixed. All playback/capture tests still fail on both Detailed analysis:CI failure: DSP firmware crash on NVL-S (regression vs. previously-reported bug)Tested commit Result: All playback/capture-dependent test cases fail on both boards with an Identical PC/backtrace/address on both boards → deterministic firmware bug, not This looks like a regression against a previously-filed bug, not a fixWe have an existing internal bug report ( In that prior report, the failure was graceful: With this PR, the same Hypothesis: this PR enables actually mapping/using the vpage region Suggested next stepPlease check the map-then-use ordering / error handling around |



Fixes the NVL-S
vpage_alloc failed -22 ... total 1048294 free 1048294seen in the daily-nvl-s CI run.Root cause
vpage_init()computed the region size as an unsigned subtractionL2_end - (unused_start + virtual_heap + library). On NVL-S (2MB L2, default 0x140000 heap + 0x100000 library) that underflows by 0x11a000 into a 0xFFEE6000 byte (1048294 page) region whose end wraps the 32-bit address space.sys_mm_drv_map_region_safe()then failsvirt + size <= region_endfor every address, so everyvpage_alloc()returns -EINVAL andvregionfalls back to the heap. It is not a leak: the first page (0xa023a000) is always chosen because nothing is ever allocated.Changes
CONFIG_LIBRARY_BASE_ADDRESS(or end of virtual memory), capped by the physical L2 left after the image. Layouts that fit in L2 are unchanged.vpages_free_and_unmap()movingvelems[num_elems_in_use](one past the last element) over the released slot. Freeing a non-last allocation orphaned the last element; the next alloc overwrote its tracking entry and it could never be freed (leaked virtual + physical pages).vpage_free_out_of_orderboot test.Testing
intel_adsp/ace40/nvls(xt-clang, full link) and the vpage object for nvl and ptl.vpage: region ...log line, the boot test, andcheck-playback-all-formats.Draft until tested on NVL-S.
🤖 Generated with Claude Code