arch/loongarch/kernel/cpu-probe.c
Source file repositories/reference/linux-study-clean/arch/loongarch/kernel/cpu-probe.c
File Facts
- System
- Linux kernel
- Corpus path
arch/loongarch/kernel/cpu-probe.c- Extension
.c- Size
- 10344 bytes
- Lines
- 416
- Domain
- Architecture Layer
- Bucket
- arch/loongarch
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/kernel.hlinux/ptrace.hlinux/cpu.hlinux/smp.hlinux/stddef.hlinux/export.hlinux/printk.hlinux/uaccess.hasm/cpu-features.hasm/elf.hasm/fpu.hasm/loongarch.hasm/pgtable-bits.hasm/setup.h
Detected Declarations
function cpu_set_fpu_fcsr_maskfunction cpu_setup_simdfunction cpu_final_simdfunction set_elf_platformfunction cpu_probe_addrbitsfunction set_isafunction cpu_probe_commonfunction cpu_probe_loongsonfunction cpu_reportfunction cpu_probefunction cpu_show_spectre_v1export elf_hwcapexport vm_map_baseexport __ua_limit
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Processor capabilities determination functions.
*
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited
*/
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/ptrace.h>
#include <linux/cpu.h>
#include <linux/smp.h>
#include <linux/stddef.h>
#include <linux/export.h>
#include <linux/printk.h>
#include <linux/uaccess.h>
#include <asm/cpu-features.h>
#include <asm/elf.h>
#include <asm/fpu.h>
#include <asm/loongarch.h>
#include <asm/pgtable-bits.h>
#include <asm/setup.h>
/* Hardware capabilities */
unsigned int elf_hwcap __read_mostly;
EXPORT_SYMBOL_GPL(elf_hwcap);
/*
* Determine the FCSR mask for FPU hardware.
*/
static inline void cpu_set_fpu_fcsr_mask(struct cpuinfo_loongarch *c)
{
unsigned long sr, mask, fcsr, fcsr0, fcsr1;
fcsr = c->fpu_csr0;
mask = FPU_CSR_ALL_X | FPU_CSR_ALL_E | FPU_CSR_ALL_S | FPU_CSR_RM;
sr = read_csr_euen();
enable_fpu();
fcsr0 = fcsr & mask;
write_fcsr(LOONGARCH_FCSR0, fcsr0);
fcsr0 = read_fcsr(LOONGARCH_FCSR0);
fcsr1 = fcsr | ~mask;
write_fcsr(LOONGARCH_FCSR0, fcsr1);
fcsr1 = read_fcsr(LOONGARCH_FCSR0);
write_fcsr(LOONGARCH_FCSR0, fcsr);
write_csr_euen(sr);
c->fpu_mask = ~(fcsr0 ^ fcsr1) & ~mask;
}
/* simd = -1/0/128/256 */
static unsigned int simd = -1U;
static int __init cpu_setup_simd(char *str)
{
get_option(&str, &simd);
pr_info("Set SIMD width = %u\n", simd);
return 0;
}
early_param("simd", cpu_setup_simd);
static int __init cpu_final_simd(void)
{
struct cpuinfo_loongarch *c = &cpu_data[0];
if (simd < 128) {
c->options &= ~LOONGARCH_CPU_LSX;
elf_hwcap &= ~HWCAP_LOONGARCH_LSX;
}
if (simd < 256) {
c->options &= ~LOONGARCH_CPU_LASX;
elf_hwcap &= ~HWCAP_LOONGARCH_LASX;
}
simd = 0;
if (c->options & LOONGARCH_CPU_LSX)
simd = 128;
if (c->options & LOONGARCH_CPU_LASX)
simd = 256;
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/ptrace.h`, `linux/cpu.h`, `linux/smp.h`, `linux/stddef.h`, `linux/export.h`, `linux/printk.h`.
- Detected declarations: `function cpu_set_fpu_fcsr_mask`, `function cpu_setup_simd`, `function cpu_final_simd`, `function set_elf_platform`, `function cpu_probe_addrbits`, `function set_isa`, `function cpu_probe_common`, `function cpu_probe_loongson`, `function cpu_report`, `function cpu_probe`.
- Atlas domain: Architecture Layer / arch/loongarch.
- Implementation status: integration 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.