lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1462960147-9175-1-git-send-email-michele.digiorgio@arm.com>
Date:	Wed, 11 May 2016 10:49:07 +0100
From:	Michele Di Giorgio <michele.digiorgio@....com>
To:	linux-pm@...r.kernel.org
Cc:	linux-kernel@...r.kernel.org, Javi Merino <javi.merino@....com>,
	Michele Di Giorgio <michele.digiorgio@....com>,
	Zhang Rui <rui.zhang@...el.com>,
	Eduardo Valentin <edubezval@...il.com>,
	Peter Feuerer <peter@...e.net>
Subject: [PATCH] thermal: check validity get_trip_hyst function pointer in bang-bang governor

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@...el.com>
CC: Eduardo Valentin <edubezval@...il.com>
CC: Peter Feuerer <peter@...e.net>
Signed-off-by: Michele Di Giorgio <michele.digiorgio@....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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ