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:30:28 +0200	[thread overview]
Message-ID: <20250709203033.90125-3-darwi@linutronix.de> (raw)
In-Reply-To: <20250709203033.90125-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:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-09 17:04 [PATCH v1 0/7] x86: Disentangle <asm/processor.h> dependency on CPUID APIs Ahmed S. Darwish
2025-07-09 17:04 ` [PATCH v1 1/7] x86/cpuid: Remove transitional <asm/cpuid.h> header Ahmed S. Darwish
2025-07-09 17:04 ` [PATCH v1 2/7] ASoC: Intel: avs: Include CPUID header at file scope Ahmed S. Darwish
2025-07-09 17:04 ` [PATCH v1 3/7] x86: Reorder headers alphabetically Ahmed S. Darwish
2025-07-09 17:04 ` [PATCH v1 4/7] drivers: " Ahmed S. Darwish
2025-07-09 17:04 ` [PATCH v1 5/7] treewide: Explicitly include <asm/cpuid/api.h> Ahmed S. Darwish
2025-07-09 17:04 ` [PATCH v1 6/7] x86/cpu: <asm/processor.h>: Do not include CPUID API header Ahmed S. Darwish
2025-07-09 17:04 ` [PATCH v1 7/7] x86/cpuid: Rename cpuid_leaf()/cpuid_subleaf() APIs Ahmed S. Darwish
2025-07-09 17:13 ` [PATCH v1 0/7] x86: Disentangle <asm/processor.h> dependency on CPUID APIs Sean Christopherson
2025-07-09 17:48   ` 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 1/6] x86/cpuid: Remove transitional <asm/cpuid.h> header Ahmed S. Darwish
2025-07-09 20:30   ` Ahmed S. Darwish [this message]
2025-07-09 20:30   ` [PATCH v2 3/6] x86: Reorder headers alphabetically Ahmed S. Darwish
2025-07-09 20:30   ` [PATCH v2 4/6] drivers: " Ahmed S. Darwish
2025-07-09 20:30   ` [PATCH v2 5/6] treewide: Explicitly include CPUID headers Ahmed S. Darwish
2025-07-09 20:30   ` [PATCH v2 6/6] x86/cpu: <asm/processor.h>: Do not include CPUID API header Ahmed S. Darwish
2025-07-14 20:34     ` kernel test robot
2025-07-16 17:17       ` Ahmed S. Darwish
  -- strict thread matches above, loose matches on Subject: below --
2025-06-12 23:39 [PATCH v3 00/44] x86: Introduce a centralized CPUID data model 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 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=20250709203033.90125-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®