ASoC: SOF: ipc4-topology: fix link failure with SND_INTEL_DSP_CONFIG=m
Subsystems (3)
PATCH 1/1 ASoC: SOF: ipc4-topology: fix link failure with SND_INTEL_DSP_CONFIG=m
Hi everyone,
Just to bring this to your attention.
snd-sof can be built into vmlinux while the Intel NHLT code that ipc4-topology.c calls is in a module, and then 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'
This happens with a non-Intel SOF platform built in and the Intel option modular, for example SND_SOC_SOF_IMX_COMMON=y selecting SND_SOC_SOF while SND_SOC_SOF_INTEL_COMMON=m selects SND_INTEL_DSP_CONFIG=m.
The existing guard cannot prevent it. intel-nhlt.o is shipped by SND_INTEL_DSP_CONFIG, but the guard tests SND_INTEL_NHLT, a bool that SND_INTEL_DSP_CONFIG selects "if ACPI", and a select from an m-valued symbol sets a bool to y. So SND_INTEL_NHLT is y whenever the provider is y or m, and the condition can only tell "NHLT present somewhere" from "absent", never built-in from modular. The static inline fallbacks in include/sound/intel-nhlt.h are keyed on the same condition and are therefore unreachable too.
Test reachability of the option that actually ships the code instead. No header change is needed: the file already stubs snd_sof_get_nhlt_endpoint_data() in its own #else branch, and wherever IS_REACHABLE is true with ACPI=y, SND_INTEL_NHLT is y as well, so the real declarations are in scope.
This is the same remedy as commit 8a3fea95fab1 ("ASoC: SOF:SND_INTEL_DSP_CONFIG dependency") applied for snd_intel_dsp_driver_probe in sof-pci-dev.c, which commit 194fe0fc3422 ("ASoC: SOF: pci: move DSP_CONFIG use to platform-specific drivers") later resolved by moving that call to Intel-specific code. Moving these calls likewise would be the complete fix so this is the one-line one.
Found with kreach, a static check that compares what Kconfig allows against the symbols the compiled objects actually reference.
--- sound/soc/sof/ipc4-topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/ipc4-topology.c +1 -1
@@ -1790,7 +1790,7 @@ static void sof_ipc4_unprepare_copier_module(struct snd_sof_widget *swidget) } } -#if IS_ENABLED (CONFIG_ACPI ) &&IS_ENABLED (CONFIG_SND_INTEL_NHLT ) +#if IS_ENABLED (CONFIG_ACPI ) &&IS_REACHABLE (CONFIG_SND_INTEL_DSP_CONFIG )static int snd_sof_get_hw_config_params (struct snd_sof_dev *sdev,struct snd_sof_dai *dai,int *sample_rate,int *channel_count,int *bit_depth) {
Signature · 1 line
2.43.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] ASoC: SOF: IS_REACHABLE() stubs out snd_sof_get_nhlt_endpoint_data() for modular Intel IPC4…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] ASoC: SOF: IS_REACHABLE() stubs out snd_sof_get_nhlt_endpoint_data() for modular Intel IPC4
- [Low] ASoC: SOF: conversational email greeting in commit changelog --
commit 92afe44aeb8258bf82f3d1cf70150bb75c4ca99c
Author: Jude Gyimah <[email protected]>
ASoC: SOF: ipc4-topology: fix link failure with SND_INTEL_DSP_CONFIG=m
This commit changes the preprocessor guard in ipc4-topology.c from IS_ENABLED(CONFIG_SND_INTEL_NHLT) to IS_REACHABLE(CONFIG_SND_INTEL_DSP_CONFIG) to avoid a link failure when snd-sof is built-in and snd-intel-dspcfg is modular.
Quoted 3 lines
Hi everyone,
Just to bring this to your attention.
[Severity: Low]
This isn't a bug, but this conversational email greeting belongs below the "---" separator rather than in the permanent git changelog.
sound/soc/sof/ipc4-topology.c static void sof_ipc4_unprepare_copier_module(struct snd_sof_widget *swidget) · line 1799
Quoted 13 lines
sound/soc/sof/ipc4-topology.c +1
-1@@ -1793,7 +1793,7 @@ static void sof_ipc4_unprepare_copier_module(struct snd_sof_widget *swidget) } } -#if IS_ENABLED (CONFIG_ACPI ) &&IS_ENABLED (CONFIG_SND_INTEL_NHLT ) +#if IS_ENABLED (CONFIG_ACPI ) &&IS_REACHABLE (CONFIG_SND_INTEL_DSP_CONFIG )static int snd_sof_get_hw_config_params (struct snd_sof_dev *sdev,struct snd_sof_dai *dai,int *sample_rate,int *channel_count,int *bit_depth) {
[Severity: Medium]
Does using IS_REACHABLE() here break SSP and DMIC DAI setup at runtime when an Intel IPC4 driver is built as a module alongside a built-in non-Intel SOF driver?
CONFIG_SND_SOC_SOF_IPC4 is only selected by Intel SOF drivers, while ipc4-topology.o is linked into snd-sof.o (CONFIG_SND_SOC_SOF). When CONFIG_SND_SOC_SOF=y and the Intel IPC4 driver is modular with CONFIG_SND_INTEL_DSP_CONFIG=m, IS_REACHABLE(CONFIG_SND_INTEL_DSP_CONFIG) evaluates to false in built-in ipc4-topology.o and compiles in the #else stub of snd_sof_get_nhlt_endpoint_data() that returns 0 without setting *dst or *len.
In sof_ipc4_widget_setup_comp_dai(), SOF_DAI_INTEL_SSP and SOF_DAI_INTEL_DMIC leave ipc4_copier->copier_config as NULL and gtw_cfg.config_length as 0, relying on sof_ipc4_prepare_dai_copier() -> snd_sof_get_nhlt_endpoint_data() to attach the NHLT endpoint blob. With the stubbed implementation, copier preparation silently sends the DSP IPC without the required NHLT hardware configuration payload.
Should SND_SOC_SOF select SND_INTEL_DSP_CONFIG when SND_SOC_SOF_IPC4 (or SND_INTEL_NHLT) is enabled, or should the NHLT lookup calls move to Intel platform callbacks?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 7 lines · Jude Gyimah
}
(quoted diff) +1
-1-#if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_INTEL_NHLT) +#if IS_ENABLED(CONFIG_ACPI) &&
IS_REACHABLE(CONFIG_SND_INTEL_DSP_CONFIG)
static int snd_sof_get_hw_config_params(structsnd_sof_dev*sdev,
structsnd_sof_dai*dai,
IS_REACHABLE() is practically always a mistake, don't do that.
There is surely a way to correctly express the dependencies and avoid the configuration that leads to this.
Arnd
Quoted 4 lines
IS_REACHABLE()is practically always a mistake, don't do that.There is surely a way to correctly express the dependencies and avoid the configuration that leads to this.
Fair enough, I'll drop that patch.
I did try to express this in Kconfig and couldn't get it to work. Here's what I saw, in case it saves someone else the effort.
Adding this to SND_SOC_SOF:
depends on SND_INTEL_DSP_CONFIG || !SND_INTEL_DSP_CONFIG
doesn't avoid the bad configuration. SND_SOC_SOF has no prompt and is only reached via select, and select ignores depends on. So olddefconfig keeps SND_SOC_SOF=y with SND_INTEL_DSP_CONFIG=m and just prints:
WARNING: unmet direct dependencies detected for SND_SOC_SOF
Putting the same dependency on the selector, SND_SOC_SOF_IMX_COMMON, moves the warning to that symbol and quietly demotes SND_SOC_SOF to m. That fixes the link failure, but only through an unmet-dependency warning, which isn't really expressing anything.
I think the underlying problem is that the provider can't be selected. The NHLT parser isn't a module of its own. intel-nhlt.o is built into snd-intel-dspcfg:
sound/hda/core/Makefile:18: snd-intel-dspcfg-$(CONFIG_SND_INTEL_NHLT) += intel-nhlt.o
sound/hda/core/Makefile:19: obj-$(CONFIG_SND_INTEL_DSP_CONFIG) += snd-intel-dspcfg.oSND_INTEL_NHLT is a bool that only decides whether that object joins the module. A consumer therefore can't say "I need the NHLT parser". What it gets is decided by SND_INTEL_DSP_CONFIG, which is about Intel DSP driver detection and gets selected by SND_HDA_INTEL and others for unrelated reasons. No symbol means what the caller needs.
Moving the calls into Intel-specific code, as 194fe0fc3422 did for snd_intel_dsp_driver_probe, doesn't look sufficient either. ipc4-topology.c fills ipc4_data->nhlt from the topology manifest when the BIOS has none:
/* no NHLT in BIOS, so use the one from topology manifest */
So generic SOF can end up holding an NHLT table without any Intel platform code involved, and it needs the parser itself. The field is even declared void * in ipc4-priv.h, which suggests the layering was already felt to be wrong.
If that's right, the fix is to make the parser selectable. SND_INTEL_NHLT would get its own tristate and module:
obj-$(CONFIG_SND_INTEL_NHLT) += snd-intel-nhlt.o
and its users, SND_SOC_SOF included, would select it. A select from a y symbol forces y, so the y/m mismatch can't happen, with no IS_REACHABLE and no depends on.
I'm happy to write that if you think it's the right shape. I'd like to check first, since it moves an object between modules and touches the Intel callers as well as this one.
The config and the failing link are here:
https://lore.kernel.org/r/[email protected]
Thanks,
Jude