drivers/platform/x86/intel/pmc/core.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/intel/pmc/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/intel/pmc/core.c- Extension
.c- Size
- 54022 bytes
- Lines
- 2078
- Domain
- Driver Families
- Bucket
- drivers/platform
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/bitfield.hlinux/debugfs.hlinux/delay.hlinux/dmi.hlinux/err.hlinux/io.hlinux/module.hlinux/pci.hlinux/slab.hlinux/suspend.hlinux/units.hasm/cpuid/api.hasm/cpu_device_id.hasm/intel-family.hasm/msr.hasm/tsc.hcore.hssram_telemetry.h../pmt/telemetry.h
Detected Declarations
enum header_typefunction pmc_core_reg_readfunction pmc_core_reg_writefunction pmc_core_adjust_slp_s0_stepfunction set_etr3function etr3_is_visiblefunction etr3_showfunction scoped_guardfunction etr3_storefunction pmc_core_dev_state_getfunction pmc_core_pson_residency_getfunction pmc_core_check_read_lock_bitfunction pmc_core_slps0_displayfunction pmc_core_lpm_get_arr_sizefunction pmc_core_lpm_displayfunction pmc_core_reg_read_bytefunction pmc_core_display_mapfunction pmc_core_ppfear_showfunction pmc_core_mtpmc_link_statusfunction pmc_core_send_msgfunction pmc_core_mphy_pg_showfunction pmc_core_pll_showfunction pmc_core_send_ltr_ignorefunction pmc_core_ltr_writefunction pmc_core_ltr_ignore_writefunction pmc_core_ltr_ignore_showfunction pmc_core_ltr_restore_writefunction pmc_core_ltr_restore_showfunction pmc_core_slps0_dbg_latchfunction pmc_core_slps0_dbg_showfunction convert_ltr_scalefunction pmc_core_ltr_showfunction pmc_core_s0ix_blocker_showfunction pmc_core_ltr_ignore_allfunction pmc_core_ltr_restore_allfunction adjust_lpm_residencyfunction pmc_core_substate_res_showfunction pmc_for_each_modefunction pmc_core_substate_sts_regs_showfunction pmc_core_substate_l_sts_regs_showfunction pmc_core_substate_req_header_showfunction pmc_core_substate_blk_req_showfunction pmc_for_each_modefunction pmc_core_substate_blk_req_openfunction pmc_core_substate_req_regs_showfunction pmc_for_each_modefunction pmc_core_substate_req_regs_openfunction pmc_core_get_crystal_freq
Annotated Snippet
const struct file_operations pmc_core_substate_blk_req_fops = {
.owner = THIS_MODULE,
.open = pmc_core_substate_blk_req_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int pmc_core_substate_req_regs_show(struct seq_file *s, void *unused)
{
struct pmc_dev *pmcdev = s->private;
u32 sts_offset;
u32 sts_offset_live;
u32 *lpm_req_regs;
unsigned int mp, pmc_idx;
int num_maps;
for (pmc_idx = 0; pmc_idx < ARRAY_SIZE(pmcdev->pmcs); ++pmc_idx) {
struct pmc *pmc = pmcdev->pmcs[pmc_idx];
const struct pmc_bit_map **maps;
if (!pmc)
continue;
maps = pmc->map->lpm_sts;
num_maps = pmc->map->lpm_num_maps;
sts_offset = pmc->map->lpm_status_offset;
sts_offset_live = pmc->map->lpm_live_status_offset;
lpm_req_regs = pmc->lpm_req_regs;
/*
* When there are multiple PMCs, though the PMC may exist, the
* requirement register discovery could have failed so check
* before accessing.
*/
if (!lpm_req_regs)
continue;
/* Display the header */
pmc_core_substate_req_header_show(s, pmc_idx, HEADER_STATUS);
/* Loop over maps */
for (mp = 0; mp < num_maps; mp++) {
u32 req_mask = 0;
u32 lpm_status;
u32 lpm_status_live;
const struct pmc_bit_map *map;
int i, len = 32;
u8 mode;
/*
* Capture the requirements and create a mask so that we only
* show an element if it's required for at least one of the
* enabled low power modes
*/
pmc_for_each_mode(mode, pmc)
req_mask |= lpm_req_regs[mp + (mode * num_maps)];
/* Get the last latched status for this map */
lpm_status = pmc_core_reg_read(pmc, sts_offset + (mp * 4));
/* Get the runtime status for this map */
lpm_status_live = pmc_core_reg_read(pmc, sts_offset_live + (mp * 4));
/* Loop over elements in this map */
map = maps[mp];
for (i = 0; map[i].name && i < len; i++) {
u32 bit_mask = map[i].bit_mask;
if (!(bit_mask & req_mask)) {
/*
* Not required for any enabled states
* so don't display
*/
continue;
}
/* Display the element name in the first column */
seq_printf(s, "pmc%d: %34s |", pmc_idx, map[i].name);
/* Loop over the enabled states and display if required */
pmc_for_each_mode(mode, pmc) {
bool required = lpm_req_regs[mp + (mode * num_maps)] &
bit_mask;
seq_printf(s, " %9s |", required ? "Required" : " ");
}
/* In Status column, show the last captured state of this agent */
seq_printf(s, " %9s |", lpm_status & bit_mask ? "Yes" : " ");
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/debugfs.h`, `linux/delay.h`, `linux/dmi.h`, `linux/err.h`, `linux/io.h`, `linux/module.h`, `linux/pci.h`.
- Detected declarations: `enum header_type`, `function pmc_core_reg_read`, `function pmc_core_reg_write`, `function pmc_core_adjust_slp_s0_step`, `function set_etr3`, `function etr3_is_visible`, `function etr3_show`, `function scoped_guard`, `function etr3_store`, `function pmc_core_dev_state_get`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.