From patchwork Tue Oct 15 23:13:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 176401 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp6565646ill; Tue, 15 Oct 2019 16:13:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGve8Wzt5QDPbaKxD2U2gkM3/1X66Y7Ng4v2CCezARjIeuZNeKOBuWezPaYyO422kMP/7n X-Received: by 2002:a17:906:55d1:: with SMTP id z17mr36922290ejp.300.1571181203823; Tue, 15 Oct 2019 16:13:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571181203; cv=none; d=google.com; s=arc-20160816; b=pnc22Vno0ezFr87hLra3udyGktb0BV/nfWwk46aPpkhaBhzy4T6hzEURtawlz8PyBe AyVrRHpPTZ89uLkrvVVNPlqMeb0XANEm8Y1HJO86lkPjK3YVvV/UovxqYqohos/L0Iem qcX1JXZLMRh5rrm0XpaTSg4M5Zbohya7+Nrij4y9UCBlv6Bp2fL+UNALGP0Cbm5Tgt4w 7XzPJhCMpCh6kZfGpmX7PkLEV74TemJRV3o16mUIGUrYmDKwhtf/YbAMhBdef3u/9O41 M/fhpcRQGrOYLQ0bOYyjM9De0SDpbP6ejOZnqVA6RrgLXeqfMJhUgPJi6a1EzxDOT/fF 06PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=AkK1IUD9itHRJl3qrEDn5W76PGecDNNhAPPx6TQzzz8=; b=KudU6A1NeKDiQ22BXnXBGT+EH/vG58ayagA1irrtJtxGSpNhF6SvsoZOyyPJUhfnDE ngrHo/hlrzYxxXipOuFH/WDlLrr/FsTRHMozveuzRQpBt9svYXfYHJEHp07YGpCkMyYC maQHZA6dcHGuwwSk9tjjqESmde8odhd8UKZ5NMIHACuGMEWWimsm75felWCIW+C0yDqQ 4BiK1O1ZI3yqBG0sQ7UfACdoHVFXDCAR8eLNtDskdfHveQIVKg3Bl6hzy/Zf4XFo3qL4 uRu0lbfEW3KxkHuhw+bAZaeOAiT8hzZZF0roecWO2VCM6GfNguJtHrUeRvN+rOFPh5op 27RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AvW3Elfq; 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 w12si14597966ejb.303.2019.10.15.16.13.23; Tue, 15 Oct 2019 16:13:23 -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=AvW3Elfq; 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 S1728323AbfJOXNW (ORCPT + 23 others); Tue, 15 Oct 2019 19:13:22 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42119 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725970AbfJOXNW (ORCPT ); Tue, 15 Oct 2019 19:13:22 -0400 Received: by mail-pf1-f194.google.com with SMTP id q12so13435453pff.9 for ; Tue, 15 Oct 2019 16:13:21 -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:in-reply-to:references; bh=AkK1IUD9itHRJl3qrEDn5W76PGecDNNhAPPx6TQzzz8=; b=AvW3ElfqMmv+CbwmItArkaa8Rnz/cRp/ZjdTku9q8Ee33KpjYuWQFNgI+dHLaI+BKQ g8ZAmo2OSohykJP7k51g8OEWglMNLi3t7Xtt4yO0UjuRrXaJI/rhAUrYQBxf1xNCXfdA MzIDfjz0+GUt/sETI1G27w2IX9E6rDBVIuRXfTd7xFYwcorAP0ndQHDKk927gOOnTc8E vvGhjl5G0Vhfr1Ld0z9UPChshknavZ7V9hN3cDWJCIBnmyRDyhrXuj91SlVJkoZx5WKi E4ww6h3XOzqRdgesiRhI5pXXwaeWGMy/P2glv8rSQVIAO6Yh5XlPnrnskfOTwGp7AWIn W9FQ== 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:in-reply-to :references; bh=AkK1IUD9itHRJl3qrEDn5W76PGecDNNhAPPx6TQzzz8=; b=V9PijaRu6SgLiS5vLasgnuOuoVGvWKi8FdfejTbtLlPihpyKbAFiZNczgH44HXgWmV ULUdbJCQO23LvDvHmzIpe2i11QDOvdnF1RuAnnzTzwICL3dB1Q3sfLoJhGxwLMfFyMdB gBK/sZNmK41jdjp14BRJScVqNUJg+SnFm0oNAaEruGmS+lpEfCvPxhP1cUQWs3aikowi SYtgR/XYpeBKBqCRCK1Qnb40GhPSAVjmsQ5Re4oWEoRecNwiKcQo46WaqeY2ge5ztqSp qlhPJXivsEUrAGiYbk02c/kHqXcKRmUoN9ubeHywLDZTGZGA2rREGMK26SM8Ywks7klC VNJQ== X-Gm-Message-State: APjAAAUjNTb+Kx96kCyrivPrNTgkWCwrhJ+SVYDMoYEHWxVq3O5MYWUE FzMTuHnHx94IYg4WWkdUplRicGPq1dtBjw== X-Received: by 2002:a62:6d81:: with SMTP id i123mr20789870pfc.57.1571181200905; Tue, 15 Oct 2019 16:13:20 -0700 (PDT) Received: from localhost ([49.248.193.232]) by smtp.gmail.com with ESMTPSA id m102sm352863pje.5.2019.10.15.16.13.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Oct 2019 16:13:20 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, swboyd@chromium.org, Zhang Rui , Eduardo Valentin , Daniel Lezcano Cc: linux-pm@vger.kernel.org Subject: [PATCH] of-thermal: Disable polling when interrupt property is found in DT Date: Wed, 16 Oct 2019 04:43:16 +0530 Message-Id: <1b53ef537203e629328285b4597a09e4a586d688.1571181041.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, in order to enable interrupt-only mode, one must set polling-delay-passive and polling-delay properties in the DT to 0, otherwise the thermal framework will continue to setup a periodic timers to monitor the thermal zones. Change the behaviour, so that on DT-based systems, we no longer have to set the properties to zero if we find an 'interrupt' property in the sensor. Following data shows the number of times thermal_zone_device_set_polling() is invoked with and without this patch. So the patch achieves the same behaviour as setting the delay properties to 0. Current behaviour (without setting delay properties to 0): FUNC COUNT thermal_zone_device_update 302 thermal_zone_device_set_pollin 7911 Current behaviour (with delay properties set to 0): FUNC COUNT thermal_zone_device_update 3 thermal_zone_device_set_pollin 6 With this patch (without setting delay properties to 0): FUNC COUNT thermal_zone_device_update 3 thermal_zone_device_set_pollin 6 Suggested-by: Stephen Boyd Signed-off-by: Amit Kucheria --- drivers/thermal/of-thermal.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index dc5093be553e..79ad587462b1 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -412,7 +412,8 @@ static struct thermal_zone_device_ops of_thermal_ops = { static struct thermal_zone_device * thermal_zone_of_add_sensor(struct device_node *zone, struct device_node *sensor, void *data, - const struct thermal_zone_of_device_ops *ops) + const struct thermal_zone_of_device_ops *ops, + bool force_interrupts) { struct thermal_zone_device *tzd; struct __thermal_zone *tz; @@ -433,6 +434,11 @@ thermal_zone_of_add_sensor(struct device_node *zone, tzd->ops->get_temp = of_thermal_get_temp; tzd->ops->get_trend = of_thermal_get_trend; + if (force_interrupts) { + tz->passive_delay = 0; + tz->polling_delay = 0; + } + /* * The thermal zone core will calculate the window if they have set the * optional set_trips pointer. @@ -486,6 +492,7 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, { struct device_node *np, *child, *sensor_np; struct thermal_zone_device *tzd = ERR_PTR(-ENODEV); + bool force_interrupts = false; np = of_find_node_by_name(NULL, "thermal-zones"); if (!np) @@ -498,6 +505,9 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, sensor_np = of_node_get(dev->of_node); + if (of_find_property(sensor_np, "interrupts", NULL)) + force_interrupts = true; + for_each_available_child_of_node(np, child) { struct of_phandle_args sensor_specs; int ret, id; @@ -520,7 +530,8 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, if (sensor_specs.np == sensor_np && id == sensor_id) { tzd = thermal_zone_of_add_sensor(child, sensor_np, - data, ops); + data, ops, + force_interrupts); if (!IS_ERR(tzd)) tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED);