arch/arm/kernel/cpuidle.c
Source file repositories/reference/linux-study-clean/arch/arm/kernel/cpuidle.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm/kernel/cpuidle.c- Extension
.c- Size
- 4048 bytes
- Lines
- 149
- Domain
- Architecture Layer
- Bucket
- arch/arm
- 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/cpuidle.hlinux/of.hasm/cpuidle.h
Detected Declarations
function arm_cpuidle_simple_enterfunction arm_cpuidle_suspendfunction arm_cpuidle_get_opsfunction arm_cpuidle_read_opsfunction arm_cpuidle_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright 2012 Linaro Ltd.
*/
#include <linux/cpuidle.h>
#include <linux/of.h>
#include <asm/cpuidle.h>
extern struct of_cpuidle_method __cpuidle_method_of_table[];
static const struct of_cpuidle_method __cpuidle_method_of_table_sentinel
__used __section("__cpuidle_method_of_table_end");
static struct cpuidle_ops cpuidle_ops[NR_CPUS] __ro_after_init;
/**
* arm_cpuidle_simple_enter() - a wrapper to cpu_do_idle()
* @dev: not used
* @drv: not used
* @index: not used
*
* A trivial wrapper to allow the cpu_do_idle function to be assigned as a
* cpuidle callback by matching the function signature.
*
* Returns the index passed as parameter
*/
__cpuidle int arm_cpuidle_simple_enter(struct cpuidle_device *dev, struct
cpuidle_driver *drv, int index)
{
cpu_do_idle();
return index;
}
/**
* arm_cpuidle_suspend() - function to enter low power idle states
* @index: an integer used as an identifier for the low level PM callbacks
*
* This function calls the underlying arch specific low level PM code as
* registered at the init time.
*
* Returns the result of the suspend callback.
*/
int arm_cpuidle_suspend(int index)
{
int cpu = smp_processor_id();
return cpuidle_ops[cpu].suspend(index);
}
/**
* arm_cpuidle_get_ops() - find a registered cpuidle_ops by name
* @method: the method name
*
* Search in the __cpuidle_method_of_table array the cpuidle ops matching the
* method name.
*
* Returns a struct cpuidle_ops pointer, NULL if not found.
*/
static const struct cpuidle_ops *__init arm_cpuidle_get_ops(const char *method)
{
struct of_cpuidle_method *m = __cpuidle_method_of_table;
for (; m->method; m++)
if (!strcmp(m->method, method))
return m->ops;
return NULL;
}
/**
* arm_cpuidle_read_ops() - Initialize the cpuidle ops with the device tree
* @dn: a pointer to a struct device node corresponding to a cpu node
* @cpu: the cpu identifier
*
* Get the method name defined in the 'enable-method' property, retrieve the
* associated cpuidle_ops and do a struct copy. This copy is needed because all
* cpuidle_ops are tagged __initconst and will be unloaded after the init
* process.
*
* Return 0 on sucess, -ENOENT if no 'enable-method' is defined, -EOPNOTSUPP if
* no cpuidle_ops is registered for the 'enable-method', or if either init or
* suspend callback isn't defined.
*/
static int __init arm_cpuidle_read_ops(struct device_node *dn, int cpu)
{
const char *enable_method;
const struct cpuidle_ops *ops;
Annotation
- Immediate include surface: `linux/cpuidle.h`, `linux/of.h`, `asm/cpuidle.h`.
- Detected declarations: `function arm_cpuidle_simple_enter`, `function arm_cpuidle_suspend`, `function arm_cpuidle_get_ops`, `function arm_cpuidle_read_ops`, `function arm_cpuidle_init`.
- Atlas domain: Architecture Layer / arch/arm.
- 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.