Re: [PATCH] ALSA: hda: give the NHLT parser a module of its own

From: Takashi Iwai

Date: Thu Dec 03 2026 - 06:40:20 EST


On Wed, 02 Dec 2026 15:07:33 +0100,
Jude Gyimah wrote:
>
> snd-sof calls the NHLT parser from generic code, and with a non-Intel SOF
> platform built in and the Intel option modular the link fails:
>
> ipc4-topology.c:(.text+0x22bc): undefined reference to
> `intel_nhlt_get_endpoint_blob'
> ipc4-topology.c:(.text+0x2424): undefined reference to
> `intel_nhlt_ssp_device_type'
>
> SND_SOC_SOF_IMX_COMMON=y selects SND_SOC_SOF, while
> SND_SOC_SOF_INTEL_COMMON=m leaves SND_INTEL_DSP_CONFIG=m.
>
> There is no symbol to depend on to prevent that. intel-nhlt.o is built
> into snd-intel-dspcfg, and SND_INTEL_NHLT is a bool that only decides
> whether the object joins that module, so the parser's level is really
> decided by SND_INTEL_DSP_CONFIG, which is about Intel DSP driver
> detection and gets selected by SND_HDA_INTEL for unrelated reasons.
>
> Moving the calls into Intel code, as commit 194fe0fc3422 ("ASoC: SOF:
> pci: move DSP_CONFIG use to platform-specific drivers") did for
> snd_intel_dsp_driver_probe, would not be enough: ipc4-topology.c fills
> ipc4_data->nhlt from the topology manifest when the BIOS has none, so
> generic SOF can hold a table with no Intel code involved and has to be
> able to parse it.
>
> Make the parser selectable instead. SND_INTEL_NHLT becomes a tristate
> with its own module, and whoever parses an NHLT table selects it; a
> select from a built-in symbol forces the target built in, so the
> mismatch stops being expressible. SND_INTEL_SOUNDWIRE_ACPI beside it is
> already arranged this way.
>
> Kconfig and Makefile change together because neither is right alone:
> either order leaves SND_INTEL_NHLT=y with SND_INTEL_DSP_CONFIG=n, where
> the object is not built but the header still declares the functions.
>
> IS_REACHABLE() would be worse than the link error. With the guard false
> the #else stub of snd_sof_get_nhlt_endpoint_data() returns 0 without
> setting *dst or *len, and the caller reads 0 as success, so SSP and DMIC
> copiers would be prepared with no NHLT payload at all. Selecting the
> parser keeps the real implementation: ipc4-topology.o still references
> intel_nhlt_get_endpoint_blob in the configuration above.
>
> Tested on arm64 at v7.3. That configuration links with no undefined
> references and no Kconfig warning, SND_INTEL_NHLT following SND_SOC_SOF
> to y while SND_INTEL_DSP_CONFIG stays m. allnoconfig, defconfig,
> allmodconfig and allyesconfig are warning-free and snd-intel-nhlt builds
> as a module.
>
> Found with kreach, a static check that compares what Kconfig allows
> against the symbols the compiled objects actually reference.
>
> Fixes: aa84ffb72158 ("ASoC: SOF: ipc4-topology: Add support for SSP/DMIC DAI's")
> Link: https://lore.kernel.org/r/20261107114944.561731-1-jude.gyimah87@xxxxxxxxx
> Signed-off-by: Jude Gyimah <jude.gyimah87@xxxxxxxxx>

Applied to for-next branch. Thanks.


Takashi