drivers/cpufreq/acpi-cpufreq.c
Source file repositories/reference/linux-study-clean/drivers/cpufreq/acpi-cpufreq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/cpufreq/acpi-cpufreq.c- Extension
.c- Size
- 27205 bytes
- Lines
- 1085
- Domain
- Driver Families
- Bucket
- drivers/cpufreq
- 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.
- 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/kernel.hlinux/module.hlinux/init.hlinux/smp.hlinux/sched.hlinux/cpufreq.hlinux/compiler.hlinux/dmi.hlinux/slab.hlinux/string_helpers.hlinux/platform_device.hlinux/acpi.hlinux/io.hlinux/delay.hlinux/uaccess.hacpi/processor.hacpi/cppc_acpi.hasm/msr.hasm/processor.hasm/cpufeature.hasm/cpu_device_id.h
Detected Declarations
struct acpi_cpufreq_datastruct drv_cmdfunction boost_statefunction boost_set_msrfunction boost_set_msr_eachfunction set_boostfunction show_freqdomain_cpusfunction store_cpbfunction show_cpbfunction check_est_cpufunction check_amd_hwpstate_cpufunction extract_iofunction extract_msrfunction extract_freqfunction cpu_freq_read_intelfunction cpu_freq_write_intelfunction cpu_freq_read_amdfunction cpu_freq_write_amdfunction cpu_freq_read_iofunction cpu_freq_write_iofunction do_drv_readfunction drv_readfunction do_drv_writefunction drv_writefunction get_cur_valfunction get_cur_freq_on_cpufunction check_freqsfunction acpi_cpufreq_targetfunction acpi_cpufreq_fast_switchfunction acpi_cpufreq_guess_freqfunction free_acpi_perf_datafunction cpufreq_boost_down_prepfunction acpi_cpufreq_early_initfunction sw_any_bug_foundfunction acpi_cpufreq_blacklistfunction get_max_boost_ratiofunction get_max_boost_ratiofunction acpi_cpufreq_resolve_max_freqfunction acpi_cpufreq_cpu_initfunction acpi_cpufreq_cpu_exitfunction acpi_cpufreq_resumefunction acpi_cpufreq_boost_initfunction acpi_cpufreq_probefunction acpi_cpufreq_removefunction acpi_cpufreq_initfunction acpi_cpufreq_exit
Annotated Snippet
struct acpi_cpufreq_data {
unsigned int resume;
unsigned int cpu_feature;
unsigned int acpi_perf_cpu;
cpumask_var_t freqdomain_cpus;
void (*cpu_freq_write)(struct acpi_pct_register *reg, u32 val);
u32 (*cpu_freq_read)(struct acpi_pct_register *reg);
};
/* acpi_perf_data is a pointer to percpu data. */
static struct acpi_processor_performance __percpu *acpi_perf_data;
static inline struct acpi_processor_performance *to_perf_data(struct acpi_cpufreq_data *data)
{
return per_cpu_ptr(acpi_perf_data, data->acpi_perf_cpu);
}
static struct cpufreq_driver acpi_cpufreq_driver;
static unsigned int acpi_pstate_strict;
static bool boost_state(unsigned int cpu)
{
u64 msr;
switch (boot_cpu_data.x86_vendor) {
case X86_VENDOR_INTEL:
case X86_VENDOR_CENTAUR:
case X86_VENDOR_ZHAOXIN:
rdmsrq_on_cpu(cpu, MSR_IA32_MISC_ENABLE, &msr);
return !(msr & MSR_IA32_MISC_ENABLE_TURBO_DISABLE);
case X86_VENDOR_HYGON:
case X86_VENDOR_AMD:
rdmsrq_on_cpu(cpu, MSR_K7_HWCR, &msr);
return !(msr & MSR_K7_HWCR_CPB_DIS);
}
return false;
}
static int boost_set_msr(bool enable)
{
u32 msr_addr;
u64 msr_mask, val;
switch (boot_cpu_data.x86_vendor) {
case X86_VENDOR_INTEL:
case X86_VENDOR_CENTAUR:
case X86_VENDOR_ZHAOXIN:
msr_addr = MSR_IA32_MISC_ENABLE;
msr_mask = MSR_IA32_MISC_ENABLE_TURBO_DISABLE;
break;
case X86_VENDOR_HYGON:
case X86_VENDOR_AMD:
msr_addr = MSR_K7_HWCR;
msr_mask = MSR_K7_HWCR_CPB_DIS;
break;
default:
return -EINVAL;
}
rdmsrq(msr_addr, val);
if (enable)
val &= ~msr_mask;
else
val |= msr_mask;
wrmsrq(msr_addr, val);
return 0;
}
static void boost_set_msr_each(void *p_en)
{
bool enable = (bool) p_en;
boost_set_msr(enable);
}
static int set_boost(struct cpufreq_policy *policy, int val)
{
on_each_cpu_mask(policy->cpus, boost_set_msr_each,
(void *)(long)val, 1);
pr_debug("CPU %*pbl: Core Boosting %s.\n",
cpumask_pr_args(policy->cpus), str_enabled_disabled(val));
return 0;
}
static ssize_t show_freqdomain_cpus(struct cpufreq_policy *policy, char *buf)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/smp.h`, `linux/sched.h`, `linux/cpufreq.h`, `linux/compiler.h`, `linux/dmi.h`.
- Detected declarations: `struct acpi_cpufreq_data`, `struct drv_cmd`, `function boost_state`, `function boost_set_msr`, `function boost_set_msr_each`, `function set_boost`, `function show_freqdomain_cpus`, `function store_cpb`, `function show_cpb`, `function check_est_cpu`.
- Atlas domain: Driver Families / drivers/cpufreq.
- 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.