Commit 412f9e8b authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] cpufreq for x86-64

Reuses the i386 cpufreq code and add an notifier to the x86-64
timer code to track frequency changes.

All previous criticism of earlier patches should be addressed:
 - it doesn't touch i386 now
 - Doesn't include the ACPI P states driver anymore following brodo's request.

Also fix a typo in the last version.
parent a001f96a
......@@ -318,8 +318,9 @@ config SOFTWARE_SUSPEND
source "drivers/acpi/Kconfig"
endmenu
source "arch/x86_64/kernel/cpufreq/Kconfig"
endmenu
menu "Bus options (PCI etc.)"
......
......@@ -26,3 +26,5 @@ obj-$(CONFIG_MODULES) += module.o
bootflag-y += ../../i386/kernel/bootflag.o
cpuid-$(CONFIG_X86_CPUID) += ../../i386/kernel/cpuid.o
obj-$(CONFIG_CPU_FREQ) += cpufreq/
#
# CPU Frequency scaling
#
menu "CPU Frequency scaling"
config CPU_FREQ
bool "CPU Frequency scaling"
help
Clock scaling allows you to change the clock speed of CPUs on the
fly. This is a nice method to save battery power on notebooks,
because the lower the clock speed, the less power the CPU consumes.
For more information, take a look at linux/Documentation/cpu-freq or
at <http://www.brodo.de/cpufreq/>
If in doubt, say N.
source "drivers/cpufreq/Kconfig"
config CPU_FREQ_TABLE
tristate "CPU frequency table helpers"
depends on CPU_FREQ
default y
help
Many CPUFreq drivers use these helpers, so only say N here if
the CPUFreq driver of your choice doesn't need these helpers.
If in doubt, say Y.
comment "CPUFreq processor drivers"
depends on CPU_FREQ
config X86_POWERNOW_K8
tristate "AMD Opteron/Athlon64 PowerNow!"
depends on CPU_FREQ_TABLE
help
This adds the CPUFreq driver for mobile AMD Opteron/Athlon64 processors.
For details, take a look at linux/Documentation/cpu-freq.
If in doubt, say N.
endmenu
#
# Reuse the i386 cpufreq drivers
#
obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o
$(obj)/powernow-k8.c: $(obj)/powernow-k8.h
@ln -sf ../../../i386/kernel/cpu/cpufreq/powernow-k8.c $(obj)/powernow-k8.c
$(obj)/powernow-k8.h:
@ln -sf ../../../i386/kernel/cpu/cpufreq/powernow-k8.h $(obj)/powernow-k8.h
clean-files += powernow-k8.c powernow-k8.h
......@@ -28,6 +28,7 @@
#include <asm/vsyscall.h>
#include <asm/timex.h>
#include <asm/proto.h>
#include <linux/cpufreq.h>
#ifdef CONFIG_X86_LOCAL_APIC
#include <asm/apic.h>
#endif
......@@ -455,6 +456,51 @@ unsigned long get_cmos_time(void)
return mktime(year, mon, day, hour, min, sec);
}
#ifdef CONFIG_CPU_FREQ
/* Frequency scaling support. Adjust the TSC based timer when the cpu frequency
changes.
RED-PEN: On SMP we assume all CPUs run with the same frequency. It's
not that important because current Opteron setups do not support
scaling on SMP anyroads.
Should fix up last_tsc too. Currently gettimeofday in the
first tick after the change will be slightly wrong. */
static unsigned int ref_freq = 0;
static unsigned long loops_per_jiffy_ref = 0;
//static unsigned long fast_gettimeoffset_ref = 0;
static unsigned long cpu_khz_ref = 0;
static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
void *data)
{
struct cpufreq_freqs *freq = data;
if (!ref_freq) {
ref_freq = freq->old;
loops_per_jiffy_ref = cpu_data[freq->cpu].loops_per_jiffy;
cpu_khz_ref = cpu_khz;
}
if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) ||
(val == CPUFREQ_POSTCHANGE && freq->old > freq->new)) {
cpu_data[freq->cpu].loops_per_jiffy =
cpufreq_scale(loops_per_jiffy_ref, ref_freq, freq->new);
cpu_khz = cpufreq_scale(cpu_khz_ref, ref_freq, freq->new);
vxtime.tsc_quot = (1000L << 32) / cpu_khz;
}
return 0;
}
static struct notifier_block time_cpufreq_notifier_block = {
.notifier_call = time_cpufreq_notifier
};
#endif
/*
* calibrate_tsc() calibrates the processor TSC in a very simple way, comparing
* it to the HPET timer of known frequency.
......@@ -641,6 +687,11 @@ void __init time_init(void)
vxtime.hz = vxtime_hz;
rdtscll_sync(&vxtime.last_tsc);
setup_irq(0, &irq0);
#ifdef CONFIG_CPU_FREQ
cpufreq_register_notifier(&time_cpufreq_notifier_block,
CPUFREQ_TRANSITION_NOTIFIER);
#endif
}
void __init time_init_smp(void)
......
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