drivers/gpu/drm/xe/xe_hwmon.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_hwmon.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xe/xe_hwmon.c- Extension
.c- Size
- 46648 bytes
- Lines
- 1586
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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/hwmon-sysfs.hlinux/hwmon.hlinux/jiffies.hlinux/types.hlinux/units.hdrm/drm_managed.hregs/xe_gt_regs.hregs/xe_mchbar_regs.hregs/xe_pcode_regs.hxe_device.hxe_hwmon.hxe_mmio.hxe_pcode.hxe_pcode_api.hxe_sriov.hxe_pm.hxe_vsec.hregs/xe_pmt.h
Detected Declarations
struct xe_hwmon_energy_infostruct xe_hwmon_fan_infostruct xe_hwmon_thermal_infostruct xe_hwmonenum xe_hwmon_regenum xe_hwmon_reg_operationenum xe_hwmon_channelenum xe_fan_channelenum xe_temp_limitenum sensor_attr_powerfunction prepare_power_limit_param2function xe_hwmon_pcode_read_power_limitfunction xe_hwmon_pcode_rmw_power_limitfunction xe_hwmon_get_regfunction xe_hwmon_power_max_readfunction xe_hwmon_power_max_writefunction xe_hwmon_power_rated_max_readfunction bitsfunction xe_hwmon_power_max_interval_showfunction xe_hwmon_power_max_interval_storefunction xe_hwmon_attributes_visiblefunction xe_hwmon_pcode_read_thermal_infofunction get_mc_tempfunction get_pcie_tempfunction xe_hwmon_pcode_read_i1function xe_hwmon_pcode_write_i1function xe_hwmon_pcode_read_fan_controlfunction xe_hwmon_power_curr_crit_readfunction xe_hwmon_power_curr_crit_writefunction xe_hwmon_get_voltagefunction is_vram_ch_availablefunction xe_hwmon_temp_is_visiblefunction xe_hwmon_temp_readfunction xe_hwmon_power_is_visiblefunction xe_hwmon_power_readfunction xe_hwmon_power_writefunction xe_hwmon_curr_is_visiblefunction xe_hwmon_curr_readfunction xe_hwmon_curr_writefunction xe_hwmon_in_is_visiblefunction xe_hwmon_in_readfunction xe_hwmon_energy_is_visiblefunction xe_hwmon_energy_readfunction xe_hwmon_fan_is_visiblefunction xe_hwmon_fan_input_readfunction xe_hwmon_fan_readfunction xe_hwmon_is_visiblefunction xe_hwmon_read
Annotated Snippet
struct xe_hwmon_energy_info {
/** @reg_val_prev: previous energy reg val */
u32 reg_val_prev;
/** @accum_energy: accumulated energy */
long accum_energy;
};
/**
* struct xe_hwmon_fan_info - to cache previous fan reading
*/
struct xe_hwmon_fan_info {
/** @reg_val_prev: previous fan reg val */
u32 reg_val_prev;
/** @time_prev: previous timestamp */
u64 time_prev;
};
/**
* struct xe_hwmon_thermal_info - to store temperature data
*/
struct xe_hwmon_thermal_info {
union {
/** @limit: temperatures limits */
u8 limit[TEMP_LIMIT_MAX];
/** @data: temperature limits in dwords */
u32 data[DIV_ROUND_UP(TEMP_LIMIT_MAX, sizeof(u32))];
};
/** @count: no of temperature sensors available for the platform */
u8 count;
/** @value: signed value from each sensor */
s8 value[U8_MAX];
/** @vram_label: vram label names */
char vram_label[MAX_VRAM_CHANNELS][MAX_LABEL_SIZE];
};
/**
* struct xe_hwmon - xe hwmon data structure
*/
struct xe_hwmon {
/** @hwmon_dev: hwmon device for xe */
struct device *hwmon_dev;
/** @xe: Xe device */
struct xe_device *xe;
/** @hwmon_lock: lock for rw attributes*/
struct mutex hwmon_lock;
/** @scl_shift_power: pkg power unit */
int scl_shift_power;
/** @scl_shift_energy: pkg energy unit */
int scl_shift_energy;
/** @scl_shift_time: pkg time unit */
int scl_shift_time;
/** @ei: Energy info for energyN_input */
struct xe_hwmon_energy_info ei[CHANNEL_MAX];
/** @fi: Fan info for fanN_input */
struct xe_hwmon_fan_info fi[FAN_MAX];
/** @boot_power_limit_read: is boot power limits read */
bool boot_power_limit_read;
/** @pl1_on_boot: power limit PL1 on boot */
u32 pl1_on_boot[CHANNEL_MAX];
/** @pl2_on_boot: power limit PL2 on boot */
u32 pl2_on_boot[CHANNEL_MAX];
/** @temp: Temperature info */
struct xe_hwmon_thermal_info temp;
};
static inline int prepare_power_limit_param2(const struct xe_hwmon *hwmon)
{
if (hwmon->boot_power_limit_read) {
if (hwmon->xe->info.platform >= XE_CRESCENTISLAND)
return READ_PL_ACCEPTED;
else
return READ_PL_FROM_PCODE;
} else {
return READ_PL_FROM_FW;
}
}
static int xe_hwmon_pcode_read_power_limit(const struct xe_hwmon *hwmon, u32 attr, int channel,
u32 *uval)
{
struct xe_tile *root_tile = xe_device_get_root_tile(hwmon->xe);
u32 val0 = 0, val1 = 0;
int ret = 0;
ret = xe_pcode_read(root_tile, PCODE_MBOX(PCODE_POWER_SETUP,
(channel == CHANNEL_CARD) ?
READ_PSYSGPU_POWER_LIMIT :
READ_PACKAGE_POWER_LIMIT,
prepare_power_limit_param2(hwmon)), &val0, &val1);
Annotation
- Immediate include surface: `linux/hwmon-sysfs.h`, `linux/hwmon.h`, `linux/jiffies.h`, `linux/types.h`, `linux/units.h`, `drm/drm_managed.h`, `regs/xe_gt_regs.h`, `regs/xe_mchbar_regs.h`.
- Detected declarations: `struct xe_hwmon_energy_info`, `struct xe_hwmon_fan_info`, `struct xe_hwmon_thermal_info`, `struct xe_hwmon`, `enum xe_hwmon_reg`, `enum xe_hwmon_reg_operation`, `enum xe_hwmon_channel`, `enum xe_fan_channel`, `enum xe_temp_limit`, `enum sensor_attr_power`.
- Atlas domain: Driver Families / drivers/gpu.
- 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.