From: Michele Di Giorgio <michele.digiorgio@arm.com>
To: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Javi Merino <javi.merino@arm.com>,
Michele Di Giorgio <michele.digiorgio@arm.com>,
Zhang Rui <rui.zhang@intel.com>,
Eduardo Valentin <edubezval@gmail.com>,
Peter Feuerer <peter@piie.net>
Subject: [PATCH] thermal: check validity get_trip_hyst function pointer in bang-bang governor
Date: Wed, 11 May 2016 10:49:07 +0100 [thread overview]
Message-ID: <1462960147-9175-1-git-send-email-michele.digiorgio@arm.com> (raw)
Bang-bang thermal governor uses trip point hysteresis to make decisions.
Hysteresis is a required property in the device tree for trip points, but it is
an optional thermal zone device operation. Hence, we need to check whether the
function pointer is valid or not.
If it is not available, we assume the hysteresis to be zero. Consequently, a
highly varying temperature will make the governor continuosly switch a cooling
device ON and OFF.
CC: Zhang Rui <rui.zhang@intel.com>
CC: Eduardo Valentin <edubezval@gmail.com>
CC: Peter Feuerer <peter@piie.net>
Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com>
---
Using trip_hyst == 0 makes the governor work sensibly but may cause oscillations
of the control signals of a cooling device. An alternative to this could be to
fail the registration of the thermal governor.
Another way would be to set the default value of the hysteresis to x% of the
trip temperature, to make the governor less sensitive to highly varying inputs.
drivers/thermal/gov_bang_bang.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c
index 39d1519..bb118a1 100644
--- a/drivers/thermal/gov_bang_bang.c
+++ b/drivers/thermal/gov_bang_bang.c
@@ -29,7 +29,13 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
struct thermal_instance *instance;
tz->ops->get_trip_temp(tz, trip, &trip_temp);
- tz->ops->get_trip_hyst(tz, trip, &trip_hyst);
+
+ if (!tz->ops->get_trip_hyst) {
+ pr_warn_once("Undefined get_trip_hyst for thermal zone %s - "
+ "running with default hysteresis zero\n", tz->type);
+ trip_hyst = 0;
+ } else
+ tz->ops->get_trip_hyst(tz, trip, &trip_hyst);
dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n",
trip, trip_temp, tz->temperature,
--
1.9.1
next reply other threads:[~2016-05-11 9:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-11 9:49 Michele Di Giorgio [this message]
2016-05-22 9:40 ` [PATCH] thermal: check validity get_trip_hyst function pointer in bang-bang governor Peter Feuerer
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=1462960147-9175-1-git-send-email-michele.digiorgio@arm.com \
--to=michele.digiorgio@arm.com \
--cc=edubezval@gmail.com \
--cc=javi.merino@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=peter@piie.net \
--cc=rui.zhang@intel.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).