mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cpufrequency change on AC-Adapter Event
@ 2006-02-21 21:37 Thomas Ogrisegg
  2006-02-21 22:12 ` Dominik Brodowski
  2006-02-22 22:12 ` Pavel Machek
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Ogrisegg @ 2006-02-21 21:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: davej

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

Problem Description:
Whenever the status of the AC-Adapter on my laptop changes, the CPU
frequency automatically changes as well. For example, if the AC adapter
is online my CPU has the highest frequency (3,06 GHz). When the adapter
is unplugged, the frequency automatically decreases to 1,6 GHz. However,
currently the Kernel simply doesn't notice. It looks like the system is
still running at 3,06 GHz (/proc/cpuinfo and
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq both show that),
but it doesn't like a simple test program showed.

My patch solves this problem: Whenever the status of the AC Adapter
changes, it calls 'cpufreq_reinit' which in turn reinits the CPUfreq
driver.

This, of course, only works if the ACPI AC driver is compiled in.

Signed-off-by: Thomas Ogrisegg <tom-lkml@lkml.fnord.at>

[-- Attachment #2: cpufreq.diff --]
[-- Type: text/plain, Size: 1937 bytes --]

diff -uNr -X linux-2.6.15/Documentation/dontdiff linux-2.6.15/drivers/acpi/ac.c linux-2.6.15.4/drivers/acpi/ac.c
--- linux-2.6.15/drivers/acpi/ac.c	2006-01-03 04:21:10.000000000 +0100
+++ linux-2.6.15.4/drivers/acpi/ac.c	2006-02-19 17:50:20.000000000 +0100
@@ -29,6 +29,7 @@
 #include <linux/types.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
+#include <linux/cpufreq.h>
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 
@@ -213,6 +214,8 @@
 		break;
 	}
 
+	cpufreq_reinit();
+
 	return_VOID;
 }
 
diff -uNr -X linux-2.6.15/Documentation/dontdiff linux-2.6.15/drivers/cpufreq/cpufreq.c linux-2.6.15.4/drivers/cpufreq/cpufreq.c
--- linux-2.6.15/drivers/cpufreq/cpufreq.c	2006-01-03 04:21:10.000000000 +0100
+++ linux-2.6.15.4/drivers/cpufreq/cpufreq.c	2006-02-21 20:00:06.000000000 +0100
@@ -863,6 +863,30 @@
 
 
 /**
+ * cpufreq_reinit - reinitialize CPU frequency of all CPUs
+ */
+
+int cpufreq_reinit(void)
+{
+	int cpu, ret;
+	struct cpufreq_policy *policy;
+
+	for_each_online_cpu (cpu) {
+		policy = cpufreq_cpu_get(cpu);
+		if (!policy)
+			return -EINVAL;
+		ret = cpufreq_driver->exit(policy);
+		if (ret)
+			return ret;
+		ret = cpufreq_driver->init(policy);
+		if (ret)
+			return ret;
+	}
+	return (0);
+}
+EXPORT_SYMBOL(cpufreq_reinit);
+
+/**
  *	cpufreq_suspend - let the low level driver prepare for suspend
  */
 
--- linux-2.6.15/include/linux/cpufreq.h	2006-01-03 04:21:10.000000000 +0100
+++ linux-2.6.15.4/include/linux/cpufreq.h	2006-02-21 20:37:27.000000000 +0100
@@ -256,6 +256,11 @@
 /* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it */
 unsigned int cpufreq_get(unsigned int cpu);
 
+#ifdef CONFIG_CPU_FREQ
+int cpu_freq_reinit(void);
+#else
+static inline int cpu_freq_reinit(void) { return 0; }
+#endif
 
 /*********************************************************************
  *                       CPUFREQ DEFAULT GOVERNOR                    *

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-02-22 22:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-21 21:37 [PATCH] cpufrequency change on AC-Adapter Event Thomas Ogrisegg
2006-02-21 22:12 ` Dominik Brodowski
2006-02-22 22:12 ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®