From patchwork Tue Apr 9 21:59:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Bresticker X-Patchwork-Id: 2417991 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@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 14F863FD8C for ; Tue, 9 Apr 2013 21:59:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934575Ab3DIV7v (ORCPT ); Tue, 9 Apr 2013 17:59:51 -0400 Received: from mail-ia0-f201.google.com ([209.85.210.201]:34093 "EHLO mail-ia0-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761010Ab3DIV7u (ORCPT ); Tue, 9 Apr 2013 17:59:50 -0400 Received: by mail-ia0-f201.google.com with SMTP id k25so783277iah.2 for ; Tue, 09 Apr 2013 14:59:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=/gvROORxeoqgoMColAuXVQUWCH2MYCOZrIbYLfYWtoU=; b=ArqcOnDohnyqKmBgtpVobTptBLdLZK3OkH18jFAnAXOdALQtTx2tJCLonXlSo9bbDy iNQdyAgSwX50fs4Y2981syrp3hM0dwEy/qXZJljaY3sS+exZtD/zqBc+Hht38f9VsWII AnY+YoXevsQBvFUClwcqNW7SjzzaKCX/zyNNrPdznsHSg4WWxeUTSoZeewdoHtXJuEYt oledIdx7rJYWoY0CuHHHFW2+sf7hDfkju8Yx0/n5p+GFfSWpYrc9kLRQzNUvDp8hccpt xRxmLS7bLAgFwDjh+hiWj6PXFJAduw040umUO22fAmFNYkwgzFJU00NhBbF178PkT3Cr X3Vw== X-Received: by 10.50.173.39 with SMTP id bh7mr13799067igc.4.1365544790325; Tue, 09 Apr 2013 14:59:50 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id l10si2347671ige.0.2013.04.09.14.59.50 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 09 Apr 2013 14:59:50 -0700 (PDT) Received: from abrestic.mtv.corp.google.com (abrestic.mtv.corp.google.com [172.22.72.111]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id B0B1B5A4028; Tue, 9 Apr 2013 14:59:49 -0700 (PDT) Received: by abrestic.mtv.corp.google.com (Postfix, from userid 137652) id 5F8E5221471; Tue, 9 Apr 2013 14:59:49 -0700 (PDT) From: Andrew Bresticker To: Zhang Rui , Eduardo Valentin Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Bresticker Subject: [PATCH] thermal: step_wise: set throttle target within thermal instance limits Date: Tue, 9 Apr 2013 14:59:47 -0700 Message-Id: <1365544787-22940-1-git-send-email-abrestic@chromium.org> X-Mailer: git-send-email 1.8.1.3 X-Gm-Message-State: ALoCoQnQWwRzHwGlSsZNK0l9yY3Oynsn5iWohRoN2vrEb43gsLdcvjwGnpptWsRcdckAXAFNp3e/GvIWFaIeqrK5b8u/CQzG82pyFfVKbob6vJhLpXRw8wskRIjoqYGnGl6AFf8dh5I7SK3cZM/bpzIZyILvcaprxuShUMh84QLQdHBlxzX9S0QebDEqfl4eCEQGTvdfsTKY Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org When selecting a target cooling state in get_target_state(), make sure that the state is at least as high as the minimum when the temperature is rising and at least as low as the maximum when the temperature is falling. This is necessary because, in the THREAML_TREND_RAISING and THERMAL_TREND_DROPPING cases, the current state may only be incremented or decremented by one even if it is outside the bounds of the thermal instance. This might occur, for example, if the CPU is heating up and hits a thermal trip point for the first time when it's frequency is much higher than the range specified by the thermal instance corresponding to the trip point. Signed-off-by: Andrew Bresticker Acked-by: Eduardo Valentin --- drivers/thermal/step_wise.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c index 407cde3..ca4f79f 100644 --- a/drivers/thermal/step_wise.c +++ b/drivers/thermal/step_wise.c @@ -59,9 +59,12 @@ static unsigned long get_target_state(struct thermal_instance *instance, switch (trend) { case THERMAL_TREND_RAISING: - if (throttle) + if (throttle) { cur_state = cur_state < instance->upper ? (cur_state + 1) : instance->upper; + if (cur_state < instance->lower) + cur_state = instance->lower; + } break; case THERMAL_TREND_RAISE_FULL: if (throttle) @@ -71,8 +74,11 @@ static unsigned long get_target_state(struct thermal_instance *instance, if (cur_state == instance->lower) { if (!throttle) cur_state = -1; - } else + } else { cur_state -= 1; + if (cur_state > instance->upper) + cur_state = instance->upper; + } break; case THERMAL_TREND_DROP_FULL: if (cur_state == instance->lower) {