drivers/gpu/drm/nouveau/nvkm/subdev/therm/temp.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/subdev/therm/temp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nvkm/subdev/therm/temp.c- Extension
.c- Size
- 7567 bytes
- Lines
- 254
- 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.h
Detected Declarations
function filesfunction nvkm_therm_temp_safety_checksfunction nvkm_therm_sensor_set_threshold_statefunction nvkm_therm_sensor_get_threshold_statefunction nv_poweroff_workfunction nvkm_therm_sensor_eventfunction nvkm_therm_threshold_hyst_pollingfunction alarm_timer_callbackfunction nvkm_therm_program_alarms_pollingfunction nvkm_therm_sensor_initfunction nvkm_therm_sensor_finifunction nvkm_therm_sensor_preinitfunction nvkm_therm_sensor_ctor
Annotated Snippet
if (active) {
nvkm_therm_fan_set(therm, true, 100);
nvkm_therm_fan_mode(therm, NVKM_THERM_CTRL_AUTO);
}
break;
case NVKM_THERM_THRS_DOWNCLOCK:
if (therm->emergency.downclock)
therm->emergency.downclock(therm, active);
break;
case NVKM_THERM_THRS_CRITICAL:
if (therm->emergency.pause)
therm->emergency.pause(therm, active);
break;
case NVKM_THERM_THRS_SHUTDOWN:
if (active) {
struct work_struct *work;
work = kmalloc_obj(*work, GFP_ATOMIC);
if (work) {
INIT_WORK(work, nv_poweroff_work);
schedule_work(work);
}
}
break;
case NVKM_THERM_THRS_NR:
break;
}
}
/* must be called with alarm_program_lock taken ! */
static void
nvkm_therm_threshold_hyst_polling(struct nvkm_therm *therm,
const struct nvbios_therm_threshold *thrs,
enum nvkm_therm_thrs thrs_name)
{
enum nvkm_therm_thrs_direction direction;
enum nvkm_therm_thrs_state prev_state, new_state;
int temp = therm->func->temp_get(therm);
prev_state = nvkm_therm_sensor_get_threshold_state(therm, thrs_name);
if (temp >= thrs->temp && prev_state == NVKM_THERM_THRS_LOWER) {
direction = NVKM_THERM_THRS_RISING;
new_state = NVKM_THERM_THRS_HIGHER;
} else if (temp <= thrs->temp - thrs->hysteresis &&
prev_state == NVKM_THERM_THRS_HIGHER) {
direction = NVKM_THERM_THRS_FALLING;
new_state = NVKM_THERM_THRS_LOWER;
} else
return; /* nothing to do */
nvkm_therm_sensor_set_threshold_state(therm, thrs_name, new_state);
nvkm_therm_sensor_event(therm, thrs_name, direction);
}
static void
alarm_timer_callback(struct nvkm_alarm *alarm)
{
struct nvkm_therm *therm =
container_of(alarm, struct nvkm_therm, sensor.therm_poll_alarm);
struct nvbios_therm_sensor *sensor = &therm->bios_sensor;
struct nvkm_timer *tmr = therm->subdev.device->timer;
unsigned long flags;
spin_lock_irqsave(&therm->sensor.alarm_program_lock, flags);
nvkm_therm_threshold_hyst_polling(therm, &sensor->thrs_fan_boost,
NVKM_THERM_THRS_FANBOOST);
nvkm_therm_threshold_hyst_polling(therm,
&sensor->thrs_down_clock,
NVKM_THERM_THRS_DOWNCLOCK);
nvkm_therm_threshold_hyst_polling(therm, &sensor->thrs_critical,
NVKM_THERM_THRS_CRITICAL);
nvkm_therm_threshold_hyst_polling(therm, &sensor->thrs_shutdown,
NVKM_THERM_THRS_SHUTDOWN);
spin_unlock_irqrestore(&therm->sensor.alarm_program_lock, flags);
/* schedule the next poll in one second */
if (therm->func->temp_get(therm) >= 0)
nvkm_timer_alarm(tmr, 1000000000ULL, alarm);
}
void
nvkm_therm_program_alarms_polling(struct nvkm_therm *therm)
{
Annotation
- Immediate include surface: `priv.h`.
- Detected declarations: `function files`, `function nvkm_therm_temp_safety_checks`, `function nvkm_therm_sensor_set_threshold_state`, `function nvkm_therm_sensor_get_threshold_state`, `function nv_poweroff_work`, `function nvkm_therm_sensor_event`, `function nvkm_therm_threshold_hyst_polling`, `function alarm_timer_callback`, `function nvkm_therm_program_alarms_polling`, `function nvkm_therm_sensor_init`.
- 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.