From patchwork Tue Apr 23 12:27:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhang Rui X-Patchwork-Id: 2477401 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id E1B8A3FCA5 for ; Tue, 23 Apr 2013 12:27:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755613Ab3DWM1N (ORCPT ); Tue, 23 Apr 2013 08:27:13 -0400 Received: from mga14.intel.com ([143.182.124.37]:57205 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755467Ab3DWM1N (ORCPT ); Tue, 23 Apr 2013 08:27:13 -0400 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 23 Apr 2013 05:27:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,533,1363158000"; d="scan'208,223";a="230804223" Received: from unknown (HELO [10.255.20.203]) ([10.255.20.203]) by AZSMGA002.ch.intel.com with ESMTP; 23 Apr 2013 05:27:10 -0700 Message-ID: <1366720029.2094.2.camel@rzhang1-mobl4> Subject: [PATCH] ACPI thermal: do not always return THERMAL_TREND_RAISING for active trip points From: Zhang Rui To: "Rafael J. Wysocki" , ACPI Devel Maling List Cc: Len Brown Date: Tue, 23 Apr 2013 20:27:09 +0800 X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From 2e678ef60a7926daa9217ac7eaedea33043f2e35 Mon Sep 17 00:00:00 2001 From: Zhang Rui 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 Signed-off-by: Zhang Rui Tested-by: Matthias Tested-by: Ville Syrjälä --- drivers/acpi/thermal.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 8470771..b846ce0 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -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; } /*