drivers/cpufreq/longhaul.c
Source file repositories/reference/linux-study-clean/drivers/cpufreq/longhaul.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/cpufreq/longhaul.c- Extension
.c- Size
- 25979 bytes
- Lines
- 1003
- 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/moduleparam.hlinux/init.hlinux/cpufreq.hlinux/pci.hlinux/slab.hlinux/string.hlinux/delay.hlinux/timex.hlinux/io.hlinux/acpi.hasm/msr.hasm/cpu_device_id.hacpi/processor.hlonghaul.h
Detected Declarations
function calc_speedfunction longhaul_get_cpu_multfunction do_longhaul1function do_powersaverfunction longhaul_setstatefunction v3function guess_fsbfunction longhaul_get_rangesfunction longhaul_setup_voltagescalingfunction cpufreq_for_each_entry_idxfunction longhaul_targetfunction longhaul_getfunction longhaul_walk_callbackfunction enable_arbiter_disablefunction longhaul_setup_southbridgefunction longhaul_cpu_initfunction longhaul_initfunction longhaul_exit
Annotated Snippet
if (!cx_address) {
ACPI_FLUSH_CPU_CACHE();
halt();
} else {
ACPI_FLUSH_CPU_CACHE();
/* Invoke C3 */
inb(cx_address);
/* Dummy op - must do something useless after P_LVL3
* read */
t = inl(acpi_gbl_FADT.xpm_timer_block.address);
}
longhaul.bits.EnableSoftVID = 0;
wrmsrq(MSR_VIA_LONGHAUL, longhaul.val);
}
/* Change frequency on next halt or sleep */
longhaul.bits.EnableSoftBusRatio = 1;
wrmsrq(MSR_VIA_LONGHAUL, longhaul.val);
if (!cx_address) {
ACPI_FLUSH_CPU_CACHE();
halt();
} else {
ACPI_FLUSH_CPU_CACHE();
/* Invoke C3 */
inb(cx_address);
/* Dummy op - must do something useless after P_LVL3 read */
t = inl(acpi_gbl_FADT.xpm_timer_block.address);
}
/* Disable bus ratio bit */
longhaul.bits.EnableSoftBusRatio = 0;
wrmsrq(MSR_VIA_LONGHAUL, longhaul.val);
/* Reduce voltage if necessary */
if (can_scale_voltage && !dir) {
longhaul.bits.EnableSoftVID = 1;
wrmsrq(MSR_VIA_LONGHAUL, longhaul.val);
/* Change voltage */
if (!cx_address) {
ACPI_FLUSH_CPU_CACHE();
halt();
} else {
ACPI_FLUSH_CPU_CACHE();
/* Invoke C3 */
inb(cx_address);
/* Dummy op - must do something useless after P_LVL3
* read */
t = inl(acpi_gbl_FADT.xpm_timer_block.address);
}
longhaul.bits.EnableSoftVID = 0;
wrmsrq(MSR_VIA_LONGHAUL, longhaul.val);
}
}
/**
* longhaul_setstate()
* @policy: cpufreq_policy structure containing the current policy.
* @table_index: index of the frequency within the cpufreq_frequency_table.
*
* Sets a new clock ratio.
*/
static int longhaul_setstate(struct cpufreq_policy *policy,
unsigned int table_index)
{
unsigned int mults_index;
int speed, mult;
struct cpufreq_freqs freqs;
unsigned long flags;
unsigned int pic1_mask, pic2_mask;
u16 bm_status = 0;
u32 bm_timeout = 1000;
unsigned int dir = 0;
mults_index = longhaul_table[table_index].driver_data;
/* Safety precautions */
mult = mults[mults_index & 0x1f];
if (mult == -1)
return -EINVAL;
speed = calc_speed(mult);
if ((speed > highest_speed) || (speed < lowest_speed))
return -EINVAL;
/* Voltage transition before frequency transition? */
if (can_scale_voltage && longhaul_index < table_index)
dir = 1;
freqs.old = calc_speed(longhaul_get_cpu_mult());
freqs.new = speed;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/cpufreq.h`, `linux/pci.h`, `linux/slab.h`, `linux/string.h`.
- Detected declarations: `function calc_speed`, `function longhaul_get_cpu_mult`, `function do_longhaul1`, `function do_powersaver`, `function longhaul_setstate`, `function v3`, `function guess_fsb`, `function longhaul_get_ranges`, `function longhaul_setup_voltagescaling`, `function cpufreq_for_each_entry_idx`.
- 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.