public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Andres Salomon <dilinger@queued.net>, x86@kernel.org
Cc: linux-kernel@vger.kernel.org, Marcelo Tosatti <marcelo@kvack.org>,
	stable@vger.kernel.org
Subject: [PATCH] Fix Geode LX timekeeping in generic build
Date: Wed, 16 Sep 2015 14:10:03 +0100	[thread overview]
Message-ID: <1442409003.131189.87.camel@infradead.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 3306 bytes --]

In 2007, commit 07190a08eef36 ("Mark TSC on GeodeLX reliable") bypassed
verification of the TSC on Geode LX. However, this code (now in the
check_system_tsc_reliable() function in arch/x86/kernel/tsc.c) was only
present if CONFIG_MGEODE_LX was set. 

OpenWRT has recently started building its generic Geode target for
Geode GX, not LX, to include support for additional platforms. This
broke the timekeeping on LX-based devices, because the TSC wasn't
marked as reliable: https://dev.openwrt.org/ticket/20531

By adding a runtime check on is_geode_lx(), we can also include the fix
if CONFIG_MGEODEGX1 or CONFIG_X86_GENERIC are set, thus fixing the
problem.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Cc: stable@vger.kernel.org
---
I'm slightly concerned about bypassing verification though, when the
reason I *noticed* this issue is because the verification *failed*:

[    8.893307] xt_time: kernel timezone is -0000                                
[   14.522754] clocksource: timekeeping watchdog: Marking clocksource 'tsc' as unstable because the skew is too large:                                          
[   14.555090] clocksource:                       'pit' wd_now: eba5b2f7 wd_last: eb9ca2c8 mask: ffffffff                                                       
[   14.564406] clocksource:                       'tsc' cs_now: 29eb8ba17 cs_last: 28c61a5f6 mask: ffffffffffffffff                                             
[   14.598508] clocksource: Switched to clocksource pit  

If the bypass is supposed to be just an optimisation, surely this means
there's something else wrong? Or that bypassing the validation wasn't
the right thing to do in the first place?

FWIW the clock *does* run correctly if using the TSC, after applying
this patch. If I let it fall back to the PIT, it gains time wildly.

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 7437b41..dc9af7a 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -21,6 +21,7 @@
 #include <asm/hypervisor.h>
 #include <asm/nmi.h>
 #include <asm/x86_init.h>
+#include <asm/geode.h>
 
 unsigned int __read_mostly cpu_khz;	/* TSC clocks / usec, not used here */
 EXPORT_SYMBOL(cpu_khz);
@@ -1013,15 +1014,17 @@ EXPORT_SYMBOL_GPL(mark_tsc_unstable);
 
 static void __init check_system_tsc_reliable(void)
 {
-#ifdef CONFIG_MGEODE_LX
-	/* RTSC counts during suspend */
+#if defined(CONFIG_MGEODEGX1) || defined(CONFIG_MGEODE_LX) || defined(CONFIG_X86_GENERIC)
+	if (is_geode_lx()) {
+		/* RTSC counts during suspend */
 #define RTSC_SUSP 0x100
-	unsigned long res_low, res_high;
+		unsigned long res_low, res_high;
 
-	rdmsr_safe(MSR_GEODE_BUSCONT_CONF0, &res_low, &res_high);
-	/* Geode_LX - the OLPC CPU has a very reliable TSC */
-	if (res_low & RTSC_SUSP)
-		tsc_clocksource_reliable = 1;
+		rdmsr_safe(MSR_GEODE_BUSCONT_CONF0, &res_low, &res_high);
+		/* Geode_LX - the OLPC CPU has a very reliable TSC */
+		if (res_low & RTSC_SUSP)
+			tsc_clocksource_reliable = 1;
+	}
 #endif
 	if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE))
 		tsc_clocksource_reliable = 1;



-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation


[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5691 bytes --]

             reply	other threads:[~2015-09-16 13:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16 13:10 David Woodhouse [this message]
2015-09-16 14:03 ` [tip:x86/urgent] x86/platform: Fix Geode LX timekeeping in the generic x86 build tip-bot for David Woodhouse

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=1442409003.131189.87.camel@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=dilinger@queued.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@kvack.org \
    --cc=stable@vger.kernel.org \
    --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