From patchwork Wed Jun 29 15:10:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12900281 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E49D7C43334 for ; Wed, 29 Jun 2022 15:12:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234061AbiF2PMS (ORCPT ); Wed, 29 Jun 2022 11:12:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234077AbiF2PME (ORCPT ); Wed, 29 Jun 2022 11:12:04 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 961C2340C9 for ; Wed, 29 Jun 2022 08:10:29 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id o4so19006542wrh.3 for ; Wed, 29 Jun 2022 08:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=q3ZYq3bcsj/UjtaD25DcyTAm2D/1RmGVwIAKcRPY+eg=; b=CmfYYcfr9K4XbkT5SOVFmJr3HuPO8kzgs7aT8gxU2yyEUPp6GOVCS8JG+2P3gzMlbj yKeowkAkIbJykRtw72dw9FERYSt6OhnDV90lVoenDJ6YiMW27N0D3oCzJdSLLG33V9C1 wL6nDNlwM4meKfHLoGHjvaKpuzsQ88v+Qu7lYNugA3HQl5BIxNkR/fzCJDge2CCkLdJg oRd6Ld+/46jhOoHppRz+S5f0j7K+V2Zq9ZeJsgKBNEKDiDYxRXSVqEyrxjjvQovJqeFm GXVEdxkh3WDLpVa5h/tX89cGWi2oD86jhuiQIq7Ft6t/jCFpOSHR6nRELoiSIxGwQe8V EeXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=q3ZYq3bcsj/UjtaD25DcyTAm2D/1RmGVwIAKcRPY+eg=; b=GYO8M1gGDiL1mpEFx53FEHzpXvf9b/cnY8QqvSqAEU6GOXF79ZrAe68HcFvrYUkB4W 0OYBJiCWZyqmf+Y2DURwCAv8Bmh8v/RSuXfVwqSmWLN7hFR2dScnOw/QJHe/gXC2pqzZ 16zX/eOs/Ir9Mp4ps5eQsuUD/abWpg8tNjLQEjgrZWDmJG9nlsX15rOs3aCGLNaCY7QW D+6LiYOOCoko9pUP01gva4yKoU+PiOfJ/wB+z0EREBWnO1t3J7x5WsFff1rri1nvEsRY wWGY3yo8SyRodHF4SMye1p6CWc+PJCpwkz/UQ/Fuyv5ksqAU7LAtbwt+tvrY38dds+/8 /J1Q== X-Gm-Message-State: AJIora87XpdRbrg9vRlbDLb1MtY7TwrhBy1kRz6MS7Jbyp2mXcp2kHz2 eP0EqWDA1uhJ6B9zTEuCpoIo4Q== X-Google-Smtp-Source: AGRyM1vWMbd1NwnfZaHax5oHnxcFN5zGrIUsdhYd0b6WXkGuttwDKXF/INDjHiqVGqyNHSzC+DHU/g== X-Received: by 2002:a5d:604d:0:b0:21b:9b2c:be31 with SMTP id j13-20020a5d604d000000b0021b9b2cbe31mr3710411wrt.91.1656515427060; Wed, 29 Jun 2022 08:10:27 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0a5500b0039c4d022a44sm3509029wmq.1.2022.06.29.08.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 08:10:26 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH 1/2] thermal/core: Use clamp() helper in the stepwise governor Date: Wed, 29 Jun 2022 17:10:11 +0200 Message-Id: <20220629151012.3115773-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The code is actually clampling the next cooling device state using the lowest and highest states of the thermal instance. That code can be replaced by the clamp() macro which does exactly the same. It results in a simpler routine to read. Signed-off-by: Daniel Lezcano --- drivers/thermal/gov_step_wise.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wise.c index 12acb12aac50..6efbfaf014da 100644 --- a/drivers/thermal/gov_step_wise.c +++ b/drivers/thermal/gov_step_wise.c @@ -11,6 +11,7 @@ */ #include +#include #include #include "thermal_core.h" @@ -52,10 +53,7 @@ static unsigned long get_target_state(struct thermal_instance *instance, if (!instance->initialized) { if (throttle) { - next_target = (cur_state + 1) >= instance->upper ? - instance->upper : - ((cur_state + 1) < instance->lower ? - instance->lower : (cur_state + 1)); + next_target = clamp((cur_state + 1), instance->lower, instance->upper); } else { next_target = THERMAL_NO_TARGET; } @@ -66,10 +64,7 @@ static unsigned long get_target_state(struct thermal_instance *instance, switch (trend) { case THERMAL_TREND_RAISING: if (throttle) { - next_target = cur_state < instance->upper ? - (cur_state + 1) : instance->upper; - if (next_target < instance->lower) - next_target = instance->lower; + next_target = clamp((cur_state + 1), instance->lower, instance->upper); } break; case THERMAL_TREND_RAISE_FULL: @@ -82,9 +77,7 @@ static unsigned long get_target_state(struct thermal_instance *instance, next_target = THERMAL_NO_TARGET; } else { if (!throttle) { - next_target = cur_state - 1; - if (next_target > instance->upper) - next_target = instance->upper; + next_target = clamp((cur_state - 1), instance->lower, instance->upper); } } break; From patchwork Wed Jun 29 15:10:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12900282 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4F86CCA47C for ; Wed, 29 Jun 2022 15:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234126AbiF2PMT (ORCPT ); Wed, 29 Jun 2022 11:12:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234180AbiF2PMF (ORCPT ); Wed, 29 Jun 2022 11:12:05 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BE173EF0B for ; Wed, 29 Jun 2022 08:10:30 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id m6-20020a05600c3b0600b003a0489f412cso888512wms.1 for ; Wed, 29 Jun 2022 08:10:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k/xWzWXDjwfHlllM6Hvtaj2XKm2chFd2jJ2ssW13thU=; b=qsokU08JAvgideuDlR9em8hS0EkmPliIb05x2bqVwzfMJUXEcMybvE8u+D9fjuvrel 3QP+Zfdry1XM7qWyYh1zl7MuHNSyz91nmJf4hqVKCRw+dJ031mY8hDrkA82oAuuy8il7 fih/AQexicIQKz9WipwwHNAaBGpZrOHEaMVPVJUjEpz85Wk/4YYFHBBENSu662mFOkrN BrYhMS/zOn+luxiZSNjz4us5OdpFp23sLI+h4I9mtioJ+WYgB/aoGxHUjHuuvZAhOqqW ba9htJQvX6bRUfjigXVSQP3ftiXSqWGJT6OlyTAAayxCEGFUb6ZWnVss1/8dSkOIVNv/ aXew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k/xWzWXDjwfHlllM6Hvtaj2XKm2chFd2jJ2ssW13thU=; b=5fNUWwFy4l0tx2bukyfsqMseZxglgo34fGyzqaetf5LLY2MbVaZ5iQaM13h5BturqC tzAg91pX9+j6BAnlD2gEH6FZzf/TKeR9axqp5kSi2DlCT6orpcwVaEfwIvB9AObPG7Z2 R+gn8gY7LxjOa8nk18YpM68Sq+4HU34INgIalmv1PfGo5yLvAu4pT7UXiukjVWUVjzLk f/1w6DnHAv+6Au99vcU9zM6CQR2iohELl7QZ5C+SguhI64wEC6IXTrbSQqldjLeRNXlg IaWe2xJyfz4xpv6wayJhxHrRmxl3+auqSqwvp9lOmZeaJhIJdIBRvOA2Q2oqZHJbMk9G mhuQ== X-Gm-Message-State: AJIora+GHcK+EbSOXkBDa4RrUnf10KD8DCuyysyVtGOQ7nwpK/WEcnN6 3sjNGqoMgdzCbTKqyVldWM53Vw== X-Google-Smtp-Source: AGRyM1sC3dsIpYTDwO198OxJpK+5oBNuhHGguIKYVnPwaVxiGRjAVt7t7Cx8Bi4DEbZwA8B0MrKFlQ== X-Received: by 2002:a05:600c:509:b0:3a0:45d9:43e7 with SMTP id i9-20020a05600c050900b003a045d943e7mr4209360wmc.176.1656515428563; Wed, 29 Jun 2022 08:10:28 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0a5500b0039c4d022a44sm3509029wmq.1.2022.06.29.08.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 08:10:27 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH 2/2] thermal/core: Remove DROP_FULL and RAISE_FULL Date: Wed, 29 Jun 2022 17:10:12 +0200 Message-Id: <20220629151012.3115773-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220629151012.3115773-1-daniel.lezcano@linaro.org> References: <20220629151012.3115773-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The trends DROP_FULL and RAISE_FULL are not used and were never used in the past AFAICT. Remove these conditions as they seems to not be handled anywhere. Signed-off-by: Daniel Lezcano --- drivers/thermal/gov_step_wise.c | 11 ----------- include/linux/thermal.h | 2 -- 2 files changed, 13 deletions(-) diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wise.c index 6efbfaf014da..9729b46d0258 100644 --- a/drivers/thermal/gov_step_wise.c +++ b/drivers/thermal/gov_step_wise.c @@ -67,10 +67,6 @@ static unsigned long get_target_state(struct thermal_instance *instance, next_target = clamp((cur_state + 1), instance->lower, instance->upper); } break; - case THERMAL_TREND_RAISE_FULL: - if (throttle) - next_target = instance->upper; - break; case THERMAL_TREND_DROPPING: if (cur_state <= instance->lower) { if (!throttle) @@ -81,13 +77,6 @@ static unsigned long get_target_state(struct thermal_instance *instance, } } break; - case THERMAL_TREND_DROP_FULL: - if (cur_state == instance->lower) { - if (!throttle) - next_target = THERMAL_NO_TARGET; - } else - next_target = instance->lower; - break; default: break; } diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 522c9180a08d..c8528bb6c01c 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -41,8 +41,6 @@ enum thermal_trend { THERMAL_TREND_STABLE, /* temperature is stable */ THERMAL_TREND_RAISING, /* temperature is raising */ THERMAL_TREND_DROPPING, /* temperature is dropping */ - THERMAL_TREND_RAISE_FULL, /* apply highest cooling action */ - THERMAL_TREND_DROP_FULL, /* apply lowest cooling action */ }; /* Thermal notification reason */