drivers/gpu/drm/nouveau/nvkm/subdev/therm/fan.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fan.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nvkm/subdev/therm/fan.c- Extension
.c- Size
- 7704 bytes
- Lines
- 280
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
priv.hsubdev/bios/fan.hsubdev/gpio.hsubdev/timer.h
Detected Declarations
function filesfunction nvkm_fan_alarmfunction nvkm_therm_fan_getfunction nvkm_therm_fan_setfunction nvkm_therm_fan_sensefunction nvkm_therm_fan_user_getfunction nvkm_therm_fan_user_setfunction nvkm_therm_fan_set_defaultsfunction nvkm_therm_fan_safety_checksfunction nvkm_therm_fan_initfunction nvkm_therm_fan_finifunction nvkm_therm_fan_ctor
Annotated Snippet
if (prev != cur) {
if (!start)
start = nvkm_timer_read(tmr);
cycles++;
prev = cur;
}
} while (cycles < 5 && nvkm_timer_read(tmr) - start < 250000000);
end = nvkm_timer_read(tmr);
if (cycles == 5) {
tach = (u64)60000000000ULL;
do_div(tach, (end - start));
return tach;
} else
return 0;
}
int
nvkm_therm_fan_user_get(struct nvkm_therm *therm)
{
return nvkm_therm_fan_get(therm);
}
int
nvkm_therm_fan_user_set(struct nvkm_therm *therm, int percent)
{
if (therm->mode != NVKM_THERM_CTRL_MANUAL)
return -EINVAL;
return nvkm_therm_fan_set(therm, true, percent);
}
static void
nvkm_therm_fan_set_defaults(struct nvkm_therm *therm)
{
therm->fan->bios.pwm_freq = 0;
therm->fan->bios.min_duty = 0;
therm->fan->bios.max_duty = 100;
therm->fan->bios.bump_period = 500;
therm->fan->bios.slow_down_period = 2000;
therm->fan->bios.linear_min_temp = 40;
therm->fan->bios.linear_max_temp = 85;
}
static void
nvkm_therm_fan_safety_checks(struct nvkm_therm *therm)
{
if (therm->fan->bios.min_duty > 100)
therm->fan->bios.min_duty = 100;
if (therm->fan->bios.max_duty > 100)
therm->fan->bios.max_duty = 100;
if (therm->fan->bios.min_duty > therm->fan->bios.max_duty)
therm->fan->bios.min_duty = therm->fan->bios.max_duty;
}
int
nvkm_therm_fan_init(struct nvkm_therm *therm)
{
return 0;
}
int
nvkm_therm_fan_fini(struct nvkm_therm *therm, bool suspend)
{
struct nvkm_timer *tmr = therm->subdev.device->timer;
if (suspend)
nvkm_timer_alarm(tmr, 0, &therm->fan->alarm);
return 0;
}
int
nvkm_therm_fan_ctor(struct nvkm_therm *therm)
{
struct nvkm_subdev *subdev = &therm->subdev;
struct nvkm_device *device = subdev->device;
struct nvkm_gpio *gpio = device->gpio;
struct nvkm_bios *bios = device->bios;
struct dcb_gpio_func func;
int ret;
/* attempt to locate a drivable fan, and determine control method */
ret = nvkm_gpio_find(gpio, 0, DCB_GPIO_FAN, 0xff, &func);
if (ret == 0) {
/* FIXME: is this really the place to perform such checks ? */
if (func.line != 16 && func.log[0] & DCB_GPIO_LOG_DIR_IN) {
nvkm_debug(subdev, "GPIO_FAN is in input mode\n");
ret = -EINVAL;
} else {
ret = nvkm_fanpwm_create(therm, &func);
Annotation
- Immediate include surface: `priv.h`, `subdev/bios/fan.h`, `subdev/gpio.h`, `subdev/timer.h`.
- Detected declarations: `function files`, `function nvkm_fan_alarm`, `function nvkm_therm_fan_get`, `function nvkm_therm_fan_set`, `function nvkm_therm_fan_sense`, `function nvkm_therm_fan_user_get`, `function nvkm_therm_fan_user_set`, `function nvkm_therm_fan_set_defaults`, `function nvkm_therm_fan_safety_checks`, `function nvkm_therm_fan_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.