Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1184897ybb; Fri, 10 Apr 2020 19:56:42 -0700 (PDT) X-Google-Smtp-Source: APiQypIvy+prscVgpbnFTGwVhpBQO2PlZZJElS4/PBtTp9rzn/XBWOnIYK42sSZ9lTPUYaHJESL6 X-Received: by 2002:ae9:e905:: with SMTP id x5mr6670578qkf.61.1586573802392; Fri, 10 Apr 2020 19:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586573802; cv=none; d=google.com; s=arc-20160816; b=VEYBBwqDsgIDgSIcDvYZNuix988pybuh3lTXimZOe0oSv2x9ss8mtZp1Sd+atJ+VEw 5fayDUaVsEMF12IFH3Z7SH02Nkug4w7NSDDoINiw7rF6k65BtUDN6mcMCP0nyst0VGYZ 2cjteUGi+wd2DxpuJXmwltJVFc7vi3fQiWThHGlEu4j9ALNpCt/8UojvB9pgz80pYobS ksSbgG99t8GLRPGjq+F99Wf7+hu7bmKq6COr21LJJMLip59/XC343sWmDXEO5fSaA4Ja xlyuhWz6bHpkdCr6K36jrz/6KHX5DqUCnbq9DtplsjrCuiuYXMGdbEdPmWvDFa/4TliL rJYg== 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 :ironport-sdr:ironport-sdr; bh=hikayiPmaBSuEFvjTsAegcziLKUJpqsKmWeIuFsbbOY=; b=w6fnsFfku5VCUI7NB0bPJ2Q2vaCjNcowCbyrxMDXnbMjzsAmjOBbcjdlDy3DEM9N9z s35QcvD8tEvt9ocyQ/pSu40Wq8Ms8DOZg1tRTTF6TSXW+r7+cYLhm4xMxHNFow4ncrcq aejkbBdCDF8JyESPyDZdT5VMgs+CZr1Jp5uCd7mvWONRc1w5jNos/gbVYaFHtm9KNtzN XDPb5I+6wIeKywCPJX8iWUWTp5DBf/OVAl2E9DVXyjQ3qUmQqb72o7hWALmCBWD4i1DM ereVcV4DVy1SzQ7e9kVrDmu22iK5fp9bGOI7IK81fm7mSt2zCfbBIajP8nDS/DchltXz H/QQ== 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 v62si1296418qkb.107.2020.04.10.19.56.26; Fri, 10 Apr 2020 19:56:42 -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 S1726676AbgDKCzo (ORCPT + 99 others); Fri, 10 Apr 2020 22:55:44 -0400 Received: from mga17.intel.com ([192.55.52.151]:33534 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726654AbgDKCzo (ORCPT ); Fri, 10 Apr 2020 22:55:44 -0400 IronPort-SDR: NBVfcLPGYFaba3r/IheqLOGZJ4PgW9k+3MteTSE4F6qXUmMnqaF3KTKkbYkFiqondOQzsbOFa2 /HBUdDmxQ0IA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2020 19:55:44 -0700 IronPort-SDR: RYDMMs5NiZmiBSdJjKPbnh/69/JnJglUjZ8FSGkRM9/sDUkp7MmkdvJGPMgU7pJjFCtTMl3h6q kN+LS6w4P/YA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,368,1580803200"; d="scan'208";a="452580329" Received: from lzhao24-mobl.ccr.corp.intel.com ([10.255.29.254]) by fmsmga005.fm.intel.com with ESMTP; 10 Apr 2020 19:55:42 -0700 Message-ID: Subject: Re: [PATCH 1/2] thermal: core: Move thermal_cdev_update next to updated=false From: Zhang Rui To: Daniel Lezcano Cc: linux-kernel@vger.kernel.org, amit.kucheria@verdurent.com, "open list:THERMAL" Date: Sat, 11 Apr 2020 10:55:42 +0800 In-Reply-To: <0c9796c5-95fe-0349-d128-393da9b344d6@linaro.org> References: <20200409151515.6607-1-daniel.lezcano@linaro.org> <8e4c2825d71e5bf5602b92937a49c04187c68e17.camel@intel.com> <0c9796c5-95fe-0349-d128-393da9b344d6@linaro.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2020-04-10 at 13:26 +0200, Daniel Lezcano wrote: > On 10/04/2020 12:14, Zhang Rui wrote: > > Hi, Daniel, > > > > On Thu, 2020-04-09 at 17:15 +0200, Daniel Lezcano wrote: > > > The call to the thermal_cdev_update() function is done after > > > browsing > > > the thermal instances which sets the updated flag by browsing > > > them > > > again. > > > > > > Instead of doing this, let's move the call right after setting > > > the > > > cooling device 'updated' flag as it is done in the other > > > governors. > > > > The reason we do this in two steps is that we want to avoid > > redundant > > cooling device state changes. > > > > Further more, I think it is better to move the thermal_cdev_update > > out > > of .throllte() callback, to thermal_zone_device_update(). So that > > we do > > not need to update the cooling device for each trip point. > > > > is there any specific reason we need to do thermal_cdev_update() > > for > > every potential change? > > I agree we can go further and move the cooling device update in the > thermal_zone_device_update() by letting the throttle callback let us > know an update is needed with the return value. > > Makes sense to provide more changes on top of those two patches ? Hmmm, without the update flag, we can only updating all the cooling devices blindly. And this is time consuming for some cooling devices. thanks, rui > > > > Signed-off-by: Daniel Lezcano > > > --- > > > drivers/thermal/gov_bang_bang.c | 10 +--------- > > > drivers/thermal/step_wise.c | 10 +--------- > > > 2 files changed, 2 insertions(+), 18 deletions(-) > > > > > > diff --git a/drivers/thermal/gov_bang_bang.c > > > b/drivers/thermal/gov_bang_bang.c > > > index 991a1c54296d..c292a69845bb 100644 > > > --- a/drivers/thermal/gov_bang_bang.c > > > +++ b/drivers/thermal/gov_bang_bang.c > > > @@ -64,6 +64,7 @@ static void thermal_zone_trip_update(struct > > > thermal_zone_device *tz, int trip) > > > mutex_lock(&instance->cdev->lock); > > > instance->cdev->updated = false; /* cdev needs update > > > */ > > > mutex_unlock(&instance->cdev->lock); > > > + thermal_cdev_update(instance->cdev); > > > } > > > > > > mutex_unlock(&tz->lock); > > > @@ -98,17 +99,8 @@ static void thermal_zone_trip_update(struct > > > thermal_zone_device *tz, int trip) > > > */ > > > static int bang_bang_control(struct thermal_zone_device *tz, int > > > trip) > > > { > > > - struct thermal_instance *instance; > > > - > > > thermal_zone_trip_update(tz, trip); > > > > > > - mutex_lock(&tz->lock); > > > - > > > - list_for_each_entry(instance, &tz->thermal_instances, tz_node) > > > - thermal_cdev_update(instance->cdev); > > > - > > > - mutex_unlock(&tz->lock); > > > - > > > return 0; > > > } > > > > > > diff --git a/drivers/thermal/step_wise.c > > > b/drivers/thermal/step_wise.c > > > index 2ae7198d3067..298eedac0293 100644 > > > --- a/drivers/thermal/step_wise.c > > > +++ b/drivers/thermal/step_wise.c > > > @@ -167,6 +167,7 @@ static void thermal_zone_trip_update(struct > > > thermal_zone_device *tz, int trip) > > > mutex_lock(&instance->cdev->lock); > > > instance->cdev->updated = false; /* cdev needs update > > > */ > > > mutex_unlock(&instance->cdev->lock); > > > + thermal_cdev_update(instance->cdev); > > > } > > > > > > mutex_unlock(&tz->lock); > > > @@ -185,20 +186,11 @@ static void thermal_zone_trip_update(struct > > > thermal_zone_device *tz, int trip) > > > */ > > > static int step_wise_throttle(struct thermal_zone_device *tz, > > > int > > > trip) > > > { > > > - struct thermal_instance *instance; > > > - > > > thermal_zone_trip_update(tz, trip); > > > > > > if (tz->forced_passive) > > > thermal_zone_trip_update(tz, THERMAL_TRIPS_NONE); > > > > > > - mutex_lock(&tz->lock); > > > - > > > - list_for_each_entry(instance, &tz->thermal_instances, tz_node) > > > - thermal_cdev_update(instance->cdev); > > > - > > > - mutex_unlock(&tz->lock); > > > - > > > return 0; > > > } > > > > >