diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/xen/Makefile | 2 | ||||
-rw-r--r-- | drivers/xen/cpu_hotplug.c | 90 | ||||
-rw-r--r-- | drivers/xen/events.c | 4 |
3 files changed, 95 insertions, 1 deletions
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile index 363286c54290..f62d8df27696 100644 --- a/drivers/xen/Makefile +++ b/drivers/xen/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | obj-y += grant-table.o features.o events.o manage.o | 1 | obj-y += grant-table.o features.o events.o manage.o cpu_hotplug.o |
2 | obj-y += xenbus/ | 2 | obj-y += xenbus/ |
3 | obj-$(CONFIG_XEN_XENCOMM) += xencomm.o | 3 | obj-$(CONFIG_XEN_XENCOMM) += xencomm.o |
4 | obj-$(CONFIG_XEN_BALLOON) += balloon.o | 4 | obj-$(CONFIG_XEN_BALLOON) += balloon.o |
diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c new file mode 100644 index 000000000000..1bc003536cdb --- /dev/null +++ b/drivers/xen/cpu_hotplug.c | |||
@@ -0,0 +1,90 @@ | |||
1 | #include <linux/notifier.h> | ||
2 | |||
3 | #include <xen/xenbus.h> | ||
4 | |||
5 | #include <asm-x86/xen/hypervisor.h> | ||
6 | #include <asm/cpu.h> | ||
7 | |||
8 | static void enable_hotplug_cpu(int cpu) | ||
9 | { | ||
10 | if (!cpu_present(cpu)) | ||
11 | arch_register_cpu(cpu); | ||
12 | |||
13 | cpu_set(cpu, cpu_present_map); | ||
14 | } | ||
15 | |||
16 | static void disable_hotplug_cpu(int cpu) | ||
17 | { | ||
18 | if (cpu_present(cpu)) | ||
19 | arch_unregister_cpu(cpu); | ||
20 | |||
21 | cpu_clear(cpu, cpu_present_map); | ||
22 | } | ||
23 | |||
24 | static void vcpu_hotplug(unsigned int cpu) | ||
25 | { | ||
26 | int err; | ||
27 | char dir[32], state[32]; | ||
28 | |||
29 | if (!cpu_possible(cpu)) | ||
30 | return; | ||
31 | |||
32 | sprintf(dir, "cpu/%u", cpu); | ||
33 | err = xenbus_scanf(XBT_NIL, dir, "availability", "%s", state); | ||
34 | if (err != 1) { | ||
35 | printk(KERN_ERR "XENBUS: Unable to read cpu state\n"); | ||
36 | return; | ||
37 | } | ||
38 | |||
39 | if (strcmp(state, "online") == 0) { | ||
40 | enable_hotplug_cpu(cpu); | ||
41 | } else if (strcmp(state, "offline") == 0) { | ||
42 | (void)cpu_down(cpu); | ||
43 | disable_hotplug_cpu(cpu); | ||
44 | } else { | ||
45 | printk(KERN_ERR "XENBUS: unknown state(%s) on CPU%d\n", | ||
46 | state, cpu); | ||
47 | } | ||
48 | } | ||
49 | |||
50 | static void handle_vcpu_hotplug_event(struct xenbus_watch *watch, | ||
51 | const char **vec, unsigned int len) | ||
52 | { | ||
53 | unsigned int cpu; | ||
54 | char *cpustr; | ||
55 | const char *node = vec[XS_WATCH_PATH]; | ||
56 | |||
57 | cpustr = strstr(node, "cpu/"); | ||
58 | if (cpustr != NULL) { | ||
59 | sscanf(cpustr, "cpu/%u", &cpu); | ||
60 | vcpu_hotplug(cpu); | ||
61 | } | ||
62 | } | ||
63 | |||
64 | static int setup_cpu_watcher(struct notifier_block *notifier, | ||
65 | unsigned long event, void *data) | ||
66 | { | ||
67 | static struct xenbus_watch cpu_watch = { | ||
68 | .node = "cpu", | ||
69 | .callback = handle_vcpu_hotplug_event}; | ||
70 | |||
71 | (void)register_xenbus_watch(&cpu_watch); | ||
72 | |||
73 | return NOTIFY_DONE; | ||
74 | } | ||
75 | |||
76 | static int __init setup_vcpu_hotplug_event(void) | ||
77 | { | ||
78 | static struct notifier_block xsn_cpu = { | ||
79 | .notifier_call = setup_cpu_watcher }; | ||
80 | |||
81 | if (!is_running_on_xen()) | ||
82 | return -ENODEV; | ||
83 | |||
84 | register_xenstore_notifier(&xsn_cpu); | ||
85 | |||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | arch_initcall(setup_vcpu_hotplug_event); | ||
90 | |||
diff --git a/drivers/xen/events.c b/drivers/xen/events.c index b6c2b8f16bee..c3290bc186a0 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c | |||
@@ -360,6 +360,10 @@ static void unbind_from_irq(unsigned int irq) | |||
360 | per_cpu(virq_to_irq, cpu_from_evtchn(evtchn)) | 360 | per_cpu(virq_to_irq, cpu_from_evtchn(evtchn)) |
361 | [index_from_irq(irq)] = -1; | 361 | [index_from_irq(irq)] = -1; |
362 | break; | 362 | break; |
363 | case IRQT_IPI: | ||
364 | per_cpu(ipi_to_irq, cpu_from_evtchn(evtchn)) | ||
365 | [index_from_irq(irq)] = -1; | ||
366 | break; | ||
363 | default: | 367 | default: |
364 | break; | 368 | break; |
365 | } | 369 | } |