Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
From: Amit Kucheria <amit.kucheria@linaro.org>
To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	swboyd@chromium.org, Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <edubezval@gmail.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>
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> (raw)
In-Reply-To: <cover.1571181041.git.amit.kucheria@linaro.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 <swboyd@chromium.org>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
---
 drivers/thermal/of-thermal.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

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);
 
-- 
2.17.1


       reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1571181041.git.amit.kucheria@linaro.org>
2019-10-15 23:13 ` Amit Kucheria [this message]
2019-10-16  4:57   ` Stephen Boyd
2019-10-16  5:22     ` Amit Kucheria
2019-10-30  6:51   ` Daniel Lezcano
2019-11-04  6:26     ` Amit Kucheria
2019-11-07 12:49       ` Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1b53ef537203e629328285b4597a09e4a586d688.1571181041.git.amit.kucheria@linaro.org \
    --to=amit.kucheria@linaro.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=edubezval@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=swboyd@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org
	public-inbox-index linux-arm-msm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git