mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
	LKML <linux-kernel@vger.kernel.org>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	Alok Kataria <akataria@vmware.com>, Michael Buesch <mb@bu3sch.de>
Subject: Re: Regression in 2.6.27 caused by commit bfc0f59
Date: Mon, 1 Sep 2008 20:35:57 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.1.10.0809012033280.3210@nehalem.linux-foundation.org> (raw)
In-Reply-To: <alpine.LFD.1.10.0809012015160.12958@nehalem.linux-foundation.org>



On Mon, 1 Sep 2008, Linus Torvalds wrote:
> 
> Well, the biggest problem is actually _detection_.
> 
> We have three different timers, and they all have their own problems. How 
> do you reliably detect which one to use? The PM_TIMER clearly is _not_ 
> always the answer here, but the code just assumes it is!

On the machine you have trouble with the PIT on, does this thing trigger?

If it does, that could be a simple way to say whether you prefer PM_TIMER 
over PIT.

For me, even on a modern machine, I get a pit_count of 46321, which 
matches the "about one microsecond for an ISA/LPC read" timing pretty 
well. What do you get? 

		Linus

---
 arch/x86/kernel/tsc.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 8e786b0..7cf7543 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -131,6 +131,7 @@ unsigned long native_calibrate_tsc(void)
 	u64 tsc1, tsc2, tr1, tr2, delta, pm1, pm2, hpet1, hpet2;
 	int hpet = is_hpet_enabled();
 	unsigned int tsc_khz_val = 0;
+	unsigned int pit_count;
 
 	local_irq_save(flags);
 
@@ -142,7 +143,9 @@ unsigned long native_calibrate_tsc(void)
 	outb((CLOCK_TICK_RATE / (1000 / 50)) & 0xff, 0x42);
 	outb((CLOCK_TICK_RATE / (1000 / 50)) >> 8, 0x42);
 	tr1 = get_cycles();
-	while ((inb(0x61) & 0x20) == 0);
+	pit_count = 0;
+	while ((inb(0x61) & 0x20) == 0)
+		pit_count++;
 	tr2 = get_cycles();
 
 	tsc2 = tsc_read_refs(&pm2, hpet ? &hpet2 : NULL);
@@ -150,6 +153,18 @@ unsigned long native_calibrate_tsc(void)
 	local_irq_restore(flags);
 
 	/*
+	 * We should have waited for about 50ms, and a real hardware
+	 * PIT access _should_ take about a microsecond even if it's
+	 * over an ISA bus (or something that tries to emulate timings).
+	 *
+	 * So pit_count should be 50,000+. If it's a lot lower, that
+	 * implies it might be some emulated device rather than real
+	 * hardware..
+	 */
+	if (pit_count < 25000)
+		printk("Slow PIT device (%u) - emulated using SMI?\n", pit_count);
+
+	/*
 	 * Preset the result with the raw and inaccurate PIT
 	 * calibration value
 	 */

  reply	other threads:[~2008-09-02  3:36 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-31 22:54 Larry Finger
2008-09-01 11:14 ` Thomas Gleixner
2008-09-01 15:37   ` Larry Finger
2008-09-01 17:49     ` Thomas Gleixner
2008-09-01 17:44   ` Larry Finger
2008-09-01 18:31     ` Thomas Gleixner
2008-09-01 19:10       ` Linus Torvalds
2008-09-01 20:07         ` Thomas Gleixner
2008-09-01 21:30           ` Thomas Gleixner
2008-09-01 22:02           ` Linus Torvalds
2008-09-01 22:33             ` Thomas Gleixner
2008-09-01 22:56               ` Linus Torvalds
2008-09-01 23:24                 ` Thomas Gleixner
2008-09-02  6:37                   ` Andi Kleen
2008-09-02 12:21                     ` Thomas Gleixner
2008-09-01 22:16           ` Linus Torvalds
2008-09-01 23:16             ` Thomas Gleixner
2008-09-02  3:18               ` Linus Torvalds
2008-09-02  3:35                 ` Linus Torvalds [this message]
2008-09-02  4:54                   ` Larry Finger
2008-09-02  9:17                   ` Alan Cox
2008-09-02 12:15                   ` Thomas Gleixner
2008-09-02 15:09                     ` Linus Torvalds
2008-09-02 18:14                       ` Thomas Gleixner
2008-09-02 18:41                         ` Alok Kataria
2008-09-02 21:16                           ` Thomas Gleixner
2008-09-02 18:42                         ` Linus Torvalds
2008-09-02 21:13                           ` Thomas Gleixner
2008-09-02 22:21                             ` Linus Torvalds
2008-09-02 23:10                               ` Thomas Gleixner
2008-09-03  1:49                                 ` Linus Torvalds
2008-09-02 22:54                           ` [PATCH] Fix TSC calibration issues Thomas Gleixner
2008-09-03  2:14                             ` Linus Torvalds
2008-09-03  9:11                               ` Thomas Gleixner
2008-09-04  1:14                                 ` Alok Kataria
2008-09-04  2:56                                   ` Linus Torvalds
2008-09-04  3:16                                     ` Arjan van de Ven
2008-09-04  3:59                                       ` Linus Torvalds
2008-09-04  4:10                                         ` Arjan van de Ven
2008-09-04  4:20                                           ` Linus Torvalds
2008-09-04  4:27                                             ` Arjan van de Ven
2008-09-04  4:25                                         ` Willy Tarreau
2008-09-04  4:53                                           ` Linus Torvalds
2008-09-04  5:09                                             ` Willy Tarreau
2008-09-04  1:18                                 ` [PATCH] Change warning message in TSC calibration Alok Kataria
2008-09-03  2:51                             ` [PATCH] Fix TSC calibration issues Larry Finger
2008-09-03  4:00                               ` Linus Torvalds
2008-09-03  4:34                                 ` Larry Finger
2008-09-05 13:45                       ` Regression in 2.6.27 caused by commit bfc0f59 Mark Lord
2008-09-02 17:17                 ` Bill Davidsen
2008-09-01 19:36       ` Larry Finger
2008-09-01 20:09         ` Thomas Gleixner
2008-09-01 20:23           ` Larry Finger
2008-09-01 20:45             ` Thomas Gleixner
2008-09-01 18:42     ` Linus Torvalds
2008-09-01 19:08       ` Thomas Gleixner

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=alpine.LFD.1.10.0809012033280.3210@nehalem.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=Larry.Finger@lwfinger.net \
    --cc=akataria@vmware.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mb@bu3sch.de \
    --cc=rjw@sisk.pl \
    --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

Powered by JetHome