Skip to contentSkip to conversation

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

PATCH New Zhang Rui 1 participant 1 message Apr 23, 2013

Subsystems (2)
lore
Share & tools
lore

Zhang Rui

author reviewer
#0 lore raw

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

From 2e678ef60a7926daa9217ac7eaedea33043f2e35 Mon Sep 17 00:00:00 2001
From: Zhang Rui <[email protected]>
Date: Tue, 16 Apr 2013 13:54:27 +0800
Subject: [PATCH] ACPI thermal: do not always return THERMAL_TREND_RAISING for
active trip points

Commit 4ae46befb49d4173122e0afa995c4e93d01948a2
introduces a regression that the fan is always on
even if the system is in idle state.

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.

https://bugzilla.kernel.org/show_bug.cgi?id=56591
https://bugzilla.kernel.org/show_bug.cgi?id=56601
https://bugzilla.kernel.org/show_bug.cgi?id=50041#c45

---
 drivers/acpi/thermal.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/acpi/thermal.c +12 -3
index 8470771..b846ce0 100644
@@ -723,9 +723,18 @@ static int thermal_get_trend(struct thermal_zone_device *thermal,
 		return -EINVAL;
 
 	if (type == THERMAL_TRIP_ACTIVE) {
-		/* aggressive active cooling */
-		*trend = THERMAL_TREND_RAISING;
-		return 0;
+		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;
+			return 0;
+		} else
+			/* Fall back on default trend */
+			return -EINVAL;
 	}
 
 	/*
Signature · 8 lines
1.7.9.5



--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html