All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard James <richard@techdrive.com.au>
To: linux-kernel@vger.kernel.org
Subject: Updated Ross Dickson C1Halt patch for 2.6.5
Date: Wed, 07 Apr 2004 17:16:53 +1000	[thread overview]
Message-ID: <4073AAE5.2010005@techdrive.com.au> (raw)

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

This patch works against kernel 2.6.5 as it did for 2.6.3. If you try 
and turn APIC off in settings then the kernel will crash at compile 
because of his C1halt function. I'm not sure how to fix that. I forgot 
to record the compile error as well. To use it you need to send 
idle=C1patch to the kernel at boot and their needs to be a way so that 
you can instead select this from the config menu and toggle it on and 
off with the APIC controls.

Richard James :)

[-- Attachment #2: nforce2-idleC1halt-rd-2.6.5.patch --]
[-- Type: text/plain, Size: 2207 bytes --]

--- process.c.origional	2004-04-06 19:14:01.000000000 +1000
+++ process.c	2004-04-06 19:13:44.000000000 +1000
@@ -50,6 +50,7 @@
 #include <asm/math_emu.h>
 #endif
 
+#include <asm/apic.h>
 #include <linux/irq.h>
 #include <linux/err.h>
 
@@ -88,7 +89,7 @@ EXPORT_SYMBOL(enable_hlt);
  * We use this if we don't have any better
  * idle routine..
  */
-void default_idle(void)
+static void default_idle(void)
 {
 	if (!hlt_counter && current_cpu_data.hlt_works_ok) {
 		local_irq_disable();
@@ -99,6 +100,28 @@ void default_idle(void)
 	}
 }
 
+ /*
+ * We use this to avoid nforce2 lockups
+ * Reduces frequency of C1 disconnects
+ */
+static void c1halt_idle(void)
+{
+	if (!hlt_counter && current_cpu_data.hlt_works_ok) {
+		local_irq_disable();
+		/* only hlt disconnect if more than 1.6% of apic interval remains */
+		if( (!need_resched()) &&
+			(apic_read(APIC_TMCCT) > (apic_read(APIC_TMICT)>>6))) {
+			ndelay(600); /* helps nforce2 but adds 0.6us hard int latency */
+			safe_halt();  /* nothing better to do until we wake up */
+		}
+		else
+			local_irq_enable();
+	}
+}
+
+
+
+
 /*
  * On SMP it's slightly faster (but much more power-consuming!)
  * to poll the ->work.need_resched flag instead of waiting for the
@@ -137,16 +160,14 @@ static void poll_idle (void)
  * low exit latency (ie sit in a loop waiting for
  * somebody to say that they'd like to reschedule)
  */
+static void (*idle)(void);
 void cpu_idle (void)
 {
 	/* endless idle loop with no priority at all */
 	while (1) {
 		while (!need_resched()) {
-			void (*idle)(void) = pm_idle;
-
 			if (!idle)
-				idle = default_idle;
-
+				idle = pm_idle ? pm_idle : default_idle;
 			irq_stat[smp_processor_id()].idle_timestamp = jiffies;
 			idle();
 		}
@@ -201,10 +222,13 @@ static int __init idle_setup (char *str)
 {
 	if (!strncmp(str, "poll", 4)) {
 		printk("using polling idle threads.\n");
-		pm_idle = poll_idle;
+		idle = poll_idle;
 	} else if (!strncmp(str, "halt", 4)) {
 		printk("using halt in idle threads.\n");
-		pm_idle = default_idle;
+	  idle = default_idle;
+	} else if (!strncmp(str, "C1halt", 6)) {
+		printk("using C1 halt disconnect friendly idle threads.\n");
+		idle = c1halt_idle;
 	}
 
 	return 1;

             reply	other threads:[~2004-04-07  7:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-07  7:16 Richard James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-04-07 16:58 Updated Ross Dickson C1Halt patch for 2.6.5 Ross Dickson
2004-04-10 20:05 Alex Davis

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=4073AAE5.2010005@techdrive.com.au \
    --to=richard@techdrive.com.au \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.