Commit 74e7a24b authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Linus Torvalds

[PATCH] cpufreq: add sysfs interface

This patch adds a sysfs interface to the cpufreq core, and marks the
previous /proc/cpufreq interface as deprecated.

As in drivers/base/cpu.c a "CPU driver" is registered, cpufreq acts as
"interface" to this, offering the following files for each CPU
(in /system/devices/sys/cpu.../) where CPUfreq support is present

cpuinfo_min_freq (ro)	- minimum frequency (in kHz) the CPU supports
cpuinfo_max_freq (ro)	- maximum frequency (in kHz) the CPU supports
scaling_min_freq (rw)	- minimum frequency (in kHz) cpufreq may scale
			     the CPU core to
scaling_max_freq (rw)	- maximum frequency (in kHz) cpufreq may scale
			     the CPU core to
scaling_governor (rw)	- governor == "A feedback device on a machine
			      or engine that is used to provide
			      automatic control, as of speed,
			      pressure, or temperature" [1, as noted
			      by David Kimdon]. Decides what frequency
			      is used. Currently, only "performance"
			      and "powersave" are supported, more may
			      be added later.

(In future, a file scaling_driver (ro) which shows what CPUfreq driver
is used (arm-sa1100,  gx-suspmod, speedstep, longrun, powernow-k6,
...) might be added, and this driver will be allowed to add files
scaling_driver_* for driver-specific settings like "prefer fast FSB".
And scaling_governor_* files might offer settings for the governor.)

To implement this sysfs interface, the driver model "interface" code
is used. Unfortunately, it has a non-trivial locking bug in
drivers/base/intf.c: there's a down_write call for
cls->subsys.rwsem in add_intf(), which then calls add(), which may call
intf->add_device(), which may call interface_add_data(), which calls
kobject_register(), which calls kobject_add(), which then tries to
down_write cls->subsys.rwsem. Remember, that was already locked writable
in add_intf().

Because of that, interface_add_data() is commented out; this means
that no link in /system/class/cpu/cpufreq is added, and that the
dev-removal code isn't called. This shouldn't be a problem yet,
though; as no cpufreq driver I know of is capable of CPU hotplugging.

    Dominik

[1] http://dictionary.reference.com/search?q=governor
parent ba3e3dba
...@@ -949,15 +949,27 @@ config CPU_FREQ ...@@ -949,15 +949,27 @@ config CPU_FREQ
If in doubt, say N. If in doubt, say N.
config CPU_FREQ_PROC_INTF
bool "/proc/cpufreq interface (DEPRECATED)"
depends on CPU_FREQ && PROC_FS
help
This enables the /proc/cpufreq interface for controlling
CPUFreq. Please note that it is recommended to use the sysfs
interface instead (which is built automatically).
For details, take a look at linux/Documentation/cpufreq.
If in doubt, say N.
config CPU_FREQ_24_API config CPU_FREQ_24_API
bool "/proc/sys/cpu/ interface (2.4. / OLD)" bool "/proc/sys/cpu/ interface (2.4. / OLD)"
depends on CPU_FREQ depends on CPU_FREQ
help help
This enables the /proc/sys/cpu/ sysctl interface for controlling This enables the /proc/sys/cpu/ sysctl interface for controlling
CPUFreq, as known from the 2.4.-kernel patches for CPUFreq. 2.5 CPUFreq, as known from the 2.4.-kernel patches for CPUFreq. 2.5
uses /proc/cpufreq instead. Please note that some drivers do not uses a sysfs interface instead. Please note that some drivers do
work well with the 2.4. /proc/sys/cpu sysctl interface, so if in not work well with the 2.4. /proc/sys/cpu sysctl interface,
doubt, say N here. so if in doubt, say N here.
For details, take a look at linux/Documentation/cpufreq. For details, take a look at linux/Documentation/cpufreq.
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/threads.h> #include <linux/threads.h>
#include <linux/device.h>
/********************************************************************* /*********************************************************************
...@@ -57,6 +58,7 @@ struct cpufreq_policy { ...@@ -57,6 +58,7 @@ struct cpufreq_policy {
unsigned int max; /* in kHz */ unsigned int max; /* in kHz */
unsigned int policy; /* see above */ unsigned int policy; /* see above */
struct cpufreq_cpuinfo cpuinfo; /* see above */ struct cpufreq_cpuinfo cpuinfo; /* see above */
struct intf_data intf; /* interface data */
}; };
#define CPUFREQ_ADJUST (0) #define CPUFREQ_ADJUST (0)
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment