Skip to content

Commit ada19a3

Browse files
committed
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq
* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq: (35 commits) [CPUFREQ] Prevent p4-clockmod from auto-binding to the ondemand governor. [CPUFREQ] Make cpufreq-nforce2 less obnoxious [CPUFREQ] p4-clockmod reports wrong frequency. [CPUFREQ] powernow-k8: Use a common exit path. [CPUFREQ] Change link order of x86 cpufreq modules [CPUFREQ] conservative: remove 10x from def_sampling_rate [CPUFREQ] conservative: fixup governor to function more like ondemand logic [CPUFREQ] conservative: fix dbs_cpufreq_notifier so freq is not locked [CPUFREQ] conservative: amend author's email address [CPUFREQ] Use swap() in longhaul.c [CPUFREQ] checkpatch cleanups for acpi-cpufreq [CPUFREQ] powernow-k8: Only print error message once, not per core. [CPUFREQ] ondemand/conservative: sanitize sampling_rate restrictions [CPUFREQ] ondemand/conservative: deprecate sampling_rate{min,max} [CPUFREQ] powernow-k8: Always compile powernow-k8 driver with ACPI support [CPUFREQ] Introduce /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_transition_latency [CPUFREQ] checkpatch cleanups for powernow-k8 [CPUFREQ] checkpatch cleanups for ondemand governor. [CPUFREQ] checkpatch cleanups for powernow-k7 [CPUFREQ] checkpatch cleanups for speedstep related drivers. ...
2 parents 8d80ce8 + 36e8abf commit ada19a3

30 files changed

Lines changed: 1372 additions & 995 deletions

‎Documentation/cpu-freq/governors.txt‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,28 @@ accessible parameters:
117117
sampling_rate: measured in uS (10^-6 seconds), this is how often you
118118
want the kernel to look at the CPU usage and to make decisions on
119119
what to do about the frequency. Typically this is set to values of
120-
around '10000' or more.
121-
122-
show_sampling_rate_(min|max): the minimum and maximum sampling rates
123-
available that you may set 'sampling_rate' to.
120+
around '10000' or more. It's default value is (cmp. with users-guide.txt):
121+
transition_latency * 1000
122+
The lowest value you can set is:
123+
transition_latency * 100 or it may get restricted to a value where it
124+
makes not sense for the kernel anymore to poll that often which depends
125+
on your HZ config variable (HZ=1000: max=20000us, HZ=250: max=5000).
126+
Be aware that transition latency is in ns and sampling_rate is in us, so you
127+
get the same sysfs value by default.
128+
Sampling rate should always get adjusted considering the transition latency
129+
To set the sampling rate 750 times as high as the transition latency
130+
in the bash (as said, 1000 is default), do:
131+
echo `$(($(cat cpuinfo_transition_latency) * 750 / 1000)) \
132+
>ondemand/sampling_rate
133+
134+
show_sampling_rate_(min|max): THIS INTERFACE IS DEPRECATED, DON'T USE IT.
135+
You can use wider ranges now and the general
136+
cpuinfo_transition_latency variable (cmp. with user-guide.txt) can be
137+
used to obtain exactly the same info:
138+
show_sampling_rate_min = transtition_latency * 500 / 1000
139+
show_sampling_rate_max = transtition_latency * 500000 / 1000
140+
(divided by 1000 is to illustrate that sampling rate is in us and
141+
transition latency is exported ns).
124142

125143
up_threshold: defines what the average CPU usage between the samplings
126144
of 'sampling_rate' needs to be for the kernel to make a decision on

‎Documentation/cpu-freq/user-guide.txt‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ cpuinfo_min_freq : this file shows the minimum operating
152152
frequency the processor can run at(in kHz)
153153
cpuinfo_max_freq : this file shows the maximum operating
154154
frequency the processor can run at(in kHz)
155+
cpuinfo_transition_latency The time it takes on this CPU to
156+
switch between two frequencies in nano
157+
seconds. If unknown or known to be
158+
that high that the driver does not
159+
work with the ondemand governor, -1
160+
(CPUFREQ_ETERNAL) will be returned.
161+
Using this information can be useful
162+
to choose an appropriate polling
163+
frequency for a kernel governor or
164+
userspace daemon. Make sure to not
165+
switch the frequency too often
166+
resulting in performance loss.
155167
scaling_driver : this file shows what cpufreq driver is
156168
used to set the frequency on this CPU
157169

‎arch/x86/include/asm/timer.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ unsigned long native_calibrate_tsc(void);
1111

1212
#ifdef CONFIG_X86_32
1313
extern int timer_ack;
14+
#endif
1415
extern int recalibrate_cpu_khz(void);
15-
#endif /* CONFIG_X86_32 */
1616

1717
extern int no_timer_check;
1818

‎arch/x86/kernel/cpu/cpufreq/Kconfig‎

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,30 +87,15 @@ config X86_POWERNOW_K7_ACPI
8787
config X86_POWERNOW_K8
8888
tristate "AMD Opteron/Athlon64 PowerNow!"
8989
select CPU_FREQ_TABLE
90+
depends on ACPI && ACPI_PROCESSOR
9091
help
91-
This adds the CPUFreq driver for mobile AMD Opteron/Athlon64 processors.
92+
This adds the CPUFreq driver for K8/K10 Opteron/Athlon64 processors.
9293

9394
To compile this driver as a module, choose M here: the
9495
module will be called powernow-k8.
9596

9697
For details, take a look at <file:Documentation/cpu-freq/>.
9798

98-
If in doubt, say N.
99-
100-
config X86_POWERNOW_K8_ACPI
101-
bool
102-
prompt "ACPI Support" if X86_32
103-
depends on ACPI && X86_POWERNOW_K8 && ACPI_PROCESSOR
104-
depends on !(X86_POWERNOW_K8 = y && ACPI_PROCESSOR = m)
105-
default y
106-
help
107-
This provides access to the K8s Processor Performance States via ACPI.
108-
This driver is probably required for CPUFreq to work with multi-socket and
109-
SMP systems. It is not required on at least some single-socket yet
110-
multi-core systems, even if SMP is enabled.
111-
112-
It is safe to say Y here.
113-
11499
config X86_GX_SUSPMOD
115100
tristate "Cyrix MediaGX/NatSemi Geode Suspend Modulation"
116101
depends on X86_32 && PCI
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
# Link order matters. K8 is preferred to ACPI because of firmware bugs in early
2+
# K8 systems. ACPI is preferred to all other hardware-specific drivers.
3+
# speedstep-* is preferred over p4-clockmod.
4+
5+
obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o
6+
obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o
17
obj-$(CONFIG_X86_POWERNOW_K6) += powernow-k6.o
28
obj-$(CONFIG_X86_POWERNOW_K7) += powernow-k7.o
3-
obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o
49
obj-$(CONFIG_X86_LONGHAUL) += longhaul.o
510
obj-$(CONFIG_X86_E_POWERSAVER) += e_powersaver.o
611
obj-$(CONFIG_ELAN_CPUFREQ) += elanfreq.o
@@ -10,7 +15,6 @@ obj-$(CONFIG_X86_GX_SUSPMOD) += gx-suspmod.o
1015
obj-$(CONFIG_X86_SPEEDSTEP_ICH) += speedstep-ich.o
1116
obj-$(CONFIG_X86_SPEEDSTEP_LIB) += speedstep-lib.o
1217
obj-$(CONFIG_X86_SPEEDSTEP_SMI) += speedstep-smi.o
13-
obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o
1418
obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o
1519
obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o
1620
obj-$(CONFIG_X86_CPUFREQ_NFORCE2) += cpufreq-nforce2.o

‎arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* acpi-cpufreq.c - ACPI Processor P-States Driver ($Revision: 1.4 $)
2+
* acpi-cpufreq.c - ACPI Processor P-States Driver
33
*
44
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
55
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
@@ -36,16 +36,18 @@
3636
#include <linux/ftrace.h>
3737

3838
#include <linux/acpi.h>
39+
#include <linux/io.h>
40+
#include <linux/delay.h>
41+
#include <linux/uaccess.h>
42+
3943
#include <acpi/processor.h>
4044

41-
#include <asm/io.h>
4245
#include <asm/msr.h>
4346
#include <asm/processor.h>
4447
#include <asm/cpufeature.h>
45-
#include <asm/delay.h>
46-
#include <asm/uaccess.h>
4748

48-
#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "acpi-cpufreq", msg)
49+
#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, \
50+
"acpi-cpufreq", msg)
4951

5052
MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski");
5153
MODULE_DESCRIPTION("ACPI Processor P-States Driver");
@@ -95,7 +97,7 @@ static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data)
9597

9698
perf = data->acpi_data;
9799

98-
for (i=0; i<perf->state_count; i++) {
100+
for (i = 0; i < perf->state_count; i++) {
99101
if (value == perf->states[i].status)
100102
return data->freq_table[i].frequency;
101103
}
@@ -110,7 +112,7 @@ static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)
110112
msr &= INTEL_MSR_RANGE;
111113
perf = data->acpi_data;
112114

113-
for (i=0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
115+
for (i = 0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
114116
if (msr == perf->states[data->freq_table[i].index].status)
115117
return data->freq_table[i].frequency;
116118
}
@@ -138,15 +140,13 @@ struct io_addr {
138140
u8 bit_width;
139141
};
140142

141-
typedef union {
142-
struct msr_addr msr;
143-
struct io_addr io;
144-
} drv_addr_union;
145-
146143
struct drv_cmd {
147144
unsigned int type;
148145
const struct cpumask *mask;
149-
drv_addr_union addr;
146+
union {
147+
struct msr_addr msr;
148+
struct io_addr io;
149+
} addr;
150150
u32 val;
151151
};
152152

@@ -369,7 +369,7 @@ static unsigned int check_freqs(const struct cpumask *mask, unsigned int freq,
369369
unsigned int cur_freq;
370370
unsigned int i;
371371

372-
for (i=0; i<100; i++) {
372+
for (i = 0; i < 100; i++) {
373373
cur_freq = extract_freq(get_cur_val(mask), data);
374374
if (cur_freq == freq)
375375
return 1;
@@ -494,7 +494,7 @@ acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu)
494494
unsigned long freq;
495495
unsigned long freqn = perf->states[0].core_frequency * 1000;
496496

497-
for (i=0; i<(perf->state_count-1); i++) {
497+
for (i = 0; i < (perf->state_count-1); i++) {
498498
freq = freqn;
499499
freqn = perf->states[i+1].core_frequency * 1000;
500500
if ((2 * cpu_khz) > (freqn + freq)) {
@@ -673,7 +673,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
673673

674674
/* detect transition latency */
675675
policy->cpuinfo.transition_latency = 0;
676-
for (i=0; i<perf->state_count; i++) {
676+
for (i = 0; i < perf->state_count; i++) {
677677
if ((perf->states[i].transition_latency * 1000) >
678678
policy->cpuinfo.transition_latency)
679679
policy->cpuinfo.transition_latency =
@@ -682,8 +682,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
682682

683683
data->max_freq = perf->states[0].core_frequency * 1000;
684684
/* table init */
685-
for (i=0; i<perf->state_count; i++) {
686-
if (i>0 && perf->states[i].core_frequency >=
685+
for (i = 0; i < perf->state_count; i++) {
686+
if (i > 0 && perf->states[i].core_frequency >=
687687
data->freq_table[valid_states-1].frequency / 1000)
688688
continue;
689689

‎arch/x86/kernel/cpu/cpufreq/cpufreq-nforce2.c‎

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* nforce2_chipset:
3333
* FSB is changed using the chipset
3434
*/
35-
static struct pci_dev *nforce2_chipset_dev;
35+
static struct pci_dev *nforce2_dev;
3636

3737
/* fid:
3838
* multiplier * 10
@@ -56,7 +56,9 @@ MODULE_PARM_DESC(fid, "CPU multiplier to use (11.5 = 115)");
5656
MODULE_PARM_DESC(min_fsb,
5757
"Minimum FSB to use, if not defined: current FSB - 50");
5858

59-
#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "cpufreq-nforce2", msg)
59+
#define PFX "cpufreq-nforce2: "
60+
#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, \
61+
"cpufreq-nforce2", msg)
6062

6163
/**
6264
* nforce2_calc_fsb - calculate FSB
@@ -118,11 +120,11 @@ static void nforce2_write_pll(int pll)
118120
int temp;
119121

120122
/* Set the pll addr. to 0x00 */
121-
pci_write_config_dword(nforce2_chipset_dev, NFORCE2_PLLADR, 0);
123+
pci_write_config_dword(nforce2_dev, NFORCE2_PLLADR, 0);
122124

123125
/* Now write the value in all 64 registers */
124126
for (temp = 0; temp <= 0x3f; temp++)
125-
pci_write_config_dword(nforce2_chipset_dev, NFORCE2_PLLREG, pll);
127+
pci_write_config_dword(nforce2_dev, NFORCE2_PLLREG, pll);
126128

127129
return;
128130
}
@@ -139,22 +141,22 @@ static unsigned int nforce2_fsb_read(int bootfsb)
139141
u32 fsb, temp = 0;
140142

141143
/* Get chipset boot FSB from subdevice 5 (FSB at boot-time) */
142-
nforce2_sub5 = pci_get_subsys(PCI_VENDOR_ID_NVIDIA,
143-
0x01EF, PCI_ANY_ID, PCI_ANY_ID, NULL);
144+
nforce2_sub5 = pci_get_subsys(PCI_VENDOR_ID_NVIDIA, 0x01EF,
145+
PCI_ANY_ID, PCI_ANY_ID, NULL);
144146
if (!nforce2_sub5)
145147
return 0;
146148

147149
pci_read_config_dword(nforce2_sub5, NFORCE2_BOOTFSB, &fsb);
148150
fsb /= 1000000;
149151

150152
/* Check if PLL register is already set */
151-
pci_read_config_byte(nforce2_chipset_dev, NFORCE2_PLLENABLE, (u8 *)&temp);
153+
pci_read_config_byte(nforce2_dev, NFORCE2_PLLENABLE, (u8 *)&temp);
152154

153155
if (bootfsb || !temp)
154156
return fsb;
155157

156158
/* Use PLL register FSB value */
157-
pci_read_config_dword(nforce2_chipset_dev, NFORCE2_PLLREG, &temp);
159+
pci_read_config_dword(nforce2_dev, NFORCE2_PLLREG, &temp);
158160
fsb = nforce2_calc_fsb(temp);
159161

160162
return fsb;
@@ -174,18 +176,18 @@ static int nforce2_set_fsb(unsigned int fsb)
174176
int pll = 0;
175177

176178
if ((fsb > max_fsb) || (fsb < NFORCE2_MIN_FSB)) {
177-
printk(KERN_ERR "cpufreq: FSB %d is out of range!\n", fsb);
179+
printk(KERN_ERR PFX "FSB %d is out of range!\n", fsb);
178180
return -EINVAL;
179181
}
180182

181183
tfsb = nforce2_fsb_read(0);
182184
if (!tfsb) {
183-
printk(KERN_ERR "cpufreq: Error while reading the FSB\n");
185+
printk(KERN_ERR PFX "Error while reading the FSB\n");
184186
return -EINVAL;
185187
}
186188

187189
/* First write? Then set actual value */
188-
pci_read_config_byte(nforce2_chipset_dev, NFORCE2_PLLENABLE, (u8 *)&temp);
190+
pci_read_config_byte(nforce2_dev, NFORCE2_PLLENABLE, (u8 *)&temp);
189191
if (!temp) {
190192
pll = nforce2_calc_pll(tfsb);
191193

@@ -197,7 +199,7 @@ static int nforce2_set_fsb(unsigned int fsb)
197199

198200
/* Enable write access */
199201
temp = 0x01;
200-
pci_write_config_byte(nforce2_chipset_dev, NFORCE2_PLLENABLE, (u8)temp);
202+
pci_write_config_byte(nforce2_dev, NFORCE2_PLLENABLE, (u8)temp);
201203

202204
diff = tfsb - fsb;
203205

@@ -222,7 +224,7 @@ static int nforce2_set_fsb(unsigned int fsb)
222224
}
223225

224226
temp = 0x40;
225-
pci_write_config_byte(nforce2_chipset_dev, NFORCE2_PLLADR, (u8)temp);
227+
pci_write_config_byte(nforce2_dev, NFORCE2_PLLADR, (u8)temp);
226228

227229
return 0;
228230
}
@@ -244,7 +246,8 @@ static unsigned int nforce2_get(unsigned int cpu)
244246
* nforce2_target - set a new CPUFreq policy
245247
* @policy: new policy
246248
* @target_freq: the target frequency
247-
* @relation: how that frequency relates to achieved frequency (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
249+
* @relation: how that frequency relates to achieved frequency
250+
* (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
248251
*
249252
* Sets a new CPUFreq policy.
250253
*/
@@ -276,7 +279,7 @@ static int nforce2_target(struct cpufreq_policy *policy,
276279
/* local_irq_save(flags); */
277280

278281
if (nforce2_set_fsb(target_fsb) < 0)
279-
printk(KERN_ERR "cpufreq: Changing FSB to %d failed\n",
282+
printk(KERN_ERR PFX "Changing FSB to %d failed\n",
280283
target_fsb);
281284
else
282285
dprintk("Changed FSB successfully to %d\n",
@@ -327,8 +330,8 @@ static int nforce2_cpu_init(struct cpufreq_policy *policy)
327330
/* FIX: Get FID from CPU */
328331
if (!fid) {
329332
if (!cpu_khz) {
330-
printk(KERN_WARNING
331-
"cpufreq: cpu_khz not set, can't calculate multiplier!\n");
333+
printk(KERN_WARNING PFX
334+
"cpu_khz not set, can't calculate multiplier!\n");
332335
return -ENODEV;
333336
}
334337

@@ -343,7 +346,7 @@ static int nforce2_cpu_init(struct cpufreq_policy *policy)
343346
}
344347
}
345348

346-
printk(KERN_INFO "cpufreq: FSB currently at %i MHz, FID %d.%d\n", fsb,
349+
printk(KERN_INFO PFX "FSB currently at %i MHz, FID %d.%d\n", fsb,
347350
fid / 10, fid % 10);
348351

349352
/* Set maximum FSB to FSB at boot time */
@@ -392,17 +395,18 @@ static struct cpufreq_driver nforce2_driver = {
392395
*/
393396
static unsigned int nforce2_detect_chipset(void)
394397
{
395-
nforce2_chipset_dev = pci_get_subsys(PCI_VENDOR_ID_NVIDIA,
398+
nforce2_dev = pci_get_subsys(PCI_VENDOR_ID_NVIDIA,
396399
PCI_DEVICE_ID_NVIDIA_NFORCE2,
397400
PCI_ANY_ID, PCI_ANY_ID, NULL);
398401

399-
if (nforce2_chipset_dev == NULL)
402+
if (nforce2_dev == NULL)
400403
return -ENODEV;
401404

402-
printk(KERN_INFO "cpufreq: Detected nForce2 chipset revision %X\n",
403-
nforce2_chipset_dev->revision);
404-
printk(KERN_INFO
405-
"cpufreq: FSB changing is maybe unstable and can lead to crashes and data loss.\n");
405+
printk(KERN_INFO PFX "Detected nForce2 chipset revision %X\n",
406+
nforce2_dev->revision);
407+
printk(KERN_INFO PFX
408+
"FSB changing is maybe unstable and can lead to "
409+
"crashes and data loss.\n");
406410

407411
return 0;
408412
}
@@ -420,7 +424,7 @@ static int __init nforce2_init(void)
420424

421425
/* detect chipset */
422426
if (nforce2_detect_chipset()) {
423-
printk(KERN_ERR "cpufreq: No nForce2 chipset.\n");
427+
printk(KERN_INFO PFX "No nForce2 chipset.\n");
424428
return -ENODEV;
425429
}
426430

0 commit comments

Comments
 (0)