Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751773AbdI1G6A (ORCPT ); Thu, 28 Sep 2017 02:58:00 -0400 Received: from mail-pg0-f47.google.com ([74.125.83.47]:45556 "EHLO mail-pg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751091AbdI1G56 (ORCPT ); Thu, 28 Sep 2017 02:57:58 -0400 X-Google-Smtp-Source: AOwi7QAdZLrT3Qa7c9sJKV2R5cd/trcCkBokd6rJdTMAG4P1prJMaSJcPbChQ9L6hUfzHzcLT0oR5A== Date: Thu, 28 Sep 2017 14:57:52 +0800 From: Leo Yan To: Daniel Lezcano Cc: rui.zhang@intel.com, edubezval@gmail.com, jean.wangtao@linaro.org, Keerthy , "open list:THERMAL" , open list Subject: Re: [PATCH V2] thermal/drivers/hisi: Switch to interrupt mode Message-ID: <20170928065752.GA31697@leoy-linaro> References: <1bfd974e-3dc1-e99b-d0dd-50102cee762d@ti.com> <1506575625-20388-1-git-send-email-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1506575625-20388-1-git-send-email-daniel.lezcano@linaro.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3230 Lines: 95 Hi Daniel, On Thu, Sep 28, 2017 at 07:13:44AM +0200, Daniel Lezcano wrote: > At this moment, we have both the interrupt setup and the polling enabled. The > interrupt does nothing more than forcing an update while the temperature is > polled every second. > > We can do much better than that, threshold is set to 65C in the DT and the > passive cooling device enters in the dance when 75C is reached. We need to > sample the temperature at 65C in order to let the IPA gather enough values for > the PID computation. If the SoC is running at a temperature below 65C, we will > be constantly polling for nothing. > > This patch disables the sensor when the temperature is below 65C and enables it > when passing the threshold. It results the thermal sensor driver will have no > activity most of the time. > > Cc: Keerthy > Cc: Leo Yang s/Yang/Yan :) Have tested this patch on Hikey at my side: Reviewed-by: Leo Yan Tested-by: Leo Yan > Signed-off-by: Daniel Lezcano > --- > drivers/thermal/hisi_thermal.c | 24 ++++++++++++++---------- > 1 file changed, 14 insertions(+), 10 deletions(-) > > diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c > index 39f4627..74ea70d 100644 > --- a/drivers/thermal/hisi_thermal.c > +++ b/drivers/thermal/hisi_thermal.c > @@ -218,6 +218,15 @@ static int hisi_thermal_get_temp(void *__data, int *temp) > return 0; > } > > +static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor, > + bool on) > +{ > + struct thermal_zone_device *tzd = sensor->tzd; > + > + tzd->ops->set_mode(tzd, > + on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED); > +} > + > static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { > .get_temp = hisi_thermal_get_temp, > }; > @@ -236,12 +245,16 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) > dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n", > temp, sensor->thres_temp); > > + hisi_thermal_toggle_sensor(&data->sensor, true); > + > thermal_zone_device_update(data->sensor.tzd, > THERMAL_EVENT_UNSPECIFIED); > > } else if (temp < sensor->thres_temp) { > dev_crit(&data->pdev->dev, "THERMAL ALARM stopped: %d < %d\n", > temp, sensor->thres_temp); > + > + hisi_thermal_toggle_sensor(&data->sensor, false); > } > > return IRQ_HANDLED; > @@ -286,15 +299,6 @@ static const struct of_device_id of_hisi_thermal_match[] = { > }; > MODULE_DEVICE_TABLE(of, of_hisi_thermal_match); > > -static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor, > - bool on) > -{ > - struct thermal_zone_device *tzd = sensor->tzd; > - > - tzd->ops->set_mode(tzd, > - on ? THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED); > -} > - > static int hisi_thermal_setup(struct hisi_thermal_data *data) > { > struct hisi_thermal_sensor *sensor; > @@ -393,7 +397,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) > return ret; > } > > - hisi_thermal_toggle_sensor(&data->sensor, true); > + hisi_thermal_toggle_sensor(&data->sensor, false); > > return 0; > } > -- > 2.7.4 >