[PATCH] ASoC: Intel: avs: Include CPUID header at file scope

From: Ahmed S. Darwish

Date: Fri Sep 05 2025 - 08:14:41 EST


Commit

cbe37a4d2b3c ("ASoC: Intel: avs: Configure basefw on TGL-based platforms")

includes the main CPUID header from within a C function. This works by
sheer luck and forbids further refactoring inside the CPUID header.

Include the CPUID header at file scope instead.

Note, for the CPUID(0x15) leaf number, use CPUID_LEAF_TSC instead of
defining a custom local macro for it.

[ bp: Massage, zap the CONFIG_X86 ifdeffery and dependency on
COMPILE_TEST because this driver gets enough compile testing on x86
alone already. ]

Signed-off-by: Ahmed S. Darwish <darwi@xxxxxxxxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Link: https://patch.msgid.link/20250905121515.192792-2-darwi@xxxxxxxxxxxxx
---
sound/soc/intel/Kconfig | 2 +-
sound/soc/intel/avs/tgl.c | 18 ++++++------------
2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig
index 412555e626b8..63367364916a 100644
--- a/sound/soc/intel/Kconfig
+++ b/sound/soc/intel/Kconfig
@@ -95,7 +95,7 @@ config SND_SOC_INTEL_KEEMBAY

config SND_SOC_INTEL_AVS
tristate "Intel AVS driver"
- depends on X86 || COMPILE_TEST
+ depends on X86
depends on PCI
depends on COMMON_CLK
select ACPI_NHLT if ACPI
diff --git a/sound/soc/intel/avs/tgl.c b/sound/soc/intel/avs/tgl.c
index afb066516101..ba4831f4de5a 100644
--- a/sound/soc/intel/avs/tgl.c
+++ b/sound/soc/intel/avs/tgl.c
@@ -7,12 +7,12 @@
//

#include <linux/pci.h>
+#include <asm/cpuid/api.h>
+
#include "avs.h"
#include "debug.h"
#include "messages.h"

-#define CPUID_TSC_LEAF 0x15
-
static int avs_tgl_dsp_core_power(struct avs_dev *adev, u32 core_mask, bool power)
{
core_mask &= AVS_MAIN_CORE_MASK;
@@ -42,20 +42,14 @@ static int avs_tgl_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stal

static int avs_tgl_config_basefw(struct avs_dev *adev)
{
+ unsigned int freq = cpuid_ecx(CPUID_LEAF_TSC);
struct pci_dev *pci = adev->base.pci;
struct avs_bus_hwid hwid;
int ret;
-#ifdef CONFIG_X86
- unsigned int ecx;

-#include <asm/cpuid/api.h>
- ecx = cpuid_ecx(CPUID_TSC_LEAF);
- if (ecx) {
- ret = avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_XTAL_FREQ_HZ, sizeof(ecx), &ecx);
- if (ret)
- return AVS_IPC_RET(ret);
- }
-#endif
+ ret = avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_XTAL_FREQ_HZ, sizeof(freq), &freq);
+ if (ret)
+ return AVS_IPC_RET(ret);

hwid.device = pci->device;
hwid.subsystem = pci->subsystem_vendor | (pci->subsystem_device << 16);
--
2.51.0

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette