Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753935AbcKOUVZ (ORCPT ); Tue, 15 Nov 2016 15:21:25 -0500 Received: from mga14.intel.com ([192.55.52.115]:54771 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752679AbcKOUVO (ORCPT ); Tue, 15 Nov 2016 15:21:14 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,496,1473145200"; d="scan'208";a="786813648" From: Bin Gao To: Thomas Gleixner Cc: Ingo Molnar , H Peter Anvin , x86@kernel.org, Peter Zijlstra , linux-kernel@vger.kernel.org, Bin Gao Subject: [PATCH 2/4] x86/tsc: mark TSC frequency determined by CPUID as known Date: Tue, 15 Nov 2016 12:27:22 -0800 Message-Id: <1479241644-234277-3-git-send-email-bin.gao@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1479241644-234277-1-git-send-email-bin.gao@linux.intel.com> References: <1479241644-234277-1-git-send-email-bin.gao@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1332 Lines: 38 Unlike TSC calibration where we determin TSC frequency by another timer with known frequency, CPUs/SoCs with CPUID leaf 0x15 come with a known frequency and will report the frequency to software via CPUID instruction. This hardware provided frequency is the "real" frequency of TSC so we set the X86_FEATURE_TSC_KNOWN_FREQ flag to skip the whole software calibration process. We had a 24 hours test on one of the CPUID 0x15 capable platforms. With PIT calibrated frequency, we got more than 3 seconds drift whereas with CPUID determined frequency we only got less than 0.5 second drift. This makes us believe that we should prefer CPUID determined frequency over software calibrated frequency. Signed-off-by: Bin Gao --- arch/x86/kernel/tsc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 3ba146e..f1a7fb5 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -702,6 +702,13 @@ unsigned long native_calibrate_tsc(void) } } + /* + * TSC frequency determined by CPUID is a "hardware reported" + * frequency and is the most accurate one so far we have. This + * is considered a known frequency. + */ + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ); + return crystal_khz * ebx_numerator / eax_denominator; } -- 1.9.1