public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@hp.com>
To: linux-ia64@vger.kernel.org
Subject: RE: [PATCH] more robust halt_light
Date: Wed, 03 Mar 2004 22:31:08 +0000	[thread overview]
Message-ID: <1078353068.2480.74.camel@patsy.fc.hp.com> (raw)
In-Reply-To: <1078336640.2480.37.camel@patsy.fc.hp.com>


   Bjorn pointed out that the existing enable/disable_hlt routines that
I copied from the other archs are rather racey.  Here's a new version
that uses atomic ops to avoid that.  Original patch description below.

  This patch adds some i386-ish enable/disable features to the
pal_halt_light cpu idle implementation as well as tries to avoid bad
interactions with certain revs of PAL on McKinley cpus.  Hopefully this
will provide enough flexibility that we can leave it configured on in
the kernel by default.  My latest measurements on a 1.3GHz rx2600 show
that enabling pal_halt_light in the cpu_idle routine saves 23W/cpu on an
idle system.

Thanks,

	Alex

-- 
Alex Williamson                             HP Linux & Open Source Lab

=== arch/ia64/kernel/process.c 1.51 vs edited ==--- 1.51/arch/ia64/kernel/process.c	Sat Feb 28 03:02:47 2004
+++ edited/arch/ia64/kernel/process.c	Wed Mar  3 14:58:24 2004
@@ -39,6 +39,8 @@
 
 #include "sigframe.h"
 
+static atomic_t hlt_counter = ATOMIC_INIT(0);
+
 void (*ia64_mark_idle)(int);
 
 
@@ -159,6 +161,20 @@
 		ia64_do_signal(oldset, scr, in_syscall);
 }
 
+void disable_hlt(void)
+{
+	atomic_inc(&hlt_counter);
+}
+
+EXPORT_SYMBOL(disable_hlt);
+
+void enable_hlt(void)
+{
+	atomic_dec(&hlt_counter);
+}
+
+EXPORT_SYMBOL(enable_hlt);
+
 /*
  * We use this if we don't have any better idle routine..
  */
@@ -166,7 +182,7 @@
 default_idle (void)
 {
 #ifdef CONFIG_IA64_PAL_IDLE
-	if (!need_resched())
+	if (!atomic_read(&hlt_counter) && local_cpu_data->hlt_works_ok && !need_resched())
 		safe_halt();
 #endif
 }
=== arch/ia64/kernel/setup.c 1.68 vs edited ==--- 1.68/arch/ia64/kernel/setup.c	Mon Jan 19 16:38:10 2004
+++ edited/arch/ia64/kernel/setup.c	Wed Mar  3 15:09:39 2004
@@ -76,6 +76,10 @@
 
 unsigned char aux_device_present = 0xaa;        /* XXX remove this when legacy I/O is gone */
 
+#ifdef CONFIG_IA64_PAL_IDLE
+static unsigned char nohlt;
+#endif
+
 /*
  * The merge_mask variable needs to be set to (max(iommu_page_size(iommu)) - 1).  This
  * mask specifies a mask of address bits that must be 0 in order for two buffers to be
@@ -429,13 +433,20 @@
 		   "revision   : %u\n"
 		   "archrev    : %u\n"
 		   "features   :%s\n"	/* don't change this---it _is_ right! */
+#ifdef CONFIG_IA64_PAL_IDLE
+		   "halt works : %s\n"
+#endif
 		   "cpu number : %lu\n"
 		   "cpu regs   : %u\n"
 		   "cpu MHz    : %lu.%06lu\n"
 		   "itc MHz    : %lu.%06lu\n"
 		   "BogoMIPS   : %lu.%02lu\n\n",
 		   cpunum, c->vendor, family, c->model, c->revision, c->archrev,
-		   features, c->ppn, c->number,
+		   features,
+#ifdef CONFIG_IA64_PAL_IDLE
+		   c->hlt_works_ok ? "yes" : "no",
+#endif
+		   c->ppn, c->number,
 		   c->proc_freq / 1000000, c->proc_freq % 1000000,
 		   c->itc_freq / 1000000, c->itc_freq % 1000000,
 		   lpj*HZ/500000, (lpj*HZ/5000) % 100);
@@ -523,6 +534,31 @@
 	}
 	c->unimpl_va_mask = ~((7L<<61) | ((1L << (impl_va_msb + 1)) - 1));
 	c->unimpl_pa_mask = ~((1L<<63) | ((1L << phys_addr_size) - 1));
+
+#ifdef CONFIG_IA64_PAL_IDLE
+	if (!nohlt) {
+
+		c->hlt_works_ok = 1;
+
+#ifdef CONFIG_PERFMON
+		/*
+		 * McKinley has a PAL that in some revisions that doesn't
+		 * behave well with the PMU.  The belief is PAL >= 7.64 will
+		 * fix the problem.
+		 */
+		if (c->family = 0x1f && c->model = 0) {
+			pal_version_u_t min_ver, cur_ver;
+
+			if (ia64_pal_version(&min_ver, &cur_ver) = 0) {
+
+				if (cur_ver.pal_version_s.pv_pal_b_model <= 0x7 &&
+				    cur_ver.pal_version_s.pv_pal_b_rev < 0x64)
+					c->hlt_works_ok = 0;
+			}
+		}
+#endif
+	}
+#endif
 }
 
 void
@@ -674,3 +710,14 @@
 	ia64_patch_mckinley_e9((unsigned long) __start___mckinley_e9_bundles,
 			       (unsigned long) __end___mckinley_e9_bundles);
 }
+
+#ifdef CONFIG_IA64_PAL_IDLE
+static int __init no_halt(char *s)
+{
+	local_cpu_data->hlt_works_ok = 0;
+	nohlt = 1;
+	return 1;
+}
+
+__setup("no-hlt", no_halt);
+#endif
=== include/asm-ia64/processor.h 1.56 vs edited ==--- 1.56/include/asm-ia64/processor.h	Wed Feb 25 15:46:40 2004
+++ edited/include/asm-ia64/processor.h	Wed Mar  3 09:12:46 2004
@@ -180,6 +180,9 @@
 #ifdef CONFIG_NUMA
 	struct ia64_node_data *node_data;
 #endif
+#ifdef CONFIG_IA64_PAL_IDLE
+	__u8 hlt_works_ok;
+#endif
 };
 
 DECLARE_PER_CPU(struct cpuinfo_ia64, cpu_info);



  parent reply	other threads:[~2004-03-03 22:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-03 17:57 [PATCH] more robust halt_light Alex Williamson
2004-03-03 20:38 ` Seth, Rohit
2004-03-03 21:08 ` Alex Williamson
2004-03-03 22:31 ` Alex Williamson [this message]
2004-03-03 22:45 ` David Mosberger
2004-03-03 22:56 ` Jesse Barnes
2004-03-03 23:35 ` Grant Grundler
2004-03-04  2:40 ` Seth, Rohit
2004-03-04  2:48 ` Seth, Rohit
2004-03-04 15:47 ` Alex Williamson
2004-03-04 17:16 ` Jesse Barnes
2004-03-04 17:17 ` Jesse Barnes

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=1078353068.2480.74.camel@patsy.fc.hp.com \
    --to=alex.williamson@hp.com \
    --cc=linux-ia64@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox