arch/riscv/kernel/suspend.c
Source file repositories/reference/linux-study-clean/arch/riscv/kernel/suspend.c
File Facts
- System
- Linux kernel
- Corpus path
arch/riscv/kernel/suspend.c- Extension
.c- Size
- 4865 bytes
- Lines
- 199
- Domain
- Architecture Layer
- Bucket
- arch/riscv
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ftrace.hlinux/suspend.hasm/csr.hasm/sbi.hasm/suspend.h
Detected Declarations
function Copyrightfunction devicesfunction suspend_restore_csrsfunction cpu_suspendfunction sbi_system_suspendfunction sbi_system_suspend_enterfunction sbi_system_suspend_initfunction sbi_suspend_finisherfunction riscv_sbi_hart_suspendfunction riscv_sbi_suspend_state_is_validfunction riscv_sbi_hsm_is_supported
Annotated Snippet
sbi_probe_extension(SBI_EXT_SUSP) > 0) {
pr_info("SBI SUSP extension detected\n");
if (IS_ENABLED(CONFIG_SUSPEND))
suspend_set_ops(&sbi_system_suspend_ops);
}
return 0;
}
arch_initcall(sbi_system_suspend_init);
static int sbi_suspend_finisher(unsigned long suspend_type,
unsigned long resume_addr,
unsigned long opaque)
{
struct sbiret ret;
ret = sbi_ecall(SBI_EXT_HSM, SBI_EXT_HSM_HART_SUSPEND,
suspend_type, resume_addr, opaque, 0, 0, 0);
return (ret.error) ? sbi_err_map_linux_errno(ret.error) : 0;
}
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)
return false;
if (state > SBI_HSM_SUSPEND_NON_RET_DEFAULT &&
state < SBI_HSM_SUSPEND_NON_RET_PLATFORM)
return false;
return true;
}
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");
return false;
}
return true;
}
#endif /* CONFIG_RISCV_SBI */
Annotation
- Immediate include surface: `linux/ftrace.h`, `linux/suspend.h`, `asm/csr.h`, `asm/sbi.h`, `asm/suspend.h`.
- Detected declarations: `function Copyright`, `function devices`, `function suspend_restore_csrs`, `function cpu_suspend`, `function sbi_system_suspend`, `function sbi_system_suspend_enter`, `function sbi_system_suspend_init`, `function sbi_suspend_finisher`, `function riscv_sbi_hart_suspend`, `function riscv_sbi_suspend_state_is_valid`.
- Atlas domain: Architecture Layer / arch/riscv.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.