/* * Snapshot kernel memory and reset the system. * * swsusp_save() is executed in the suspend finisher so that the CPU * context pointer and memory are part of the saved image, which is * required by the resume kernel image to restart execution from * swsusp_arch_suspend(). * * soft_restart is not technically needed, but is used to get success * returned from cpu_suspend. * * When soft reboot completes, the hibernation snapshot is written out. */ static int notrace arch_save_image(unsigned long unused) { int ret; ret = swsusp_save(); if (ret == 0) _soft_restart(virt_to_phys(cpu_resume), false); return ret; }
/* * Restore page contents for physical pages that were in use during loading * hibernation image. Switch to idmap_pgd so the physical page tables * are overwritten with the same contents. */ static void notrace arch_restore_image(void *unused) { struct pbe *pbe; cpu_switch_mm(idmap_pgd, &init_mm); for (pbe = restore_pblist; pbe; pbe = pbe->next) copy_page(pbe->orig_address, pbe->address); _soft_restart(virt_to_phys(cpu_resume), false); }
/* * Snapshot kernel memory and reset the system. * * swsusp_save() is executed in the suspend finisher so that the CPU * context pointer and memory are part of the saved image, which is * required by the resume kernel image to restart execution from * swsusp_arch_suspend(). * * soft_restart is not technically needed, but is used to get success * returned from cpu_suspend. * * When soft reboot completes, the hibernation snapshot is written out. */ static int notrace arch_save_image(unsigned long unused) { int ret; ret = swsusp_save(); #ifdef CONFIG_MTK_HIBERNATION swsusp_saved = (ret == 0) ? 1 : 0; #else if (ret == 0) _soft_restart(virt_to_phys(cpu_resume), false); #endif return ret; }
/* * Restore page contents for physical pages that were in use during loading * hibernation image. Switch to idmap_pgd so the physical page tables * are overwritten with the same contents. */ static void notrace arch_restore_image(void *unused) { #ifdef CONFIG_MTK_HIBERNATION mtk_arch_restore_image(); #else struct pbe *pbe; cpu_switch_mm(idmap_pgd, &init_mm); for (pbe = restore_pblist; pbe; pbe = pbe->next) copy_page(pbe->orig_address, pbe->address); _soft_restart(virt_to_phys(cpu_resume), false); #endif }
void soft_restart(unsigned long addr) { _soft_restart(addr, num_online_cpus() == 1); }