drivers/thermal/intel/therm_throt.c
Source file repositories/reference/linux-study-clean/drivers/thermal/intel/therm_throt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/intel/therm_throt.c- Extension
.c- Size
- 23586 bytes
- Lines
- 817
- Domain
- Driver Families
- Bucket
- drivers/thermal
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- 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/interrupt.hlinux/notifier.hlinux/jiffies.hlinux/kernel.hlinux/percpu.hlinux/export.hlinux/types.hlinux/init.hlinux/smp.hlinux/sysfs.hlinux/cpu.hasm/processor.hasm/thermal.hasm/traps.hasm/apic.hasm/irq.hasm/msr.hintel_hfi.hthermal_interrupt.h
Detected Declarations
struct _thermal_statestruct thermal_statefunction thermal_intr_init_core_clear_maskfunction thermal_intr_init_pkg_clear_maskfunction thermal_clear_package_intr_statusfunction get_therm_statusfunction throttle_active_workfunction therm_throt_processfunction thresh_event_validfunction int_pln_enable_setupfunction thermal_throttle_add_devfunction thermal_throttle_remove_devfunction thermal_throttle_onlinefunction thermal_throttle_offlinefunction thermal_throttle_init_devicefunction notify_package_thresholdsfunction notify_thresholdsfunction notify_hwp_interruptfunction intel_thermal_interruptfunction intel_thermal_supportedfunction x86_thermal_enabledfunction therm_lvt_initfunction intel_init_thermalmodule init thermal_throttle_init_deviceexport platform_thermal_notifyexport platform_thermal_package_notifyexport platform_thermal_package_rate_controlexport thermal_clear_package_intr_status
Annotated Snippet
device_initcall(thermal_throttle_init_device);
#endif /* CONFIG_SYSFS */
static void notify_package_thresholds(__u64 msr_val)
{
bool notify_thres_0 = false;
bool notify_thres_1 = false;
if (!platform_thermal_package_notify)
return;
/* lower threshold check */
if (msr_val & THERM_LOG_THRESHOLD0)
notify_thres_0 = true;
/* higher threshold check */
if (msr_val & THERM_LOG_THRESHOLD1)
notify_thres_1 = true;
if (!notify_thres_0 && !notify_thres_1)
return;
if (platform_thermal_package_rate_control &&
platform_thermal_package_rate_control()) {
/* Rate control is implemented in callback */
platform_thermal_package_notify(msr_val);
return;
}
/* lower threshold reached */
if (notify_thres_0 && thresh_event_valid(PACKAGE_LEVEL, 0))
platform_thermal_package_notify(msr_val);
/* higher threshold reached */
if (notify_thres_1 && thresh_event_valid(PACKAGE_LEVEL, 1))
platform_thermal_package_notify(msr_val);
}
static void notify_thresholds(__u64 msr_val)
{
/* check whether the interrupt handler is defined;
* otherwise simply return
*/
if (!platform_thermal_notify)
return;
/* lower threshold reached */
if ((msr_val & THERM_LOG_THRESHOLD0) &&
thresh_event_valid(CORE_LEVEL, 0))
platform_thermal_notify(msr_val);
/* higher threshold reached */
if ((msr_val & THERM_LOG_THRESHOLD1) &&
thresh_event_valid(CORE_LEVEL, 1))
platform_thermal_notify(msr_val);
}
void __weak notify_hwp_interrupt(void)
{
wrmsrq_safe(MSR_HWP_STATUS, 0);
}
/* Thermal transition interrupt handler */
void intel_thermal_interrupt(void)
{
__u64 msr_val;
if (static_cpu_has(X86_FEATURE_HWP))
notify_hwp_interrupt();
rdmsrq(MSR_IA32_THERM_STATUS, msr_val);
/* Check for violation of core thermal thresholds*/
notify_thresholds(msr_val);
therm_throt_process(msr_val & THERM_STATUS_PROCHOT,
THERMAL_THROTTLING_EVENT,
CORE_LEVEL);
if (this_cpu_has(X86_FEATURE_PLN) && int_pln_enable)
therm_throt_process(msr_val & THERM_STATUS_POWER_LIMIT,
POWER_LIMIT_EVENT,
CORE_LEVEL);
if (this_cpu_has(X86_FEATURE_PTS)) {
rdmsrq(MSR_IA32_PACKAGE_THERM_STATUS, msr_val);
/* check violations of package thermal thresholds */
notify_package_thresholds(msr_val);
therm_throt_process(msr_val & PACKAGE_THERM_STATUS_PROCHOT,
THERMAL_THROTTLING_EVENT,
PACKAGE_LEVEL);
if (this_cpu_has(X86_FEATURE_PLN) && int_pln_enable)
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/notifier.h`, `linux/jiffies.h`, `linux/kernel.h`, `linux/percpu.h`, `linux/export.h`, `linux/types.h`, `linux/init.h`.
- Detected declarations: `struct _thermal_state`, `struct thermal_state`, `function thermal_intr_init_core_clear_mask`, `function thermal_intr_init_pkg_clear_mask`, `function thermal_clear_package_intr_status`, `function get_therm_status`, `function throttle_active_work`, `function therm_throt_process`, `function thresh_event_valid`, `function int_pln_enable_setup`.
- Atlas domain: Driver Families / drivers/thermal.
- 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.