drivers/thermal/intel/int340x_thermal/processor_thermal_wt_hint.c
Source file repositories/reference/linux-study-clean/drivers/thermal/intel/int340x_thermal/processor_thermal_wt_hint.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thermal/intel/int340x_thermal/processor_thermal_wt_hint.c- Extension
.c- Size
- 7647 bytes
- Lines
- 298
- 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/bitfield.hlinux/pci.hprocessor_thermal_device.h
Detected Declarations
function workload_type_index_showfunction workload_hint_enable_showfunction workload_hint_enablefunction workload_hint_enable_storefunction workload_slow_hint_enable_showfunction workload_slow_hint_enable_storefunction notification_delay_ms_showfunction notification_delay_ms_storefunction workload_hint_attr_visiblefunction proc_thermal_check_wt_intrfunction proc_thermal_wt_intr_callbackfunction proc_thermal_wt_hint_addfunction proc_thermal_wt_hint_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* processor thermal device interface for reading workload type hints
* from the user space. The hints are provided by the firmware.
*
* Operation:
* When user space enables workload type prediction:
* - Use mailbox to:
* Configure notification delay
* Enable processor thermal device interrupt
*
* - The predicted workload type can be read from MMIO:
* Offset 0x5B18 shows if there was an interrupt
* active for change in workload type and also
* predicted workload type.
*
* Two interface functions are provided to call when there is a
* thermal device interrupt:
* - proc_thermal_check_wt_intr():
* Check if the interrupt is for change in workload type. Called from
* interrupt context.
*
* - proc_thermal_wt_intr_callback():
* Callback for interrupt processing in thread context. This involves
* sending notification to user space that there is a change in the
* workload type.
*
* Copyright (c) 2023, Intel Corporation.
*/
#include <linux/bitfield.h>
#include <linux/pci.h>
#include "processor_thermal_device.h"
#define SOC_WT GENMASK_ULL(47, 40)
#define SOC_WT_SLOW_PREDICTION_INT_ENABLE_BIT 22
#define SOC_WT_PREDICTION_INT_ENABLE_BIT 23
#define SOC_WT_PREDICTION_INT_ACTIVE BIT(2)
/*
* Closest possible to 1 Second is 1024 ms with programmed time delay
* of 0x0A.
*/
static u8 notify_delay = 0x0A;
static u16 notify_delay_ms = 1024;
static DEFINE_MUTEX(wt_lock);
static u8 wt_enable;
static u8 wt_slow_enable;
/* Show current predicted workload type index */
static ssize_t workload_type_index_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct proc_thermal_device *proc_priv;
struct pci_dev *pdev = to_pci_dev(dev);
u64 status = 0;
int wt;
mutex_lock(&wt_lock);
if (!wt_enable && !wt_slow_enable) {
mutex_unlock(&wt_lock);
return -ENODATA;
}
proc_priv = pci_get_drvdata(pdev);
status = readq(proc_priv->mmio_base + SOC_WT_RES_INT_STATUS_OFFSET);
mutex_unlock(&wt_lock);
wt = FIELD_GET(SOC_WT, status);
return sysfs_emit(buf, "%d\n", wt);
}
static DEVICE_ATTR_RO(workload_type_index);
static ssize_t workload_hint_enable_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
return sysfs_emit(buf, "%d\n", wt_enable);
}
static ssize_t workload_hint_enable(struct device *dev, u8 enable_bit, u8 *status,
struct device_attribute *attr,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/pci.h`, `processor_thermal_device.h`.
- Detected declarations: `function workload_type_index_show`, `function workload_hint_enable_show`, `function workload_hint_enable`, `function workload_hint_enable_store`, `function workload_slow_hint_enable_show`, `function workload_slow_hint_enable_store`, `function notification_delay_ms_show`, `function notification_delay_ms_store`, `function workload_hint_attr_visible`, `function proc_thermal_check_wt_intr`.
- 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.