Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3282942ybc; Thu, 21 Nov 2019 06:11:48 -0800 (PST) X-Google-Smtp-Source: APXvYqz845sEjWbrGT81GR6bt5HvNm1tkMrJ7ySvn2IHKI41qTDz/tQedi7DG/gnhC9EVdX19hB7 X-Received: by 2002:a2e:984f:: with SMTP id e15mr7675464ljj.109.1574345508681; Thu, 21 Nov 2019 06:11:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574345508; cv=none; d=google.com; s=arc-20160816; b=Qumq66GXN2CZCS3wsPaJLNGe8LAAC5zwfYaQOGLmcMbU+oFH3rpg01RGcoMxuq0ixC YMAFGwU1551BV8CrUNp2JFvp/AtLYA+x+sJDvhhbj80tdgkOKgoOqxeYwgXxjcUzajVc ZfDrhkf1ZCVZUlJ8xTQju/x28bN0wT/WQ3eBUAPM6Iz4i8tvaVq/W1zcC6XcWpbCvene y9fTMw9otxTlKtD78L9uK1jEHT65n3WJsl59G0AGLKWzdYVIPdpcn+mYT0zRhobma/Se n3Ss9fC3wOUvvMPkQBjUhEywflo2An/ASmZEofeP4uM9FDoACpDcVsHT3mr8a1GP9LKd TDHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature; bh=ndBghIAW5jexbjstvssowNgkv48SOm6LHbFBASVDuQI=; b=eRLjBdbBjtNZJ+q5iPfNbOsb+6G656Fx/kIKXqBIONIJQUw4UclI33VfHC9/aOU3cC ASZAKg/oXeDsh0HD+DrbiwDZ+K6n3fD9k0ZqrBdzeyVDK5bPqcpPj0Ix/H7agkGbyqpY B603QHWOHXrqZ4UZ9adjNR5pbyD+9cooOem/fsBK9x1kbJDWWhpn7IFmqwetQWZnasik uDeyvbbMvp8Q/dQRG7QGWaJvbMrxTzirT0TJTHRZ4lXgosvmB4jkka38efLy8nYlkpfB iMDkpxNPXNHA1UDdFBnUrb8QcyrP3IK4+3x2GLN2CSiPfkhumxwuNzP8NvOPUWSsmT49 VCgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E+3g4JXD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o21si2062866edt.135.2019.11.21.06.11.23; Thu, 21 Nov 2019 06:11:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E+3g4JXD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726573AbfKUOKE (ORCPT + 99 others); Thu, 21 Nov 2019 09:10:04 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:44818 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726293AbfKUOKD (ORCPT ); Thu, 21 Nov 2019 09:10:03 -0500 Received: by mail-qt1-f194.google.com with SMTP id o11so3759685qtr.11 for ; Thu, 21 Nov 2019 06:10:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=ndBghIAW5jexbjstvssowNgkv48SOm6LHbFBASVDuQI=; b=E+3g4JXDHhaV3nv6Jnkpf/uAYDpBcirtfCOtykviPuf8+8JadmxlqRxUSn/i/KNfi/ xeXN6tcZhDjIGC/IeUgOCPvR0gwQu7VKBYj3LMVUGRRgG7McU7A58hCxswbVh0DNGp0U Ryi8oflhf2IrzM7D3mrt04WStpLx8hISOn9RxKB4pWAlNcOOXNoeBlUZ24X2pl/JSdUG 4IB7uxRMijM70jcRyRe5pBrJrUn1n/2ZyWYg7UADvp8p73bxZTUo4OF3kx/XH+TNPyBs P5Ouep2zfOJTWEVPZcMj50GwwOoUBL3LA3L1ThGjNckQ7kDrEaLvuRIKWcd7rz90/czD fhBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=ndBghIAW5jexbjstvssowNgkv48SOm6LHbFBASVDuQI=; b=Zr+lOjgZHmmefujHVTw8tYHEzpZ2tsjpjPCFQuDslckNzNRCAGE+dOiAzQMqK/Jj0c eEzqAx72HF5z6Ojov7MsmIfbWTTOG+lwP1i/tD/kxJHZoRS2DXphGkT+kMGXx/gNYhmC NoaBIw8NrRO6DAP7fi7l2yrPPesIr/yScmDTWhPFbwlHLppQQH0NB33ANtVHyvX/LA2Z kO5W3hjW4UUWUkDNJ4JyriBl3F1LyvvY9xdMz9TEZUsTf+LgW5Q/pgRjQv+sMlx2gBt9 IcJTP+uZMG3gOybargcCMkof7uH/VKHboQZ9dDJI/uPnGt2HfeUwl9u+QH1BMmkvjMjU fTYw== X-Gm-Message-State: APjAAAWnjVkBo/pYJ0uBi2BFKqSLNhI44auuMUKSPEqDa3j0azrNKBPu RXUdbbkSLHWAAJOmaic4LllYhA== X-Received: by 2002:ac8:7454:: with SMTP id h20mr8866546qtr.146.1574345402032; Thu, 21 Nov 2019 06:10:02 -0800 (PST) Received: from [192.168.1.169] (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.gmail.com with ESMTPSA id o53sm1557251qtj.91.2019.11.21.06.10.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Nov 2019 06:10:00 -0800 (PST) Subject: Re: [PATCH] drivers: thermal: step_wise: add support for hysteresis To: Amit Kucheria , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, swboyd@chromium.org, j-keerthy@ti.com, Zhang Rui , Eduardo Valentin , Daniel Lezcano , Amit Kucheria References: <8e812065f4a76325097c5f9c17f3386736d8c1d4.1574315190.git.amit.kucheria@linaro.org> Cc: Ram Chandrasekar , Lina Iyer , linux-pm@vger.kernel.org From: Thara Gopinath Message-ID: <5DD69AB7.3060307@linaro.org> Date: Thu, 21 Nov 2019 09:09:59 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <8e812065f4a76325097c5f9c17f3386736d8c1d4.1574315190.git.amit.kucheria@linaro.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/21/2019 12:50 AM, Amit Kucheria wrote: > From: Ram Chandrasekar > > Currently, step wise governor increases the mitigation when the > temperature goes above a threshold and decreases the mitigation when the > temperature goes below the threshold. If there is a case where the > temperature is wavering around the threshold, the mitigation will be > applied and removed every iteration, which is not very efficient. > > The use of hysteresis temperature could avoid this ping-pong of > mitigation by relaxing the mitigation to happen only when the > temperature goes below this lower hysteresis value. Hi Amit, Can this not lead to ping-pong around the hysteresis temperature? If the idea is to minimize ping-pong isn't average a better method? Warm Regards Thara > > Signed-off-by: Ram Chandrasekar > Signed-off-by: Lina Iyer > [Rebased patch from downstream] > Signed-off-by: Amit Kucheria > --- > drivers/thermal/step_wise.c | 35 ++++++++++++++++++++++++----------- > 1 file changed, 24 insertions(+), 11 deletions(-) > > diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c > index 6e051cbd824ff..2c8a34a7cf959 100644 > --- a/drivers/thermal/step_wise.c > +++ b/drivers/thermal/step_wise.c > @@ -24,7 +24,7 @@ > * 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, > + * If the temperature is lower than a hysteresis temperature, > * 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 > @@ -115,30 +115,31 @@ static void update_passive_instance(struct thermal_zone_device *tz, > > static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) > { > - int trip_temp; > + int trip_temp, hyst_temp; > enum thermal_trip_type trip_type; > enum thermal_trend trend; > struct thermal_instance *instance; > - bool throttle = false; > + bool throttle; > int old_target; > > if (trip == THERMAL_TRIPS_NONE) { > - trip_temp = tz->forced_passive; > + hyst_temp = trip_temp = tz->forced_passive; > trip_type = THERMAL_TRIPS_NONE; > } else { > tz->ops->get_trip_temp(tz, trip, &trip_temp); > + hyst_temp = trip_temp; > + if (tz->ops->get_trip_hyst) { > + tz->ops->get_trip_hyst(tz, trip, &hyst_temp); > + hyst_temp = trip_temp - hyst_temp; > + } > tz->ops->get_trip_type(tz, trip, &trip_type); > } > > trend = get_tz_trend(tz, trip); > > - if (tz->temperature >= trip_temp) { > - throttle = true; > - trace_thermal_zone_trip(tz, trip, trip_type); > - } > - > - dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n", > - trip, trip_type, trip_temp, trend, throttle); > + dev_dbg(&tz->device, > + "Trip%d[type=%d,temp=%d,hyst=%d]:trend=%d,throttle=%d\n", > + trip, trip_type, trip_temp, hyst_temp, trend, throttle); > > mutex_lock(&tz->lock); > > @@ -147,6 +148,18 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) > continue; > > old_target = instance->target; > + throttle = false; > + /* > + * Lower the mitigation only if the temperature > + * goes below the hysteresis temperature. > + */ > + if (tz->temperature >= trip_temp || > + (tz->temperature >= hyst_temp && > + old_target != THERMAL_NO_TARGET)) { > + throttle = true; > + trace_thermal_zone_trip(tz, trip, trip_type); > + } > + > instance->target = get_target_state(instance, trend, throttle); > dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n", > old_target, (int)instance->target); >