drivers/acpi/cppc_acpi.c
Source file repositories/reference/linux-study-clean/drivers/acpi/cppc_acpi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/cppc_acpi.c- Extension
.c- Size
- 66265 bytes
- Lines
- 2254
- Domain
- Driver Families
- Bucket
- drivers/acpi
- 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.
- 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/delay.hlinux/iopoll.hlinux/ktime.hlinux/rwsem.hlinux/wait.hlinux/topology.hlinux/dmi.hlinux/units.hlinux/unaligned.hacpi/cppc_acpi.h
Detected Declarations
struct cppc_pcc_datafunction GENMASKfunction check_pcc_chanfunction write_lockfunction Timefunction cppc_chan_tx_donefunction acpi_get_psdfunction acpi_cpc_validfunction for_each_online_cpufunction cppc_allow_fast_switchfunction for_each_online_cpufunction acpi_get_psd_mapfunction for_each_possible_cpufunction register_pcc_channelfunction cpc_ffh_supportedfunction cpc_supported_by_cpufunction pcc_data_allocfunction Namefunction acpi_cppc_processor_exitfunction cpc_read_ffhfunction cpc_write_ffhfunction cpc_readfunction cpc_writefunction cppc_get_reg_val_in_pccfunction cppc_get_reg_valfunction cppc_set_reg_val_in_pccfunction cppc_set_reg_valfunction cppc_get_desired_perffunction cppc_get_nominal_perffunction cppc_get_highest_perffunction cppc_get_epp_perffunction cppc_get_perf_capsfunction CPC_IN_PCCfunction cppc_perf_ctrs_in_pcc_cpufunction cppc_get_perf_ctrsfunction for_each_online_cpufunction cppc_get_perf_ctrsfunction CPC_IN_PCCfunction cppc_set_epp_perffunction cppc_set_eppfunction cppc_get_auto_act_windowfunction cppc_set_auto_act_windowfunction cppc_get_auto_selfunction cppc_set_auto_selfunction cppc_set_enablefunction cppc_get_perffunction CPC_IN_PCCfunction cppc_set_perf
Annotated Snippet
struct cppc_pcc_data {
struct pcc_mbox_chan *pcc_channel;
bool pcc_channel_acquired;
unsigned int deadline_us;
unsigned int pcc_mpar, pcc_mrtt, pcc_nominal;
bool pending_pcc_write_cmd; /* Any pending/batched PCC write cmds? */
bool platform_owns_pcc; /* Ownership of PCC subspace */
unsigned int pcc_write_cnt; /* Running count of PCC write commands */
/*
* Lock to provide controlled access to the PCC channel.
*
* For performance critical usecases(currently cppc_set_perf)
* We need to take read_lock and check if channel belongs to OSPM
* before reading or writing to PCC subspace
* We need to take write_lock before transferring the channel
* ownership to the platform via a Doorbell
* This allows us to batch a number of CPPC requests if they happen
* to originate in about the same time
*
* For non-performance critical usecases(init)
* Take write_lock for all purposes which gives exclusive access
*/
struct rw_semaphore pcc_lock;
/* Wait queue for CPUs whose requests were batched */
wait_queue_head_t pcc_write_wait_q;
ktime_t last_cmd_cmpl_time;
ktime_t last_mpar_reset;
int mpar_count;
int refcount;
};
/* Array to represent the PCC channel per subspace ID */
static struct cppc_pcc_data *pcc_data[MAX_PCC_SUBSPACES];
/* The cpu_pcc_subspace_idx contains per CPU subspace ID */
static DEFINE_PER_CPU(int, cpu_pcc_subspace_idx);
/*
* The cpc_desc structure contains the ACPI register details
* as described in the per CPU _CPC tables. The details
* include the type of register (e.g. PCC, System IO, FFH etc.)
* and destination addresses which lets us READ/WRITE CPU performance
* information using the appropriate I/O methods.
*/
static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr);
/* pcc mapped address + header size + offset within PCC subspace */
#define GET_PCC_VADDR(offs, pcc_ss_id) (pcc_data[pcc_ss_id]->pcc_channel->shmem + \
0x8 + (offs))
/* Check if a CPC register is in PCC */
#define CPC_IN_PCC(cpc) ((cpc)->type == ACPI_TYPE_BUFFER && \
(cpc)->cpc_entry.reg.space_id == \
ACPI_ADR_SPACE_PLATFORM_COMM)
/* Check if a CPC register is in FFH */
#define CPC_IN_FFH(cpc) ((cpc)->type == ACPI_TYPE_BUFFER && \
(cpc)->cpc_entry.reg.space_id == \
ACPI_ADR_SPACE_FIXED_HARDWARE)
/* Check if a CPC register is in SystemMemory */
#define CPC_IN_SYSTEM_MEMORY(cpc) ((cpc)->type == ACPI_TYPE_BUFFER && \
(cpc)->cpc_entry.reg.space_id == \
ACPI_ADR_SPACE_SYSTEM_MEMORY)
/* Check if a CPC register is in SystemIo */
#define CPC_IN_SYSTEM_IO(cpc) ((cpc)->type == ACPI_TYPE_BUFFER && \
(cpc)->cpc_entry.reg.space_id == \
ACPI_ADR_SPACE_SYSTEM_IO)
/* Evaluates to True if reg is a NULL register descriptor */
#define IS_NULL_REG(reg) ((reg)->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY && \
(reg)->address == 0 && \
(reg)->bit_width == 0 && \
(reg)->bit_offset == 0 && \
(reg)->access_width == 0)
/* Evaluates to True if an optional cpc field is supported */
#define CPC_SUPPORTED(cpc) ((cpc)->type == ACPI_TYPE_INTEGER ? \
!!(cpc)->cpc_entry.int_value : \
!IS_NULL_REG(&(cpc)->cpc_entry.reg))
/*
* Each bit indicates the optionality of the register in per-cpu
* cpc_regs[] with the corresponding index. 0 means mandatory and 1
* means optional.
*/
#define REG_OPTIONAL (0x7FC7D0)
Annotation
- Immediate include surface: `linux/delay.h`, `linux/iopoll.h`, `linux/ktime.h`, `linux/rwsem.h`, `linux/wait.h`, `linux/topology.h`, `linux/dmi.h`, `linux/units.h`.
- Detected declarations: `struct cppc_pcc_data`, `function GENMASK`, `function check_pcc_chan`, `function write_lock`, `function Time`, `function cppc_chan_tx_done`, `function acpi_get_psd`, `function acpi_cpc_valid`, `function for_each_online_cpu`, `function cppc_allow_fast_switch`.
- Atlas domain: Driver Families / drivers/acpi.
- 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.