Skip to contentSkip to conversation

amd76x_pm: C3 powersaving for AMD K7

PATCH In review Joerg Sommrey 4 participants 4 messages Jan 31, 2006 – Feb 1, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amd76x_pm: C3 powersaving for AMD K7

This is a processor idle module for AMD SMP 760MP(X) based systems. The patch was originally written by Tony Lindgren and has been around since 2002. It enables C2 mode on AMD SMP systems and thus saves about 70 - 90 W of energy in the idle mode compared to the default idle mode. The idle function has been rewritten and is now free of locking issues and is independent from the number of CPUs. The impact from this module on the system clock and on i/o transfer are now fairly low.

This patch can also be found at
http://www.sommrey.de/amd76x_pm/amd76x_pm-2.6.15-4.patch

In this version more locking was added to make sure all or no CPU enter C3 mode.

Documentation/amd76x_pm.txt +330 -0
diff -Nru linux-2.6.15/Documentation/amd76x_pm.txt linux-2.6.15-jo/Documentation/amd76x_pm.txt
@@ -0,0 +1,330 @@
+	ACPI style power management for SMP AMD-760MP(X) based systems
+	==============================================================
+
+The ACPI project started to support C3 for SMP.  This doesn't work for
+me yet, so there still is a need for a special module dealing with
+AMD-760MP(X) systems.
+
+Using this module saves about 70 - 90W of energy in the idle mode compared
+to the default idle mode. Waking up from the idle mode is fast to keep the
+system response time good. 
+
+This code runs on two-way AMD boxes at the moment, but the basic idling
+algorithm is independent of the number of CPUs.
+
+Known issues:
+-------------
+- Currently there's a bug somewhere where the reading the
+  P_LVL2 for the first time causes the system to sleep instead of 
+  idling. This means that you need to hit the power button once to
+  wake the system after loading the module for the first time after
+  reboot. After that the system idles as supposed.
+  (Only observed on Tony's system - AMD766.)
+
+- On kernel up to and including 2.6.13 there might appear a weird
+  keyboard repeating after an uptime of 1-2 days.  This seems to
+  coincide with IRQ 0 being routed to CPU1: setting smp_affinity to 1 for
+  IRQ 0 soon after booting circumvents the problem.  On 2.6.14 interrupt
+  routing has changed and I didn't watch the problem anymore.
+
+- There might be reduced throughput of disk or network devices.  See
+  below for how to configure the "irq rate watcher" to avoid this.
+
+- Occasional hard lockups might be caused by amd76x_pm.  I'm still working
+  on this issue.
+
+- I have reports about a buzzing sound from the mainboard when amd76x_pm
+  is loaded and some reports about unclean audio playback.
+
+Influenced by Vcool, and LVCool. Rewrote everything from scratch to
+use the PCI features in Linux, and to support SMP systems.
+
+Currently tested amongst others on a TYAN S2460 (760MP) system (Tony), an
+ASUS A7M266-D (760MPX) system (Johnathan) and a TYAN S2466 (760MPX)
+system (Jo). Adding support for other Athlon SMP or single processor
+systems should be easy if desired.  
+
+The file /sys/devices/pci0000:00/0000:00:00.0/C3_cnt shows the number of
+C3 calls since module load.
+
+There are some parameters for tuning the behaviour of amd76x_pm:
+lazy_idle, spin_idle, watch_irqs, watch_int and min_C1
+
+lazy_idle and spin_idle are closely related:
+
+- lazy_idle defines the number of idle calls into amd76x_smp_idle that are
+  needed to *enable* C3 mode.  This parameter is the maximum loop counter
+  for an outer loop with interrupts enabled that guarantees low latencies. 
+  The default for lazy_idle is 512.
+
+- spin_idle defines the maximum number of spin cycles in an inner idle loop
+  where one CPU waits for all others to get into C3-enabled mode. When all
+  CPUs are in C2-enable mode they (more ore less) simultaneously *enter* C3
+  mode. In this inner loop interrupts are disabled.  The loop is left
+  immediatly if there is something waiting to be scheduled.  The default
+  for spin_idle is 4*lazy_idle.
+
+lazy_idle and spin_idle define a "rubber measure" for the idling
+behaviour: lazy_idle defines the minimum "idling" needed to enter C3 and
+spin_idle defines when to give up.
+
+Low values for lazy_idle and high values for spin_idle give better
+cooling.  Higher values for lazy_idle simply give less cooling.  spin_idle
+is a kind of emergency break to leave C3-enable mode if CPUs don't
+synchronize.
+
+irq rate watcher:
+-----------------
+Interrupts are disabled in C3 mode.  The CPUs are woken up by timer
+interrups, by NMIs and some other events.  This causes a high interrupt
+latency for other interrupts that leads to a significant reduction in io
+or network throughput.  There has been introduced a "irq rate watcher" to
+get rid of this issue.  If the irq rate watcher detects that an interrupt
+has a rate above a given limit, C3 idling is disabled and a low latency C1
+idling mode is used instead. The parameters watch_irqs, watch_int and
+min_C1 control this irq rate watcher:
+
+- watch_irqs defines which interrupts are to be watched and optionally
+  at which interrupt rate C3 mode shall be disabled.  The syntax for 
+  watch_irqs is irq1[:rate1],irq2[:rate2],...  The rate is measured in
+  interrupts per second and defaults to 128.  There is no default for
+  watch_irqs.  To enable the irq rate watcher you must specify this
+  parameter.  Enter the interrupts used by disk controllers or network
+  adapters here.
+  
+- watch_int defines the time interval (in milliseconds) at which the
+  interrupt rate is checked.  Too low values may result in an overhead
+  and too high values cause the C1 mode to "kick in" later.  The default
+  for watch_int is 1 second.
+
+- min_C1 defines the mininum number of check intervals with low
+  interrupt rates that are needed to leave the forced C1 mode.
+
+All parameters lazy_idle, spin_idle, watch_irqs and watch_int may be
+given as module parameters to amd76x_pm.  Furthermore, they may be
+queried or changed via their sysfs entries in
+/sys/module/amd76x_pm/parameters.  (The location in sysfs has changed
+from earlier versions!)
+
+Setting watch_int to zero or removing all interrupts from watch_irqs
+causes the irq rate watcher to stop.  The module needs to be reloaded to
+start the watcher again.
+
+NB: In the past there was a major impact from amd76x_pm on the system
+clock stability.  At least on my box this effect has been reduced
+noticable.  This is caused by two changes:
+
+- The redesign of the idle function lead to a reduced time spent in
+  amd76x_smp_idle() and this propably caused lower latencies.
+  
+- The introduction of the irq rate watcher significantly reduced
+  latencies under load.
+
+Some hints on tuning lazy_idle and spin_idle:
+Watch the rate of C3 calls per second.  Anything below HZ seems to be
+completely useless.  Start with a moderate low value for lazy_idle, e.g.
+2^5 and a very high value for spin_idle, e.g. 2^20.  Then double lazy_idle
+until you see a significant increase in core temperature or a reduction
+of the C3 rate.  Go back to the last "good" value.  Then halve spin_idle
+until you see a decrease in C3 rate or a raising core temperature again
+and go back to the previous value.  There's a small program c3rate.c
+attached at the end of this file that you may use to watch the C3 rate.
+The rtc driver must be enabled to use it.
+
+If you want to play around in this field: There is a different version
+of amd76x_pm.c that has experimental und untested support for "normal
+throttling" and "power on suspend".  See http://www.sommrey.de/amd76x_pm
+
+This software is licensed under GNU General Public License Version 2 
+as specified in file COPYING in the Linux kernel source tree main 
+directory.
+
+Copyright (C) 2002		Johnathan Hicks <[email protected]>
+				Tony Lindgren <[email protected]>
+
+Copyright (C) 2005 - 2006	Joerg Sommrey <[email protected]>
+
+History:
+
+  20020702 - amd-smp-idle: Tony Lindgren <[email protected]>
+Influenced by Vcool, and LVCool. Rewrote everything from scratch to
+use the PCI features in Linux, and to support SMP systems. Provides
+C2 idling on SMP AMD-760MP systems.
+
+  20020722: JH
+  	I adapted Tony's code for the AMD-765/766 southbridge and adapted it
+  	according to the AMD-768 data sheet to provide the same capability for
+  	SMP AMD-760MPX systems. Posted to acpi-devel list.
+  	
+  20020722: Alan Cox
+  	Replaces non-functional amd76x_pm code in -ac tree.
+  	
+  20020730: JH
+  	Added ability to do normal throttling (the non-thermal kind), C3 idling
+  	and Power On Suspend (S1 sleep). It would be very easy to tie swsusp
+  	into activate_amd76x_SLP(). C3 idling doesn't happen yet; see my note
+  	in amd76x_smp_idle(). I've noticed that when NTH and idling are both
+  	enabled, my hardware locks and requires a hard reset, so I have
+  	#ifndefed around the idle loop setting to prevent this. POS locks it up
+  	too, both ought to be fixable. I've also noticed that idling and NTH
+  	make some interference that is picked up by the onboard sound chip on
+  	my ASUS A7M266-D motherboard.
+
+  20030601: Pasi Savolainen
+     Simple port to 2.5
+     Added sysfs interface for making nice graphs with mrtg.
+     Look for /sys/devices/pci0/00:00.0/C2_cnt & lazy_idle (latter writable)
+
+  20050601: Joerg Sommrey (jo)
+     2.6 stuff
+     redesigned amd76x_smp_idle.  The algorithm is basically the same
+        but the implementation has changed.  This part is now independent
+        from the number of CPUs and data is locked against concurrent
+        updates from different CPUs.
+     use _smp_processor_id()
+     use cpu_idle_wait()
+     NTH and POS code not touched and not tested.
+
+  20050621: jo
+     separated C3, NTH and POS code into extra patch
+
+  20050812: jo
+     rewritten amd76x_smp_idle completely. It's much simpler now but
+     does a good job - the KISS approach.  Introduced a new tunable
+     spin_idle.
+
+  20050819: jo
+     new irq rate watcher task that forces C1-idling if irq-rate exceeds a
+     given limit.
+
+  20050820: jo
+     make all modules parameters r/w in sysfs.
+
+  20050906: jo
+     avoid some local_irq_disable/enable
+
+  20060108: jo
+     using percpu-variables
+
+  20060110: jo
+     eliminated a race condition in the idle loop.  Thanks to Arjan van
+     de Ven, who pointed to this issue.
+  
+  20060121: jo
+     Switched from C2 to C3 idling, inspired by processor_idle.c
+     C2 idling has just been replaced by C3 idling, there is no C2/C3
+     transition.
+     Restoring all touched northbridge and southbridge register bits to
+     their original values on module unload.
+
+  20060129: jo
+     Major redesign of the idle loop again.  Now there is a two-phase
+     process to make sure all or no CPUs go into C3.  In phase one each
+     CPU waits for the other to become idle.  In phase two all CPUs come
+     to an agreement about going C3 or not.  Now using spinlocks.
+     Simplicity has gone :-(
+
+---- c3rate.c ---- snip here ----------------------------------------
+#include <stdlib.h>
+#include <stdio.h>
+#include <linux/rtc.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+#define C3_CNT "/sys/devices/pci0000:00/0000:00:00.0/C3_cnt"
+int fd;
+
+void
+disable_rtc(void) {
+	int retval;
+	/* Disable alarm interrupts */
+	retval = ioctl(fd, RTC_UIE_OFF, 0);
+	if (retval == -1) {
+		perror("ioctl(RTC_UIE_OFF)");
+		_exit(errno);
+	}
+	close(fd);
+}
+
+int
+main(int argc, char **argv)
+{
+	int retval;
+	unsigned long data;
+	char idlebuffer[64];
+	int idlefd;
+	ssize_t bytes;
+	unsigned long  lastcount;
+	unsigned long  irqcount;
+	unsigned long c3_old, c3_new;
+	int rate = 0;
+	int firstloop = 1;
+
+	if(argc > 1)
+		rate = atoi(argv[1]);
+	if (rate <= 0)
+		rate = 16;
+
+	fd = open ("/dev/rtc", O_RDONLY);
+
+	if (fd ==  -1) {
+		perror("/dev/rtc");
+		exit(errno);
+	}
+
+	/* Set the alarm to every second */
+
+	retval = ioctl(fd, RTC_UIE_ON, 0);
+	if (retval == -1) {
+		perror("ioctl(RTC_UIE_ON)");
+		exit(errno);
+	}
+	atexit(disable_rtc);
+
+	irqcount = 0;
+	while (1) {
+		/* This blocks until the alarm ring causes an interrupt */
+		retval = read(fd, &data, sizeof data);
+		if (retval == -1) {
+			perror("read");
+			exit(errno);
+		}
+		if (firstloop) {
+			idlebuffer[0] = '\0';
+			idlefd = open(C3_CNT, O_RDONLY);
+			if (idlefd != -1) {
+				bytes = read(idlefd, idlebuffer, sizeof idlebuffer);
+				close(idlefd);
+				idlebuffer[bytes] = '\0';
+			}
+			c3_old = strtoul(idlebuffer, NULL, 10);
+			firstloop = 0;
+			continue;
+		}
+		lastcount = data >> 8;
+		irqcount += lastcount;
+
+		if (irqcount >= rate) {
+			idlebuffer[0] = '\0';
+			idlefd = open(C3_CNT, O_RDONLY);
+			if (idlefd != -1) {
+				bytes = read(idlefd, idlebuffer, sizeof idlebuffer);
+				close(idlefd);
+				idlebuffer[bytes] = '\0';
+			}
+			c3_new = strtoul(idlebuffer, NULL, 10);
+			printf("%lu\n", (c3_new - c3_old) / irqcount);
+			c3_old = c3_new;
+			irqcount = 0;
+		}
+
+	}
+	
+	return 0;
+
+} /* end main */
+---- c3rate.c ---- snip here ----------------------------------------
drivers/acpi/Kconfig +14 -0
diff -Nru linux-2.6.15/drivers/acpi/Kconfig linux-2.6.15-jo/drivers/acpi/Kconfig
@@ -340,4 +340,18 @@
 		$>modprobe acpi_memhotplug 
 endif	# ACPI
 
+config AMD76X_PM
+        tristate "AMD76x Native Power Management support"
+        default n
+        depends on X86 && PCI
+        ---help---
+          This driver enables Power Management on AMD760MP & AMD760MPX chipsets.
+          This is about same as ACPI C3, which doesn't seem to work on
+          AMD760MPX a.t.m.
+          See Documentation/amd76x_pm.txt for further details.
+
+          Say M here to build a module called amd76x_pm.
+
+          If unsure, say N.
+
 endmenu
drivers/acpi/Makefile +5 -0
diff -Nru linux-2.6.15/drivers/acpi/Makefile linux-2.6.15-jo/drivers/acpi/Makefile
@@ -57,3 +57,8 @@
 obj-$(CONFIG_ACPI_TOSHIBA)	+= toshiba_acpi.o
 obj-y				+= scan.o motherboard.o
 obj-$(CONFIG_ACPI_HOTPLUG_MEMORY)	+= acpi_memhotplug.o
+
+#
+# not really ACPI thing, but closely related
+#
+obj-$(CONFIG_AMD76X_PM)               += amd76x_pm.o
drivers/acpi/amd76x_pm.c +749 -0

749 lines not on this page · raw message

include/linux/amd76x_pm.h +89 -0

89 lines not on this page · raw message

#1 lore raw
Quoted 10 lines · Joerg Sommrey

This is a processor idle module for AMD SMP 760MP(X) based systems.
The patch was originally written by Tony Lindgren and has been around since 2002. It enables C2 mode on AMD SMP systems and thus saves about 70 - 90 W of energy in the idle mode compared to the default idle mode. The idle function has been rewritten and is now free of locking issues and is independent from the number of CPUs. The impact from this module on the system clock and on i/o transfer are now fairly low.

Quoted 7 lines

This patch can also be found at
http://www.sommrey.de/amd76x_pm/amd76x_pm-2.6.15-4.patch

In this version more locking was added to make sure all or no CPU enter C3 mode.

Thanks. I'll merge this into -mm and shall plague the ACPI guys with it. They have said discouraging things about board-specific drivers in the past. We shall see.

Tony, could you please review section 11 of Documentation/SubmittingPatches and if OK, send a Signed-off-by:?

Some minor pointlets, and a bug:

Should CONFIG_AMD76X_PM depend on ACPI?

Quoted 8 lines
drivers/acpi/amd76x_pm.c +8 -0
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/device.h>
+#include <linux/init.h>

drivers/acpi/amd76x_pm.c line 32

Quoted 10 lines
drivers/acpi/amd76x_pm.c +10 -0
+#include <linux/fs.h>
+#include <linux/version.h>
+#include <asm/atomic.h>
+#include <linux/kernel.h>
+#include <linux/workqueue.h>
+#include <linux/jiffies.h>
+#include <linux/kernel_stat.h>
+#include <linux/spinlock.h>
+
+#include <linux/amd76x_pm.h>

We conventionally put <asm> includes after the <linux> includes.

Quoted 1 line

+#define VERSION "20060129"

Driver versions go out of date very quickly once they're merged up.

drivers/acpi/amd76x_pm.c line 38

Quoted 3 lines
drivers/acpi/amd76x_pm.c +3 -0
+// #define AMD76X_LOG_C1 1
+
+extern void default_idle(void);

Please don't put extern declarations in .c. We should find a header file for this. IIRC, it'll need to be arch-specific - default_idle() doesn't have the same prototype on all architectures, or doesn't exist on some, or something. I do recall there were problems.

drivers/acpi/amd76x_pm.c line 47

Quoted 9 lines
drivers/acpi/amd76x_pm.c +9 -0
+static void amd76x_smp_idle(void);
+static int amd76x_pm_main(void);
+
+static unsigned long lazy_idle = 0;
+static unsigned long spin_idle = 0;
+static unsigned long watch_int = 0;
+static unsigned long min_C1 = AMD76X_MIN_C1;
+static unsigned int sb_id = 0;
+static unsigned int nb_id = 0;

Unneeded (and undesirable) initialisation-to-zero.

drivers/acpi/amd76x_pm.c line 113

Quoted 7 lines
drivers/acpi/amd76x_pm.c +7 -0
+static struct idle_stat amd76x_stat __cacheline_aligned_in_smp = {
+	.num_idle = ATOMIC_INIT(0),
+	.lock = SPIN_LOCK_UNLOCKED,
+	.num_prepare = 0,
+	.num_ready = 0,
+	.num_C3 = ATOMIC_INIT(0),
+};

Two unneeded (but harmless) initialisations-to-zero.

drivers/acpi/amd76x_pm.c line 212

Quoted 2 lines
drivers/acpi/amd76x_pm.c +2 -0
+static void
+amd76x_get_PM(void)

We prefer to do

static void amd76x_get_PM(void)

Review

Quoted 1 line
(quoted diff) +1 -0
+	if(enable) {
	if (enable) {

(many instances)

drivers/acpi/amd76x_pm.c line 363

Quoted 3 lines
drivers/acpi/amd76x_pm.c +3 -0
+	if (likely(++(prs->idle_count) <= lazy_idle)) {
+		return;
+	}

Unneeded braces.

Quoted 5 lines
drivers/acpi/amd76x_pm.c +5 -0
+	/* Now we are ready do go C3. */
+	local_irq_disable();
+	num_online = num_online_cpus();
+
+	/* to enter prepare phase no CPU must be in ready phase */

drivers/acpi/amd76x_pm.c line 379

Quoted 10 lines
drivers/acpi/amd76x_pm.c +10 -0
+	for (;;) {
+		smp_mb();
+		spin_lock(&amd76x_stat.lock);
+		if (!amd76x_stat.num_ready) {
+			amd76x_stat.num_prepare++;
+			break;
+		}
+		spin_unlock(&amd76x_stat.lock);
+	}
+	spin_unlock(&amd76x_stat.lock);

What does the smp_mb() do?

Maybe add a cpu_relax() into the tight loop?

Quoted 11 lines
drivers/acpi/amd76x_pm.c +11 -0
+	atomic_inc(&amd76x_stat.num_idle);
+	/* Spin inside inner loop until either
+	 * - spin_idle cycles are reached
+	 * - there is work
+	 * - another CPU has left the inner loop
+	 * - all CPUs are idle
+	 */
+
+	ready_for_C3 = 0;
+	for (i = 0; i < spin_idle; i++) {
+		if (unlikely(need_resched()))

drivers/acpi/amd76x_pm.c line 401

Quoted 10 lines
drivers/acpi/amd76x_pm.c +10 -0
+			break;
+
+		smp_mb();
+		if (unlikely(atomic_read(&amd76x_stat.num_idle)
+					== num_online)) {
+			ready_for_C3 = 1;
+			atomic_inc(&amd76x_stat.num_C3);
+			break;
+		}
+	}

Ditto.

Quoted 7 lines
drivers/acpi/amd76x_pm.c +7 -0
+static void
+setup_watch(void)
+{
+	if (watch_int <= 0)
+		watch_int = AMD76X_WATCH_INT;
+	if (watch_item[0].irq != -1 && watch_int) {
+		schedule_work(&work);

drivers/acpi/amd76x_pm.c line 549

Quoted 10 lines
drivers/acpi/amd76x_pm.c +10 -0
+		printk(KERN_INFO "amd76x_pm: irq rate watcher started. "
+				"watch_int = %lu ms, min_C1 = %lu\n",
+				watch_int, min_C1);
+	} else
+		printk(KERN_INFO "amd76x_pm: irq rate watcher disabled.\n");
+}
+
+static void
+watch_irq(void *parm)
+{

Some comments which describe what these functions do would be nice.

drivers/acpi/amd76x_pm.c line 594

Quoted 12 lines
drivers/acpi/amd76x_pm.c +12 -0
+/*
+ * Finds and initializes the bridges, and then sets the idle function
+ */
+static int
+amd76x_pm_main(void)
+{
+	int i;
+	struct cpu_stat *prs;
+
+	amd76x_pm_cfg.orig_idle = 0;
+	if(lazy_idle == 0)
+	    lazy_idle = AMD76X_LAZY_IDLE;

Use hard tabs, please.

drivers/acpi/amd76x_pm.c line 605

Quoted 11 lines
drivers/acpi/amd76x_pm.c +11 -0
+	printk(KERN_INFO "amd76x_pm: lazy_idle = %lu\n", lazy_idle);
+	if(spin_idle == 0)
+		spin_idle = 2 * lazy_idle;
+	printk(KERN_INFO "amd76x_pm: spin_idle = %lu\n", spin_idle);
+
+	/* Find southbridge */
+	pdev_sb = NULL;
+	while((pdev_sb =
+		pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev_sb)) != NULL) {
+		if(pci_match_id(amd_sb_tbl, pdev_sb) != NULL)
+			goto found_sb;

for_each_pci_dev()?

drivers/acpi/amd76x_pm.c line 616

Quoted 11 lines
drivers/acpi/amd76x_pm.c +11 -0
+	}
+	printk(KERN_ERR "amd76x_pm: Could not find southbridge\n");
+	return -ENODEV;
+
+found_sb:
+	/* Find northbridge */
+	pdev_nb = NULL;
+	while((pdev_nb =
+		pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev_nb)) != NULL) {
+		if(pci_match_id(amd_nb_tbl, pdev_nb) != NULL)
+			goto found_nb;

Ditto.

drivers/acpi/amd76x_pm.c line 670

Quoted 8 lines
drivers/acpi/amd76x_pm.c +8 -0
+
+	prs_ref = alloc_percpu(struct cpu_stat);
+
+	for (i = 0; i < NR_CPUS; i++) {
+		prs = per_cpu_ptr(prs_ref, i);
+		prs->idle_count = 0;
+		prs->C3_cnt = 0;
+	}

alloc_percpu() only allocates stuff for cpu_possible() CPUs. Use for_each_cpu() here.

Quoted 16 lines
drivers/acpi/amd76x_pm.c +16 -0
+static void __exit
+amd76x_pm_cleanup(void)
+{
+	int i;
+	unsigned int C3_cnt = 0;
+	struct cpu_stat *prs;
+
+	pm_idle = amd76x_pm_cfg.orig_idle;
+
+	cpu_idle_wait();
+
+
+	/* This isn't really needed. */
+	for_each_online_cpu(i) {
+		prs = per_cpu_ptr(prs_ref, i);
+		C3_cnt += prs->C3_cnt;

drivers/acpi/amd76x_pm.c line 720

Quoted 10 lines
drivers/acpi/amd76x_pm.c +10 -0
+	}
+	printk(KERN_INFO "amd76x_pm: %u C3 calls\n", C3_cnt);
+
+	/* remove sysfs */
+	device_remove_file(&pdev_nb->dev, &dev_attr_C3_cnt);
+
+	schedule_watch = 0;
+	flush_scheduled_work();
+	cancel_delayed_work(&work);
+	flush_scheduled_work();

That'll stop it for sure ;)

#2 lore raw
Quoted 8 lines · Andrew Morton
Quoted 8 lines

This is a processor idle module for AMD SMP 760MP(X) based systems.
The patch was originally written by Tony Lindgren and has been around since 2002. It enables C2 mode on AMD SMP systems and thus saves about 70 - 90 W of energy in the idle mode compared to the default idle mode. The idle function has been rewritten and is now free of locking issues and is independent from the number of CPUs. The impact from this module on the system clock and on i/o transfer are now fairly low.

Very nice, but I do have problems with it (last tested version about a month ago).

I have a Tyan S2466 (760/8MPX) motherboard with a Promise PDC20575 (SATAII150 TX2plus), with two disks configured as raid-1. As soon as C2 starts to kick in (or C3 that doesn't matter) my syslog/dmesg starts to fill up with error messages from the attached disks and one of the two (at random) disks is kicked out of the raid. It looks like the other disk keeps functioning although it keeps spewing lots of error messages.

To me it looks like the Promise controller goes totally bunkus when one single interrupt is not served, or when it cannot bus master within a certain time interval. I have tried to work around this problem by using _very_ conservative values for the irq-watcher. This works well for some time, but sooner or later the problem re-appears.

So it looks like the only way is to tackle the source of the problem. I already reported this on linux-ide, but no response. I assume they think it's a amd76x_pm specific issue.

#3 lore raw
In reply to Andrew Morton
Quoted 17 lines · Andrew Morton
Quoted 16 lines · Joerg Sommrey

This is a processor idle module for AMD SMP 760MP(X) based systems.
The patch was originally written by Tony Lindgren and has been around since 2002. It enables C2 mode on AMD SMP systems and thus saves about 70 - 90 W of energy in the idle mode compared to the default idle mode. The idle function has been rewritten and is now free of locking issues and is independent from the number of CPUs. The impact from this module on the system clock and on i/o transfer are now fairly low.

This patch can also be found at
http://www.sommrey.de/amd76x_pm/amd76x_pm-2.6.15-4.patch

In this version more locking was added to make sure all or no CPU enter C3 mode.

Quoted 8 lines
Quoted 1 line

Thanks. I'll merge this into -mm and shall plague the ACPI guys with it. They have said discouraging things about board-specific drivers in the past. We shall see.

Tony, could you please review section 11 of Documentation/SubmittingPatches and if OK, send a Signed-off-by:?

Sure, here you are:

Quoted 4 lines

Some minor pointlets, and a bug:

Should CONFIG_AMD76X_PM depend on ACPI?

It works also without ACPI.

But in the long run something like this could be added for ACPI to allow easy addition of custom PM modules. That was discussed briefly on the ACPI list and people seemed to be OK with adding system for custom PM modules.

And if it was integrated with ACPI, only enabling the C states should be enough, and then ACPI would just know how to use the C states...

Regards,

Tony