linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: lkml <linux-kernel@vger.kernel.org>, linux-mm@kvack.org, vojtech@suse.cz
Subject: [PATCH] use-tsc-for-delay_pmtmr.patch
Date: Fri, 23 Jan 2004 16:26:57 -0800	[thread overview]
Message-ID: <1074904017.12446.159.camel@localhost> (raw)
In-Reply-To: <1074886056.12447.36.camel@localhost>

On Fri, 2004-01-23 at 11:27, john stultz wrote:
> If that is going to cause problems, then we'll need to pull out the
> use-pmtmr-for-delay_pmtmr patch. I guess our only option is then to use
> the TSC for delay_pmtrm() (as a loop based delay fails in other cases).
> I'll write that up and send it your way, Andrew. 

Andrew, 
	Here's the patch to replace use-pmtmr-for-delay_pmtmr. It simply uses
the TSC for delay_pmtmr much as delay_tsc does.  The only gottcha is
that __delay will be affected by cpu-frequency changes (much as the
existing loop based delay) until I hook in the cpufreq notificaiton into
the ACPI PM timesource code. I'll get to that issue early next week
(sorry, I had a few other things I had to finish today). 
Let me know if this solves the APIC trouble on your system and if so,
I'd be interested to see how it works in -mm. 

thanks
-john

diff -Nru a/arch/i386/kernel/timers/timer_pm.c b/arch/i386/kernel/timers/timer_pm.c
--- a/arch/i386/kernel/timers/timer_pm.c	Fri Jan 23 13:57:38 2004
+++ b/arch/i386/kernel/timers/timer_pm.c	Fri Jan 23 13:57:38 2004
@@ -73,6 +73,10 @@
 	if (!pmtmr_ioport)
 		return -ENODEV;
 
+	/* we use the TSC for delay_pmtmr, so make sure it exists */
+	if (!cpu_has_tsc)
+		return -ENODEV;
+
 	/* "verify" this timing source */
 	value1 = read_pmtmr();
 	for (i = 0; i < 10000; i++) {
@@ -173,23 +177,16 @@
 	return ret;
 }
 
-static void delay_pmtmr(unsigned long total_loops)
+static void delay_pmtmr(unsigned long loops)
 {
-	u32 then, now;
-	unsigned long loops;
+	unsigned long bclock, now;
 	
-	do{
-		if (total_loops > ACPI_PM_MASK)
-			loops = ACPI_PM_MASK;
-		else
-			loops =  total_loops;
-		total_loops -= loops;
-		
-		then = read_pmtmr();
-		do{ 
-			now = read_pmtmr();
-		} while (((now - then)&ACPI_PM_MASK) < loops);
-	} while (total_loops);
+	rdtscl(bclock);
+	do
+	{
+		rep_nop();
+		rdtscl(now);
+	} while ((now-bclock) < loops);
 }
 
 


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

  parent reply	other threads:[~2004-01-24  0:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-23  9:37 2.6.2-rc1-mm2 Andrew Morton
2004-01-23 13:30 ` 2.6.2-rc1-mm2 Thomas Schlichter
2004-01-23 17:59   ` 2.6.2-rc1-mm2 john stultz
2004-01-23 15:12 ` 2.6.2-rc1-mm2 Ed Tomlinson
2004-01-23 18:43   ` 2.6.2-rc1-mm2 Andrew Morton
2004-01-24  0:46     ` 2.6.2-rc1-mm2 Ed Tomlinson
2004-01-23 16:01 ` keyboard and USB problems (Re: 2.6.2-rc1-mm2) Rudo Thomas
2004-01-23 16:19   ` Vojtech Pavlik
2004-01-23 18:46     ` Andrew Morton
2004-01-23 22:16       ` More timer/bogomip damage (was " Valdis.Kletnieks
2004-01-23 19:27     ` john stultz
2004-01-23 19:54       ` Vojtech Pavlik
2004-01-23 20:15         ` john stultz
2004-01-23 21:10           ` Vojtech Pavlik
2004-01-24  0:26       ` john stultz [this message]
2004-01-23 17:08 ` 2.6.2-rc1-mm2 (compile stats) John Cherry

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=1074904017.12446.159.camel@localhost \
    --to=johnstul@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=vojtech@suse.cz \
    /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