mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda: give the NHLT parser a module of its own
@ 2026-12-02 14:07 Jude Gyimah
  0 siblings, 0 replies; only message in thread
From: Jude Gyimah @ 2026-12-02 14:07 UTC (permalink / raw)
  To: perex, tiwai, lgirdwood, peter.ujfalusi, yung-chuan.liao,
	daniel.baluta, broonie
  Cc: kai.vehmanen, pierre-louis.bossart, Vijendar.Mukunda,
	jaska.uimonen, arnd, sound-open-firmware, linux-sound,
	linux-kernel, Jude Gyimah

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@gmail.com
Signed-off-by: Jude Gyimah <jude.gyimah87@gmail.com>
---
 sound/hda/core/Kconfig      | 6 +++---
 sound/hda/core/Makefile     | 4 +++-
 sound/hda/core/intel-nhlt.c | 4 ++++
 sound/soc/sof/Kconfig       | 1 +
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/sound/hda/core/Kconfig b/sound/hda/core/Kconfig
index bfdcf6384c52..4ecc02c1c90d 100644
--- a/sound/hda/core/Kconfig
+++ b/sound/hda/core/Kconfig
@@ -21,9 +21,9 @@ config SND_HDA_EXT_CORE
        select SND_HDA_CORE
 
 config SND_INTEL_NHLT
-	bool
-	# this config should be selected only for Intel ACPI platforms.
-	# A fallback is provided so that the code compiles in all cases.
+	tristate
+	# Selected by whoever parses an NHLT table.  A fallback is provided so
+	# that the code compiles in all cases.
 
 config SND_INTEL_DSP_CONFIG
 	tristate
diff --git a/sound/hda/core/Makefile b/sound/hda/core/Makefile
index 89cb46143050..d0eb2cf1fa78 100644
--- a/sound/hda/core/Makefile
+++ b/sound/hda/core/Makefile
@@ -15,8 +15,10 @@ obj-$(CONFIG_SND_HDA_CORE) += snd-hda-core.o
 obj-$(CONFIG_SND_HDA_EXT_CORE) += ext/
 
 snd-intel-dspcfg-y := intel-dsp-config.o
-snd-intel-dspcfg-$(CONFIG_SND_INTEL_NHLT) += intel-nhlt.o
 obj-$(CONFIG_SND_INTEL_DSP_CONFIG) += snd-intel-dspcfg.o
 
+snd-intel-nhlt-y := intel-nhlt.o
+obj-$(CONFIG_SND_INTEL_NHLT) += snd-intel-nhlt.o
+
 snd-intel-sdw-acpi-y := intel-sdw-acpi.o
 obj-$(CONFIG_SND_INTEL_SOUNDWIRE_ACPI) += snd-intel-sdw-acpi.o
diff --git a/sound/hda/core/intel-nhlt.c b/sound/hda/core/intel-nhlt.c
index 6d72a871bda0..41565d74bd4d 100644
--- a/sound/hda/core/intel-nhlt.c
+++ b/sound/hda/core/intel-nhlt.c
@@ -2,6 +2,7 @@
 // Copyright (c) 2015-2019 Intel Corporation
 
 #include <linux/acpi.h>
+#include <linux/module.h>
 #include <sound/intel-nhlt.h>
 
 struct nhlt_acpi_table *intel_nhlt_init(struct device *dev)
@@ -386,3 +387,6 @@ int intel_nhlt_ssp_device_type(struct device *dev, struct nhlt_acpi_table *nhlt,
 	return -EINVAL;
 }
 EXPORT_SYMBOL(intel_nhlt_ssp_device_type);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Intel NHLT table parsing helpers");
diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig
index a487ab0b51c7..c5a1065b845a 100644
--- a/sound/soc/sof/Kconfig
+++ b/sound/soc/sof/Kconfig
@@ -272,6 +272,7 @@ endif ## SND_SOC_SOF_DEVELOPER_SUPPORT
 
 config SND_SOC_SOF
 	tristate
+	select SND_INTEL_NHLT if ACPI
 	select SND_SOC_TOPOLOGY
 	select SND_SOC_SOF_NOCODEC if SND_SOC_SOF_NOCODEC_SUPPORT
 	select SND_SOC_SOF_NOCODEC if SND_SOC_SOF_NOCODEC_DEBUG_SUPPORT
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-02 14:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-02 14:07 [PATCH] ALSA: hda: give the NHLT parser a module of its own Jude Gyimah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®