control.c (4ea0b4ad1a4a2f3d2ffb0db8b7c24fe947f8480c) control.c (fdce57a04219d7a36c6646950fde6c8bcd97c044)
1/*-
2 * Copyright (c) 2010 Justin T. Gibbs, Spectra Logic Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 188 unchanged lines hidden (view full) ---

197 cpuset_t cpu_suspend_map;
198#endif
199 int suspend_cancelled;
200
201 EVENTHANDLER_INVOKE(power_suspend_early);
202 stop_all_proc();
203 EVENTHANDLER_INVOKE(power_suspend);
204
1/*-
2 * Copyright (c) 2010 Justin T. Gibbs, Spectra Logic Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 188 unchanged lines hidden (view full) ---

197 cpuset_t cpu_suspend_map;
198#endif
199 int suspend_cancelled;
200
201 EVENTHANDLER_INVOKE(power_suspend_early);
202 stop_all_proc();
203 EVENTHANDLER_INVOKE(power_suspend);
204
205#ifdef EARLY_AP_STARTUP
206 MPASS(mp_ncpus == 1 || smp_started);
207 thread_lock(curthread);
208 sched_bind(curthread, 0);
209 thread_unlock(curthread);
210#else
205 if (smp_started) {
206 thread_lock(curthread);
207 sched_bind(curthread, 0);
208 thread_unlock(curthread);
209 }
211 if (smp_started) {
212 thread_lock(curthread);
213 sched_bind(curthread, 0);
214 thread_unlock(curthread);
215 }
216#endif
210 KASSERT((PCPU_GET(cpuid) == 0), ("Not running on CPU#0"));
211
212 /*
213 * Clear our XenStore node so the toolstack knows we are
214 * responding to the suspend request.
215 */
216 xs_write(XST_NIL, "control", "shutdown", "");
217

--- 4 unchanged lines hidden (view full) ---

222 mtx_lock(&Giant);
223 if (DEVICE_SUSPEND(root_bus) != 0) {
224 mtx_unlock(&Giant);
225 printf("%s: device_suspend failed\n", __func__);
226 return;
227 }
228
229#ifdef SMP
217 KASSERT((PCPU_GET(cpuid) == 0), ("Not running on CPU#0"));
218
219 /*
220 * Clear our XenStore node so the toolstack knows we are
221 * responding to the suspend request.
222 */
223 xs_write(XST_NIL, "control", "shutdown", "");
224

--- 4 unchanged lines hidden (view full) ---

229 mtx_lock(&Giant);
230 if (DEVICE_SUSPEND(root_bus) != 0) {
231 mtx_unlock(&Giant);
232 printf("%s: device_suspend failed\n", __func__);
233 return;
234 }
235
236#ifdef SMP
237#ifdef EARLY_AP_STARTUP
238 /*
239 * Suspend other CPUs. This prevents IPIs while we
240 * are resuming, and will allow us to reset per-cpu
241 * vcpu_info on resume.
242 */
243 cpu_suspend_map = all_cpus;
244 CPU_CLR(PCPU_GET(cpuid), &cpu_suspend_map);
245 if (!CPU_EMPTY(&cpu_suspend_map))
246 suspend_cpus(cpu_suspend_map);
247#else
230 CPU_ZERO(&cpu_suspend_map); /* silence gcc */
231 if (smp_started) {
232 /*
233 * Suspend other CPUs. This prevents IPIs while we
234 * are resuming, and will allow us to reset per-cpu
235 * vcpu_info on resume.
236 */
237 cpu_suspend_map = all_cpus;
238 CPU_CLR(PCPU_GET(cpuid), &cpu_suspend_map);
239 if (!CPU_EMPTY(&cpu_suspend_map))
240 suspend_cpus(cpu_suspend_map);
241 }
242#endif
248 CPU_ZERO(&cpu_suspend_map); /* silence gcc */
249 if (smp_started) {
250 /*
251 * Suspend other CPUs. This prevents IPIs while we
252 * are resuming, and will allow us to reset per-cpu
253 * vcpu_info on resume.
254 */
255 cpu_suspend_map = all_cpus;
256 CPU_CLR(PCPU_GET(cpuid), &cpu_suspend_map);
257 if (!CPU_EMPTY(&cpu_suspend_map))
258 suspend_cpus(cpu_suspend_map);
259 }
260#endif
261#endif
243
244 /*
245 * Prevent any races with evtchn_interrupt() handler.
246 */
247 disable_intr();
248 intr_suspend();
249 xen_hvm_suspend();
250

--- 29 unchanged lines hidden (view full) ---

280
281 /*
282 * Warm up timecounter again and reset system clock.
283 */
284 timecounter->tc_get_timecount(timecounter);
285 timecounter->tc_get_timecount(timecounter);
286 inittodr(time_second);
287
262
263 /*
264 * Prevent any races with evtchn_interrupt() handler.
265 */
266 disable_intr();
267 intr_suspend();
268 xen_hvm_suspend();
269

--- 29 unchanged lines hidden (view full) ---

299
300 /*
301 * Warm up timecounter again and reset system clock.
302 */
303 timecounter->tc_get_timecount(timecounter);
304 timecounter->tc_get_timecount(timecounter);
305 inittodr(time_second);
306
307#ifdef EARLY_AP_STARTUP
308 thread_lock(curthread);
309 sched_unbind(curthread);
310 thread_unlock(curthread);
311#else
288 if (smp_started) {
289 thread_lock(curthread);
290 sched_unbind(curthread);
291 thread_unlock(curthread);
292 }
312 if (smp_started) {
313 thread_lock(curthread);
314 sched_unbind(curthread);
315 thread_unlock(curthread);
316 }
317#endif
293
294 resume_all_proc();
295
296 EVENTHANDLER_INVOKE(power_resume);
297
298 if (bootverbose)
299 printf("System resumed after suspension\n");
300

--- 148 unchanged lines hidden ---
318
319 resume_all_proc();
320
321 EVENTHANDLER_INVOKE(power_resume);
322
323 if (bootverbose)
324 printf("System resumed after suspension\n");
325

--- 148 unchanged lines hidden ---