linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>,
	Durgadoss R <durgadoss.r@intel.com>, Borislav Petkov <bp@suse.de>,
	Peter Feuerer <peter@piie.net>, Andreas Mohr <andi@lisas.de>,
	Alexander Lam <azl@andrew.cmu.edu>
Subject: [PATCH] acerhdf: Fix fan activation with new thermal governor
Date: Sat, 23 Feb 2013 20:20:10 +0100	[thread overview]
Message-ID: <1361647210-12983-1-git-send-email-bp@alien8.de> (raw)
In-Reply-To: <20130222111521.GA25473@pd.tnic>

From: Borislav Petkov <bp@suse.de>

The new step_wise thermal governor wasn't able to handle the one-trip
point design of acerhdf where we want to turn off the fan if we go under
the 'fanoff' temperature and to turn it on only after exceeding the
'fanon' temperature.

Do that by looking at the current fan state and return the temperature
accordingly.

Suggested-by: Zhang Rui <rui.zhang@intel.com>
Cc: Peter Feuerer <peter@piie.net>
Cc: Andreas Mohr <andi@lisas.de>
Cc: Alexander Lam <azl@andrew.cmu.edu>
Signed-off-by: Borislav Petkov <bp@suse.de>
---

Guys,

this fixes acerhdf to the old behavior. Testing here looks ok - I'd
appreciate if you could verify this too.

Thanks.

 drivers/platform/x86/acerhdf.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index f94467c05225..b44033756909 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -405,13 +405,33 @@ static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int trip,
 	return 0;
 }
 
+/*
+ * This is more or less a quirky wagging the dog so that a one-trip
+ * point can still work with the step_wise governor. Basically, we cheat
+ * with the trip temperature depending on whether the current state of
+ * the fan (on vs off).
+ */
 static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int trip,
 				 unsigned long *temp)
 {
-	if (trip == 0)
+	int err = 0, state;
+
+	err = acerhdf_get_fanstate(&state);
+	if (err) {
+		/*
+		 * We want to be conservative here: in the unlikely event that
+		 * reading the fanstate failed, we want to leave the fan on.
+		 */
 		*temp = fanon;
+		return err;
+	}
 
-	return 0;
+	if (state == ACERHDF_FAN_AUTO)
+		*temp = fanoff;
+	else
+		*temp = fanon;
+
+	return err;
 }
 
 static int acerhdf_get_crit_temp(struct thermal_zone_device *thermal,
-- 
1.8.1.3.535.ga923c31


  reply	other threads:[~2013-02-23 19:20 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-14 15:32 thermal governor: does it actually work?? Andreas Mohr
2013-02-15  9:47 ` Zhang, Rui
2013-02-15 15:49   ` Andreas Mohr
2013-02-16 21:08     ` Alexander Lam
2013-02-16 21:47       ` Borislav Petkov
2013-02-17  2:43         ` Peter Feuerer
2013-02-17 14:09           ` Borislav Petkov
2013-02-17 15:41             ` Peter Feuerer
2013-02-18 13:50               ` Borislav Petkov
2013-02-18 16:47                 ` Peter Feuerer
2013-02-19 14:51                   ` Zhang Rui
2013-02-19 15:05                     ` Borislav Petkov
2013-02-19 15:27                       ` Zhang Rui
     [not found]     ` <CACWwPisqpmLjiqEh+J2DjnEtNObmmA0w=qMQYTgBsb6Ntad7Pw@mail.gmail.com>
     [not found]       ` <744357E9AAD1214791ACBA4B0B90926329F98E@SHSMSX101.ccr.corp.intel.com>
     [not found]         ` <CACWwPit=xxeeCW1+jfxE8eww+P545B5xebh3YT2yE78zcsqSMg@mail.gmail.com>
2013-02-18 20:33           ` Alexander Lam
2013-02-19 14:53           ` Zhang Rui
2013-02-19 15:35 ` Zhang Rui
2013-02-22  5:33   ` Peter Feuerer
2013-02-22 11:15     ` Borislav Petkov
2013-02-23 19:20       ` Borislav Petkov [this message]
2013-02-24 11:28         ` [PATCH] acerhdf: Fix fan activation with new thermal governor Borislav Petkov
2013-02-24 11:42           ` Peter Feuerer
2013-02-24 12:09             ` Borislav Petkov
2013-02-24 12:59               ` Borislav Petkov
2013-02-25  3:06               ` Zhang Rui
2013-02-25 10:20                 ` Borislav Petkov
2013-02-25 10:36                   ` Peter Feuerer
2013-02-24 14:34             ` Borislav Petkov
2013-02-25  3:21               ` Zhang Rui
2013-02-25 10:25                 ` Borislav Petkov
2013-02-25 12:16                   ` Borislav Petkov
2013-03-04 13:34                     ` Borislav Petkov
2013-03-04 19:25                       ` Andreas Mohr
2013-03-05 21:59                       ` Andreas Mohr
2013-03-06  3:47                         ` Zhang Rui
2013-03-06  7:00                           ` Borislav Petkov
2013-03-06  7:30                             ` Zhang Rui
2013-03-06  7:36                               ` Borislav Petkov
2013-03-07 20:17                       ` Peter Feuerer
2013-03-07 20:27                         ` Borislav Petkov
2013-02-25  3:01             ` Zhang Rui
2013-02-25  2:58           ` Zhang Rui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1361647210-12983-1-git-send-email-bp@alien8.de \
    --to=bp@alien8.de \
    --cc=andi@lisas.de \
    --cc=azl@andrew.cmu.edu \
    --cc=bp@suse.de \
    --cc=durgadoss.r@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter@piie.net \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).