drivers/thermal/intel/intel_hfi.c
Source file repositories/reference/linux-study-clean/drivers/thermal/intel/intel_hfi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/intel/intel_hfi.c- Extension
.c- Size
- 19225 bytes
- Lines
- 733
- Domain
- Driver Families
- Bucket
- drivers/thermal
- 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/bitops.hlinux/cpufeature.hlinux/cpumask.hlinux/delay.hlinux/gfp.hlinux/io.hlinux/kernel.hlinux/math.hlinux/mutex.hlinux/percpu-defs.hlinux/printk.hlinux/processor.hlinux/slab.hlinux/spinlock.hlinux/suspend.hlinux/string.hlinux/syscore_ops.hlinux/topology.hlinux/workqueue.hasm/cpuid/api.hasm/msr.hintel_hfi.hthermal_interrupt.h../thermal_netlink.h
Detected Declarations
struct hfi_cpu_datastruct hfi_hdrstruct hfi_instancestruct hfi_featuresstruct hfi_cpu_infofunction get_hfi_capsfunction update_capabilitiesfunction hfi_update_work_fnfunction intel_hfi_process_eventfunction init_hfi_cpu_indexfunction init_hfi_instancefunction hfi_enablefunction hfi_set_hw_tablefunction hfi_disablefunction intel_hfi_onlinefunction intel_hfi_offlinefunction hfi_parse_featuresfunction hfi_enable_instancefunction hfi_disable_instancefunction hfi_syscore_resumefunction hfi_syscore_suspendfunction hfi_thermal_notifyfunction intel_hfi_init
Annotated Snippet
struct hfi_cpu_data {
u8 perf_cap;
u8 ee_cap;
} __packed;
/**
* struct hfi_hdr - Header of the HFI table
* @perf_updated: Hardware updated performance capabilities
* @ee_updated: Hardware updated energy efficiency capabilities
*
* Properties of the data in an HFI table.
*/
struct hfi_hdr {
u8 perf_updated;
u8 ee_updated;
} __packed;
/**
* struct hfi_instance - Representation of an HFI instance (i.e., a table)
* @local_table: Base of the local copy of the HFI table
* @timestamp: Timestamp of the last update of the local table.
* Located at the base of the local table.
* @hdr: Base address of the header of the local table
* @data: Base address of the data of the local table
* @cpus: CPUs represented in this HFI table instance
* @hw_table: Pointer to the HFI table of this instance
* @update_work: Delayed work to process HFI updates
* @table_lock: Lock to protect acceses to the table of this instance
* @event_lock: Lock to process HFI interrupts
*
* A set of parameters to parse and navigate a specific HFI table.
*/
struct hfi_instance {
union {
void *local_table;
u64 *timestamp;
};
void *hdr;
void *data;
cpumask_var_t cpus;
void *hw_table;
struct delayed_work update_work;
raw_spinlock_t table_lock;
raw_spinlock_t event_lock;
};
/**
* struct hfi_features - Supported HFI features
* @nr_table_pages: Size of the HFI table in 4KB pages
* @cpu_stride: Stride size to locate the capability data of a logical
* processor within the table (i.e., row stride)
* @hdr_size: Size of the table header
*
* Parameters and supported features that are common to all HFI instances
*/
struct hfi_features {
size_t nr_table_pages;
unsigned int cpu_stride;
unsigned int hdr_size;
};
/**
* struct hfi_cpu_info - Per-CPU attributes to consume HFI data
* @index: Row of this CPU in its HFI table
* @hfi_instance: Attributes of the HFI table to which this CPU belongs
*
* Parameters to link a logical processor to an HFI table and a row within it.
*/
struct hfi_cpu_info {
s16 index;
struct hfi_instance *hfi_instance;
};
static DEFINE_PER_CPU(struct hfi_cpu_info, hfi_cpu_info) = { .index = -1 };
static int max_hfi_instances;
static int hfi_clients_nr;
static struct hfi_instance *hfi_instances;
static struct hfi_features hfi_features;
static DEFINE_MUTEX(hfi_instance_lock);
static struct workqueue_struct *hfi_updates_wq;
#define HFI_UPDATE_DELAY_MS 100
#define HFI_THERMNL_CAPS_PER_EVENT 64
static void get_hfi_caps(struct hfi_instance *hfi_instance,
struct thermal_genl_cpu_caps *cpu_caps)
{
int cpu, i = 0;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/cpufeature.h`, `linux/cpumask.h`, `linux/delay.h`, `linux/gfp.h`, `linux/io.h`, `linux/kernel.h`, `linux/math.h`.
- Detected declarations: `struct hfi_cpu_data`, `struct hfi_hdr`, `struct hfi_instance`, `struct hfi_features`, `struct hfi_cpu_info`, `function get_hfi_caps`, `function update_capabilities`, `function hfi_update_work_fn`, `function intel_hfi_process_event`, `function init_hfi_cpu_index`.
- Atlas domain: Driver Families / drivers/thermal.
- 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.