Skip to content

platform: remove unused platform macros and inline functions - #11532

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

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

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Remove the macros, inline functions and prototypes in the platform headers that nothing uses: about 535 macro definitions and 15 functions, 1,206 lines. This is the third part of the platform header cleanup in #11517 step 1, after #11528 and #11529.

Patches

  1. platform: remove unused macros from the platform headers.
    • The DMA_TRACE_*/DMA_FLUSH_TRACE_SIZE settings, unused since 47a032c.
    • PLATFORM_SCHEDULE_IRQ(_NAME) and PLATFORM_IPC_INTERRUPT_NAME.
    • PLATFORM_DEFAULT_DELAY, and a few platform-specific leftovers.
  2. platform: remove the XTOS memory layout macros.
    • The IRAM, vector, reset and literal sizes, and the UUID/log/extended manifest ELF sections, which only the XTOS linker scripts used (removed in f6add88).
    • The Tiger Lake XTOS boot loader layout.
    • The XTOS heap allocator settings and the unused EDF task stack size.
  3. platform: intel: remove the unused cAVS register definitions. The XTOS-era register map in the Tiger Lake memory.h (shim, GPDMA, gateways, DMIC, SSP, ALH, ROM, L1 cache control, ...), which Zephyr's intel_adsp owns, and the unused sideband IPC fields.
  4. platform: imx: remove unused peripheral base addresses. EDMA, SDMA, ESAI, SAI and MICFIL, which the Zephyr NXP drivers take from the devicetree.
  5. platform: amd: remove unused macros.
    • The IRQ masks and XTSTR().
    • Unused FIFO offsets and the ACP 7.x DAI DMA bases.
    • The SoundWire channel/DAI index values.
    • MP1_APERTURE_ID.
  6. platform: library, posix: remove unused host platform macros. These were copied from the Intel platforms and never used by the host builds.
  7. platform: remove unused inline functions and prototypes.
    • platform_panic(), plus the two status offsets only it used.
    • platform_rfree_prepare().
    • mailbox_sw_reg_write64().
    • The host arch_get_stack_*() and IDC stubs.
    • acp_dsp_sw_intr_disable().
  8. platform: library: remove the PM runtime stubs. The host platform/lib/pm_runtime.h only had empty platform_pm_runtime_*() stubs that nothing calls.

What was kept on purpose

The candidates came from a static scan of the whole repository, which also follows macros that are only used by other unused macros. A #ifndef X fallback in another file counts as a use of X. Not removed:

  • Isolated entries in hardware register and field lists whose neighbours are still used: AMD chip_offset_byte.h and platform_misc.h, and the DMA_ID_* lists. Removing single entries there makes the register documentation patchy without simplifying anything. These headers go with the native-driver moves in [FEATURE] Remove the remaining XTOS-era code and move SOF to native Zephyr APIs and drivers #11517.
  • The _SIZE/_BASE partner of a macro that is still used, for example MAILBOX_TRACE_BASE next to MAILBOX_TRACE_SIZE.
  • The i.MX drivers/interrupt.h headers. On Zephyr only the AMD legacy interrupt path includes this header name, so the next part removes the i.MX copies as whole files.
  • The vendor-generated Xtensa core-isa.h/specreg.h copies, and the MediaTek window sizes, which are built by token pasting.
  • posix_dai_init() in src/kernel/platform/posix/dai.c: it has no caller, but it is the only user of that file's DAI tables, so removing it means removing the legacy posix DAI file. That is a separate change.

Functional change

None.

Testing

Run on 4c0f7b5 (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 (internal_ci_overlay.conf) 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, because removing header lines only shifts line numbers in the debug info. The only differing objects are the ones that embed the source hash or git version (init.c, ext_manifest.c, each platform.c, the final images), plus the acp_6_0 interrupt.c from patch 7, which removes acp_dsp_sw_intr_disable().

  • Firmware, tip: a pristine build of the same matrix. Same result: only the version-bearing objects differ, all LLEXT modules are identical, the SOF header dependencies (ninja -t deps) are unchanged, and the legacy error sets are unchanged.

  • 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.

  • 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 8 commits November 24, 2026 13:50
Nothing uses these platform.h macros any more:
- the DMA trace settings DMA_TRACE_LOCAL_SIZE, DMA_FLUSH_TRACE_SIZE,
  DMA_TRACE_PERIOD and DMA_TRACE_RESCHEDULE_TIME, since commit
  47a032c ("trace: remove the SOF DMA trace");
- PLATFORM_SCHEDULE_IRQ, PLATFORM_SCHEDULE_IRQ_NAME and
  PLATFORM_IPC_INTERRUPT_NAME, which the XTOS scheduler and interrupt
  code used;
- PLATFORM_DEFAULT_DELAY, since the delays use k_busy_wait();
- LPSRAM_SIZE on i.MX, PLATFORM_IPC_DMA_TIMEOUT in the host library and
  PLATFORM_CORE_COUNT on qemu_xtensa.

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>
These memory.h macros described the XTOS firmware image and heap
layout:
- the IRAM, vector, reset and literal sizes (IRAM_*, SOF_MEM_*,
  SOF_DYNAMIC_VECTORS_SIZE, ROM_RESET_*) and the UUID, log and extended
  manifest ELF sections (*_ENTRY_ELF_*, EXT_MANIFEST_ELF_*), which the
  XTOS linker scripts used until commit f6add88 ("platform: remove
  the XTOS linker scripts");
- the Tiger Lake XTOS boot loader layout (IMR_BOOT_LDR_* except the
  manifest base, BOOT_LDR_STACK_*), the LP SRAM stack (SOF_LP_STACK_*),
  SOF_FW_MAX_SIZE and SOF_TEXT_BASE;
- the XTOS heap allocator settings: HEAP_BUF_ALIGNMENT,
  HEAP_BUFFER_COUNT, HEAP_HP_BUFFER_BLOCK_SIZE/COUNT, the host library
  LP heaps (HEAP_RT_LP_*, HEAP_LP_SYSTEM_*, HEAP_LP_RUNTIME_*,
  SOF_LP_DATA_SIZE) and SOF_CORE_S_T_SIZE;
- the EDF task stack size PLATFORM_TASK_DEFAULT_STACK_SIZE, which no
  scheduler reads, and ARCH_OOPS_SIZE.

Zephyr lays out the image and the heaps, so nothing uses them. 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 memory.h still has the XTOS-era register map: the shim,
DMIC shim, codec command, resource, intra-DSP IPC, host window, IRQ
controller, time stamping, M/N divider, GPDMA, link and host gateway,
code loader, L2 TLB, DMIC, SSP, ALH, ROM and L1 cache control blocks,
and the HP SRAM window bases. The Zephyr intel_adsp SoC and drivers
own all of these, and SOF does not use any of them. Remove them, and
the sideband IPC register fields other than the DIPCIDR ones that the
firmware still uses.

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 i.MX memory.h headers still have the base addresses and sizes of
the EDMA, SDMA, ESAI, SAI and MICFIL blocks. The Zephyr NXP drivers
take these from the devicetree, and SOF does not use them. 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>
Nothing uses these AMD platform macros:
- the IRQ_MASK_* values and the XTSTR() helper in drivers/interrupt.h;
- the SoundWire, BT and HS FIFO offsets that are not used by the DMA
  drivers, and on ACP 7.x the DAI DMA register bases;
- the SoundWire channel and DAI index values in lib/dai.h;
- MP1_APERTURE_ID in lib/clk.h.

Remove them. The register maps in chip_offset_byte.h and
platform_misc.h are left complete.

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 library and posix platforms copied macros from the Intel
platforms that the host builds never use: all the interrupt numbers and
masks (only the AMD interrupt driver uses IRQ_NUM_SOFTWARE0 and
IRQ_NUM_TIMER1, from its own platform header), the DAI_NUM_* link counts
and SSP_DEFAULT_IDX. 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>
Nothing calls these platform functions:
- platform_panic(): the Zephyr panic path does not call a platform hook.
  With it go ACP_SOF_FW_STATUS and SRAM_REG_FW_STATUS, which only it
  used;
- platform_rfree_prepare(), an XTOS allocator hook;
- mailbox_sw_reg_write64();
- arch_get_stack_entry() and arch_get_stack_size() in the host library;
- the IDC idc_process_msg_queue() and idc_restore() stubs in the host
  library;
- acp_dsp_sw_intr_disable() in the Rembrandt interrupt driver, and its
  declarations.

Remove them, and the i.MX8 and i.MX8M comment for the
platform_shared_commit() that was already removed.

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 library platform/lib/pm_runtime.h only has empty
platform_pm_runtime_*() stubs, and nothing calls them: the host
pm_runtime_*() functions do not call into the platform. Remove the
header and its include in posix/include/sof/lib/pm_runtime.h, which
now includes <stdbool.h> itself for bool.

No functional change.

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

intel-sofci commented Nov 24, 2026 •

Copy link
Copy Markdown

PR 11532: test results

Run date: 2026-11-25 13:20 UTC

Tested commit: d5e8feaf1c27ba7876019db7a3e54f2c945c8b78

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

@lgirdwood

Copy link
Copy Markdown
Member Author

CI unrelated as we are not building xtos anymore.

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