15efdfe75SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 2363c55caSWu Zhangjin /* 3363c55caSWu Zhangjin * Suspend support specific for mips. 4363c55caSWu Zhangjin * 5f7a904dfSWu Zhangjin * Copyright (C) 2009 Lemote Inc. 6363c55caSWu Zhangjin * Author: Hu Hongbing <huhb@lemote.com> 7f7a904dfSWu Zhangjin * Wu Zhangjin <wuzhangjin@gmail.com> 8363c55caSWu Zhangjin */ 97f8998c7SGeert Uytterhoeven #include <asm/sections.h> 10363c55caSWu Zhangjin #include <asm/fpu.h> 11363c55caSWu Zhangjin #include <asm/dsp.h> 12363c55caSWu Zhangjin 13363c55caSWu Zhangjin static u32 saved_status; 14363c55caSWu Zhangjin struct pt_regs saved_regs; 15363c55caSWu Zhangjin save_processor_state(void)16363c55caSWu Zhangjinvoid save_processor_state(void) 17363c55caSWu Zhangjin { 18363c55caSWu Zhangjin saved_status = read_c0_status(); 19363c55caSWu Zhangjin 20363c55caSWu Zhangjin if (is_fpu_owner()) 21363c55caSWu Zhangjin save_fp(current); 229662dd75SAurabindo Jayamohanan 23363c55caSWu Zhangjin save_dsp(current); 24363c55caSWu Zhangjin } 25363c55caSWu Zhangjin restore_processor_state(void)26363c55caSWu Zhangjinvoid restore_processor_state(void) 27363c55caSWu Zhangjin { 28363c55caSWu Zhangjin write_c0_status(saved_status); 29363c55caSWu Zhangjin 30363c55caSWu Zhangjin if (is_fpu_owner()) 31363c55caSWu Zhangjin restore_fp(current); 329662dd75SAurabindo Jayamohanan 33363c55caSWu Zhangjin restore_dsp(current); 34363c55caSWu Zhangjin } 35363c55caSWu Zhangjin pfn_is_nosave(unsigned long pfn)36363c55caSWu Zhangjinint pfn_is_nosave(unsigned long pfn) 37363c55caSWu Zhangjin { 38363c55caSWu Zhangjin unsigned long nosave_begin_pfn = PFN_DOWN(__pa(&__nosave_begin)); 39363c55caSWu Zhangjin unsigned long nosave_end_pfn = PFN_UP(__pa(&__nosave_end)); 40363c55caSWu Zhangjin 41363c55caSWu Zhangjin return (pfn >= nosave_begin_pfn) && (pfn < nosave_end_pfn); 42363c55caSWu Zhangjin } 43