Repository navigation
Conversation
sof/lib/dma.h uses neither the register access helpers of sof/lib/io.h nor the platform memory map, but it brings both into the user-space host, DAI, copier, chain DMA, ASRC and pipeline sources that use the DMA API. Drop the includes. Three kernel sources got them through this header, so they include what they use: zephyr/wrapper.c the register helpers and the memory map, which it included as platform/lib/memory.h instead of through sof/lib/memory.h, zephyr/lib/cpu.c and ipc3/host-page-table.c the memory map. So does dma-legacy.h, which sof/lib/dma.h includes for the builds without the Zephyr native drivers: it uses the register helpers. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
rtos/timer.h uses nothing from sof/platform.h, which brings the platform definitions and clock headers into every user-space source that reads the cycle counter or the stream timestamps. Drop the include. base_fw_intel.c, zephyr/lib/alloc.c and zephyr/lib/cpu.c used HOST_PAGE_SIZE and platform_boot_complete() through this header, so they include sof/platform.h. dai-zephyr.c got the memory map through this header too, and it uses local_to_host() from it. It defines local_to_host() as a no-op if the platform doesn't, so without the include the code still built but lost the imx8ulp address translation. Include sof/lib/memory.h there. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
domain_init() only uses clock_ms_to_ticks() from rtos/clk.h in the builds without Zephyr. The Zephyr builds compute the ticks with k_ms_to_cyc_ceil64(), but still include the clock header, and with it the platform clock headers, into the user-space scheduler and IPC sources. Only include it when not building for Zephyr. The native_sim platform code used the clock definitions through this header, so it includes rtos/clk.h. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The sof_dma_*() system calls in sof/lib/sof_dma.h take Zephyr's struct dma_config and struct dma_status, and their callers use the Zephyr DMA constants, so user-space code needs zephyr/drivers/dma.h. The header has no system calls itself, and Zephyr's own header cannot be split. Remove it from the kernel-only headers, with a note that user-space code must not call its dma_*() driver functions directly, which the include check cannot catch. None does today: the user-space DMA code only uses the sof_dma_*() calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Ten sources no longer include kernel-only headers in any configuration: the ASRC, chain DMA, copier DAI and gain, UAOL, DMA and DAI library sources, the user-space IPC code and the DP scheduler thread and application code. Remove them from the leak baseline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Platform headers are kernel headers, in src/kernel/platform, but some of them define what user-space code needs, such as the mailbox window layout. Those parts move to src/platform, with the same layout and include names, so that the platform include directories in src/kernel/platform can become kernel-only. Add the platform's directory in src/platform to the include path. No platform has one yet. It is added even when it does not exist, so that existing build directories find it once it does, without running CMake again. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The mailbox window addresses and software register accessors are used by user-space code through sof/lib/mailbox.h: the software register page and the host box are mapped into the user-space LL and IPC threads. But they come from the platform mailbox headers, which use the window layout in the platform memory map, so every user of the mailbox gets the whole memory map. For the ACE platforms (MTL, LNL, PTL/WCL and NVL), move the shared ace/lib/mailbox.h and the platform mailbox headers to src/platform, and move the window layout out of each memory map into a new platform/lib/mailbox_layout.h there. The memory maps include it, and ace/lib/mailbox.h includes it, and rtos/cache.h for its accessors, instead of the memory map. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
As for the ACE platforms, move the shared cavs/lib/mailbox.h and the TGL mailbox header to src/platform, and move the window layout out of the TGL memory map into platform/lib/mailbox_layout.h there, with the HP SRAM base address that the windows are at. The memory map includes it, and cavs/lib/mailbox.h includes it, and rtos/cache.h for its accessors, instead of the memory map. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Move the i.MX mailbox headers to src/platform. On imx8, imx8m and imx8ulp they used the window layout of the memory map: move it to platform/lib/mailbox_layout.h there, with the SDRAM1 base address that the mailbox is at, and include it from the memory map and the mailbox header instead of the memory map. The imx8m_cm7, imx93 and imx95 mailbox headers define the windows themselves. Add src/platform/imx8 to the imx8 code owner entry. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Move the qemu_xtensa mailbox header, which defines its windows and stubs out the software registers, to src/platform. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Move the mailbox headers of the native_sim (posix) and host library platforms to src/platform, and move the mailbox window definitions out of their memory maps into platform/lib/mailbox_layout.h there. Add the new directories where the host builds, the testbench, the topology parser and the ZTest unit tests add the platform include directories. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The platform mailbox headers now include what they need, the window layout, so sof/lib/mailbox.h no longer needs the platform memory map. Drop the include, which brought the memory map into every user-space source that uses the mailbox. base_fw.c got HOST_PAGE_SIZE through it on qemu_xtensa, so it includes the memory map. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The mailbox windows that user-space code uses, the software registers and the host box or the stream window, are mapped into the user-space LL and IPC threads, and sof/lib/mailbox.h no longer includes any kernel-only header. Remove it from the kernel-only headers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add a README for src/platform, which holds the platform headers that user-space code may include, and point to it from the kernel platform README, which no longer has the mailbox. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Seven sources that only used the mailbox no longer include kernel-only headers in any configuration: the copier host and IPC gateway code, the data blob helpers, the host component, the IPC4 module adapter and the volume component. Remove them from the leak baseline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Collaborator
|
@lgirdwood part 3 merged, ready for this one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 4 of #11306 (kernel / user-space partition), fourth part: move the mailbox headers that user-space code uses out of the kernel platform directories into a new
src/platform, and shrink the leak baseline from 29 to 22 sources.Based on #11470. Only the last ten commits are new.
Why
User-space code uses the mailbox through
sof/lib/mailbox.h, and that use is intended:user_access_to_mailbox()maps exactly these windows into the user-space LL and IPC threads.But the window addresses come from the platform mailbox headers, which build on the window layout in the platform memory map. They live in
src/kernel/platform/<platform>/include, the include directories that Phase 4 is to make kernel-only. So every user of the mailbox got the platform memory map, and the platform include directories could not become kernel-only.What changes
src/platformdirectory. It holds the platform headers that user-space code may include, with the same layout and include names assrc/kernel/platform, and it is on the include path next to it.platform/lib/mailbox_layout.hinsrc/platform. The memory map includes it.HP_SRAM_BASEon TGL andSDRAM1_BASEon i.MX.src/platformas they are:platform/lib/mailbox.h, and the shared Intelace/lib/mailbox.handcavs/lib/mailbox.h. They include the layout instead of the memory map.sof/lib/mailbox.hno longer includes the memory map, and the checker no longer treats it as kernel-only.This covers Intel (TGL, MTL, LNL, PTL/WCL, NVL), i.MX (imx8, imx8x, imx8m, imx8m_cm7, imx8ulp, imx93, imx95), qemu_xtensa, native_sim (posix) and the host library. The AMD and MediaTek mailbox headers stay in
src/kernel/platformfor now: these platforms do not build on main and are waiting for the native drivers in Phase 0.In the CI configurations, the platform memory map now only reaches 4 user-space sources (16 before), and seven sources that only used the mailbox leave the baseline.
Patches
zephyr: add the platform'ssrc/platformdirectory to the include path. It is added even if it does not exist yet, so that existing build directories pick it up when it appears, without running CMake again.platform: intel: ace: moveace/lib/mailbox.hand the MTL, LNL, PTL/WCL and NVL mailbox headers, and split their window layouts out of the memory maps.platform: intel: cavs: the same forcavs/lib/mailbox.hand TGL.platform: imx: the same for the i.MX platforms. imx8m_cm7, imx93 and imx95 define their windows in the mailbox header, so these only move.src/platform/imx8gets the imx8 code owner.platform: qemu_xtensa: move the mailbox header.platform: posix, library: the same for native_sim and the host library. The new directories are added where the host builds, the testbench, the topology parser and the ZTest unit tests add the platform include directories.lib: mailbox: drop the memory map fromsof/lib/mailbox.h.base_fw.cusedHOST_PAGE_SIZEthrough it on qemu_xtensa and now includes the memory map.scripts: kernel_user_partition: allowsof/lib/mailbox.h.src/platform; the kernel platform README no longer lists the mailbox.The window layout headers are moved code: each one has its platform's block from the memory map, unchanged.
What is left
The 22 remaining sources use kernel APIs:
rtos/timer.h(11 sources).irq_local_disable()/irq_local_enable()(7 sources).perf_cnt.h,agent.h,cpu-clk-manager.h,watchdog.handpm_runtime.h.The mailbox is the first content of
src/platform. Making thesrc/kernel/platforminclude directories kernel-only also needs the rest of what user-space code takes from them to move, or be replaced.Functional change
None.
Testing
--strict, it passes for each of the 12 CI build configurations, built locally as CI does (repro-build.conf,-Werror), and for every other configuration below. Across all of them, exactly the 22 baseline sources leak.CONFIG_SOF_USERSPACE_PROXY=n;os_linux_overlay.conf;llext_relocatable.conf;app/debug_stream_overlay.conf, and PTL with that overlay and user-space LL.SYS_INIT()order), and the per-function disassembly. No object changes at any commit. In the images, only two functions differ:sof_init()on imx8m_cm7, imx93 and imx95, which embeds the git hash, and, in thelib: mailboxcommit, one assertion line number in qemu_xtensa'shost_common_update(), which has assertions enabled. Dropping the include line moves theassert()insof/lib/mailbox.hup by one.All of the above was run on #11470, on 607d0a9 (current main).
🤖 Generated with Claude Code