drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c- Extension
.c- Size
- 18306 bytes
- Lines
- 717
- 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
priv.hsubdev/bios.hsubdev/bios/boost.hsubdev/bios/cstep.hsubdev/bios/perf.hsubdev/bios/vpstate.hsubdev/fb.hsubdev/therm.hsubdev/volt.hcore/option.h
Detected Declarations
function filesfunction nvkm_cstate_validfunction nvkm_cstate_find_bestfunction list_for_each_entry_from_reversefunction nvkm_cstate_getfunction list_for_each_entryfunction nvkm_cstate_progfunction nvkm_cstate_delfunction nvkm_cstate_newfunction nvkm_pstate_progfunction list_for_each_entryfunction nvkm_pstate_workfunction nvkm_pstate_calcfunction nvkm_pstate_infofunction list_for_each_entryfunction nvkm_pstate_delfunction list_for_each_entry_safefunction nvkm_pstate_newfunction nvkm_clk_ustate_updatefunction nvkm_clk_nstatefunction nvkm_clk_ustatefunction nvkm_clk_astatefunction nvkm_clk_tstatefunction nvkm_clk_dstatefunction nvkm_clk_pwrsrcfunction nvkm_clk_readfunction nvkm_clk_finifunction nvkm_clk_initfunction nvkm_clk_dtorfunction list_for_each_entry_safefunction nvkm_clk_ctorfunction nvkm_clk_new_
Annotated Snippet
if (subd && boostS.domain == domain) {
if (adjust)
input = input * boostS.percent / 100;
input = max(boostS.min, input);
input = min(boostS.max, input);
break;
}
} while (subd);
}
return input;
}
/******************************************************************************
* C-States
*****************************************************************************/
static bool
nvkm_cstate_valid(struct nvkm_clk *clk, struct nvkm_cstate *cstate,
u32 max_volt, int temp)
{
const struct nvkm_domain *domain = clk->domains;
struct nvkm_volt *volt = clk->subdev.device->volt;
int voltage;
while (domain && domain->name != nv_clk_src_max) {
if (domain->flags & NVKM_CLK_DOM_FLAG_VPSTATE) {
u32 freq = cstate->domain[domain->name];
switch (clk->boost_mode) {
case NVKM_CLK_BOOST_NONE:
if (clk->base_khz && freq > clk->base_khz)
return false;
fallthrough;
case NVKM_CLK_BOOST_BIOS:
if (clk->boost_khz && freq > clk->boost_khz)
return false;
}
}
domain++;
}
if (!volt)
return true;
voltage = nvkm_volt_map(volt, cstate->voltage, temp);
if (voltage < 0)
return false;
return voltage <= min(max_volt, volt->max_uv);
}
static struct nvkm_cstate *
nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
struct nvkm_cstate *cstate)
{
struct nvkm_device *device = clk->subdev.device;
struct nvkm_volt *volt = device->volt;
int max_volt;
if (!pstate || !cstate)
return NULL;
if (!volt)
return cstate;
max_volt = volt->max_uv;
if (volt->max0_id != 0xff)
max_volt = min(max_volt,
nvkm_volt_map(volt, volt->max0_id, clk->temp));
if (volt->max1_id != 0xff)
max_volt = min(max_volt,
nvkm_volt_map(volt, volt->max1_id, clk->temp));
if (volt->max2_id != 0xff)
max_volt = min(max_volt,
nvkm_volt_map(volt, volt->max2_id, clk->temp));
list_for_each_entry_from_reverse(cstate, &pstate->list, head) {
if (nvkm_cstate_valid(clk, cstate, max_volt, clk->temp))
return cstate;
}
return NULL;
}
static struct nvkm_cstate *
nvkm_cstate_get(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
{
struct nvkm_cstate *cstate;
if (cstatei == NVKM_CLK_CSTATE_HIGHEST)
return list_last_entry(&pstate->list, typeof(*cstate), head);
else {
list_for_each_entry(cstate, &pstate->list, head) {
Annotation
- Immediate include surface: `priv.h`, `subdev/bios.h`, `subdev/bios/boost.h`, `subdev/bios/cstep.h`, `subdev/bios/perf.h`, `subdev/bios/vpstate.h`, `subdev/fb.h`, `subdev/therm.h`.
- Detected declarations: `function files`, `function nvkm_cstate_valid`, `function nvkm_cstate_find_best`, `function list_for_each_entry_from_reverse`, `function nvkm_cstate_get`, `function list_for_each_entry`, `function nvkm_cstate_prog`, `function nvkm_cstate_del`, `function nvkm_cstate_new`, `function nvkm_pstate_prog`.
- 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.