From patchwork Wed Sep 24 08:27:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 4962561 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EB160BEEA5 for ; Wed, 24 Sep 2014 08:29:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DE57A20265 for ; Wed, 24 Sep 2014 08:29:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C39142010C for ; Wed, 24 Sep 2014 08:29:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753337AbaIXI1t (ORCPT ); Wed, 24 Sep 2014 04:27:49 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:48798 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753568AbaIXI1r (ORCPT ); Wed, 24 Sep 2014 04:27:47 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NCE008S1CUA2560@mailout1.samsung.com>; Wed, 24 Sep 2014 17:27:46 +0900 (KST) X-AuditID: cbfee61a-f79c06d000004e71-3e-542280815299 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 1F.1A.20081.18082245; Wed, 24 Sep 2014 17:27:46 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NCE00FDSCTFY620@mmp1.samsung.com>; Wed, 24 Sep 2014 17:27:45 +0900 (KST) From: Lukasz Majewski To: Zhang Rui , Eduardo Valentin Cc: Linux PM list , Lukasz Majewski , Bartlomiej Zolnierkiewicz , linux-kernel@vger.kernel.org, Lukasz Majewski Subject: [PATCH 1/3] thermal: step_wise: fix: Prevent from binary overflow when trend is dropping Date: Wed, 24 Sep 2014 10:27:10 +0200 Message-id: <1411547232-21493-2-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1411547232-21493-1-git-send-email-l.majewski@samsung.com> References: <1411547232-21493-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprELMWRmVeSWpSXmKPExsVy+t9jAd2mBqUQgyONzBYbZ6xntZh/5Rqr xZtH3BZvHm5mtLi8aw6bxefeI4wWTx72sTmwe+ycdZfdY/Gel0we66a9Zfbo27KK0ePzJrkA 1igum5TUnMyy1CJ9uwSujBVnN7AW7OSoOH59OmMD4x+2LkZODgkBE4lp09YxQdhiEhfurQeK c3EICSxilFjy7RIjhNPFJHFmwyxmkCo2AT2Jz3efAnVwcIgIeEtsWcMBUsMscINRYkr/ZLBJ wgLJEu1zG8FsFgFVib+HOxlB6nkF3CSezayFWKYo0f1sAtgRnALuEjd/P2MHsYWASg7+Osg+ gZF3ASPDKkbR1ILkguKk9FxDveLE3OLSvHS95PzcTYzgkHomtYNxZYPFIUYBDkYlHt4J4koh QqyJZcWVuYcYJTiYlUR4T5QChXhTEiurUovy44tKc1KLDzFKc7AoifMeaLUOFBJITyxJzU5N LUgtgskycXBKNTDOVLWMvmN/ZNcUxv23L0ySscjyfZ8vf3Cnu+K9XX3/fKakKxZP3Drhg9V/ A9P/5WqHUy+z8zPcl801uGnEMEX0wvqf54qa956J1l4/+VCk2Kv2Kz/nTBFweHExJTCDc+vn A2yiH8+GPtk5v+xK7/mL6qunXBWedXj3op27e79cFEt1sb915gS3mRJLcUaioRZzUXEiAKph w5klAgAA Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It turns out that some boards can have instance->lower greater than 0 and when thermal trend is dropping it results with next_target equal to -1. Since the next_target is defined as unsigned long it is interpreted as 0xFFFFFFFF and larger than instance->upper. As a result the next_target is set to instance->upper which ramps up to maximal cooling device target when the temperature is steadily decreasing. Signed-off-by: Lukasz Majewski --- drivers/thermal/step_wise.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c index 3b54c2c..fdd1f52 100644 --- a/drivers/thermal/step_wise.c +++ b/drivers/thermal/step_wise.c @@ -77,7 +77,7 @@ static unsigned long get_target_state(struct thermal_instance *instance, next_target = instance->upper; break; case THERMAL_TREND_DROPPING: - if (cur_state == instance->lower) { + if (cur_state <= instance->lower) { if (!throttle) next_target = THERMAL_NO_TARGET; } else {