Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751769AbbGFHmz (ORCPT ); Mon, 6 Jul 2015 03:42:55 -0400 Received: from terminus.zytor.com ([198.137.202.10]:44259 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754011AbbGFHmu (ORCPT ); Mon, 6 Jul 2015 03:42:50 -0400 Date: Mon, 6 Jul 2015 00:42:36 -0700 From: tip-bot for Adrian Hunter Message-ID: Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, luto@amacapital.net, adrian.hunter@intel.com, tglx@linutronix.de, mingo@kernel.org, ak@linux.intel.com, hpa@zytor.com, lenb@kernel.org Reply-To: luto@amacapital.net, adrian.hunter@intel.com, tglx@linutronix.de, mingo@kernel.org, ak@linux.intel.com, lenb@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org In-Reply-To: <556EB717.9070607@intel.com> References: <556EB717.9070607@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/tsc: Let high latency PIT fail fast in quick_pit_calibrate() Git-Commit-ID: 5aac644a9944bea93b4f05ced1883a902a2535f6 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2089 Lines: 60 Commit-ID: 5aac644a9944bea93b4f05ced1883a902a2535f6 Gitweb: http://git.kernel.org/tip/5aac644a9944bea93b4f05ced1883a902a2535f6 Author: Adrian Hunter AuthorDate: Wed, 3 Jun 2015 10:39:46 +0300 Committer: Thomas Gleixner CommitDate: Mon, 6 Jul 2015 09:41:00 +0200 x86/tsc: Let high latency PIT fail fast in quick_pit_calibrate() If it takes longer than 12us to read the PIT counter lsb/msb, then the error margin will never fall below 500ppm within 50ms, and Fast TSC calibration will always fail. This patch detects when that will happen and fails fast. Note the failure message is not printed in that case because: 1. it will always happen on that class of hardware 2. the absence of the message is more informative than its presence Signed-off-by: Adrian Hunter Cc: Andy Lutomirski Cc: Linus Torvalds Cc: Len Brown Cc: Andi Kleen Link: http://lkml.kernel.org/r/556EB717.9070607@intel.com Signed-off-by: Thomas Gleixner --- arch/x86/kernel/tsc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 5054497..7437b41 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -598,10 +598,19 @@ static unsigned long quick_pit_calibrate(void) if (!pit_expect_msb(0xff-i, &delta, &d2)) break; + delta -= tsc; + + /* + * Extrapolate the error and fail fast if the error will + * never be below 500 ppm. + */ + if (i == 1 && + d1 + d2 >= (delta * MAX_QUICK_PIT_ITERATIONS) >> 11) + return 0; + /* * Iterate until the error is less than 500 ppm */ - delta -= tsc; if (d1+d2 >= delta >> 11) continue; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/