Skip to content

Commit d739426

Browse files
Ahmed S. Darwishgregkh
authored andcommitted
ASoC: Intel: avs: Include CPUID header at file scope
[ Upstream commit 7f78e0b ] Commit cbe37a4 ("ASoC: Intel: avs: Configure basefw on TGL-based platforms") includes the main CPUID header from within a C function. This works by luck and forbids valid refactoring inside that header. Include the CPUID header at file scope instead. Remove the COMPILE_TEST build flag so that the CONFIG_X86 conditionals can be removed. The driver gets enough compilation testing already on x86. For clarity, refactor the CPUID(0x15) code into its own function without changing any of the driver's logic. Fixes: cbe37a4 ("ASoC: Intel: avs: Configure basefw on TGL-based platforms") Suggested-by: Borislav Petkov <bp@alien8.de> # CONFIG_X86 removal Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/all/20250612234010.572636-3-darwi@linutronix.de Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7e16c12 commit d739426

2 files changed

Lines changed: 25 additions & 14 deletions

File tree

sound/soc/intel/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ config SND_SOC_INTEL_KEEMBAY
9595

9696
config SND_SOC_INTEL_AVS
9797
tristate "Intel AVS driver"
98-
depends on X86 || COMPILE_TEST
98+
depends on X86
9999
depends on PCI
100100
depends on COMMON_CLK
101101
select ACPI_NHLT if ACPI

sound/soc/intel/avs/tgl.c

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#include <linux/pci.h>
10+
#include <asm/cpuid/api.h>
1011
#include "avs.h"
1112
#include "debug.h"
1213
#include "messages.h"
@@ -38,28 +39,38 @@ static int avs_tgl_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stal
3839
return avs_dsp_core_stall(adev, core_mask, stall);
3940
}
4041

41-
static int avs_tgl_config_basefw(struct avs_dev *adev)
42+
/*
43+
* Succeed if CPUID(0x15) is not available, or if the nominal core crystal clock
44+
* frequency cannot be enumerated from it. There is nothing to do in both cases.
45+
*/
46+
static int avs_tgl_set_xtal_freq(struct avs_dev *adev)
4247
{
43-
struct pci_dev *pci = adev->base.pci;
44-
struct avs_bus_hwid hwid;
48+
unsigned int freq;
4549
int ret;
46-
#ifdef CONFIG_X86
47-
unsigned int ecx;
48-
49-
#include <asm/cpuid/api.h>
5050

5151
if (boot_cpu_data.cpuid_level < CPUID_LEAF_TSC)
52-
goto no_cpuid;
52+
return 0;
5353

54-
ecx = cpuid_ecx(CPUID_LEAF_TSC);
55-
if (ecx) {
56-
ret = avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_XTAL_FREQ_HZ, sizeof(ecx), &ecx);
54+
freq = cpuid_ecx(CPUID_LEAF_TSC);
55+
if (freq) {
56+
ret = avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_XTAL_FREQ_HZ, sizeof(freq), &freq);
5757
if (ret)
5858
return AVS_IPC_RET(ret);
5959
}
60-
#endif
6160

62-
no_cpuid:
61+
return 0;
62+
}
63+
64+
static int avs_tgl_config_basefw(struct avs_dev *adev)
65+
{
66+
struct pci_dev *pci = adev->base.pci;
67+
struct avs_bus_hwid hwid;
68+
int ret;
69+
70+
ret = avs_tgl_set_xtal_freq(adev);
71+
if (ret)
72+
return ret;
73+
6374
hwid.device = pci->device;
6475
hwid.subsystem = pci->subsystem_vendor | (pci->subsystem_device << 16);
6576
hwid.revision = pci->revision;

0 commit comments

Comments
 (0)