Skip to content

Commit

Permalink
drm/nouveau/fan: handle the cases where we are outside of the linear …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
Martin Peres authored and Ben Skeggs committed Feb 20, 2013
1 parent 93260d3 commit a624baf
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/gpu/drm/nouveau/core/subdev/therm/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a624baf

Please sign in to comment.