drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c- Extension
.c- Size
- 12168 bytes
- Lines
- 456
- 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.hcore/option.hsubdev/pmu.h
Detected Declarations
function filesfunction nvkm_therm_update_tripfunction nvkm_therm_compute_linear_dutyfunction nvkm_therm_update_linearfunction nvkm_therm_update_linear_fallbackfunction nvkm_therm_updatefunction nvkm_therm_cstatefunction nvkm_therm_alarmfunction nvkm_therm_fan_modefunction nvkm_therm_attr_getfunction nvkm_therm_attr_setfunction nvkm_therm_clkgate_enablefunction nvkm_therm_clkgate_finifunction nvkm_therm_clkgate_oneinitfunction nvkm_therm_intrfunction nvkm_therm_finifunction nvkm_therm_oneinitfunction nvkm_therm_initfunction nvkm_therm_clkgate_initfunction nvkm_therm_dtorfunction nvkm_therm_ctorfunction nvkm_therm_new_
Annotated Snippet
switch(therm->fan->bios.fan_mode) {
case NVBIOS_THERM_FAN_TRIP:
duty = nvkm_therm_update_trip(therm);
break;
case NVBIOS_THERM_FAN_LINEAR:
duty = nvkm_therm_update_linear(therm);
break;
case NVBIOS_THERM_FAN_OTHER:
if (therm->cstate) {
duty = therm->cstate;
poll = false;
} else {
duty = nvkm_therm_update_linear_fallback(therm);
}
break;
}
immd = false;
break;
case NVKM_THERM_CTRL_NONE:
default:
nvkm_timer_alarm(tmr, 0, &therm->alarm);
poll = false;
}
if (poll)
nvkm_timer_alarm(tmr, 1000000000ULL, &therm->alarm);
spin_unlock_irqrestore(&therm->lock, flags);
if (duty >= 0) {
nvkm_debug(subdev, "FAN target request: %d%%\n", duty);
nvkm_therm_fan_set(therm, immd, duty);
}
}
int
nvkm_therm_cstate(struct nvkm_therm *therm, int fan, int dir)
{
struct nvkm_subdev *subdev = &therm->subdev;
if (!dir || (dir < 0 && fan < therm->cstate) ||
(dir > 0 && fan > therm->cstate)) {
nvkm_debug(subdev, "default fan speed -> %d%%\n", fan);
therm->cstate = fan;
nvkm_therm_update(therm, -1);
}
return 0;
}
static void
nvkm_therm_alarm(struct nvkm_alarm *alarm)
{
struct nvkm_therm *therm =
container_of(alarm, struct nvkm_therm, alarm);
nvkm_therm_update(therm, -1);
}
int
nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode)
{
struct nvkm_subdev *subdev = &therm->subdev;
struct nvkm_device *device = subdev->device;
static const char *name[] = {
"disabled",
"manual",
"automatic"
};
/* The default PPWR ucode on fermi interferes with fan management */
if ((mode >= ARRAY_SIZE(name)) ||
(mode != NVKM_THERM_CTRL_NONE && nvkm_pmu_fan_controlled(device)))
return -EINVAL;
/* do not allow automatic fan management if the thermal sensor is
* not available */
if (mode == NVKM_THERM_CTRL_AUTO &&
therm->func->temp_get(therm) < 0)
return -EINVAL;
if (therm->mode == mode)
return 0;
nvkm_debug(subdev, "fan management: %s\n", name[mode]);
nvkm_therm_update(therm, mode);
return 0;
}
int
nvkm_therm_attr_get(struct nvkm_therm *therm, enum nvkm_therm_attr_type type)
{
switch (type) {
case NVKM_THERM_ATTR_FAN_MIN_DUTY:
Annotation
- Immediate include surface: `priv.h`, `core/option.h`, `subdev/pmu.h`.
- Detected declarations: `function files`, `function nvkm_therm_update_trip`, `function nvkm_therm_compute_linear_duty`, `function nvkm_therm_update_linear`, `function nvkm_therm_update_linear_fallback`, `function nvkm_therm_update`, `function nvkm_therm_cstate`, `function nvkm_therm_alarm`, `function nvkm_therm_fan_mode`, `function nvkm_therm_attr_get`.
- 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.