public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Len Brown <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org,
	bin.gao@intel.com, hpa@zytor.com, tglx@linutronix.de,
	len.brown@intel.com
Subject: [tip:x86/urgent] x86/tsc: Future-proof native_calibrate_tsc()
Date: Sun, 14 Jan 2018 03:43:19 -0800	[thread overview]
Message-ID: <tip-da4ae6c4a0b8dee5a5377a385545d2250fa8cddb@git.kernel.org> (raw)
In-Reply-To: <0fe2503aa7d7fc69137141fc705541a78101d2b9.1513920414.git.len.brown@intel.com>

Commit-ID:  da4ae6c4a0b8dee5a5377a385545d2250fa8cddb
Gitweb:     https://git.kernel.org/tip/da4ae6c4a0b8dee5a5377a385545d2250fa8cddb
Author:     Len Brown <len.brown@intel.com>
AuthorDate: Fri, 22 Dec 2017 00:27:54 -0500
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 14 Jan 2018 12:14:50 +0100

x86/tsc: Future-proof native_calibrate_tsc()

If the crystal frequency cannot be determined via CPUID(15).crystal_khz or
the built-in table then native_calibrate_tsc() will still set the
X86_FEATURE_TSC_KNOWN_FREQ flag which prevents the refined TSC calibration.

As a consequence such systems use cpu_khz for the TSC frequency which is
incorrect when cpu_khz != tsc_khz resulting in time drift.

Return early when the crystal frequency cannot be retrieved without setting
the X86_FEATURE_TSC_KNOWN_FREQ flag. This ensures that the refined TSC
calibration is invoked.

[ tglx: Steam-blastered changelog. Sigh ]

Fixes: 4ca4df0b7eb0 ("x86/tsc: Mark TSC frequency determined by CPUID as known")
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: peterz@infradead.org
Cc: Bin Gao <bin.gao@intel.com>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/0fe2503aa7d7fc69137141fc705541a78101d2b9.1513920414.git.len.brown@intel.com

---
 arch/x86/kernel/tsc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 8ea117f..ce4b711 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -612,6 +612,8 @@ unsigned long native_calibrate_tsc(void)
 		}
 	}
 
+	if (crystal_khz == 0)
+		return 0;
 	/*
 	 * TSC frequency determined by CPUID is a "hardware reported"
 	 * frequency and is the most accurate one so far we have. This

      parent reply	other threads:[~2018-01-14 11:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-22  5:27 [PATCH 1/3] x86/tsc: Future-proof native_calibrate_tsc() Len Brown
2017-12-22  5:27 ` [PATCH 2/3] x86/tsc: Fix erroneous TSC rate on Skylake Xeon Len Brown
2018-01-02 15:36   ` Prarit Bhargava
2018-01-02 21:09     ` Len Brown
2018-01-14 11:43   ` [tip:x86/urgent] " tip-bot for Len Brown
2017-12-22  5:27 ` [PATCH 3/3] x86/tsc: Print tsc_khz, when it differs from cpu_khz Len Brown
2018-01-14 11:44   ` [tip:x86/urgent] " tip-bot for Len Brown
2018-01-14 11:43 ` tip-bot for Len Brown [this message]

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=tip-da4ae6c4a0b8dee5a5377a385545d2250fa8cddb@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bin.gao@intel.com \
    --cc=hpa@zytor.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    /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