arch/sparc/kernel/leon_smp.c
Source file repositories/reference/linux-study-clean/arch/sparc/kernel/leon_smp.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/kernel/leon_smp.c- Extension
.c- Size
- 11642 bytes
- Lines
- 471
- Domain
- Architecture Layer
- Bucket
- arch/sparc
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/head.hlinux/kernel.hlinux/sched/mm.hlinux/threads.hlinux/smp.hlinux/interrupt.hlinux/kernel_stat.hlinux/of.hlinux/init.hlinux/spinlock.hlinux/mm.hlinux/swap.hlinux/profile.hlinux/pm.hlinux/delay.hlinux/gfp.hlinux/cpu.hlinux/clockchips.hasm/cacheflush.hasm/tlbflush.hasm/ptrace.hlinux/atomic.hasm/irq_regs.hasm/traps.hasm/delay.hasm/irq.hasm/page.hasm/oplib.hasm/cpudata.hasm/asi.hasm/leon.hasm/leon_amba.h
Detected Declarations
struct leon_ipi_workfunction do_swapfunction leon_cpu_pre_startingfunction leon_cpu_pre_onlinefunction leon_configure_cache_smpfunction leon_smp_setbroadcastfunction leon_smp_nrcpusfunction leon_boot_cpusfunction leon_boot_one_cpufunction leon_smp_donefunction leon_ipi_initfunction for_each_possible_cpufunction leon_send_ipifunction leon_ipi_singlefunction leon_ipi_mask_onefunction leon_ipi_reschedfunction leonsmp_ipi_interruptfunction leon_cross_callfunction leon_cross_call_irqfunction leon_init_smp
Annotated Snippet
struct leon_ipi_work {
int single;
int msk;
int resched;
};
static DEFINE_PER_CPU_SHARED_ALIGNED(struct leon_ipi_work, leon_ipi_work);
/* Initialize IPIs on the LEON, in order to save IRQ resources only one IRQ
* is used for all three types of IPIs.
*/
static void __init leon_ipi_init(void)
{
int cpu, len;
struct leon_ipi_work *work;
struct property *pp;
struct device_node *rootnp;
struct tt_entry *trap_table;
unsigned long flags;
/* Find IPI IRQ or stick with default value */
rootnp = of_find_node_by_path("/ambapp0");
if (rootnp) {
pp = of_find_property(rootnp, "ipi_num", &len);
if (pp && (*(int *)pp->value))
leon_ipi_irq = *(int *)pp->value;
}
printk(KERN_INFO "leon: SMP IPIs at IRQ %d\n", leon_ipi_irq);
/* Adjust so that we jump directly to smpleon_ipi */
local_irq_save(flags);
trap_table = &sparc_ttable[SP_TRAP_IRQ1 + (leon_ipi_irq - 1)];
trap_table->inst_three += smpleon_ipi - real_irq_entry;
local_ops->cache_all();
local_irq_restore(flags);
for_each_possible_cpu(cpu) {
work = &per_cpu(leon_ipi_work, cpu);
work->single = work->msk = work->resched = 0;
}
}
static void leon_send_ipi(int cpu, int level)
{
unsigned long mask;
mask = leon_get_irqmask(level);
LEON3_BYPASS_STORE_PA(&leon3_irqctrl_regs->force[cpu], mask);
}
static void leon_ipi_single(int cpu)
{
struct leon_ipi_work *work = &per_cpu(leon_ipi_work, cpu);
/* Mark work */
work->single = 1;
/* Generate IRQ on the CPU */
leon_send_ipi(cpu, leon_ipi_irq);
}
static void leon_ipi_mask_one(int cpu)
{
struct leon_ipi_work *work = &per_cpu(leon_ipi_work, cpu);
/* Mark work */
work->msk = 1;
/* Generate IRQ on the CPU */
leon_send_ipi(cpu, leon_ipi_irq);
}
static void leon_ipi_resched(int cpu)
{
struct leon_ipi_work *work = &per_cpu(leon_ipi_work, cpu);
/* Mark work */
work->resched = 1;
/* Generate IRQ on the CPU (any IRQ will cause resched) */
leon_send_ipi(cpu, leon_ipi_irq);
}
void leonsmp_ipi_interrupt(void)
{
struct leon_ipi_work *work = this_cpu_ptr(&leon_ipi_work);
if (work->single) {
work->single = 0;
smp_call_function_single_interrupt();
}
Annotation
- Immediate include surface: `asm/head.h`, `linux/kernel.h`, `linux/sched/mm.h`, `linux/threads.h`, `linux/smp.h`, `linux/interrupt.h`, `linux/kernel_stat.h`, `linux/of.h`.
- Detected declarations: `struct leon_ipi_work`, `function do_swap`, `function leon_cpu_pre_starting`, `function leon_cpu_pre_online`, `function leon_configure_cache_smp`, `function leon_smp_setbroadcast`, `function leon_smp_nrcpus`, `function leon_boot_cpus`, `function leon_boot_one_cpu`, `function leon_smp_done`.
- Atlas domain: Architecture Layer / arch/sparc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.