aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2009-12-01 06:47:14 -0500
committerJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>2009-12-03 14:14:56 -0500
commit65f63384b391bf4d384327d8a7c6de9860290b5c (patch)
treed42741a7582839ed8740b9cfb99416f2fcf46a6a /drivers
parentfed5ea87e02aaf902ff38c65b4514233db03dc09 (diff)
xen: improve error handling in do_suspend.
The existing error handling has a few issues: - If freeze_processes() fails it exits with shutting_down = SHUTDOWN_SUSPEND. - If dpm_suspend_noirq() fails it exits without resuming xenbus. - If stop_machine() fails it exits without resuming xenbus or calling dpm_resume_end(). - xs_suspend()/xs_resume() and dpm_suspend_noirq()/dpm_resume_noirq() were not nested in the obvious way. Fix by ensuring each failure case goto's the correct label. Treat a failure of stop_machine() as a cancelled suspend in order to follow the correct resume path. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Cc: Stable Kernel <stable@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/xen/manage.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index 7b69a1aef877..2fb7d39b814c 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -86,32 +86,32 @@ static void do_suspend(void)
86 err = freeze_processes(); 86 err = freeze_processes();
87 if (err) { 87 if (err) {
88 printk(KERN_ERR "xen suspend: freeze failed %d\n", err); 88 printk(KERN_ERR "xen suspend: freeze failed %d\n", err);
89 return; 89 goto out;
90 } 90 }
91#endif 91#endif
92 92
93 err = dpm_suspend_start(PMSG_SUSPEND); 93 err = dpm_suspend_start(PMSG_SUSPEND);
94 if (err) { 94 if (err) {
95 printk(KERN_ERR "xen suspend: dpm_suspend_start %d\n", err); 95 printk(KERN_ERR "xen suspend: dpm_suspend_start %d\n", err);
96 goto out; 96 goto out_thaw;
97 } 97 }
98 98
99 printk(KERN_DEBUG "suspending xenstore...\n");
100 xs_suspend();
101
102 err = dpm_suspend_noirq(PMSG_SUSPEND); 99 err = dpm_suspend_noirq(PMSG_SUSPEND);
103 if (err) { 100 if (err) {
104 printk(KERN_ERR "dpm_suspend_noirq failed: %d\n", err); 101 printk(KERN_ERR "dpm_suspend_noirq failed: %d\n", err);
105 goto resume_devices; 102 goto out_resume;
106 } 103 }
107 104
105 printk(KERN_DEBUG "suspending xenstore...\n");
106 xs_suspend();
107
108 err = stop_machine(xen_suspend, &cancelled, cpumask_of(0)); 108 err = stop_machine(xen_suspend, &cancelled, cpumask_of(0));
109 109
110 dpm_resume_noirq(PMSG_RESUME); 110 dpm_resume_noirq(PMSG_RESUME);
111 111
112 if (err) { 112 if (err) {
113 printk(KERN_ERR "failed to start xen_suspend: %d\n", err); 113 printk(KERN_ERR "failed to start xen_suspend: %d\n", err);
114 goto out; 114 cancelled = 1;
115 } 115 }
116 116
117 if (!cancelled) { 117 if (!cancelled) {
@@ -120,15 +120,17 @@ static void do_suspend(void)
120 } else 120 } else
121 xs_suspend_cancel(); 121 xs_suspend_cancel();
122 122
123resume_devices: 123out_resume:
124 dpm_resume_end(PMSG_RESUME); 124 dpm_resume_end(PMSG_RESUME);
125 125
126 /* Make sure timer events get retriggered on all CPUs */ 126 /* Make sure timer events get retriggered on all CPUs */
127 clock_was_set(); 127 clock_was_set();
128out: 128
129out_thaw:
129#ifdef CONFIG_PREEMPT 130#ifdef CONFIG_PREEMPT
130 thaw_processes(); 131 thaw_processes();
131#endif 132#endif
133out:
132 shutting_down = SHUTDOWN_INVALID; 134 shutting_down = SHUTDOWN_INVALID;
133} 135}
134#endif /* CONFIG_PM_SLEEP */ 136#endif /* CONFIG_PM_SLEEP */