drivers/firmware/psci/psci_checker.c
Source file repositories/reference/linux-study-clean/drivers/firmware/psci/psci_checker.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/psci/psci_checker.c- Extension
.c- Size
- 12498 bytes
- Lines
- 491
- Domain
- Driver Families
- Bucket
- drivers/firmware
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/atomic.hlinux/completion.hlinux/cpu.hlinux/cpuidle.hlinux/cpu_pm.hlinux/kernel.hlinux/kthread.huapi/linux/sched/types.hlinux/module.hlinux/preempt.hlinux/psci.hlinux/slab.hlinux/tick.hlinux/topology.hasm/cpuidle.huapi/linux/psci.h
Detected Declarations
function psci_ops_checkfunction down_and_up_cpusfunction cpu_downfunction free_cpu_groupsfunction alloc_init_cpu_groupsfunction hotplug_testsfunction dummy_callbackfunction suspend_test_threadfunction suspend_testsfunction for_each_online_cpufunction psci_checker
Annotated Snippet
if (psci_tos_resident_on(cpu)) {
tos_resident_cpu = cpu;
break;
}
if (tos_resident_cpu == -1)
pr_warn("UP Trusted OS resides on no online CPU\n");
}
return 0;
}
/*
* offlined_cpus is a temporary array but passing it as an argument avoids
* multiple allocations.
*/
static unsigned int down_and_up_cpus(const struct cpumask *cpus,
struct cpumask *offlined_cpus)
{
int cpu;
int err = 0;
cpumask_clear(offlined_cpus);
/* Try to power down all CPUs in the mask. */
for_each_cpu(cpu, cpus) {
int ret = remove_cpu(cpu);
/*
* cpu_down() checks the number of online CPUs before the TOS
* resident CPU.
*/
if (cpumask_weight(offlined_cpus) + 1 == nb_available_cpus) {
if (ret != -EBUSY) {
pr_err("Unexpected return code %d while trying "
"to power down last online CPU %d\n",
ret, cpu);
++err;
}
} else if (cpu == tos_resident_cpu) {
if (ret != -EPERM) {
pr_err("Unexpected return code %d while trying "
"to power down TOS resident CPU %d\n",
ret, cpu);
++err;
}
} else if (ret != 0) {
pr_err("Error occurred (%d) while trying "
"to power down CPU %d\n", ret, cpu);
++err;
}
if (ret == 0)
cpumask_set_cpu(cpu, offlined_cpus);
}
/* Try to power up all the CPUs that have been offlined. */
for_each_cpu(cpu, offlined_cpus) {
int ret = add_cpu(cpu);
if (ret != 0) {
pr_err("Error occurred (%d) while trying "
"to power up CPU %d\n", ret, cpu);
++err;
} else {
cpumask_clear_cpu(cpu, offlined_cpus);
}
}
/*
* Something went bad at some point and some CPUs could not be turned
* back on.
*/
WARN_ON(!cpumask_empty(offlined_cpus) ||
num_online_cpus() != nb_available_cpus);
return err;
}
static void free_cpu_groups(int num, cpumask_var_t **pcpu_groups)
{
int i;
cpumask_var_t *cpu_groups = *pcpu_groups;
for (i = 0; i < num; ++i)
free_cpumask_var(cpu_groups[i]);
kfree(cpu_groups);
}
static int alloc_init_cpu_groups(cpumask_var_t **pcpu_groups)
{
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/completion.h`, `linux/cpu.h`, `linux/cpuidle.h`, `linux/cpu_pm.h`, `linux/kernel.h`, `linux/kthread.h`, `uapi/linux/sched/types.h`.
- Detected declarations: `function psci_ops_check`, `function down_and_up_cpus`, `function cpu_down`, `function free_cpu_groups`, `function alloc_init_cpu_groups`, `function hotplug_tests`, `function dummy_callback`, `function suspend_test_thread`, `function suspend_tests`, `function for_each_online_cpu`.
- Atlas domain: Driver Families / drivers/firmware.
- 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.