From patchwork Tue Mar 21 05:47:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 72701 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1605857wrt; Mon, 20 Mar 2023 22:59:09 -0700 (PDT) X-Google-Smtp-Source: AK7set9GU+JSKjQGdmMjcOHcaZc+ihL6cweJmxi5dvd5Zx+XMsCUYz5XFgzMlZccxpVh7IiUDH+K X-Received: by 2002:a17:902:e548:b0:1a0:4531:af58 with SMTP id n8-20020a170902e54800b001a04531af58mr1271617plf.63.1679378349175; Mon, 20 Mar 2023 22:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679378349; cv=none; d=google.com; s=arc-20160816; b=E2LChQWkYViPvdlok5QL8nakkuNa9RkKFzk6y/HD/9jlm5j1ipoLF84INhg8GFF2AB h8vh65wC0KLuzBNL0RZM9raqoJ/2rT6DH4VsxMgqONgplTqQbHqtWpHuUa/hExPOD9bc i/cD9grzAM+r8ArqsfLjJ7Riza8Ir384GbXBHjuWQL2L+vL7iekgXDYMz6b7teKcvZyC DztSYraUTZlCIYgnDIu1+RAgET/MZSzMNbom4EMiJ1SDd0v1iUQ56eptfy/m0OcQosfh l/jIQNn5+vYWsoXpimEY+fht8tOxKT/YboxqmBDYcmi8inOB7Oqmlr2PqnWpuVpiba8z 2HWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=VT0tyLiX3FlCsxCN5d69apbj7NHEVtFUiVAHEoMjeSU=; b=iTf6oxCqW0hE0zqnHmvSM2D2xKqvfjwLfKYJ31ySrvczyzm93zceFgYnS1D4J0s1md LQN2yv51lRnDFpZg3dWbORR/+ZWLQRu/3vWMmWqCmHk2y5olSQphoxDQ5Cp55c33ZdAs Xmt67kJHCdYJ2mF/XdyK+bpXQcLeo4C2UEJamkS/3Up5lHNXuMm8yVM/+grEHdClYobX YN0tnlrBLWdWoEnRVVMZ3wTMTSx9lMCGMmsSxUmfeIMfMs9eeW5GqHhovZvi+9jTuq9M X/89HiLTVxHxEzfdTVI96258tNG6S8gS7/p2aUF5SD+oCDEv59mnaDybVpvLPP+d0Rtr nm3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="c/NlWFT7"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h16-20020a170902f55000b001a067e3b1edsi441293plf.592.2023.03.20.22.58.54; Mon, 20 Mar 2023 22:59:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="c/NlWFT7"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229884AbjCUFra (ORCPT + 99 others); Tue, 21 Mar 2023 01:47:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbjCUFr2 (ORCPT ); Tue, 21 Mar 2023 01:47:28 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6674B298FD; Mon, 20 Mar 2023 22:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679377645; x=1710913645; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=7BhFhs8BuGPv7rmu8S+dpE17X+MFawyQP4/vYdI0Bt4=; b=c/NlWFT73VVtC2w0WrQaopjg5B1uXYb1+wCtSIdvEDtW802Ixix2N1Qs jpUtlcGI98tpk4ELky3FEocxMSrVyKagOOt8FMa5rR+YceMp66iInt1bf BbLnTLTFpygc5bOYsW7gOmhDtCbOQG3USiv9mCYQaDEltii3d6+uRTxlA oXMxXufkZCkPfjLD+Y0QSGcfX/MOxiPHMGFO9X0KYMaesyGUeNGXYUVzj sGqnE+FmcR8NslJMam+WQfNIel3H5LjBBFphe0FMYMcbAdc9xi8rT8j0Z F0IZ3Sxbl18zXRWlAy2WuRQaTxNXoigGkjs4+ux1GgQEhI6cDInm2peVz w==; X-IronPort-AV: E=McAfee;i="6600,9927,10655"; a="336359299" X-IronPort-AV: E=Sophos;i="5.98,278,1673942400"; d="scan'208";a="336359299" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2023 22:47:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10655"; a="927271464" X-IronPort-AV: E=Sophos;i="5.98,278,1673942400"; d="scan'208";a="927271464" Received: from zhouf-mobl.ccr.corp.intel.com (HELO rzhang1-DESK.intel.com) ([10.249.171.160]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2023 22:47:23 -0700 From: Zhang Rui To: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 1/2] thermal/governors/step_wise: delete obsolete comment Date: Tue, 21 Mar 2023 13:47:13 +0800 Message-Id: <20230321054714.76287-1-rui.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760955831867606480?= X-GMAIL-MSGID: =?utf-8?q?1760955831867606480?= Commit 4102c4042a33 ("thermal/core: Remove DROP_FULL and RAISE_FULL") removes support for THERMAL_TREND_RAISE_FULL/DROP_FULL but leaves the comment unchanged. Delete the obsolte comment about THERMAL_TREND_RAISE_FULL/DROP_FULL. Fixes: 4102c4042a33 ("thermal/core: Remove DROP_FULL and RAISE_FULL") Signed-off-by: Zhang Rui --- drivers/thermal/gov_step_wise.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wise.c index 31235e169c5a..7a760b6a4279 100644 --- a/drivers/thermal/gov_step_wise.c +++ b/drivers/thermal/gov_step_wise.c @@ -21,19 +21,11 @@ * a. if the trend is THERMAL_TREND_RAISING, use higher cooling * state for this trip point * b. if the trend is THERMAL_TREND_DROPPING, do nothing - * c. if the trend is THERMAL_TREND_RAISE_FULL, use upper limit - * for this trip point - * d. if the trend is THERMAL_TREND_DROP_FULL, use lower limit - * for this trip point * If the temperature is lower than a trip point, * a. if the trend is THERMAL_TREND_RAISING, do nothing * b. if the trend is THERMAL_TREND_DROPPING, use lower cooling * state for this trip point, if the cooling state already * equals lower limit, deactivate the thermal instance - * c. if the trend is THERMAL_TREND_RAISE_FULL, do nothing - * d. if the trend is THERMAL_TREND_DROP_FULL, use lower limit, - * if the cooling state already equals lower limit, - * deactivate the thermal instance */ static unsigned long get_target_state(struct thermal_instance *instance, enum thermal_trend trend, bool throttle) From patchwork Tue Mar 21 05:47:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 72698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1604320wrt; Mon, 20 Mar 2023 22:53:08 -0700 (PDT) X-Google-Smtp-Source: AK7set8AiXXm47YChGrdzb4Pohev1xkK7pBMj696BSRuGtqkgpMIHxANltlJs/QuU+37qkPtuFUn X-Received: by 2002:a17:902:d0d4:b0:199:4be8:be48 with SMTP id n20-20020a170902d0d400b001994be8be48mr1525404pln.19.1679377987998; Mon, 20 Mar 2023 22:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679377987; cv=none; d=google.com; s=arc-20160816; b=porigT3+WNr4o410/9j2fi8osjt5sTKg5U+IutPui5kJQV8oVirirXTDR1MRZ2P89B E4ueBKQ8kRJdfARZEFwXtNiZxYi/txoAUUIUgPoR85lC/yMDeImjXH8HIw8pzU0e8WX8 MOa/IWTGhA1X+iLnoPSanu3EumkRlb6J32yCwzxx0Epa55NqkEt16Zsa29gTRXLrFUKx MLROSxIqVn4A487RP0ciBvtxuTNUT9LN0arluWxtWf+IsuB6iSpCiUdbvVKTg9V3AMaA IcuAJDxMAIocE4NUhX3m+IoI7xOhJqxketJlVNWBOhxJIu9r0SJk91Z7/H7XhP4Msk2f Oyfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bGZaBPrOGtJQpo177vhfRswde5we1TXalMgB6f32B0Y=; b=e/U2+KacQ++Ft+eojzoP5kQD+erNa9gsi+DCFQj013pHCAc3ag+FRSoU00oi7Zw2aA lJbGDygdXlxG+3LJ9LFVG4UE+ibHTFbSMdmNUuKc4d5WLbrXPHtJfbtrVIWsGCCgl0OF G73IR1hyR+SGSCVsonAUlnOKfwbLFBaVAwX47V+mTMefvFbxPqw4Uw2DGl5+coiDw0qV AwbkFVIccS+vAll0pHlVYYOpL5g1BNF/YW2PRlNY5kZJaUWNXXM7kblHY0wUcEGaMZcc L6l9dGqZ13lZSh1kM2LbqkSSFUUAriqwUXgS9MtH455utIJ08bkDV/gg8l8+HNad+w7X QnaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ALhnGtdE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a17090301c700b001a048529dd3si12983128plh.54.2023.03.20.22.52.54; Mon, 20 Mar 2023 22:53:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ALhnGtdE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229936AbjCUFrd (ORCPT + 99 others); Tue, 21 Mar 2023 01:47:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbjCUFr3 (ORCPT ); Tue, 21 Mar 2023 01:47:29 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 055B82A152; Mon, 20 Mar 2023 22:47:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679377647; x=1710913647; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lQJIJFxogi+f9wpwcy5bQR4Ve4cHujdBkxgNOyEbJ+I=; b=ALhnGtdEa53/UGguXkqfgG5XpK2Vg9Rt00t0TbY40LEJGyVzHoEfJVde +RskY9AAfe2W1ReG36HDiuYa8h1kzfE2wUzUTm2Qba7uQewXZgSIYzJ2o Lc3SakI7RT9DValajNWGTQewNrlYjlKdLGJVPWO70ME5iK2wTGEjMqXpu grRqG6vmq9+2wNpvPkxTcviJof4/FnhgG9gFM+4DebvW7iWvZgUEzxVvU zDYI6WmBAczzAYfW1XT9gf7TzSd1IorKDhq6MbkPaLDyGPU8p3x9vrlGA Qtq4iooJlr1yp4mnHY8RGU2sr437RHN9JWcFwOtmUR1O3cBH3nNlIXb4F A==; X-IronPort-AV: E=McAfee;i="6600,9927,10655"; a="336359303" X-IronPort-AV: E=Sophos;i="5.98,278,1673942400"; d="scan'208";a="336359303" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2023 22:47:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10655"; a="927271471" X-IronPort-AV: E=Sophos;i="5.98,278,1673942400"; d="scan'208";a="927271471" Received: from zhouf-mobl.ccr.corp.intel.com (HELO rzhang1-DESK.intel.com) ([10.249.171.160]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2023 22:47:25 -0700 From: Zhang Rui To: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/2] thermal/governors/step_wise: Adjust code logic to align with the comment Date: Tue, 21 Mar 2023 13:47:14 +0800 Message-Id: <20230321054714.76287-2-rui.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230321054714.76287-1-rui.zhang@intel.com> References: <20230321054714.76287-1-rui.zhang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760955452772432185?= X-GMAIL-MSGID: =?utf-8?q?1760955452772432185?= For the algorithm of choosing the next target state in step_wise governor, the code does the right thing but is implemented in a way different from what the comment describes. And this hurts the code readability. As the logic in the comment is simpler, adjust the code logic to align with the comment. No functional change. Signed-off-by: Zhang Rui --- drivers/thermal/gov_step_wise.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wise.c index 7a760b6a4279..318b38d04eb9 100644 --- a/drivers/thermal/gov_step_wise.c +++ b/drivers/thermal/gov_step_wise.c @@ -53,24 +53,16 @@ static unsigned long get_target_state(struct thermal_instance *instance, return next_target; } - switch (trend) { - case THERMAL_TREND_RAISING: - if (throttle) { + if (throttle) { + if (trend == THERMAL_TREND_RAISING) next_target = clamp((cur_state + 1), instance->lower, instance->upper); - } - break; - case THERMAL_TREND_DROPPING: - if (cur_state <= instance->lower) { - if (!throttle) + } else { + if (trend == THERMAL_TREND_DROPPING) { + if (cur_state <= instance->lower) next_target = THERMAL_NO_TARGET; - } else { - if (!throttle) { + else next_target = clamp((cur_state - 1), instance->lower, instance->upper); - } } - break; - default: - break; } return next_target;