drivers/thermal/intel/int340x_thermal/processor_thermal_power_floor.c
Source file repositories/reference/linux-study-clean/drivers/thermal/intel/int340x_thermal/processor_thermal_power_floor.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/intel/int340x_thermal/processor_thermal_power_floor.c- Extension
.c- Size
- 3912 bytes
- Lines
- 128
- 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/pci.hprocessor_thermal_device.h
Detected Declarations
function Copyrightfunction proc_thermal_power_floor_set_statefunction proc_thermal_power_floor_get_statefunction proc_thermal_check_power_floor_intrfunction proc_thermal_power_floor_intr_callback
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Processor thermal device module for registering and processing
* power floor. When the hardware reduces the power to the minimum
* possible, the power floor is notified via an interrupt.
*
* Operation:
* When user space enables power floor reporting:
* - Use mailbox to:
* Enable processor thermal device interrupt
*
* - Current status of power floor is read from offset 0x5B18
* bit 39.
*
* Two interface functions are provided to call when there is a
* thermal device interrupt:
* - proc_thermal_power_floor_intr():
* Check if the interrupt is for change in power floor.
* Called from interrupt context.
*
* - proc_thermal_power_floor_intr_callback():
* Callback for interrupt processing in thread context. This involves
* sending notification to user space that there is a change in the
* power floor status.
*
* Copyright (c) 2023, Intel Corporation.
*/
#include <linux/pci.h>
#include "processor_thermal_device.h"
#define SOC_POWER_FLOOR_STATUS BIT(39)
#define SOC_POWER_FLOOR_SHIFT 39
#define SOC_POWER_FLOOR_INT_ENABLE_BIT 31
#define SOC_POWER_FLOOR_INT_ACTIVE BIT(3)
int proc_thermal_read_power_floor_status(struct proc_thermal_device *proc_priv)
{
u64 status = 0;
status = readq(proc_priv->mmio_base + SOC_WT_RES_INT_STATUS_OFFSET);
return (status & SOC_POWER_FLOOR_STATUS) >> SOC_POWER_FLOOR_SHIFT;
}
EXPORT_SYMBOL_NS_GPL(proc_thermal_read_power_floor_status, "INT340X_THERMAL");
static bool enable_state;
static DEFINE_MUTEX(pf_lock);
int proc_thermal_power_floor_set_state(struct proc_thermal_device *proc_priv, bool enable)
{
int ret = 0;
mutex_lock(&pf_lock);
if (enable_state == enable)
goto pf_unlock;
/*
* Time window parameter is not applicable to power floor interrupt configuration.
* Hence use -1 for time window.
*/
ret = processor_thermal_mbox_interrupt_config(to_pci_dev(proc_priv->dev), enable,
SOC_POWER_FLOOR_INT_ENABLE_BIT, -1);
if (!ret)
enable_state = enable;
pf_unlock:
mutex_unlock(&pf_lock);
return ret;
}
EXPORT_SYMBOL_NS_GPL(proc_thermal_power_floor_set_state, "INT340X_THERMAL");
bool proc_thermal_power_floor_get_state(struct proc_thermal_device *proc_priv)
{
return enable_state;
}
EXPORT_SYMBOL_NS_GPL(proc_thermal_power_floor_get_state, "INT340X_THERMAL");
/**
* proc_thermal_check_power_floor_intr() - Check power floor interrupt.
* @proc_priv: Processor thermal device instance.
*
* Callback to check if the interrupt for power floor is active.
*
* Context: Called from interrupt context.
*
* Return: true if power floor is active, false when not active.
*/
bool proc_thermal_check_power_floor_intr(struct proc_thermal_device *proc_priv)
Annotation
- Immediate include surface: `linux/pci.h`, `processor_thermal_device.h`.
- Detected declarations: `function Copyright`, `function proc_thermal_power_floor_set_state`, `function proc_thermal_power_floor_get_state`, `function proc_thermal_check_power_floor_intr`, `function proc_thermal_power_floor_intr_callback`.
- 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.