From patchwork Tue Sep 26 23:54:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 114299 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4410294qgf; Tue, 26 Sep 2017 16:55:58 -0700 (PDT) X-Received: by 10.99.126.84 with SMTP id o20mr12534944pgn.275.1506470158504; Tue, 26 Sep 2017 16:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506470158; cv=none; d=google.com; s=arc-20160816; b=BLe93Qq0wAt5p5Fob2LeqOSQFyxknzeK5rK0U2EWixoAaQnwPerBjlBwyt8kb3j2OF ohKTYVQnNmOIIAddvv+boaXOovpkSqMDSPzpPWbpjoGqSg/hvDvmjLIwaSuo92kWy1WA I6DVJ12fpMxLQKwNU07X8hE72bRHOvOL6y7IiuIKPhthJskkMETaWd/1N3LsVizWUTKT eJ2WggQZjC7Yt66gf6bgENOhehoUx0eXtrVEA4Hs9NllRC+ALlJmNy5eCh2tkmIqfP70 GwrppdEvWBHTapJ+uGaJ/77sRhyFk5lPnX+A+Bzas4GH+4Apq72wXhoqynGedW81mFJR zROw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=MdvIts5VtR4P5G3aV3SUbjUFmW+C3CcM1TALjr3RZQo=; b=QvYcHF7gGUpSsSbpiPaS0rHTJQvszqEHaKxGvysHgjre3ZTsoZmTdG1lhrK7aJ1uie KxCNFLhS1/FYbxZgcoYRdZdlyWkNAx65WH9RhrzK9Nfv33xml3rfZEuNxfsi4S9RfRcn FZFyT1dWxszriojQ/fNEnRgjOuMq1EzrxTu9yv3zH50bJL7WYKCB9UwyhCalcl1VU2a6 aoUG4vELENj1UOD2O/ZJ9zbEpleD0qlxctpiVTVVJjZ9iR63XRPUQzoM9mlxjA3VMwhB QW1SltfpT2As7zwKbphUJokBktY5k+loiem3tzCE8uZe5Po1jr8/ZpTz2iZuPg+2BXwq Zohw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UKssK07V; 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 p33si6531695pld.231.2017.09.26.16.55.58; Tue, 26 Sep 2017 16:55:58 -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; dkim=pass header.i=@linaro.org header.s=google header.b=UKssK07V; 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 S1032769AbdIZXz4 (ORCPT + 26 others); Tue, 26 Sep 2017 19:55:56 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:50326 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966844AbdIZXzy (ORCPT ); Tue, 26 Sep 2017 19:55:54 -0400 Received: by mail-wm0-f42.google.com with SMTP id b195so12683996wmb.5 for ; Tue, 26 Sep 2017 16:55:54 -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; bh=MdvIts5VtR4P5G3aV3SUbjUFmW+C3CcM1TALjr3RZQo=; b=UKssK07V6mmadFKHxTahy9qg/Djpr+ZBxFO0ruIovKC7Xf37V+DV9eFck1MyBH+fd/ TwzIGZ3Mlphdxh6QC0/9Hby4xpf5fcoRP/pgCvCRhewdY7pcIct0DSVcsbKi6I1wWw+0 HICaZ1OOPQF6+kn3sP5PpTmWbappq5GSi5+vM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=MdvIts5VtR4P5G3aV3SUbjUFmW+C3CcM1TALjr3RZQo=; b=Lq16pRDC796ydMiARddPcJevbhZT4MOzToC//4UfJHtUPfnVOtx6MHCr6aYtVEI0QK hhrrNYDEwLN74J9xqTMNGKnQp7FoJgEwl6h2hwAnuZu7MTby7PMWD2LMV/d6JCUmBErn +ZSdCh5goNlF5fSq+N8jfqZJ/WFhbfZCG+zW1bGFBBzSodUowaMhw0/UQHY9mFnzZ6q9 pO6zo0CjEubipv/rFEnSbon2nokxE5gV5kphG8DSskuhHh9ai7g8/fB83dsdPB+jtWWn 8453yCDCHSWws7swtPewWLEzyYFXXCEtIZAeCrs7dtnn5R7QEY8sXEezDXAHx7o7LgaQ npJg== X-Gm-Message-State: AHPjjUjZ2PlJm+ztVSlpSFUxf60hRn1jOgF9gdPwPaIj7ZoyuiaGYlg0 dA9ss5JM17YsoqZkICYsH0hCMg== X-Google-Smtp-Source: AOwi7QA4gIzB8RQd6sfqTgBgmUZgHw9cGPGtlD7aGyg1rEYJEX/QvrGQJVRaCiH2ujLJ1dfhU2eOlA== X-Received: by 10.28.58.2 with SMTP id h2mr16200wma.129.1506470153528; Tue, 26 Sep 2017 16:55:53 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:901b:4425:ce24:a9c0]) by smtp.gmail.com with ESMTPSA id f17sm2064103wmf.47.2017.09.26.16.55.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Sep 2017 16:55:52 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: leo.yan@linaro.org, Zhang Rui , linux-pm@vger.kernel.org (open list:THERMAL), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] thermal/drivers/hisi: Switch to interrupt mode Date: Wed, 27 Sep 2017 01:54:09 +0200 Message-Id: <1506470049-12597-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ooling 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 the temperature and enables it when passing the threshold. It resuls the sensor thermal sensor driver will have no activity most of the time. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) -- 2.7.4 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; }