mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jude Gyimah <jude.gyimah87@gmail.com>
To: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com,
	peter.ujfalusi@linux.intel.com, yung-chuan.liao@linux.intel.com,
	daniel.baluta@nxp.com, broonie@kernel.org
Cc: kai.vehmanen@linux.intel.com, pierre-louis.bossart@linux.dev,
	Vijendar.Mukunda@amd.com, jaska.uimonen@linux.intel.com,
	arnd@arndb.de, sound-open-firmware@alsa-project.org,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jude Gyimah <jude.gyimah87@gmail.com>
Subject: [PATCH] ALSA: hda: give the NHLT parser a module of its own
Date: Wed,  2 Dec 2026 15:07:33 +0100	[thread overview]
Message-ID: <20261202140733.116024-1-jude.gyimah87@gmail.com> (raw)

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


                 reply	other threads:[~2026-12-02 14:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202140733.116024-1-jude.gyimah87@gmail.com \
    --to=jude.gyimah87@gmail.com \
    --cc=Vijendar.Mukunda@amd.com \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=jaska.uimonen@linux.intel.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=sound-open-firmware@alsa-project.org \
    --cc=tiwai@suse.com \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®