Skip to content

platform: remove macro copies that only other platforms use - #11537

Merged
lgirdwood merged 5 commits into
thesofproject:mainfrom
lgirdwood:topic/platform-headers-5
Nov 25, 2026
Merged

lgirdwood merged 5 commits into
thesofproject:mainfrom
lgirdwood:topic/platform-headers-5

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Remove the platform macro copies that only other platforms' code uses (about 140 definitions, 280 lines), and fix the i.MX93 clk.h include guard. This is the fifth part of the platform header cleanup in #11517 step 1, after #11528, #11529, #11532 and #11534.

The earlier parts removed macros whose names nothing uses. This part looks at each platform on its own. A definition is dead if nothing that can be built with that platform's headers uses it, even if another platform's code uses the same name. For example, the PLATFORM_HEAP_* counts are defined in 15 platforms, but only the host allocator reads them, and it uses the host library platform.

Patches

  1. platform: remove the heap counts from the firmware platforms. PLATFORM_HEAP_* size the heap arrays of the host allocator in posix/include/sof/lib/mm_heap.h. Removed from the 10 firmware platform headers; the host library platform keeps them.
  2. platform: remove macros that only other platforms use.
    • PLATFORM_DEFAULT_CLOCK on the ACE platforms: only the host build and the AMD drivers read it.
    • cache_to_uncache_init().
    • CLK_DEFAULT_CPU_HZ on i.MX.
    • The cAVS/ACE MAILBOX_TRACE_* aliases. The trace window itself stays in the mailbox layout.
  3. platform: remove the rest of the XTOS memory layouts.
    • Tiger Lake: the system, shared and LP heaps, and the LP SRAM vectors.
    • i.MX: the DRAM/SDRAM banks and the XTOS heap/stack leftovers.
    • The runtime heap sizes that zephyr/lib/alloc.c reads stay.
  4. platform: library: remove unused clock and DMA macros. The host build does not build the clock code or the DMA domain schedulers.
  5. platform: imx93_a55: fix the clk.h include guard. It checked __PLATFORM_LIB_CLK_H__ but defined __PLATFORM_LIB_CLK_H___.

How the definitions were found

A definition counts as used if its name appears anywhere in code that can be built with that platform's headers, in any #if branch and under any Kconfig. That code is:

  • For a firmware platform: all generic SOF code, the Zephyr glue, and the platform's own platform and vendor driver directories.
  • For the host library platform: generic SOF code and the host-only code.

Building only some configurations is not enough. For example, host_to_local() looks unused on Tiger Lake, where the builds are IPC4, but IPC3 code still uses it, so it is kept.

AMD and MediaTek are not changed. Those builds fail on main, so the results cannot be checked by building. As in #11532, _BASE/_SIZE and _START/_END partners of used macros, isolated entries in enumerations, mailbox windows with a used member, and the explicit qemu_xtensa mailbox map are kept.

Not in this part

The remaining duplicates are still used: HOST_PAGE_SIZE (4096 on 15 platforms), the identity host_to_local()/local_to_host(), and the per-platform mailbox layouts. Merging them into shared defaults would change how each platform states its host-visible layout, so that needs its own discussion.

Functional change

None.

Testing

Run on 276f0aa (current main), at every commit and at the tip.

  • Firmware, every commit, incremental builds of 37 configurations:

    • tgl, tgl-h, mtl, lnl, ptl, wcl, nvl, nvl-s;
    • the internal CI configuration of tgl, mtl, lnl and ptl;
    • imx8, imx8x, imx8m, imx8m_cm7, imx8ulp, imx93, imx95;
    • qemu_xtensa, qemu_xtensa_mmu, native_sim;
    • PTL with the userspace overlay and with LL userspace, PTL and MTL with llext_relocatable.conf, PTL and TGL with debug_stream_overlay.conf;
    • the legacy acp_6_0, acp_7_0, acp_7_x, MediaTek and phyboard_pollux builds.

    Each commit builds the same configurations as main (the legacy ones fail with unchanged error sets). Objects, LLEXT modules and images were hashed with the debug sections stripped. The only differences are the objects that embed the source hash or git version, and the LLEXT modules that the incremental builds relink.

  • Firmware, tip: a pristine build of the same matrix, compared with a pristine build of main. The SOF header dependencies (ninja -t deps) and the legacy error sets are unchanged, and all LLEXT modules are identical. The only differing objects are the version-bearing ones: init.c, ext_manifest.c, each platform.c and the final images.

  • Host, every commit: the host library and the cmocka unit test builds (unit_test, imx8, mtk defconfigs) pass. With the debug sections stripped, all 1,291 objects are identical to main at every commit.

  • Testbench and tools (SOF CI docker image): pass, and all 260 objects are identical to main with the debug sections stripped.

  • Cadence xt-clang (RI-2022.10): MTL, PTL and NVL compile.

  • native_sim IPC3/IPC4 stub builds: pass.

  • ZTest: 23 of 23 pass, run as in CI.

  • check_kernel_includes.py --sources --strict: passes.

  • Documentation: builds with no warnings at every commit.

🤖 Generated with Claude Code

lrgirdwo and others added 5 commits November 25, 2026 13:08
The PLATFORM_HEAP_* counts size the heap arrays of the host allocator in
posix/include/sof/lib/mm_heap.h, which only the host builds use, with
the library platform. The Zephyr allocator does not read them, so the
copies in the firmware platform headers are never used. Remove them.

No functional change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Some platform macros are only used by code that is never built for
the platforms that define them:
- PLATFORM_DEFAULT_CLOCK on the ACE platforms: only the host build and
  the AMD drivers read it;
- cache_to_uncache_init(): nothing uses it any more;
- CLK_DEFAULT_CPU_HZ on i.MX;
- the MAILBOX_TRACE_BASE and MAILBOX_TRACE_SIZE aliases on cAVS and
  ACE. The trace window itself stays in the mailbox layout.

Remove them.

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 Tiger Lake and i.MX memory.h headers still describe parts of the
XTOS memory layout that the Zephyr builds do not use:
- Tiger Lake: the system, shared and LP heaps, the LP SRAM vectors
  and code, SOF_FW_BASE and SOF_STACK_TOTAL_SIZE;
- i.MX: the DRAM and SDRAM banks, HEAP_SYSTEM_0_BASE,
  HEAP_BUFFER_BLOCK_SIZE and SOF_STACK_END.

The runtime heap sizes that zephyr/lib/alloc.c reads stay, and so do
the bases next to sizes that are still used. Remove the rest.

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 host build does not build the clock code or the DMA domain
schedulers, so the host library clock frequency table, default clock
and DMA controller macros are never used. Remove them.

No functional change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
clk.h checks __PLATFORM_LIB_CLK_H__ but defines __PLATFORM_LIB_CLK_H___,
with an extra underscore, so the guard never stops a second inclusion.
Define the name it checks.

No functional change: the header only has macros that expand the same
way each time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
@intel-sofci

Copy link
Copy Markdown

PR 11537: test results

Run date: 2026-11-25 14:30 UTC

Tested commit: 72788dba1921ecd6f731b847fbd916a68baa9e28

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

@lgirdwood

Copy link
Copy Markdown
Member Author

Dead code removal: CI unrelated.

@lgirdwood
lgirdwood merged commit 2d5cac2 into thesofproject:main Nov 25, 2026
45 of 47 checks passed
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.

3 participants