summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/nouveau/core/subdev/therm
diff options
context:
space:
mode:
authorMartin Peres <martin.peres@labri.fr>2012-12-20 01:32:09 +0100
committerBen Skeggs <bskeggs@redhat.com>2013-02-20 16:00:33 +1000
commita624bafbf11c098a859dba4118a33605bfd25788 (patch)
tree1b360eaa93d2668d633ea0bae186e674c82ebdf0 /drivers/gpu/drm/nouveau/core/subdev/therm
parent93260d3c026b539931d909a4d68490c32b6d73ce (diff)
drm/nouveau/fan: handle the cases where we are outside of the linear zone
This fixes a bug where, when temperature is outside of the linear range, fan pwm would be outside of the allowed range ([0, 100]) and could get negative in some cases. It seems like a regression that happened when we re-worked the fan management logic before merging. Tested-by: Ozan Çağlayan <ozancag@gmail.com> Signed-off-by: Martin Peres <martin.peres@labri.fr> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/core/subdev/therm')
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/therm/base.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/base.c b/drivers/gpu/drm/nouveau/core/subdev/therm/base.c
index b35b4a249c5f..25b7f6a907c8 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/therm/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/therm/base.c
@@ -71,6 +71,13 @@ nouveau_therm_update_linear(struct nouveau_therm *therm)
u8 temp = therm->temp_get(therm);
u16 duty;
+ /* handle the non-linear part first */
+ if (temp < linear_min_temp)
+ return priv->fan->bios.min_duty;
+ else if (temp > linear_max_temp)
+ return priv->fan->bios.max_duty;
+
+ /* we are in the linear zone */
duty = (temp - linear_min_temp);
duty *= (priv->fan->bios.max_duty - priv->fan->bios.min_duty);
duty /= (linear_max_temp - linear_min_temp);