arch/mips/loongson64/smp.c
Source file repositories/reference/linux-study-clean/arch/mips/loongson64/smp.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/loongson64/smp.c- Extension
.c- Size
- 28820 bytes
- Lines
- 859
- Domain
- Architecture Layer
- Bucket
- arch/mips
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
irq.hlinux/init.hlinux/cpu.hlinux/sched.hlinux/sched/hotplug.hlinux/sched/task_stack.hlinux/smp.hlinux/cpufreq.hlinux/kexec.hasm/processor.hasm/smp.hasm/time.hasm/tlbflush.hasm/cacheflush.hloongson.hloongson_regs.hworkarounds.hsmp.h
Detected Declarations
function csr_mail_sendfunction csr_ipi_read_clearfunction csr_ipi_write_actionfunction csr_ipi_write_enablefunction csr_ipi_clear_buffunction csr_ipi_write_buffunction legacy_ipi_read_clearfunction legacy_ipi_write_actionfunction legacy_ipi_write_enablefunction legacy_ipi_clear_buffunction legacy_ipi_write_buffunction csr_ipi_probefunction ipi_set0_regs_initfunction ipi_clear0_regs_initfunction ipi_status0_regs_initfunction ipi_en0_regs_initfunction ipi_mailbox_buf_initfunction loongson3_send_ipi_singlefunction loongson3_send_ipi_maskfunction loongson3_ipi_interruptfunction loongson3_init_secondaryfunction loongson3_smp_finishfunction loongson3_smp_setupfunction loongson3_prepare_cpusfunction loongson3_boot_secondaryfunction loongson3_cpu_disablefunction loongson3_cpu_diefunction CKSEG1function loongson3_type2_play_deadfunction loongson3_type3_play_deadfunction play_deadfunction loongson3_disable_clockfunction loongson3_enable_clockfunction register_loongson3_notifier
Annotated Snippet
if (loongson_sysconf.reserved_cpus_mask & (1<<i)) {
/* Reserved physical CPU cores */
__cpu_number_map[i] = -1;
} else {
__cpu_number_map[i] = num;
__cpu_logical_map[num] = i;
set_cpu_possible(num, true);
/* Loongson processors are always grouped by 4 */
cpu_set_cluster(&cpu_data[num], i / 4);
num++;
}
i++;
}
pr_info("Detected %i available CPU(s)\n", num);
while (num < loongson_sysconf.nr_cpus) {
__cpu_logical_map[num] = -1;
num++;
}
csr_ipi_probe();
ipi_set0_regs_init();
ipi_clear0_regs_init();
ipi_status0_regs_init();
ipi_en0_regs_init();
ipi_mailbox_buf_init();
if (smp_group[0])
ipi_write_enable(0);
cpu_set_core(&cpu_data[0],
cpu_logical_map(0) % loongson_sysconf.cores_per_package);
cpu_data[0].package = cpu_logical_map(0) / loongson_sysconf.cores_per_package;
}
static void __init loongson3_prepare_cpus(unsigned int max_cpus)
{
if (request_irq(LS_IPI_IRQ, loongson3_ipi_interrupt,
IRQF_PERCPU | IRQF_NO_SUSPEND, "SMP_IPI", NULL))
pr_err("Failed to request IPI IRQ\n");
init_cpu_present(cpu_possible_mask);
per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
}
/*
* Setup the PC, SP, and GP of a secondary processor and start it running!
*/
static int loongson3_boot_secondary(int cpu, struct task_struct *idle)
{
pr_info("Booting CPU#%d...\n", cpu);
ipi_write_buf(cpu, idle);
return 0;
}
#ifdef CONFIG_HOTPLUG_CPU
static int loongson3_cpu_disable(void)
{
unsigned long flags;
unsigned int cpu = smp_processor_id();
set_cpu_online(cpu, false);
calculate_cpu_foreign_map();
local_irq_save(flags);
clear_c0_status(ST0_IM);
local_irq_restore(flags);
local_flush_tlb_all();
return 0;
}
static void loongson3_cpu_die(unsigned int cpu)
{
while (per_cpu(cpu_state, cpu) != CPU_DEAD)
cpu_relax();
mb();
}
/* To shutdown a core in Loongson 3, the target core should go to CKSEG1 and
* flush all L1 entries at first. Then, another core (usually Core 0) can
* safely disable the clock of the target core. loongson3_play_dead() is
* called via CKSEG1 (uncached and unmmaped)
*/
static void loongson3_type1_play_dead(int *state_addr)
{
register int val;
register long cpuid, core, node, count;
register void *addr, *base, *initfunc;
Annotation
- Immediate include surface: `irq.h`, `linux/init.h`, `linux/cpu.h`, `linux/sched.h`, `linux/sched/hotplug.h`, `linux/sched/task_stack.h`, `linux/smp.h`, `linux/cpufreq.h`.
- Detected declarations: `function csr_mail_send`, `function csr_ipi_read_clear`, `function csr_ipi_write_action`, `function csr_ipi_write_enable`, `function csr_ipi_clear_buf`, `function csr_ipi_write_buf`, `function legacy_ipi_read_clear`, `function legacy_ipi_write_action`, `function legacy_ipi_write_enable`, `function legacy_ipi_clear_buf`.
- Atlas domain: Architecture Layer / arch/mips.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.