Skip to contentSkip to conversation

ASoC: SOF: amd: fix soundwire dependencies

PATCH In review Arnd Bergmann 4 participants 10 messages Feb 19, 2024 – Feb 21, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: SOF: amd: fix soundwire dependencies

From: Arnd Bergmann <[email protected]>

The soundwire-amd driver has a bit of a layering violation requiring the SOF driver to directly call into its exported symbols rather than through an abstraction.

The SND_SOC_SOF_AMD_SOUNDWIRE Kconfig symbol tries to deal with the dependency by selecting SOUNDWIRE_AMD in a complicated set of conditions, but gets it wrong for a configuration involving SND_SOC_SOF_AMD_COMMON=y, SND_SOC_SOF_AMD_ACP63=m, and SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE=m SOUNDWIRE_AMD=m, which results in a link failure:

ld.lld: error: undefined symbol: sdw_amd_get_slave_info

Quoted 1 line
Quoted 1 line
Quoted 1 line

referenced by acp-common.c

ld.lld: error: undefined symbol: amd_sdw_scan_controller ld.lld: error: undefined symbol: sdw_amd_probe ld.lld: error: undefined symbol: sdw_amd_exit

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by acp.c
sound/soc/sof/amd/acp.o:(amd_sof_acp_remove) in archive vmlinux.a

In essence, the SND_SOC_SOF_AMD_COMMON option cannot be built-in when trying to link against a modular SOUNDWIRE_AMD driver.

Since CONFIG_SOUNDWIRE_AMD is a user-visible option, it really should never be selected by another driver in the first place, so replace the extra complexity with a normal Kconfig dependency in SND_SOC_SOF_AMD_SOUNDWIRE, plus a top-level check that forbids any of the AMD SOF drivers from being built-in with CONFIG_SOUNDWIRE_AMD=m.

In normal configs, they should all either be built-in or all loadable modules anyway, so this simplification does not limit any real usecases.

Fixes d948218424bf ("ASoC: SOF: amd: add code for invoking soundwire manager helper functions")
---
 sound/soc/sof/amd/Kconfig | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/sof/amd/Kconfig +3 -3
index c3bbe6c70fb2..2729c6eb3feb 100644
@@ -6,6 +6,7 @@
 
 config SND_SOC_SOF_AMD_TOPLEVEL
 	tristate "SOF support for AMD audio DSPs"
+	depends on SOUNDWIRE_AMD || !SOUNDWIRE_AMD
 	depends on X86 || COMPILE_TEST
 	help
 	  This adds support for Sound Open Firmware for AMD platforms.
@@ -62,15 +63,14 @@ config SND_SOC_SOF_ACP_PROBES
 
 config SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE
 	tristate
-	select SOUNDWIRE_AMD if SND_SOC_SOF_AMD_SOUNDWIRE != n
 	select SND_AMD_SOUNDWIRE_ACPI if ACPI
 
 config SND_SOC_SOF_AMD_SOUNDWIRE
 	tristate "SOF support for SoundWire based AMD platforms"
 	default SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE
 	depends on SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE
-	depends on ACPI && SOUNDWIRE
-	depends on !(SOUNDWIRE=m && SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE=y)
+	depends on ACPI
+	depends on SOUNDWIRE_AMD
 	help
 	  This adds support for SoundWire with Sound Open Firmware
 	  for AMD platforms.
Signature · 1 line
2.39.2
#1 lore raw
Quoted 22 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The soundwire-amd driver has a bit of a layering violation requiring the SOF driver to directly call into its exported symbols rather than through an abstraction.

The SND_SOC_SOF_AMD_SOUNDWIRE Kconfig symbol tries to deal with the dependency by selecting SOUNDWIRE_AMD in a complicated set of conditions, but gets it wrong for a configuration involving SND_SOC_SOF_AMD_COMMON=y, SND_SOC_SOF_AMD_ACP63=m, and SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE=m SOUNDWIRE_AMD=m, which results in a link failure:

ld.lld: error: undefined symbol: sdw_amd_get_slave_info

Quoted 1 line
Quoted 1 line
Quoted 1 line

referenced by acp-common.c

ld.lld: error: undefined symbol: amd_sdw_scan_controller ld.lld: error: undefined symbol: sdw_amd_probe ld.lld: error: undefined symbol: sdw_amd_exit

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by acp.c
sound/soc/sof/amd/acp.o:(amd_sof_acp_remove) in archive vmlinux.a

In essence, the SND_SOC_SOF_AMD_COMMON option cannot be built-in when trying to link against a modular SOUNDWIRE_AMD driver.

Quoted 8 lines

Since CONFIG_SOUNDWIRE_AMD is a user-visible option, it really should never be selected by another driver in the first place, so replace the extra complexity with a normal Kconfig dependency in SND_SOC_SOF_AMD_SOUNDWIRE, plus a top-level check that forbids any of the AMD SOF drivers from being built-in with CONFIG_SOUNDWIRE_AMD=m.

In normal configs, they should all either be built-in or all loadable modules anyway, so this simplification does not limit any real usecases.

Tested this patch. SOUNWIRE_AMD flag is not selected by default causing AMD SOF driver for ACP 6.3 platform is build without enabling SoundWire.

Quoted 37 lines
Fixes d948218424bf ("ASoC: SOF: amd: add code for invoking soundwire manager helper functions")
---
 sound/soc/sof/amd/Kconfig | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/sof/amd/Kconfig +3 -3
index c3bbe6c70fb2..2729c6eb3feb 100644
@@ -6,6 +6,7 @@
 
 config SND_SOC_SOF_AMD_TOPLEVEL
 	tristate "SOF support for AMD audio DSPs"
+	depends on SOUNDWIRE_AMD || !SOUNDWIRE_AMD
 	depends on X86 || COMPILE_TEST
 	help
 	  This adds support for Sound Open Firmware for AMD platforms.
@@ -62,15 +63,14 @@ config SND_SOC_SOF_ACP_PROBES
 
 config SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE
 	tristate
-	select SOUNDWIRE_AMD if SND_SOC_SOF_AMD_SOUNDWIRE != n
 	select SND_AMD_SOUNDWIRE_ACPI if ACPI
 
 config SND_SOC_SOF_AMD_SOUNDWIRE
 	tristate "SOF support for SoundWire based AMD platforms"
 	default SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE
 	depends on SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE
-	depends on ACPI && SOUNDWIRE
-	depends on !(SOUNDWIRE=m && SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE=y)
+	depends on ACPI
+	depends on SOUNDWIRE_AMD
 	help
 	  This adds support for SoundWire with Sound Open Firmware
 	  for AMD platforms.
#2 lore raw
Quoted 8 lines · Mukunda,Vijendar
Quoted 4 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

In normal configs, they should all either be built-in or all loadable modules anyway, so this simplification does not limit any real usecases.

Tested this patch. SOUNWIRE_AMD flag is not selected by default causing AMD SOF driver for ACP 6.3 platform is build without enabling SoundWire.

Yes, that is what I described. But as SOUNWIRE_AMD is a user visible symbol, there is no problem in expecting users to enable it when they have this hardware, and distros just enable all the drivers anyway.

Arnd

#3 lore raw
Quoted 10 lines · Arnd Bergmann
Quoted 6 lines · Mukunda,Vijendar
Quoted 3 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>
In normal configs, they should all either be built-in or all loadable modules anyway, so this simplification does not limit any real usecases.

Tested this patch. SOUNWIRE_AMD flag is not selected by default causing AMD SOF driver for ACP 6.3 platform is build without enabling SoundWire.

Yes, that is what I described. But as SOUNWIRE_AMD is a user visible symbol, there is no problem in expecting users to enable it when they have this hardware, and distros just enable all the drivers anyway.

Want to set SOUNDWIRE_AMD flag by default, similar to Intel & Qcom platforms instead of explicitly enabling the Kconfig option.

Quoted 2 lines

Arnd

#4 lore raw
Quoted 6 lines · Mukunda,Vijendar
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · Mukunda,Vijendar
Quoted 3 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>
In normal configs, they should all either be built-in or all loadable modules anyway, so this simplification does not limit any real usecases.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Tested this patch. SOUNWIRE_AMD flag is not selected by default causing AMD SOF driver for ACP 6.3 platform is build without enabling SoundWire.

Yes, that is what I described. But as SOUNWIRE_AMD is a user visible symbol, there is no problem in expecting users to enable it when they have this hardware, and distros just enable all the drivers anyway.

Want to set SOUNDWIRE_AMD flag by default, similar to Intel & Qcom platforms instead of explicitly enabling the Kconfig option.

Maybe use 'default SND_SOC_SOF_AMD_TOPLEVEL' then?

I don't think copying the mistake from the intel driver is helpful, though I agree it would be nice to be consistent between them.

As a general rule, you should not have a Kconfig symbol that is both user visible and also selected by the drivers that depend on it.

To avoid the dependency problems from coming back and keep the complexity to a minimum, I think there are two logical ways to handle soundwire:

a) keep the current drivers/soundwire/Kconfig contents and change all the 'select SOUNDWIRE_foo' to 'depends on'.

b) keep all the 'select SOUNDWIRE_foo' but drop the prompts, requiring that all drivers that use soundwire have the correct select statements, with the main CONFIG_SOUNDWIRE getting selected by the individual drivers.

Arnd

#5 lore raw
Quoted 7 lines · Arnd Bergmann
Quoted 6 lines · Mukunda,Vijendar
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · Mukunda,Vijendar
Quoted 3 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>
In normal configs, they should all either be built-in or all loadable modules anyway, so this simplification does not limit any real usecases.

Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Tested this patch. SOUNWIRE_AMD flag is not selected by default causing AMD SOF driver for ACP 6.3 platform is build without enabling SoundWire.

Yes, that is what I described. But as SOUNWIRE_AMD is a user visible symbol, there is no problem in expecting users to enable it when they have this hardware, and distros just enable all the drivers anyway.

Want to set SOUNDWIRE_AMD flag by default, similar to Intel & Qcom platforms instead of explicitly enabling the Kconfig option.

Maybe use 'default SND_SOC_SOF_AMD_TOPLEVEL' then?

Didn't get your point.

Even with the current patch, if we select 'SOUNDWIRE_AMD' flag explicitly AMD ACP63 SOF driver Kconfig option is not visible for user configuration. This results in ACP63 SOF driver won't be built at all.

Quoted 9 lines

I don't think copying the mistake from the intel driver is helpful, though I agree it would be nice to be consistent between them.

As a general rule, you should not have a Kconfig symbol that is both user visible and also selected by the drivers that depend on it.

Quoted 6 lines

To avoid the dependency problems from coming back and keep the complexity to a minimum, I think there are two logical ways to handle soundwire:

a) keep the current drivers/soundwire/Kconfig contents and change all the 'select SOUNDWIRE_foo' to 'depends on'.

Current patch already using 'depends on SOUNDWIRE_AMD" for SND_SOC_SOF_AMD_SOUNDWIRE Kconfig option.
Still we couldn't see SND_SOC_SOF_AMD_ACP63 Kconfig option is enabled.

Quoted 5 lines

b) keep all the 'select SOUNDWIRE_foo' but drop the prompts, requiring that all drivers that use soundwire have the correct select statements, with the main CONFIG_SOUNDWIRE getting selected by the individual drivers.

Didn't get your point. Could you please elaborate?

Quoted 1 line

Arnd

#6 lore raw
Quoted 13 lines · Mukunda,Vijendar
Quoted 12 lines · Arnd Bergmann
Quoted 11 lines · Mukunda,Vijendar
Quoted 10 lines · Arnd Bergmann
Quoted 6 lines · Mukunda,Vijendar
Quoted 3 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>
In normal configs, they should all either be built-in or all loadable modules anyway, so this simplification does not limit any real usecases.

Tested this patch. SOUNWIRE_AMD flag is not selected by default causing AMD SOF driver for ACP 6.3 platform is build without enabling SoundWire.

Yes, that is what I described. But as SOUNWIRE_AMD is a user visible symbol, there is no problem in expecting users to enable it when they have this hardware, and distros just enable all the drivers anyway.

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

Want to set SOUNDWIRE_AMD flag by default, similar to Intel & Qcom platforms instead of explicitly enabling the Kconfig option.

Maybe use 'default SND_SOC_SOF_AMD_TOPLEVEL' then?

Didn't get your point.

Even with the current patch, if we select 'SOUNDWIRE_AMD' flag explicitly AMD ACP63 SOF driver Kconfig option is not visible for user configuration. This results in ACP63 SOF driver won't be built at all.

I don't understand what you mean here. What I see in linux-next both with and without my patch is

config SND_SOC_SOF_AMD_ACP63
tristate "SOF support for ACP6.3 platform" depends on SND_SOC_SOF_PCI

so it clearly should be visible as long as SND_SOC_SOF_PCI is enabled.

There is still a problem that SND_SOC_SOF_AMD_TOPLEVEL can't use my "depends on SOUNDWIRE_AMD || !SOUNDWIRE_AMD" trick if SOUNDWIRE_AMD in turn uses
"default SND_SOC_SOF_AMD_TOPLEVEL", but I don't think you meant that, right?

Quoted 12 lines
Quoted 12 lines

I don't think copying the mistake from the intel driver is helpful, though I agree it would be nice to be consistent between them.

As a general rule, you should not have a Kconfig symbol that is both user visible and also selected by the drivers that depend on it.

To avoid the dependency problems from coming back and keep the complexity to a minimum, I think there are two logical ways to handle soundwire:

Quoted 5 lines
Quoted 2 lines

a) keep the current drivers/soundwire/Kconfig contents and change all the 'select SOUNDWIRE_foo' to 'depends on'.

Current patch already using 'depends on SOUNDWIRE_AMD" for SND_SOC_SOF_AMD_SOUNDWIRE Kconfig option.

Correct, because this is the Kconfig option that actually controls whether sound/soc/sof/amd/acp-common.c calls into the soundwire-amd module.

Quoted 2 lines

Still we couldn't see SND_SOC_SOF_AMD_ACP63 Kconfig option is enabled.

I need more information here. Do you have additional patches on top of what is in today's linux-next? I have it enabled on my build here.

Arnd

#7 lore raw
Quoted 29 lines · Arnd Bergmann
Quoted 13 lines · Mukunda,Vijendar
Quoted 12 lines · Arnd Bergmann
Quoted 11 lines · Mukunda,Vijendar
Quoted 10 lines · Arnd Bergmann
Quoted 6 lines · Mukunda,Vijendar
Quoted 3 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>
In normal configs, they should all either be built-in or all loadable modules anyway, so this simplification does not limit any real usecases.

Tested this patch. SOUNWIRE_AMD flag is not selected by default causing AMD SOF driver for ACP 6.3 platform is build without enabling SoundWire.

Yes, that is what I described. But as SOUNWIRE_AMD is a user visible symbol, there is no problem in expecting users to enable it when they have this hardware, and distros just enable all the drivers anyway.

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

Want to set SOUNDWIRE_AMD flag by default, similar to Intel & Qcom platforms instead of explicitly enabling the Kconfig option.

Maybe use 'default SND_SOC_SOF_AMD_TOPLEVEL' then?

Didn't get your point.

Even with the current patch, if we select 'SOUNDWIRE_AMD' flag explicitly AMD ACP63 SOF driver Kconfig option is not visible for user configuration. This results in ACP63 SOF driver won't be built at all.

I don't understand what you mean here. What I see in linux-next both with and without my patch is

config SND_SOC_SOF_AMD_ACP63
tristate "SOF support for ACP6.3 platform" depends on SND_SOC_SOF_PCI

Quoted 8 lines

so it clearly should be visible as long as SND_SOC_SOF_PCI is enabled.

There is still a problem that SND_SOC_SOF_AMD_TOPLEVEL can't use my "depends on SOUNDWIRE_AMD || !SOUNDWIRE_AMD" trick if SOUNDWIRE_AMD in turn uses
"default SND_SOC_SOF_AMD_TOPLEVEL", but I don't think you meant that, right?

Yes, you are correct.

Quoted 21 lines
Quoted 9 lines
Quoted 9 lines

I don't think copying the mistake from the intel driver is helpful, though I agree it would be nice to be consistent between them.

As a general rule, you should not have a Kconfig symbol that is both user visible and also selected by the drivers that depend on it.

Quoted 8 lines
Quoted 6 lines

To avoid the dependency problems from coming back and keep the complexity to a minimum, I think there are two logical ways to handle soundwire:

a) keep the current drivers/soundwire/Kconfig contents and change all the 'select SOUNDWIRE_foo' to 'depends on'.

Current patch already using 'depends on SOUNDWIRE_AMD" for SND_SOC_SOF_AMD_SOUNDWIRE Kconfig option.

Correct, because this is the Kconfig option that actually controls whether sound/soc/sof/amd/acp-common.c calls into the soundwire-amd module.

Quoted 5 lines
Quoted 2 lines

Still we couldn't see SND_SOC_SOF_AMD_ACP63 Kconfig option is enabled.

I need more information here. Do you have additional patches on top of what is in today's linux-next? I have it enabled on my build here.

Sorry, it's my bad. My local patches created the problem. Validated patch on our side. It's working fine.

Quoted 2 lines

Arnd

reviewer Tested-by on v1 1/1
#8 lore raw
In reply to Arnd Bergmann
Quoted 22 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The soundwire-amd driver has a bit of a layering violation requiring the SOF driver to directly call into its exported symbols rather than through an abstraction.

The SND_SOC_SOF_AMD_SOUNDWIRE Kconfig symbol tries to deal with the dependency by selecting SOUNDWIRE_AMD in a complicated set of conditions, but gets it wrong for a configuration involving SND_SOC_SOF_AMD_COMMON=y, SND_SOC_SOF_AMD_ACP63=m, and SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE=m SOUNDWIRE_AMD=m, which results in a link failure:

ld.lld: error: undefined symbol: sdw_amd_get_slave_info

Quoted 1 line
Quoted 1 line
Quoted 1 line

referenced by acp-common.c

ld.lld: error: undefined symbol: amd_sdw_scan_controller ld.lld: error: undefined symbol: sdw_amd_probe ld.lld: error: undefined symbol: sdw_amd_exit

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

referenced by acp.c
sound/soc/sof/amd/acp.o:(amd_sof_acp_remove) in archive vmlinux.a

In essence, the SND_SOC_SOF_AMD_COMMON option cannot be built-in when trying to link against a modular SOUNDWIRE_AMD driver.

Quoted 8 lines

Since CONFIG_SOUNDWIRE_AMD is a user-visible option, it really should never be selected by another driver in the first place, so replace the extra complexity with a normal Kconfig dependency in SND_SOC_SOF_AMD_SOUNDWIRE, plus a top-level check that forbids any of the AMD SOF drivers from being built-in with CONFIG_SOUNDWIRE_AMD=m.

In normal configs, they should all either be built-in or all loadable modules anyway, so this simplification does not limit any real usecases.

Quoted 37 lines
Fixes d948218424bf ("ASoC: SOF: amd: add code for invoking soundwire manager helper functions")
---
 sound/soc/sof/amd/Kconfig | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/sof/amd/Kconfig +3 -3
index c3bbe6c70fb2..2729c6eb3feb 100644
@@ -6,6 +6,7 @@
 
 config SND_SOC_SOF_AMD_TOPLEVEL
 	tristate "SOF support for AMD audio DSPs"
+	depends on SOUNDWIRE_AMD || !SOUNDWIRE_AMD
 	depends on X86 || COMPILE_TEST
 	help
 	  This adds support for Sound Open Firmware for AMD platforms.
@@ -62,15 +63,14 @@ config SND_SOC_SOF_ACP_PROBES
 
 config SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE
 	tristate
-	select SOUNDWIRE_AMD if SND_SOC_SOF_AMD_SOUNDWIRE != n
 	select SND_AMD_SOUNDWIRE_ACPI if ACPI
 
 config SND_SOC_SOF_AMD_SOUNDWIRE
 	tristate "SOF support for SoundWire based AMD platforms"
 	default SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE
 	depends on SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE
-	depends on ACPI && SOUNDWIRE
-	depends on !(SOUNDWIRE=m && SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE=y)
+	depends on ACPI
+	depends on SOUNDWIRE_AMD
 	help
 	  This adds support for SoundWire with Sound Open Firmware
 	  for AMD platforms.
maintainer
#9 lore raw
In reply to Arnd Bergmann
Quoted 11 lines · Arnd Bergmann

The soundwire-amd driver has a bit of a layering violation requiring the SOF driver to directly call into its exported symbols rather than through an abstraction.

The SND_SOC_SOF_AMD_SOUNDWIRE Kconfig symbol tries to deal with the dependency by selecting SOUNDWIRE_AMD in a complicated set of conditions, but gets it wrong for a configuration involving SND_SOC_SOF_AMD_COMMON=y, SND_SOC_SOF_AMD_ACP63=m, and SND_SOC_SOF_AMD_SOUNDWIRE_LINK_BASELINE=m SOUNDWIRE_AMD=m, which results in a link failure:

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: SOF: amd: fix soundwire dependencies

      commit: a3d543b9e6599fbbb9efc1876919627960c5e97a

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark