arch/arm/common/mcpm_entry.c
Source file repositories/reference/linux-study-clean/arch/arm/common/mcpm_entry.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm/common/mcpm_entry.c- Extension
.c- Size
- 13026 bytes
- Lines
- 457
- Domain
- Architecture Layer
- Bucket
- arch/arm
- 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.
- 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
linux/export.hlinux/kernel.hlinux/init.hlinux/irqflags.hlinux/cpu_pm.hasm/mcpm.hasm/cacheflush.hasm/idmap.hasm/cputype.hasm/suspend.h
Detected Declarations
function cachefunction cachefunction __mcpm_outbound_leave_criticalfunction __mcpm_outbound_enter_criticalfunction __mcpm_cluster_statefunction mcpm_set_entry_vectorfunction mcpm_set_early_pokefunction mcpm_platform_registerfunction mcpm_is_availablefunction mcpm_cluster_unusedfunction mcpm_cpu_power_upfunction mcpm_cpu_power_downfunction mcpm_wait_for_cpu_powerdownfunction mcpm_cpu_suspendfunction mcpm_cpu_powered_upfunction nocache_trampolinefunction mcpm_loopbackfunction mcpm_sync_initexport mcpm_is_available
Annotated Snippet
while (1) {
cpustate = c->cpus[i].cpu;
if (cpustate != CPU_GOING_DOWN)
break;
wfe();
sync_cache_r(&c->cpus[i].cpu);
}
switch (cpustate) {
case CPU_DOWN:
continue;
default:
goto abort;
}
}
return true;
abort:
__mcpm_outbound_leave_critical(cluster, CLUSTER_UP);
return false;
}
static int __mcpm_cluster_state(unsigned int cluster)
{
sync_cache_r(&mcpm_sync.clusters[cluster].cluster);
return mcpm_sync.clusters[cluster].cluster;
}
extern unsigned long mcpm_entry_vectors[MAX_NR_CLUSTERS][MAX_CPUS_PER_CLUSTER];
void mcpm_set_entry_vector(unsigned cpu, unsigned cluster, void *ptr)
{
unsigned long val = ptr ? __pa_symbol(ptr) : 0;
mcpm_entry_vectors[cluster][cpu] = val;
sync_cache_w(&mcpm_entry_vectors[cluster][cpu]);
}
extern unsigned long mcpm_entry_early_pokes[MAX_NR_CLUSTERS][MAX_CPUS_PER_CLUSTER][2];
void mcpm_set_early_poke(unsigned cpu, unsigned cluster,
unsigned long poke_phys_addr, unsigned long poke_val)
{
unsigned long *poke = &mcpm_entry_early_pokes[cluster][cpu][0];
poke[0] = poke_phys_addr;
poke[1] = poke_val;
__sync_cache_range_w(poke, 2 * sizeof(*poke));
}
static const struct mcpm_platform_ops *platform_ops;
int __init mcpm_platform_register(const struct mcpm_platform_ops *ops)
{
if (platform_ops)
return -EBUSY;
platform_ops = ops;
return 0;
}
bool mcpm_is_available(void)
{
return (platform_ops) ? true : false;
}
EXPORT_SYMBOL_GPL(mcpm_is_available);
/*
* We can't use regular spinlocks. In the switcher case, it is possible
* for an outbound CPU to call power_down() after its inbound counterpart
* is already live using the same logical CPU number which trips lockdep
* debugging.
*/
static arch_spinlock_t mcpm_lock = __ARCH_SPIN_LOCK_UNLOCKED;
static int mcpm_cpu_use_count[MAX_NR_CLUSTERS][MAX_CPUS_PER_CLUSTER];
static inline bool mcpm_cluster_unused(unsigned int cluster)
{
int i, cnt;
for (i = 0, cnt = 0; i < MAX_CPUS_PER_CLUSTER; i++)
cnt |= mcpm_cpu_use_count[cluster][i];
return !cnt;
}
int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster)
{
bool cpu_is_down, cluster_is_down;
int ret = 0;
Annotation
- Immediate include surface: `linux/export.h`, `linux/kernel.h`, `linux/init.h`, `linux/irqflags.h`, `linux/cpu_pm.h`, `asm/mcpm.h`, `asm/cacheflush.h`, `asm/idmap.h`.
- Detected declarations: `function cache`, `function cache`, `function __mcpm_outbound_leave_critical`, `function __mcpm_outbound_enter_critical`, `function __mcpm_cluster_state`, `function mcpm_set_entry_vector`, `function mcpm_set_early_poke`, `function mcpm_platform_register`, `function mcpm_is_available`, `function mcpm_cluster_unused`.
- Atlas domain: Architecture Layer / arch/arm.
- Implementation status: integration 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.