mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ahmed S. Darwish" <darwi@linutronix.de>
To: Borislav Petkov <bp@alien8.de>, Ingo Molnar <mingo@redhat.com>,
	Dave Hansen <dave.hansen@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	John Ogness <john.ogness@linutronix.de>,
	x86@kernel.org, x86-cpuid@lists.linux.dev,
	LKML <linux-kernel@vger.kernel.org>,
	"Ahmed S. Darwish" <darwi@linutronix.de>
Subject: [PATCH v2 2/6] ASoC: Intel: avs: Include CPUID header at file scope
Date: Wed,  9 Jul 2025 22:26:29 +0200	[thread overview]
Message-ID: <20250709202635.89791-3-darwi@linutronix.de> (raw)
In-Reply-To: <20250709202635.89791-1-darwi@linutronix.de>

Commit

    cbe37a4d2b3c ("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 refactorings 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.

Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
Acked-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/avs/tgl.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/sound/soc/intel/avs/tgl.c b/sound/soc/intel/avs/tgl.c
index 9dbb3ad0954a..cf19d3a7ced2 100644
--- a/sound/soc/intel/avs/tgl.c
+++ b/sound/soc/intel/avs/tgl.c
@@ -10,8 +10,6 @@
 #include "avs.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;
@@ -39,22 +37,31 @@ static int avs_tgl_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stal
 	return avs_dsp_core_stall(adev, core_mask, stall);
 }
 
+#ifdef CONFIG_X86
+#include <asm/cpuid/api.h>
+static unsigned int intel_crystal_freq_hz(void)
+{
+	return cpuid_ecx(CPUID_LEAF_TSC);
+}
+#else
+static unsigned int intel_crystal_freq_hz(void)
+{
+	return 0;
+}
+#endif /* !CONFIG_X86 */
+
 static int avs_tgl_config_basefw(struct avs_dev *adev)
 {
+	unsigned int freq = intel_crystal_freq_hz();
 	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 (freq) {
+		ret = avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_XTAL_FREQ_HZ, sizeof(freq), &freq);
 		if (ret)
 			return AVS_IPC_RET(ret);
 	}
-#endif
 
 	hwid.device = pci->device;
 	hwid.subsystem = pci->subsystem_vendor | (pci->subsystem_device << 16);
-- 
2.49.0


  parent reply	other threads:[~2025-07-09 20:27 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-12 23:39 [PATCH v3 00/44] x86: Introduce a centralized CPUID data model Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 01/44] x86/cpuid: Remove transitional <asm/cpuid.h> header Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 02/44] ASoC: Intel: avs: Include CPUID header at file scope Ahmed S. Darwish
2025-06-16  8:23   ` Cezary Rojewski
2025-07-07 16:51     ` Ahmed S. Darwish
2025-07-04 11:32   ` Borislav Petkov
2025-07-07 16:55     ` Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 03/44] x86/boot: Reorder sme.c headers alphabetically Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 04/44] x86/cpu: Reorder scattered.c " Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 05/44] x86/cpu/amd: Reorder " Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 06/44] x86/cpu/topology: " Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 07/44] x86/mce: Reorder core.c " Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 08/44] x86/paravirt: Reorder " Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 09/44] x86/perf/zhaoxin: " Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 10/44] x86/resctrl: Reorder core.c " Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 11/44] x86/tdx: Reorder " Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 12/44] cpufreq: " Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 13/44] hwmon: (fam15h_power) " Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 14/44] hwmon: (k8temp) " Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 15/44] perf/x86/amd/uncore: " Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 16/44] thermal: intel: " Ahmed S. Darwish
2025-07-04 11:34   ` Borislav Petkov
2025-07-07 17:23     ` Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 17/44] treewide: Explicitly include <asm/cpuid/api.h> Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 18/44] x86/cpuid: Rename cpuid_leaf()/cpuid_subleaf() APIs Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 19/44] x86/cpuid: Introduce <asm/cpuid/leaf_types.h> Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 20/44] x86/cpuid: Introduce a centralized CPUID data model Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 21/44] x86/cpuid: Introduce a centralized CPUID parser Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 22/44] x86/cpuid: Parse CPUID(0x80000000) Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 23/44] x86/cpuid: Introduce CPUID parser debugfs interface Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 24/44] x86/cpu: Use parsed CPUID(0x0) Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 25/44] x86/cpu: Use parsed CPUID(0x80000000) Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 26/44] x86/lib: Add CPUID(0x1) CPU family and model calculation Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 27/44] x86/cpu: Use parsed CPUID(0x1) Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 28/44] x86/cpuid: Parse CPUID(0x2) Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 29/44] x86/cpuid: Introduce parsed CPUID(0x2) API Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 30/44] x86/cpu: Use parsed CPUID(0x2) Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 31/44] x86/cacheinfo: " Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 32/44] x86/cpuid: Remove direct CPUID(0x2) query API Ahmed S. Darwish
2025-06-12 23:39 ` [PATCH v3 33/44] x86/cpuid: Parse deterministic cache parameters CPUID leaves Ahmed S. Darwish
2025-06-12 23:40 ` [PATCH v3 34/44] x86/cacheinfo: Pass a 'struct cpuinfo_x86' refrence to CPUID(0x4) code Ahmed S. Darwish
2025-06-12 23:40 ` [PATCH v3 35/44] x86/cacheinfo: Use parsed CPUID(0x4) Ahmed S. Darwish
2025-06-12 23:40 ` [PATCH v3 36/44] x86/cacheinfo: Use parsed CPUID(0x8000001d) Ahmed S. Darwish
2025-06-12 23:40 ` [PATCH v3 37/44] x86/cpuid: Parse CPUID(0x80000005) and CPUID(0x80000006) Ahmed S. Darwish
2025-06-12 23:40 ` [PATCH v3 38/44] x86/cacheinfo: Use auto-generated data types Ahmed S. Darwish
2025-06-12 23:40 ` [PATCH v3 39/44] x86/cacheinfo: Use parsed CPUID(0x80000005) and CPUID(0x80000006) Ahmed S. Darwish
2025-06-12 23:40 ` [PATCH v3 40/44] x86/amd_nb: Trickle down 'struct cpuinfo_x86' reference Ahmed S. Darwish
2025-06-12 23:40 ` [PATCH v3 41/44] x86/cpu: <asm/processor.h>: Do not include CPUID API header Ahmed S. Darwish
2025-06-13 12:46   ` kernel test robot
2025-06-12 23:40 ` [PATCH v3 42/44] x86/cpuid: Use parsed CPUID(0x80000006) Ahmed S. Darwish
2025-06-12 23:40 ` [PATCH v3 43/44] x86/cpu: Rescan CPUID table after PSN disable Ahmed S. Darwish
2025-06-12 23:40 ` [PATCH v3 44/44] x86/cpu: Rescan CPUID table after unlocking full CPUID range Ahmed S. Darwish
2025-07-09 20:26 ` [PATCH v2 0/6] x86: Disentangle <asm/processor.h> dependency on CPUID headers Ahmed S. Darwish
2025-07-09 20:26   ` [PATCH v2 1/6] x86/cpuid: Remove transitional <asm/cpuid.h> header Ahmed S. Darwish
2025-07-09 20:26   ` Ahmed S. Darwish [this message]
2025-07-09 20:26   ` [PATCH v2 3/6] x86: Reorder headers alphabetically Ahmed S. Darwish
2025-07-09 20:26   ` [PATCH v2 4/6] drivers: " Ahmed S. Darwish
2025-07-09 20:26   ` [PATCH v2 5/6] treewide: Explicitly include CPUID headers Ahmed S. Darwish
2025-07-09 20:26   ` [PATCH v2 6/6] x86/cpu: <asm/processor.h>: Do not include CPUID API header Ahmed S. Darwish
2025-07-09 20:36   ` [PATCH v2 0/6] x86: Disentangle <asm/processor.h> dependency on CPUID headers Ahmed S. Darwish
2025-07-09 17:04 [PATCH v1 0/7] x86: Disentangle <asm/processor.h> dependency on CPUID APIs Ahmed S. Darwish
2025-07-09 20:30 ` [PATCH v2 0/6] x86: Disentangle <asm/processor.h> dependency on CPUID headers Ahmed S. Darwish
2025-07-09 20:30   ` [PATCH v2 2/6] ASoC: Intel: avs: Include CPUID header at file scope Ahmed S. Darwish

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=20250709202635.89791-3-darwi@linutronix.de \
    --to=darwi@linutronix.de \
    --cc=andrew.cooper3@citrix.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86-cpuid@lists.linux.dev \
    --cc=x86@kernel.org \
    /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®