aboutsummaryrefslogtreecommitdiffstats
path: root/xen/drivers/cpufreq
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-05-14 15:22:48 +0100
committerKeir Fraser <keir.fraser@citrix.com>2010-05-14 15:22:48 +0100
commit2e4146ddc277d2ddd861646b8b1ba83182eb84bb (patch)
treeb89c9a44b6681359974a281096dc16f29dc6d304 /xen/drivers/cpufreq
parent2a814aeaaf1e2fe258ab72fc60bb86b7ca4cb102 (diff)
downloadxen-2e4146ddc277d2ddd861646b8b1ba83182eb84bb.tar.gz
xen-2e4146ddc277d2ddd861646b8b1ba83182eb84bb.tar.bz2
xen-2e4146ddc277d2ddd861646b8b1ba83182eb84bb.zip
x86: Implement cpu hotplug notifiers. Use them.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'xen/drivers/cpufreq')
-rw-r--r--xen/drivers/cpufreq/cpufreq.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c
index 627435d88c..d81a952815 100644
--- a/xen/drivers/cpufreq/cpufreq.c
+++ b/xen/drivers/cpufreq/cpufreq.c
@@ -38,6 +38,7 @@
#include <xen/xmalloc.h>
#include <xen/guest_access.h>
#include <xen/domain.h>
+#include <xen/cpu.h>
#include <asm/bug.h>
#include <asm/io.h>
#include <asm/config.h>
@@ -582,3 +583,38 @@ void __init cpufreq_cmdline_parse(char *str)
str = end;
} while (str);
}
+
+static int cpu_callback(
+ struct notifier_block *nfb, unsigned long action, void *hcpu)
+{
+ unsigned int cpu = (unsigned long)hcpu;
+
+ switch ( action )
+ {
+ case CPU_DOWN_FAILED:
+ case CPU_ONLINE:
+ (void)cpufreq_add_cpu(cpu);
+ break;
+ case CPU_DOWN_PREPARE:
+ (void)cpufreq_del_cpu(cpu);
+ break;
+ default:
+ break;
+ }
+
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block cpu_nfb = {
+ .notifier_call = cpu_callback
+};
+
+static int __init cpufreq_presmp_init(void)
+{
+ void *cpu = (void *)(long)smp_processor_id();
+ cpu_callback(&cpu_nfb, CPU_ONLINE, cpu);
+ register_cpu_notifier(&cpu_nfb);
+ return 0;
+}
+presmp_initcall(cpufreq_presmp_init);
+