// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2021 Western Digital Corporation or its affiliates. * Copyright (c) 2022 Ventana Micro Systems Inc.
*/
/* * No need to save/restore IP CSR (i.e. MIP or SIP) because: * * 1. For no-MMU (M-mode) kernel, the bits in MIP are set by * external devices (such as interrupt controller, timer, etc). * 2. For MMU (S-mode) kernel, the bits in SIP are set by * M-mode firmware and external devices (such as interrupt * controller, etc).
*/
int cpu_suspend(unsignedlong arg, int (*finish)(unsignedlong arg, unsignedlong entry, unsignedlong context))
{ int rc = 0; struct suspend_context context = { 0 };
/* Finisher should be non-NULL */ if (!finish) return -EINVAL;
/* Save additional CSRs*/
suspend_save_csrs(&context);
/* * Function graph tracer state gets incosistent when the kernel * calls functions that never return (aka finishers) hence disable * graph tracing during their execution.
*/
pause_graph_tracing();
/* Save context on stack */ if (__cpu_suspend_enter(&context)) { /* Call the finisher */
rc = finish(arg, __pa_symbol(__cpu_resume_enter),
(ulong)&context);
/* * Should never reach here, unless the suspend finisher * fails. Successful cpu_suspend() should return from * __cpu_resume_entry()
*/ if (!rc)
rc = -EOPNOTSUPP;
}
/* Enable function graph tracer */
unpause_graph_tracing();
int riscv_sbi_hart_suspend(u32 state)
{ if (state & SBI_HSM_SUSP_NON_RET_BIT) return cpu_suspend(state, sbi_suspend_finisher); else return sbi_suspend_finisher(state, 0, 0);
}
bool riscv_sbi_suspend_state_is_valid(u32 state)
{ if (state > SBI_HSM_SUSPEND_RET_DEFAULT &&
state < SBI_HSM_SUSPEND_RET_PLATFORM) returnfalse;
if (state > SBI_HSM_SUSPEND_NON_RET_DEFAULT &&
state < SBI_HSM_SUSPEND_NON_RET_PLATFORM) returnfalse;
returntrue;
}
bool riscv_sbi_hsm_is_supported(void)
{ /* * The SBI HSM suspend function is only available when: * 1) SBI version is 0.3 or higher * 2) SBI HSM extension is available
*/ if (sbi_spec_version < sbi_mk_version(0, 3) ||
!sbi_probe_extension(SBI_EXT_HSM)) {
pr_info("HSM suspend not available\n"); returnfalse;
}
returntrue;
} #endif/* CONFIG_RISCV_SBI */
Messung V0.5
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.