Commit 94a40931 authored by Zhang Rui's avatar Zhang Rui Committed by Rafael J. Wysocki

ACPI / thermal: do not always return THERMAL_TREND_RAISING for active trip points

Commit 4ae46bef "Thermal: Introduce thermal_zone_trip_update()"
introduced a regression causing the fan to be always on even when
the system is idle.

My original idea in that commit is that:
 - when the current temperature is above the trip point,
   keep the fan on, even if the temperature is dropping.
 - when the current temperature is below the trip point,
   turn on the fan when the temperature is raising,
   turn off the fan when the temperature is dropping.

But this is what the code actually does:
 - when the current temperature is above the trip point,
   the fan keeps on.
 - when the current temperature is below the trip point,
   the fan is always on because thermal_get_trend()
   in driver/acpi/thermal.c returns THERMAL_TREND_RAISING.
Thus the fan keeps running even if the system is idle.

Fix this in drivers/acpi/thermal.c.

[rjw: Changelog]
References: https://bugzilla.kernel.org/show_bug.cgi?id=56591
References: https://bugzilla.kernel.org/show_bug.cgi?id=56601
References: https://bugzilla.kernel.org/show_bug.cgi?id=50041#c45Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
Tested-by: default avatarMatthias <morpheusxyz123@yahoo.de>
Tested-by: default avatarVille Syrjälä <syrjala@sci.fi>
Cc: 3.7+ <stable@vger.kernel.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 91e13aa3
...@@ -723,9 +723,19 @@ static int thermal_get_trend(struct thermal_zone_device *thermal, ...@@ -723,9 +723,19 @@ static int thermal_get_trend(struct thermal_zone_device *thermal,
return -EINVAL; return -EINVAL;
if (type == THERMAL_TRIP_ACTIVE) { if (type == THERMAL_TRIP_ACTIVE) {
/* aggressive active cooling */ unsigned long trip_temp;
unsigned long temp = KELVIN_TO_MILLICELSIUS(tz->temperature,
tz->kelvin_offset);
if (thermal_get_trip_temp(thermal, trip, &trip_temp))
return -EINVAL;
if (temp > trip_temp) {
*trend = THERMAL_TREND_RAISING; *trend = THERMAL_TREND_RAISING;
return 0; return 0;
} else {
/* Fall back on default trend */
return -EINVAL;
}
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment