ia64/xen-unstable

view unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c @ 15849:f779ee15c553

PV-on-HVM: Fix non-SMP build warning for PV-on-HVM drivers.

smp_call_function() compiles to nothing on non-SMP, so we had a
defined-but-not-used static function.

Based on an original patch by:
Signed-off-by: Ben Guthro <bguthro@virtualiron.com>
Signed-off-by: Robert Phillips <rphillips@virtualiron.com>

Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Sep 07 10:18:54 2007 +0100 (2007-09-07)
parents 01c721fddb90
children 3d97c1c1f7c8
line source
1 #include <linux/config.h>
2 #include <linux/cpumask.h>
3 #include <linux/preempt.h>
4 #include <xen/evtchn.h>
5 #include <xen/gnttab.h>
6 #include <xen/xenbus.h>
7 #include "platform-pci.h"
8 #include <asm/hypervisor.h>
10 struct ap_suspend_info {
11 int do_spin;
12 atomic_t nr_spinning;
13 };
15 /*
16 * Use a rwlock to protect the hypercall page from being executed in AP context
17 * while the BSP is re-initializing it after restore.
18 */
19 static DEFINE_RWLOCK(suspend_lock);
21 #ifdef CONFIG_SMP
23 /*
24 * Spinning prevents, for example, APs touching grant table entries while
25 * the shared grant table is not mapped into the address space imemdiately
26 * after resume.
27 */
28 static void ap_suspend(void *_info)
29 {
30 struct ap_suspend_info *info = _info;
32 BUG_ON(!irqs_disabled());
34 atomic_inc(&info->nr_spinning);
35 mb();
37 while (info->do_spin) {
38 cpu_relax();
39 read_lock(&suspend_lock);
40 HYPERVISOR_yield();
41 read_unlock(&suspend_lock);
42 }
44 mb();
45 atomic_dec(&info->nr_spinning);
46 }
48 #define initiate_ap_suspend(i) smp_call_function(ap_suspend, i, 0, 0)
50 #else /* !defined(CONFIG_SMP) */
52 #define initiate_ap_suspend(i) 0
54 #endif
56 static int bp_suspend(void)
57 {
58 int suspend_cancelled;
60 BUG_ON(!irqs_disabled());
62 suspend_cancelled = HYPERVISOR_shutdown(SHUTDOWN_suspend);
64 if (!suspend_cancelled) {
65 write_lock(&suspend_lock);
66 platform_pci_resume();
67 write_unlock(&suspend_lock);
68 gnttab_resume();
69 irq_resume();
70 }
72 return suspend_cancelled;
73 }
75 int __xen_suspend(int fast_suspend)
76 {
77 int err, suspend_cancelled, nr_cpus;
78 struct ap_suspend_info info;
80 xenbus_suspend();
82 preempt_disable();
84 /* Prevent any races with evtchn_interrupt() handler. */
85 disable_irq(xen_platform_pdev->irq);
87 info.do_spin = 1;
88 atomic_set(&info.nr_spinning, 0);
89 smp_mb();
91 nr_cpus = num_online_cpus() - 1;
93 err = initiate_ap_suspend(&info);
94 if (err < 0) {
95 preempt_enable();
96 xenbus_suspend_cancel();
97 return err;
98 }
100 while (atomic_read(&info.nr_spinning) != nr_cpus)
101 cpu_relax();
103 local_irq_disable();
104 suspend_cancelled = bp_suspend();
105 local_irq_enable();
107 smp_mb();
108 info.do_spin = 0;
109 while (atomic_read(&info.nr_spinning) != 0)
110 cpu_relax();
112 enable_irq(xen_platform_pdev->irq);
114 preempt_enable();
116 if (!suspend_cancelled)
117 xenbus_resume();
118 else
119 xenbus_suspend_cancel();
121 return 0;
122 }