37 #include <linux/stat.h>
38 #include <linux/capability.h>
42 #include <xen/events.h>
44 #include <asm/xen/hypervisor.h>
45 #include <asm/xen/hypercall.h>
47 #define XEN_PCPU "xen_cpu: "
62 static struct bus_type xen_pcpu_subsys = {
64 .dev_name =
"xen_cpu",
79 return HYPERVISOR_dom0_op(&op);
90 return HYPERVISOR_dom0_op(&op);
104 const char *buf,
size_t count)
107 unsigned long long val;
118 ret = xen_pcpu_down(pcpu->
cpu_id);
121 ret = xen_pcpu_up(pcpu->
cpu_id);
141 if (xen_pcpu_online(info->
flags) &&
142 !xen_pcpu_online(pcpu->
flags)) {
146 }
else if (!xen_pcpu_online(info->
flags) &&
147 xen_pcpu_online(pcpu->
flags)) {
159 if (pcpu->
cpu_id == cpu_id)
166 static void pcpu_release(
struct device *dev)
168 struct pcpu *pcpu =
container_of(dev,
struct pcpu, dev);
174 static void unregister_and_remove_pcpu(
struct pcpu *pcpu)
189 static int register_pcpu(
struct pcpu *pcpu)
198 dev->
bus = &xen_pcpu_subsys;
224 static struct pcpu *create_and_register_pcpu(
struct xenpf_pcpuinfo *info)
232 pcpu = kzalloc(
sizeof(
struct pcpu),
GFP_KERNEL);
236 INIT_LIST_HEAD(&pcpu->
list);
243 err = register_pcpu(pcpu);
259 struct pcpu *pcpu =
NULL;
264 .u.pcpu_info.xen_cpuid =
cpu,
267 ret = HYPERVISOR_dom0_op(&op);
275 pcpu = get_pcpu(cpu);
282 unregister_and_remove_pcpu(pcpu);
287 pcpu = create_and_register_pcpu(info);
288 if (IS_ERR_OR_NULL(pcpu))
291 pcpu_online_status(info, pcpu);
299 static int xen_sync_pcpus(
void)
306 struct pcpu *pcpu, *
tmp;
310 while (!err && (cpu <= max_cpu)) {
311 err = sync_pcpu(cpu, &max_cpu);
317 unregister_and_remove_pcpu(pcpu);
336 static int __init xen_pcpu_init(
void)
344 xen_pcpu_interrupt, 0,
357 ret = xen_sync_pcpus();