|
21 | 21 | #include <asm/suspend.h> |
22 | 22 | #include <asm/debugreg.h> |
23 | 23 | #include <asm/fpu-internal.h> /* pcntxt_mask */ |
| 24 | +#include <asm/cpu.h> |
24 | 25 |
|
25 | 26 | #ifdef CONFIG_X86_32 |
26 | 27 | static struct saved_context saved_context; |
@@ -263,6 +264,43 @@ static int bsp_pm_callback(struct notifier_block *nb, unsigned long action, |
263 | 264 | case PM_HIBERNATION_PREPARE: |
264 | 265 | ret = bsp_check(); |
265 | 266 | break; |
| 267 | +#ifdef CONFIG_DEBUG_HOTPLUG_CPU0 |
| 268 | + case PM_RESTORE_PREPARE: |
| 269 | + /* |
| 270 | + * When system resumes from hibernation, online CPU0 because |
| 271 | + * 1. it's required for resume and |
| 272 | + * 2. the CPU was online before hibernation |
| 273 | + */ |
| 274 | + if (!cpu_online(0)) |
| 275 | + _debug_hotplug_cpu(0, 1); |
| 276 | + break; |
| 277 | + case PM_POST_RESTORE: |
| 278 | + /* |
| 279 | + * When a resume really happens, this code won't be called. |
| 280 | + * |
| 281 | + * This code is called only when user space hibernation software |
| 282 | + * prepares for snapshot device during boot time. So we just |
| 283 | + * call _debug_hotplug_cpu() to restore to CPU0's state prior to |
| 284 | + * preparing the snapshot device. |
| 285 | + * |
| 286 | + * This works for normal boot case in our CPU0 hotplug debug |
| 287 | + * mode, i.e. CPU0 is offline and user mode hibernation |
| 288 | + * software initializes during boot time. |
| 289 | + * |
| 290 | + * If CPU0 is online and user application accesses snapshot |
| 291 | + * device after boot time, this will offline CPU0 and user may |
| 292 | + * see different CPU0 state before and after accessing |
| 293 | + * the snapshot device. But hopefully this is not a case when |
| 294 | + * user debugging CPU0 hotplug. Even if users hit this case, |
| 295 | + * they can easily online CPU0 back. |
| 296 | + * |
| 297 | + * To simplify this debug code, we only consider normal boot |
| 298 | + * case. Otherwise we need to remember CPU0's state and restore |
| 299 | + * to that state and resolve racy conditions etc. |
| 300 | + */ |
| 301 | + _debug_hotplug_cpu(0, 0); |
| 302 | + break; |
| 303 | +#endif |
266 | 304 | default: |
267 | 305 | break; |
268 | 306 | } |
|
0 commit comments