* [patch 08/12] thermal: add sanity check for the passive attribute
@ 2009-11-17 22:27 akpm
2009-11-17 22:33 ` Matthew Garrett
0 siblings, 1 reply; 6+ messages in thread
From: akpm @ 2009-11-17 22:27 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, akpm, elendil, mjg, rui.zhang
From: Frans Pop <elendil@planet.nl>
Values below 1000 milli-celsius don't make sense and can cause the system
to go into a thermal heart attack: the actual temperature will always be
lower and thus the system will be throttled down to its lowest setting.
An additional problem is that values below 1000 will show as 0 in
/proc/acpi/thermal/TZx/trip_points:passive.
cat passive
0
echo -n 90 >passive
bash: echo: write error: Invalid argument
echo -n 90000 >passive
cat passive
90000
Addresses http://bugzilla.kernel.org/show_bug.cgi?id=13918
Signed-off-by: Frans Pop <elendil@planet.nl>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Len Brown <lenb@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
Documentation/thermal/sysfs-api.txt | 1 +
drivers/thermal/thermal_sys.c | 6 ++++++
2 files changed, 7 insertions(+)
diff -puN Documentation/thermal/sysfs-api.txt~thermal-add-sanity-check-for-the-passive-attribute Documentation/thermal/sysfs-api.txt
--- a/Documentation/thermal/sysfs-api.txt~thermal-add-sanity-check-for-the-passive-attribute
+++ a/Documentation/thermal/sysfs-api.txt
@@ -206,6 +206,7 @@ passive
passive trip point for the zone. Activation is done by polling with
an interval of 1 second.
Unit: millidegrees Celsius
+ Valid values: 0 (disabled) or greater than 1000
RW, Optional
*****************************
diff -puN drivers/thermal/thermal_sys.c~thermal-add-sanity-check-for-the-passive-attribute drivers/thermal/thermal_sys.c
--- a/drivers/thermal/thermal_sys.c~thermal-add-sanity-check-for-the-passive-attribute
+++ a/drivers/thermal/thermal_sys.c
@@ -225,6 +225,12 @@ passive_store(struct device *dev, struct
if (!sscanf(buf, "%d\n", &state))
return -EINVAL;
+ /* sanity check: values below 1000 millicelcius don't make sense
+ * and can cause the system to go into a thermal heart attack
+ */
+ if (state && state < 1000)
+ return -EINVAL;
+
if (state && !tz->forced_passive) {
mutex_lock(&thermal_list_lock);
list_for_each_entry(cdev, &thermal_cdev_list, node) {
_
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [patch 08/12] thermal: add sanity check for the passive attribute
2009-11-17 22:27 [patch 08/12] thermal: add sanity check for the passive attribute akpm
@ 2009-11-17 22:33 ` Matthew Garrett
2009-11-17 22:42 ` Frans Pop
0 siblings, 1 reply; 6+ messages in thread
From: Matthew Garrett @ 2009-11-17 22:33 UTC (permalink / raw)
To: akpm; +Cc: lenb, linux-acpi, elendil, rui.zhang
As noted before, I'm not a fan of this approach - I can't think of many
reasons why it'd be necessary to use temperatures below 1 degree C, but
this constraint isn't present anywhere else in the thermal code and,
really, there's plenty of things that people can break if they just echo
incorrect values into /sys.
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 08/12] thermal: add sanity check for the passive attribute
2009-11-17 22:33 ` Matthew Garrett
@ 2009-11-17 22:42 ` Frans Pop
2009-11-17 22:52 ` Matthew Garrett
0 siblings, 1 reply; 6+ messages in thread
From: Frans Pop @ 2009-11-17 22:42 UTC (permalink / raw)
To: Matthew Garrett; +Cc: akpm, lenb, linux-acpi, rui.zhang
On Tuesday 17 November 2009, Matthew Garrett wrote:
> As noted before, I'm not a fan of this approach - I can't think of many
> reasons why it'd be necessary to use temperatures below 1 degree C, but
> this constraint isn't present anywhere else in the thermal code and,
> really, there's plenty of things that people can break if they just echo
> incorrect values into /sys.
Personally I'd be in favor of adding more sanity checks rather than
removing them. The cost of the check is virtually zero.
Cheers,
FJP
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 08/12] thermal: add sanity check for the passive attribute
2009-11-17 22:42 ` Frans Pop
@ 2009-11-17 22:52 ` Matthew Garrett
2009-11-17 23:07 ` Frans Pop
0 siblings, 1 reply; 6+ messages in thread
From: Matthew Garrett @ 2009-11-17 22:52 UTC (permalink / raw)
To: Frans Pop; +Cc: akpm, lenb, linux-acpi, rui.zhang
On Tue, Nov 17, 2009 at 11:42:55PM +0100, Frans Pop wrote:
> On Tuesday 17 November 2009, Matthew Garrett wrote:
> > As noted before, I'm not a fan of this approach - I can't think of many
> > reasons why it'd be necessary to use temperatures below 1 degree C, but
> > this constraint isn't present anywhere else in the thermal code and,
> > really, there's plenty of things that people can break if they just echo
> > incorrect values into /sys.
>
> Personally I'd be in favor of adding more sanity checks rather than
> removing them. The cost of the check is virtually zero.
It makes something that's potentially useful to someone impossible, for
the benefit of people who can crash their system in half a dozen other
ways by writing inappropriate values into other files.
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 08/12] thermal: add sanity check for the passive attribute
2009-11-17 22:52 ` Matthew Garrett
@ 2009-11-17 23:07 ` Frans Pop
2009-11-17 23:12 ` Frans Pop
0 siblings, 1 reply; 6+ messages in thread
From: Frans Pop @ 2009-11-17 23:07 UTC (permalink / raw)
To: Matthew Garrett; +Cc: akpm, lenb, linux-acpi, rui.zhang
On Tuesday 17 November 2009, Matthew Garrett wrote:
> On Tue, Nov 17, 2009 at 11:42:55PM +0100, Frans Pop wrote:
> > On Tuesday 17 November 2009, Matthew Garrett wrote:
> > > As noted before, I'm not a fan of this approach - I can't think of
> > > many reasons why it'd be necessary to use temperatures below 1
> > > degree C, but this constraint isn't present anywhere else in the
> > > thermal code and, really, there's plenty of things that people can
> > > break if they just echo incorrect values into /sys.
> >
> > Personally I'd be in favor of adding more sanity checks rather than
> > removing them. The cost of the check is virtually zero.
>
> It makes something that's potentially useful to someone impossible, for
> the benefit of people who can crash their system in half a dozen other
> ways by writing inappropriate values into other files.
If you can give me one valid use case for someone running a system with a
thermal zone check below 1C I'll agree with you.
Cheers,
FJP
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 08/12] thermal: add sanity check for the passive attribute
2009-11-17 23:07 ` Frans Pop
@ 2009-11-17 23:12 ` Frans Pop
0 siblings, 0 replies; 6+ messages in thread
From: Frans Pop @ 2009-11-17 23:12 UTC (permalink / raw)
To: Matthew Garrett; +Cc: akpm, lenb, linux-acpi, rui.zhang
On Wednesday 18 November 2009, Frans Pop wrote:
> On Tuesday 17 November 2009, Matthew Garrett wrote:
> > On Tue, Nov 17, 2009 at 11:42:55PM +0100, Frans Pop wrote:
> > > On Tuesday 17 November 2009, Matthew Garrett wrote:
> > > > As noted before, I'm not a fan of this approach - I can't think of
> > > > many reasons why it'd be necessary to use temperatures below 1
> > > > degree C, but this constraint isn't present anywhere else in the
> > > > thermal code and, really, there's plenty of things that people can
> > > > break if they just echo incorrect values into /sys.
> > >
> > > Personally I'd be in favor of adding more sanity checks rather than
> > > removing them. The cost of the check is virtually zero.
> >
> > It makes something that's potentially useful to someone impossible,
> > for the benefit of people who can crash their system in half a dozen
> > other ways by writing inappropriate values into other files.
>
> If you can give me one valid use case for someone running a system with
> a thermal zone check below 1C I'll agree with you.
And to make it really realistic, it should be a use case which needs a
value between 0 and 1 C and where a value of 1 doesn't work.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-11-17 23:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-17 22:27 [patch 08/12] thermal: add sanity check for the passive attribute akpm
2009-11-17 22:33 ` Matthew Garrett
2009-11-17 22:42 ` Frans Pop
2009-11-17 22:52 ` Matthew Garrett
2009-11-17 23:07 ` Frans Pop
2009-11-17 23:12 ` Frans Pop
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox