Re: [alsa-devel] [PATCH] ASoC: skl: always select SND_SOC_HDAC_HDA

From: Pierre-Louis Bossart
Date: Sun Nov 04 2018 - 11:45:23 EST



On 11/2/18 5:03 PM, Arnd Bergmann wrote:
On 11/2/18, Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx> wrote:
On 11/2/18 6:24 AM, Arnd Bergmann wrote:
The skylake sound support is written to work both with or without
CONFIG_SND_SOC_HDAC_HDA, and uses an #ifdef to decide whether it should
link against that. However, this fails with SND_SOC_ALL_CODECS=m or
SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH=m when the Skylake support itself
is built-in, with this link error:

sound/soc/intel/skylake/skl.o: In function `skl_probe':
skl.c:(.text+0x56c): undefined reference to `snd_soc_hdac_hda_get_ops'

Using an explicit 'select' here simplifies the logic and prevents
it from happening, at the cost of always including the compile
time dependency.
Thanks Arnd for the report. I don't quite agree with the proposal, this
should be similar to HDAC_HDMI which is not selected by default, and
there's no reason to force the support for HDAudio when the vast
majority of Skylake+ devices which enable this driver don't have any
HDaudio codec.
Sure, feel free to treat this patch as a bug report and come up with
a better fix.

I have to rewind my statement. Arnd is correct, the config cannot be the same as hdac_hdmi since there is a code dependency I completely missed.

So yes indeed we have to add a select HDAC_HDA statement under the SKYLAKE config - i just don't know of any other means to say "don't build HDAC_HDA as a module when SKYLAKE is buit-in"

That said, we can add a condition that will only select HDAC_HDA if required by the machine drivers selected. The patch below doesn't seem to have circular dependencies and compiles fine with Arnd's config. I thought of it while multitasking with "Home IT" work and haven't done any testing beyond compilation. Arnd, can you give it a spin to see if this solves the issues?

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 9cc4f1848c9b..91000924eb7c 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -627,6 +627,14 @@ config SND_SOC_HDAC_HDA
ÂÂÂÂÂÂÂ tristate
ÂÂÂÂÂÂÂ select SND_HDA

+config SND_SOC_HDAC_HDA_CODEC
+ÂÂÂÂÂÂ bool
+ÂÂÂÂÂÂ help
+ÂÂÂÂÂÂÂ This config is set by machine drivers who need SND_SOC_HDAC_HDA,
+ÂÂÂÂÂÂÂ which is selected by the platform drivers (Skylake or SOF) based
+ÂÂÂÂÂÂÂ on the value of this boolean. This indirection is required to deal
+ÂÂÂÂÂÂÂ with a code dependency between platform driver and codec driver.
+
Âconfig SND_SOC_ICS43432
ÂÂÂÂÂÂÂ tristate

diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig
index 0caa1f4eb94d..25f3bca5e56d 100644
--- a/sound/soc/intel/Kconfig
+++ b/sound/soc/intel/Kconfig
@@ -107,6 +107,7 @@ config SND_SOC_INTEL_SKYLAKE_SSP_CLK
Âconfig SND_SOC_INTEL_SKYLAKE
ÂÂÂÂÂÂÂ tristate "SKL/BXT/KBL/GLK/CNL... Platforms"
ÂÂÂÂÂÂÂ depends on PCI && ACPI
+ÂÂÂÂÂÂ select SND_SOC_HDAC_HDA if SND_SOC_HDAC_HDA_CODEC
ÂÂÂÂÂÂÂ select SND_HDA_EXT_CORE
ÂÂÂÂÂÂÂ select SND_HDA_DSP_LOADER
ÂÂÂÂÂÂÂ select SND_SOC_TOPOLOGY
diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig
index 73ca1350aa31..5e7d3f4aa3ff 100644
--- a/sound/soc/intel/boards/Kconfig
+++ b/sound/soc/intel/boards/Kconfig
@@ -296,7 +296,7 @@ config SND_SOC_INTEL_KBL_DA7219_MAX98927_MACH
Âconfig SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH
ÂÂÂÂÂÂÂ tristate "SKL/KBL/BXT/APL with HDA Codecs"
ÂÂÂÂÂÂÂ select SND_SOC_HDAC_HDMI
-ÂÂÂÂÂÂ select SND_SOC_HDAC_HDA
+ÂÂÂÂÂÂ select SND_SOC_HDAC_HDA_CODEC
ÂÂÂÂÂÂÂ help
ÂÂÂÂÂÂÂÂÂ This adds support for ASoC machine driver for Intel platforms
ÂÂÂÂÂÂÂÂÂ SKL/KBL/BXT/APL with iDisp, HDA audio codecs.
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index 29225623b4b4..e0dda3fd689b 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -870,7 +870,7 @@ static int skl_create(struct pci_dev *pci,
ÂÂÂÂÂÂÂ hbus = skl_to_hbus(skl);
ÂÂÂÂÂÂÂ bus = skl_to_bus(skl);

-#if IS_ENABLED(CONFIG_SND_SOC_HDAC_HDA)
+#if IS_ENABLED(CONFIG_SND_SOC_HDAC_HDA_CODEC)
ÂÂÂÂÂÂÂ ext_ops = snd_soc_hdac_hda_get_ops();
Â#endif
ÂÂÂÂÂÂÂ snd_hdac_ext_bus_init(bus, &pci->dev, &bus_core_ops, io_ops, ext_ops);