Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1606961

[v1 7/9] x86/tsc: use cpuid to determine CPU frequency

Path csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Pavel Tatashin <pasha.tatashin@oracle.com>
Newsgroups linux.kernel
Subject [v1 7/9] x86/tsc: use cpuid to determine CPU frequency
Date Wed, 22 Mar 2017 21:20:02 +0100
Message-ID <tnUTE-85w-17@gated-at.bofh.it> (permalink)
References <tnUTE-85w-19@gated-at.bofh.it>
X-Original-To x86@kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, tglx@linutronix.de, hpa@zytor.com
X-Mailer git-send-email 1.7.1
X-Source-IP aserv0021.oracle.com [141.146.126.233]
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 43
Organization linux.* mail to news gateway
X-Original-Date Wed, 22 Mar 2017 16:24:23 -0400
X-Original-Message-ID <1490214265-899964-8-git-send-email-pasha.tatashin@oracle.com>
X-Original-References <1490214265-899964-1-git-send-email-pasha.tatashin@oracle.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1606961

Show key headers only | View raw


Newer processors implement cpuid extension to determine CPU frequency
from cpuid. This patch adds a function that can do this early in boot.

Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
---
 arch/x86/kernel/tsc.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 1c9fc23..58bd575 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -743,14 +743,14 @@ unsigned long native_calibrate_tsc(void)
 	return tsc_khz;
 }
 
-static unsigned long cpu_khz_from_cpuid(void)
+static unsigned long cpu_khz_from_cpuid_early(int vendor, int cpuid_level)
 {
 	unsigned int eax_base_mhz, ebx_max_mhz, ecx_bus_mhz, edx;
 
-	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
+	if (vendor != X86_VENDOR_INTEL)
 		return 0;
 
-	if (boot_cpu_data.cpuid_level < 0x16)
+	if (cpuid_level < 0x16)
 		return 0;
 
 	eax_base_mhz = ebx_max_mhz = ecx_bus_mhz = edx = 0;
@@ -770,7 +770,9 @@ unsigned long native_calibrate_cpu(void)
 	unsigned long flags, latch, ms, fast_calibrate;
 	int hpet = is_hpet_enabled(), i, loopmin;
 
-	fast_calibrate = cpu_khz_from_cpuid();
+	fast_calibrate = cpu_khz_from_cpuid_early(boot_cpu_data.x86_vendor,
+						  boot_cpu_data.cpuid_level);
+
 	if (fast_calibrate)
 		return fast_calibrate;
 
-- 
1.7.1

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[v1 7/9] x86/tsc: use cpuid to determine CPU frequency Pavel Tatashin <pasha.tatashin@oracle.com> - 2017-03-22 21:20 +0100

csiph-web