From: Matt Longnecker <mlongnecker@nvidia.com>
To: Zhang Rui <rui.zhang@intel.com>,
Eduardo Valentin <edubezval@gmail.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
mlongnecker@nvidia.com
Subject: [PATCH] thermal: tell cooling devices when a trip_point changes
Date: Wed, 30 Jul 2014 16:10:40 -0700 [thread overview]
Message-ID: <53D97B70.1050305@nvidia.com> (raw)
Some hardware can react autonomously at a programmed temperature.
For example, an SoC might implement a last ditch throttle or a
hardware thermal shutdown. The driver for such a device can
register itself as a cooling_device with the thermal framework.
With this change, the thermal framework notifies such a driver
when userspace alters the relevant trip temperature so that
the driver can reprogram its hardware
Signed-off-by: Matt Longnecker <mlongnecker@nvidia.com>
---
drivers/thermal/thermal_core.c | 30 ++++++++++++++++++++++++++++++
include/linux/thermal.h | 2 ++
2 files changed, 32 insertions(+)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 71b0ec0..f25272e 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -597,6 +597,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
struct thermal_zone_device *tz = to_thermal_zone(dev);
int trip, ret;
unsigned long temperature;
+ struct thermal_instance *pos = NULL;
if (!tz->ops->set_trip_temp)
return -EPERM;
@@ -609,6 +610,20 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
ret = tz->ops->set_trip_temp(tz, trip, temperature);
+ /*
+ * Notify bound cooling devices that this trip point changed.
+ * This is useful for cooling devices which represent a behavior
+ * which trips in hardware (e.g. catastrophic shutdown)
+ */
+ list_for_each_entry(pos, &tz->thermal_instances, tz_node) {
+ if (pos->tz == tz && pos->trip == trip && pos->cdev) {
+ if (pos->cdev->ops->trip_point_changed)
+ pos->cdev->ops->trip_point_changed(pos->cdev,
+ pos->tz,
+ trip);
+ }
+ }
+
return ret ? ret : count;
}
@@ -641,6 +656,7 @@ trip_point_hyst_store(struct device *dev, struct device_attribute *attr,
struct thermal_zone_device *tz = to_thermal_zone(dev);
int trip, ret;
unsigned long temperature;
+ struct thermal_instance *pos = NULL;
if (!tz->ops->set_trip_hyst)
return -EPERM;
@@ -658,6 +674,20 @@ trip_point_hyst_store(struct device *dev, struct device_attribute *attr,
*/
ret = tz->ops->set_trip_hyst(tz, trip, temperature);
+ /*
+ * Notify bound cooling devices that this trip point changed.
+ * This is useful for cooling devices which represent a behavior
+ * which trips in hardware (e.g. catastrophic shutdown)
+ */
+ list_for_each_entry(pos, &tz->thermal_instances, tz_node) {
+ if (pos->tz == tz && pos->trip == trip && pos->cdev) {
+ if (pos->cdev->ops->trip_point_changed)
+ pos->cdev->ops->trip_point_changed(pos->cdev,
+ pos->tz,
+ trip);
+ }
+ }
+
return ret ? ret : count;
}
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index f7e11c7..7da7fc5 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -138,6 +138,8 @@ struct thermal_cooling_device_ops {
int (*get_max_state) (struct thermal_cooling_device *, unsigned long *);
int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *);
int (*set_cur_state) (struct thermal_cooling_device *, unsigned long);
+ void (*trip_point_changed) (struct thermal_cooling_device *,
+ struct thermal_zone_device *, int);
};
struct thermal_cooling_device {
--
1.7.9.5
WARNING: multiple messages have this Message-ID (diff)
From: Matt Longnecker <mlongnecker@nvidia.com>
To: Zhang Rui <rui.zhang@intel.com>,
Eduardo Valentin <edubezval@gmail.com>,
<linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<mlongnecker@nvidia.com>
Subject: [PATCH] thermal: tell cooling devices when a trip_point changes
Date: Wed, 30 Jul 2014 16:10:40 -0700 [thread overview]
Message-ID: <53D97B70.1050305@nvidia.com> (raw)
Some hardware can react autonomously at a programmed temperature.
For example, an SoC might implement a last ditch throttle or a
hardware thermal shutdown. The driver for such a device can
register itself as a cooling_device with the thermal framework.
With this change, the thermal framework notifies such a driver
when userspace alters the relevant trip temperature so that
the driver can reprogram its hardware
Signed-off-by: Matt Longnecker <mlongnecker@nvidia.com>
---
drivers/thermal/thermal_core.c | 30 ++++++++++++++++++++++++++++++
include/linux/thermal.h | 2 ++
2 files changed, 32 insertions(+)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 71b0ec0..f25272e 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -597,6 +597,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
struct thermal_zone_device *tz = to_thermal_zone(dev);
int trip, ret;
unsigned long temperature;
+ struct thermal_instance *pos = NULL;
if (!tz->ops->set_trip_temp)
return -EPERM;
@@ -609,6 +610,20 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
ret = tz->ops->set_trip_temp(tz, trip, temperature);
+ /*
+ * Notify bound cooling devices that this trip point changed.
+ * This is useful for cooling devices which represent a behavior
+ * which trips in hardware (e.g. catastrophic shutdown)
+ */
+ list_for_each_entry(pos, &tz->thermal_instances, tz_node) {
+ if (pos->tz == tz && pos->trip == trip && pos->cdev) {
+ if (pos->cdev->ops->trip_point_changed)
+ pos->cdev->ops->trip_point_changed(pos->cdev,
+ pos->tz,
+ trip);
+ }
+ }
+
return ret ? ret : count;
}
@@ -641,6 +656,7 @@ trip_point_hyst_store(struct device *dev, struct device_attribute *attr,
struct thermal_zone_device *tz = to_thermal_zone(dev);
int trip, ret;
unsigned long temperature;
+ struct thermal_instance *pos = NULL;
if (!tz->ops->set_trip_hyst)
return -EPERM;
@@ -658,6 +674,20 @@ trip_point_hyst_store(struct device *dev, struct device_attribute *attr,
*/
ret = tz->ops->set_trip_hyst(tz, trip, temperature);
+ /*
+ * Notify bound cooling devices that this trip point changed.
+ * This is useful for cooling devices which represent a behavior
+ * which trips in hardware (e.g. catastrophic shutdown)
+ */
+ list_for_each_entry(pos, &tz->thermal_instances, tz_node) {
+ if (pos->tz == tz && pos->trip == trip && pos->cdev) {
+ if (pos->cdev->ops->trip_point_changed)
+ pos->cdev->ops->trip_point_changed(pos->cdev,
+ pos->tz,
+ trip);
+ }
+ }
+
return ret ? ret : count;
}
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index f7e11c7..7da7fc5 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -138,6 +138,8 @@ struct thermal_cooling_device_ops {
int (*get_max_state) (struct thermal_cooling_device *, unsigned long *);
int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *);
int (*set_cur_state) (struct thermal_cooling_device *, unsigned long);
+ void (*trip_point_changed) (struct thermal_cooling_device *,
+ struct thermal_zone_device *, int);
};
struct thermal_cooling_device {
--
1.7.9.5
next reply other threads:[~2014-07-30 23:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-30 23:10 Matt Longnecker [this message]
2014-07-30 23:10 ` [PATCH] thermal: tell cooling devices when a trip_point changes Matt Longnecker
2014-07-31 7:59 ` Javi Merino
2014-07-31 8:30 ` Zhang Rui
2014-07-31 17:17 ` Matt Longnecker
2014-07-31 17:17 ` Matt Longnecker
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=53D97B70.1050305@nvidia.com \
--to=mlongnecker@nvidia.com \
--cc=edubezval@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.