Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp201042imm; Thu, 26 Jul 2018 01:50:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgperVNnnZxyKeiT+AFxq/zgs/MgmhUsT0GvpwMfbgkdIpOHe6gJly1E+h0mb/ljMqWaGKbM1 X-Received: by 2002:a62:4494:: with SMTP id m20-v6mr1165903pfi.205.1532595050359; Thu, 26 Jul 2018 01:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532595050; cv=none; d=google.com; s=arc-20160816; b=B7GVDD4sXEoC3Ey6VRJ1AjRSObJuB8sfD1ob2oAH6pqg52zrNjh3qUFkMJx1B4KZDi WFgryl1U9wdQODL8Nfw/jwEskzBagkxwGnnhvcZmnMgHyvQN4slsn/b4JATOzFAPKMAN GYy4a5oXYAtm1O+qf4wgCEnxVDeaQCs5UnFaAPzUTLCrUIUDJHDOLEfZjEfODfZNYH4t daTe3MnR+hYXkfrQ8XgyiA+D/5o/O9I3NYYQKqUBg94Wb58hq4ibMVJDfxRRGG7LSFZA ovneCRCeJo5XOmlyPvNg23tQ1JITC9RK2ClqObNjtVJQn+uVeZQTTpjN6d3KMuHKJXc5 6c3Q== 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:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=bUZN8cgeD2jeDQEHriJtM4ZpuoQb7GqbPijI2m6CcBo=; b=LOwYoSJyrpUEId3I8eaqKe2rN6lmz2LLRCYRbdJq1dBtqrwOD1QSwANcA3nLqTHabK sD9Be7UKeLiDXWqWLkmGdtb8ywWw69H1/9dyz6acBfPAlsZVfucB2FQDUfa/kdh26XvI mp0ynbh7zFfuYcBKSZDWIW/AfK3kQSn0D7gZt4+gzmvy+1ds5mCSc2VvuF96Lhifntav PSOXm7+ilUbdf30rUnwNplCAGkM2IEOGD4VxbftKOBN4FwS/Vuz1iUawV919K/nUCGQs 4Jk4qIxOXgxbeqBx+/Dq4cV4utY/ox1gieFkYZWXUntK9JYmv/OhuwgRSD7CdGAvAM0R P9SA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b80-v6si878887pfm.230.2018.07.26.01.50.35; Thu, 26 Jul 2018 01:50:50 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729224AbeGZKF2 (ORCPT + 99 others); Thu, 26 Jul 2018 06:05:28 -0400 Received: from mga07.intel.com ([134.134.136.100]:12914 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728825AbeGZKF2 (ORCPT ); Thu, 26 Jul 2018 06:05:28 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2018 01:49:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,404,1526367600"; d="scan'208";a="219250412" Received: from taolv-mobl.ccr.corp.intel.com ([10.249.169.42]) by orsmga004.jf.intel.com with ESMTP; 26 Jul 2018 01:49:32 -0700 Message-ID: <1532594969.2358.40.camel@intel.com> Subject: Re: [PATCH] drivers: thermal: step_wise: add support for hysteresis From: Zhang Rui To: Lina Iyer , edubezval@gmail.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Ram Chandrasekar Date: Thu, 26 Jul 2018 16:49:29 +0800 In-Reply-To: <20180507175408.2154-1-ilina@codeaurora.org> References: <20180507175408.2154-1-ilina@codeaurora.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Lina, On 一, 2018-05-07 at 11:54 -0600, Lina Iyer wrote: > From: Ram Chandrasekar > > From: Ram Chandrasekar > > Step wise governor increases the mitigation level when the > temperature > goes above a threshold and will decrease the mitigation when the > temperature falls below the threshold. If it were a case, where the > temperature hovers around a threshold, the mitigation will be applied > and removed at every iteration. This reaction to the temperature is > inefficient for performance. > > 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. > the idea looks okay to me, just some minor comments. > Signed-off-by: Ram Chandrasekar > Signed-off-by: Lina Iyer > --- >  drivers/thermal/step_wise.c | 33 +++++++++++++++++++++++---------- >  1 file changed, 23 insertions(+), 10 deletions(-) > > diff --git a/drivers/thermal/step_wise.c > b/drivers/thermal/step_wise.c > index ee047ca43084..cf07e2269291 100644 > --- a/drivers/thermal/step_wise.c > +++ b/drivers/thermal/step_wise.c > @@ -36,7 +36,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, 1. if you update this, you should update "if the temperature is higher than ..." as well. 2. the updated comment does not fully match the code change you made below. >   *    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 > @@ -127,7 +127,7 @@ 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; > @@ -135,22 +135,23 @@ static void thermal_zone_trip_update(struct > thermal_zone_device *tz, int trip) >   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); >   throttle is not set properly here, so this debug message does not make sense. thanks, rui >   mutex_lock(&tz->lock); >   > @@ -159,6 +160,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);