arch/loongarch/include/asm/fpu.h
Source file repositories/reference/linux-study-clean/arch/loongarch/include/asm/fpu.h
File Facts
- System
- Linux kernel
- Corpus path
arch/loongarch/include/asm/fpu.h- Extension
.h- Size
- 7378 bytes
- Lines
- 327
- Domain
- Architecture Layer
- Bucket
- arch/loongarch
- 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/sched.hlinux/sched/task_stack.hlinux/ptrace.hlinux/thread_info.hlinux/bitops.hasm/cpu.hasm/cpu-features.hasm/current.hasm/loongarch.hasm/processor.hasm/ptrace.h
Detected Declarations
struct sigcontextfunction mask_fcsr_xfunction is_fp_enabledfunction is_lsx_enabledfunction is_lasx_enabledfunction is_simd_enabledfunction is_fpu_ownerfunction __own_fpufunction own_fpu_inatomicfunction own_fpufunction lose_fpu_inatomicfunction lose_fpufunction init_fpufunction save_fpfunction restore_fpfunction save_fpu_regsfunction is_simd_ownerfunction enable_lsxfunction disable_lsxfunction save_lsxfunction restore_lsxfunction init_lsx_upperfunction restore_lsx_upperfunction enable_lsxfunction disable_lasxfunction save_lasxfunction restore_lasxfunction init_lasx_upperfunction restore_lasx_upperfunction enable_lasxfunction thread_lasx_context_live
Annotated Snippet
if (!is_simd_enabled()) {
if (save)
_save_fp(&tsk->thread.fpu);
disable_fpu();
} else {
if (save) {
if (!is_lasx_enabled())
save_lsx(tsk);
else
save_lasx(tsk);
}
disable_fpu();
disable_lsx();
disable_lasx();
clear_tsk_thread_flag(tsk, TIF_USEDSIMD);
}
clear_tsk_thread_flag(tsk, TIF_USEDFPU);
}
KSTK_EUEN(tsk) &= ~(CSR_EUEN_FPEN | CSR_EUEN_LSXEN | CSR_EUEN_LASXEN);
}
static inline void lose_fpu(int save)
{
preempt_disable();
lose_fpu_inatomic(save, current);
preempt_enable();
}
static inline void init_fpu(void)
{
unsigned int fcsr = current->thread.fpu.fcsr;
__own_fpu();
_init_fpu(fcsr);
set_used_math();
}
static inline void save_fp(struct task_struct *tsk)
{
if (cpu_has_fpu)
_save_fp(&tsk->thread.fpu);
}
static inline void restore_fp(struct task_struct *tsk)
{
if (cpu_has_fpu)
_restore_fp(&tsk->thread.fpu);
}
static inline void save_fpu_regs(struct task_struct *tsk)
{
unsigned int euen;
if (tsk == current) {
preempt_disable();
euen = csr_read32(LOONGARCH_CSR_EUEN);
#ifdef CONFIG_CPU_HAS_LASX
if (euen & CSR_EUEN_LASXEN)
_save_lasx(¤t->thread.fpu);
else
#endif
#ifdef CONFIG_CPU_HAS_LSX
if (euen & CSR_EUEN_LSXEN)
_save_lsx(¤t->thread.fpu);
else
#endif
if (euen & CSR_EUEN_FPEN)
_save_fp(¤t->thread.fpu);
preempt_enable();
}
}
static inline int is_simd_owner(void)
{
return test_thread_flag(TIF_USEDSIMD);
}
#ifdef CONFIG_CPU_HAS_LSX
static inline void enable_lsx(void)
{
if (cpu_has_lsx)
csr_xchg32(CSR_EUEN_LSXEN, CSR_EUEN_LSXEN, LOONGARCH_CSR_EUEN);
}
static inline void disable_lsx(void)
{
Annotation
- Immediate include surface: `linux/sched.h`, `linux/sched/task_stack.h`, `linux/ptrace.h`, `linux/thread_info.h`, `linux/bitops.h`, `asm/cpu.h`, `asm/cpu-features.h`, `asm/current.h`.
- Detected declarations: `struct sigcontext`, `function mask_fcsr_x`, `function is_fp_enabled`, `function is_lsx_enabled`, `function is_lasx_enabled`, `function is_simd_enabled`, `function is_fpu_owner`, `function __own_fpu`, `function own_fpu_inatomic`, `function own_fpu`.
- Atlas domain: Architecture Layer / arch/loongarch.
- 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.