thermal: sysfs: Add a new sysfs node emul_temp
Subsystems (3)
PATCH 1/2 thermal: sysfs: Add a new sysfs node emul_temp
This patch adds support to set the emulated temperature method in thermal zone (sensor). After setting this feature thermal zone must report this temperature and not the actual temperature. The actual implementation of this emulated temperature is based on sensor capability or platform specific. This is useful in debugging different temperature threshold and its associated cooling action. Writing 0 on this node should disable emulation.
--- Documentation/thermal/sysfs-api.txt | 14 ++++++++++++++ drivers/thermal/thermal_sys.c | 26 ++++++++++++++++++++++++++ include/linux/thermal.h | 1 + 3 files changed, 41 insertions(+), 0 deletions(-)
Documentation/thermal/sysfs-api.txt +14 -0
@@ -55,6 +55,8 @@ temperature) and throttle appropriate devices. .get_trip_type: get the type of certain trip point. .get_trip_temp: get the temperature above which the certain trip point will be fired. + .set_emul_temp: set the emulation temperature which helps in debugging + different threshold temperature points. 1.1.2 void thermal_zone_device_unregister(struct thermal_zone_device *tz)
@@ -153,6 +155,7 @@ Thermal zone device sys I/F, created once it's registered: |---trip_point_[0-*]_temp: Trip point temperature |---trip_point_[0-*]_type: Trip point type |---trip_point_[0-*]_hyst: Hysteresis value for this trip point + |---emul_temp: Emulated temperature set node Thermal cooling device sys I/F, created once it's registered: /sys/class/thermal/cooling_device[0-*]:
@@ -252,6 +255,17 @@ passive Valid values: 0 (disabled) or greater than 1000 RW, Optional +emul_temp + Interface to set the emulated temperature method in thermal zone + (sensor). After setting this feature thermal zone must report + this temperature and not the actual temperature. The actual + implementation of this emulated temperature is platform specific. + This is useful in debugging different temperature threshold and its + associated cooling action. Writing 0 on this node should disable + emulation. + Unit: millidegree Celsius + WO, Optional + ***************************** * Cooling device attributes * *****************************
drivers/thermal/thermal_sys.c +26 -0
@@ -700,11 +700,31 @@ policy_show(struct device *dev, struct device_attribute *devattr, char *buf)return sprintf (buf,"%s\n" , tz->governor->name); } +static ssize_t +emul_temp_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct thermal_zone_device *tz =to_thermal_zone (dev); +int ret; +unsigned long temperature; + +if (!tz->ops->set_emul_temp) +return -EPERM ; + +if (kstrtoul (buf,10 , &temperature)) +return -EINVAL ; + + ret = tz->ops->set_emul_temp (tz, temperature); + +return ret ? ret : count; +} + static DEVICE_ATTR(type, 0444, type_show, NULL); static DEVICE_ATTR(temp, 0444, temp_show, NULL); static DEVICE_ATTR(mode, 0644, mode_show, mode_store); static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store); static DEVICE_ATTR(policy, S_IRUGO | S_IWUSR, policy_show, policy_store); +static DEVICE_ATTR(emul_temp, S_IWUSR, NULL, emul_temp_store);/* sys I/F for cooling device */ #define to_cooling_device (_dev) \
@@ -1592,6 +1612,12 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, goto unregister; } +if (ops->set_emul_temp) { + result =device_create_file (&tz->device, &dev_attr_emul_temp); +if (result) + goto unregister; + } +/* Create policy attribute */ result =device_create_file (&tz->device, &dev_attr_policy);if (result)
include/linux/thermal.h +1 -0
@@ -123,6 +123,7 @@ struct thermal_zone_device_ops {int (*set_trip_hyst) (struct thermal_zone_device *,int ,unsigned long );int (*get_crit_temp) (struct thermal_zone_device *,unsigned long *); +int (*set_emul_temp) (struct thermal_zone_device *,unsigned long );int (*get_trend) (struct thermal_zone_device *,int ,enum thermal_trend *); int (*notify) (struct thermal_zone_device *, int,
Signature · 1 line
1.7.5.4
PATCH 2/2 thermal: exynos: Use the framework for temperature emulation support
This removes the driver specific sysfs support of the temperature emulation and uses the newly added core thermal framework for thermal emulation. A platform specific handler is added to support this.
--- Documentation/thermal/exynos_thermal_emulation | 6 +- drivers/thermal/exynos_thermal.c | 154 ++++++++++-------------- 2 files changed, 64 insertions(+), 96 deletions(-)
Documentation/thermal/exynos_thermal_emulation +3 -3
@@ -14,10 +14,10 @@ manually with software code and TMU will read current temperature from user valu sensor's value. Enabling CONFIG_EXYNOS_THERMAL_EMUL option will make this support in available. -When it's enabled, sysfs node will be created under -/sys/bus/platform/devices/'exynos device name'/ with name of 'emulation'. +When it's enabled, sysfs node will be created as +/sys/devices/virtual/thermal/thermal_zone'zone id'/emul_temp. -The sysfs node, 'emulation', will contain value 0 for the initial state. When you input any +The sysfs node, 'emul_node', will contain value 0 for the initial state. When you input any temperature you want to update to sysfs node, it automatically enable emulation mode and current temperature will be changed into it. (Exynos also supports user changable delay time which would be used to delay of
drivers/thermal/exynos_thermal.c +61 -93
202 lines not on this page · raw message
Signature · 1 line
1.7.5.4
Zhang Rui
reviewerHi, Amit,
Quoted 7 lines · Amit Daniel Kachhap
This patch adds support to set the emulated temperature method in thermal zone (sensor). After setting this feature thermal zone must report this temperature and not the actual temperature. The actual implementation of this emulated temperature is based on sensor capability or platform specific. This is useful in debugging different temperature threshold and its associated cooling action. Writing 0 on this node should disable emulation.
Question:
will this bring hardware issue? Say, critical temperature reached while in emulation mode?
As this is for debug purpose, I'd prefer to have a seperate Kconfig option for this feature.
Quoted 29 lines
Signed-off-by Amit Daniel Kachhap <[email protected]>--- Documentation/thermal/sysfs-api.txt | 14 ++++++++++++++ drivers/thermal/thermal_sys.c | 26 ++++++++++++++++++++++++++ include/linux/thermal.h | 1 + 3 files changed, 41 insertions(+), 0 deletions(-)Documentation/thermal/sysfs-api.txt +3
-0@@ -55,6 +55,8 @@ temperature) and throttle appropriate devices. .get_trip_type: get the type of certain trip point. .get_trip_temp: get the temperature above which the certain trip point will be fired. + .set_emul_temp: set the emulation temperature which helps in debugging + different threshold temperature points. 1.1.2 void thermal_zone_device_unregister(struct thermal_zone_device *tz)@@ -153,6 +155,7 @@ Thermal zone device sys I/F, created once it's registered: |---trip_point_[0-*]_temp: Trip point temperature |---trip_point_[0-*]_type: Trip point type |---trip_point_[0-*]_hyst: Hysteresis value for this trip point + |---emul_temp: Emulated temperature set node Thermal cooling device sys I/F, created once it's registered: /sys/class/thermal/cooling_device[0-*]:
Documentation/thermal/sysfs-api.txt passive · line 262
Quoted 8 lines
Documentation/thermal/sysfs-api.txt +5
-0@@ -252,6 +255,17 @@ passive Valid values: 0 (disabled) or greater than 1000 RW, Optional +emul_temp + Interface to set the emulated temperature method in thermal zone + (sensor). After setting this feature thermal zone must report + this temperature and not the actual temperature. The actual + implementation of this emulated temperature is platform specific.
can we have a pure software temperature emulation method? say, the generic thermal layer caches the emulated temperature value, and hook it in update_temperature()?
This is also useful for testing in polling mode, and it does not require platform specific callback support. I mean thermal_ops->set_emul_temp is optional, but thermal emulation is always available for all platforms.
thanks,
rui
Quoted 70 lines
Documentation/thermal/sysfs-api.txt +6
-0+ This is useful in debugging different temperature threshold and its + associated cooling action. Writing 0 on this node should disable + emulation. + Unit: millidegree Celsius + WO, Optional + ***************************** * Cooling device attributes * *****************************drivers/thermal/thermal_sys.c +26
-0@@ -700,11 +700,31 @@ policy_show(struct device *dev, struct device_attribute *devattr, char *buf)return sprintf (buf,"%s\n" , tz->governor->name); } +static ssize_t +emul_temp_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct thermal_zone_device *tz =to_thermal_zone (dev); +int ret; +unsigned long temperature; + +if (!tz->ops->set_emul_temp) +return -EPERM ; + +if (kstrtoul (buf,10 , &temperature)) +return -EINVAL ; + + ret = tz->ops->set_emul_temp (tz, temperature); + +return ret ? ret : count; +} + static DEVICE_ATTR(type, 0444, type_show, NULL); static DEVICE_ATTR(temp, 0444, temp_show, NULL); static DEVICE_ATTR(mode, 0644, mode_show, mode_store); static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store); static DEVICE_ATTR(policy, S_IRUGO | S_IWUSR, policy_show, policy_store); +static DEVICE_ATTR(emul_temp, S_IWUSR, NULL, emul_temp_store);/* sys I/F for cooling device */ #define to_cooling_device (_dev) \@@ -1592,6 +1612,12 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, goto unregister; } +if (ops->set_emul_temp) { + result =device_create_file (&tz->device, &dev_attr_emul_temp); +if (result) + goto unregister; + } +/* Create policy attribute */ result =device_create_file (&tz->device, &dev_attr_policy);if (result)include/linux/thermal.h +1
-0@@ -123,6 +123,7 @@ struct thermal_zone_device_ops {int (*set_trip_hyst) (struct thermal_zone_device *,int ,unsigned long );int (*get_crit_temp) (struct thermal_zone_device *,unsigned long *); +int (*set_emul_temp) (struct thermal_zone_device *,unsigned long );int (*get_trend) (struct thermal_zone_device *,int ,enum thermal_trend *); int (*notify) (struct thermal_zone_device *, int,
Hi Rui,
Thanks for the review comments,
Quoted 11 lines · Zhang Rui
Hi, Amit,
Quoted 7 lines · Amit Daniel Kachhap
This patch adds support to set the emulated temperature method in thermal zone (sensor). After setting this feature thermal zone must report this temperature and not the actual temperature. The actual implementation of this emulated temperature is based on sensor capability or platform specific. This is useful in debugging different temperature threshold and its associated cooling action. Writing 0 on this node should disable emulation.
Quoted 3 lines
Question:
will this bring hardware issue? Say, critical temperature reached while in emulation mode?
No emulation does cause any h/w issue.
Quoted 3 lines
As this is for debug purpose, I'd prefer to have a seperate
Kconfigoption for this feature.
Yes agreed. Will re-submit with kconfig option.
Quoted 33 lines
Quoted 33 lines
Signed-off-by Amit Daniel Kachhap <[email protected]>--- Documentation/thermal/sysfs-api.txt | 14 ++++++++++++++ drivers/thermal/thermal_sys.c | 26 ++++++++++++++++++++++++++ include/linux/thermal.h | 1 + 3 files changed, 41 insertions(+), 0 deletions(-)Documentation/thermal/sysfs-api.txt +3
-0@@ -55,6 +55,8 @@ temperature) and throttle appropriate devices. .get_trip_type: get the type of certain trip point. .get_trip_temp: get the temperature above which the certain trip point will be fired. + .set_emul_temp: set the emulation temperature which helps in debugging + different threshold temperature points. 1.1.2 void thermal_zone_device_unregister(struct thermal_zone_device *tz)@@ -153,6 +155,7 @@ Thermal zone device sys I/F, created once it's registered: |---trip_point_[0-*]_temp: Trip point temperature |---trip_point_[0-*]_type: Trip point type |---trip_point_[0-*]_hyst: Hysteresis value for this trip point + |---emul_temp: Emulated temperature set node Thermal cooling device sys I/F, created once it's registered: /sys/class/thermal/cooling_device[0-*]:@@ -252,6 +255,17 @@ passive Valid values: 0 (disabled) or greater than 1000 RW, Optional
Quoted 12 lines
Documentation/thermal/sysfs-api.txt passive · line 262
Quoted 5 lines
Documentation/thermal/sysfs-api.txt +5
-0+emul_temp + Interface to set the emulated temperature method in thermal zone + (sensor). After setting this feature thermal zone must report + this temperature and not the actual temperature. The actual + implementation of this emulated temperature is platform specific.can we have a pure software temperature emulation method? say, the generic thermal layer caches the emulated temperature value, and hook it in
update_temperature()?
This is also useful for testing in polling mode, and it does not require platform specific callback support. I meanthermal_ops->set_emul_tempis optional, but thermal emulation is always available for all platforms.
Yes It makes sense and we can have pure software emulation and use the cached temperature when no platform call is registered. In my case I needed this in h/w so to have the same sensor trigger interrupts behaviour.
So the code flow can be like this,
#ifdef CONFIG_THERMAL_EMULATION
if (thermal_ops->set_emul_temp)
then pass emul_temp to platform and use the normal platform thermal_ops->get_temp
else
Store it locally and use emul_temp instead of calling platform thermal_ops->get_temp
#endif
I will re-submit with this change.
Thanks,
Amit
Quoted 80 lines
thanks,
ruiQuoted 63 lines
Documentation/thermal/sysfs-api.txt +6
-0+ This is useful in debugging different temperature threshold and its + associated cooling action. Writing 0 on this node should disable + emulation. + Unit: millidegree Celsius + WO, Optional + ***************************** * Cooling device attributes * *****************************drivers/thermal/thermal_sys.c +26
-0@@ -700,11 +700,31 @@ policy_show(struct device *dev, struct device_attribute *devattr, char *buf)return sprintf (buf,"%s\n" , tz->governor->name); } +static ssize_t +emul_temp_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct thermal_zone_device *tz =to_thermal_zone (dev); +int ret; +unsigned long temperature; + +if (!tz->ops->set_emul_temp) +return -EPERM ; + +if (kstrtoul (buf,10 , &temperature)) +return -EINVAL ; + + ret = tz->ops->set_emul_temp (tz, temperature); + +return ret ? ret : count; +} + static DEVICE_ATTR(type, 0444, type_show, NULL); static DEVICE_ATTR(temp, 0444, temp_show, NULL); static DEVICE_ATTR(mode, 0644, mode_show, mode_store); static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store); static DEVICE_ATTR(policy, S_IRUGO | S_IWUSR, policy_show, policy_store); +static DEVICE_ATTR(emul_temp, S_IWUSR, NULL, emul_temp_store);/* sys I/F for cooling device */ #define to_cooling_device (_dev) \@@ -1592,6 +1612,12 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, goto unregister; } +if (ops->set_emul_temp) { + result =device_create_file (&tz->device, &dev_attr_emul_temp); +if (result) + goto unregister; + } +/* Create policy attribute */ result =device_create_file (&tz->device, &dev_attr_policy);if (result)include/linux/thermal.h +0
-0include/linux/thermal.h struct thermal_zone_device_ops { · line 129
Quoted 7 lines
include/linux/thermal.h +1
-0@@ -123,6 +123,7 @@ struct thermal_zone_device_ops {int (*set_trip_hyst) (struct thermal_zone_device *,int ,unsigned long );int (*get_crit_temp) (struct thermal_zone_device *,unsigned long *); +int (*set_emul_temp) (struct thermal_zone_device *,unsigned long );int (*get_trend) (struct thermal_zone_device *,int ,enum thermal_trend *); int (*notify) (struct thermal_zone_device *, int,--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Kukjin Kim
Acked-byQuoted 16 lines · amit kachhap
Hi Rui,
Thanks for the review comments,
Quoted 11 lines · Zhang Rui
Hi, Amit,
Quoted 7 lines · Amit Daniel Kachhap
This patch adds support to set the emulated temperature method in thermal zone (sensor). After setting this feature thermal zone must report this temperature and not the actual temperature. The actual implementation of this emulated temperature is based on sensor capability or platform specific. This is useful in debugging different temperature threshold and its associated cooling action. Writing 0 on this node should disable emulation.
Quoted 10 lines
Quoted 3 lines
Question:
will this bring hardware issue? Say, critical temperature reached while in emulation mode?No emulation does cause any h/w issue.
Quoted 3 lines
As this is for debug purpose, I'd prefer to have a seperate
Kconfigoption for this feature.Yes agreed. Will re-submit with kconfig option.
Quoted 2 lines
Quoted 2 lines
Signed-off-by Amit Daniel Kachhap <[email protected]>
Hi Zhang,
Once Amit addresses comments from you, I think, this looks good to Exynos SoCs. And this is _really_ needed.
Feel free to add my ack on this 1st and 2nd patches:
Thanks.
- Kukjin
Zhang Rui
reviewerQuoted 75 lines · amit kachhap
Hi Rui,
Thanks for the review comments,
Quoted 11 lines · Zhang Rui
Hi, Amit,
Quoted 7 lines · Amit Daniel Kachhap
This patch adds support to set the emulated temperature method in thermal zone (sensor). After setting this feature thermal zone must report this temperature and not the actual temperature. The actual implementation of this emulated temperature is based on sensor capability or platform specific. This is useful in debugging different temperature threshold and its associated cooling action. Writing 0 on this node should disable emulation.
Quoted 3 lines
Question:
will this bring hardware issue? Say, critical temperature reached while in emulation mode?No emulation does cause any h/w issue.
Quoted 3 lines
As this is for debug purpose, I'd prefer to have a seperate
Kconfigoption for this feature.Yes agreed. Will re-submit with kconfig option.
Quoted 33 lines
Quoted 33 lines
Signed-off-by Amit Daniel Kachhap <[email protected]>--- Documentation/thermal/sysfs-api.txt | 14 ++++++++++++++ drivers/thermal/thermal_sys.c | 26 ++++++++++++++++++++++++++ include/linux/thermal.h | 1 + 3 files changed, 41 insertions(+), 0 deletions(-)Documentation/thermal/sysfs-api.txt +3
-0@@ -55,6 +55,8 @@ temperature) and throttle appropriate devices. .get_trip_type: get the type of certain trip point. .get_trip_temp: get the temperature above which the certain trip point will be fired. + .set_emul_temp: set the emulation temperature which helps in debugging + different threshold temperature points. 1.1.2 void thermal_zone_device_unregister(struct thermal_zone_device *tz)@@ -153,6 +155,7 @@ Thermal zone device sys I/F, created once it's registered: |---trip_point_[0-*]_temp: Trip point temperature |---trip_point_[0-*]_type: Trip point type |---trip_point_[0-*]_hyst: Hysteresis value for this trip point + |---emul_temp: Emulated temperature set node Thermal cooling device sys I/F, created once it's registered: /sys/class/thermal/cooling_device[0-*]:@@ -252,6 +255,17 @@ passive Valid values: 0 (disabled) or greater than 1000 RW, OptionalQuoted 12 lines
Documentation/thermal/sysfs-api.txt passive · line 262
Quoted 5 lines
Documentation/thermal/sysfs-api.txt +5
-0+emul_temp + Interface to set the emulated temperature method in thermal zone + (sensor). After setting this feature thermal zone must report + this temperature and not the actual temperature. The actual + implementation of this emulated temperature is platform specific.can we have a pure software temperature emulation method? say, the generic thermal layer caches the emulated temperature value, and hook it in
update_temperature()?
This is also useful for testing in polling mode, and it does not require platform specific callback support. I meanthermal_ops->set_emul_tempis optional, but thermal emulation is always available for all platforms.Yes It makes sense and we can have pure software emulation and use the cached temperature when no platform call is registered. In my case I needed this in h/w so to have the same sensor trigger interrupts behaviour.
So the code flow can be like this,
Quoted 9 lines
#ifdef
CONFIG_THERMAL_EMULATION
if (thermal_ops->set_emul_temp)
then passemul_tempto platform and use the normal platformthermal_ops->get_temp
else
Store it locally and useemul_tempinstead of calling platformthermal_ops->get_temp
#endif
No.
We should not support emulation is CONFIG_THERMAL_EMULATION is cleared. And further more, for pure software emulation, we should check if the real temperature reaches critical trip point.
thanks,
rui
Quoted 88 lines
I will re-submit with this change.
Thanks,
AmitQuoted 72 lines
thanks,
ruiQuoted 69 lines
Documentation/thermal/sysfs-api.txt +6
-0+ This is useful in debugging different temperature threshold and its + associated cooling action. Writing 0 on this node should disable + emulation. + Unit: millidegree Celsius + WO, Optional + ***************************** * Cooling device attributes * *****************************drivers/thermal/thermal_sys.c +26
-0@@ -700,11 +700,31 @@ policy_show(struct device *dev, struct device_attribute *devattr, char *buf)return sprintf (buf,"%s\n" , tz->governor->name); } +static ssize_t +emul_temp_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct thermal_zone_device *tz =to_thermal_zone (dev); +int ret; +unsigned long temperature; + +if (!tz->ops->set_emul_temp) +return -EPERM ; + +if (kstrtoul (buf,10 , &temperature)) +return -EINVAL ; + + ret = tz->ops->set_emul_temp (tz, temperature); + +return ret ? ret : count; +} + static DEVICE_ATTR(type, 0444, type_show, NULL); static DEVICE_ATTR(temp, 0444, temp_show, NULL); static DEVICE_ATTR(mode, 0644, mode_show, mode_store); static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store); static DEVICE_ATTR(policy, S_IRUGO | S_IWUSR, policy_show, policy_store); +static DEVICE_ATTR(emul_temp, S_IWUSR, NULL, emul_temp_store);/* sys I/F for cooling device */ #define to_cooling_device (_dev) \@@ -1592,6 +1612,12 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, goto unregister; } +if (ops->set_emul_temp) { + result =device_create_file (&tz->device, &dev_attr_emul_temp); +if (result) + goto unregister; + } +/* Create policy attribute */ result =device_create_file (&tz->device, &dev_attr_policy);if (result)include/linux/thermal.h +1
-0@@ -123,6 +123,7 @@ struct thermal_zone_device_ops {int (*set_trip_hyst) (struct thermal_zone_device *,int ,unsigned long );int (*get_crit_temp) (struct thermal_zone_device *,unsigned long *); +int (*set_emul_temp) (struct thermal_zone_device *,unsigned long );int (*get_trend) (struct thermal_zone_device *,int ,enum thermal_trend *);Quoted 8 lines
include/linux/thermal.h struct thermal_zone_device_ops { · line 129
Quoted 1 line
include/linux/thermal.h +0
-0int (*notify) (struct thermal_zone_device *, int,--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 85 lines · Zhang Rui
Quoted 75 lines · amit kachhap
Hi Rui,
Thanks for the review comments,
Quoted 11 lines · Zhang Rui
Hi, Amit,
Quoted 7 lines · Amit Daniel Kachhap
This patch adds support to set the emulated temperature method in thermal zone (sensor). After setting this feature thermal zone must report this temperature and not the actual temperature. The actual implementation of this emulated temperature is based on sensor capability or platform specific. This is useful in debugging different temperature threshold and its associated cooling action. Writing 0 on this node should disable emulation.
Quoted 3 lines
Question:
will this bring hardware issue? Say, critical temperature reached while in emulation mode?No emulation does cause any h/w issue.
Quoted 3 lines
As this is for debug purpose, I'd prefer to have a seperate
Kconfigoption for this feature.Yes agreed. Will re-submit with kconfig option.
Quoted 33 lines
Quoted 33 lines
Signed-off-by Amit Daniel Kachhap <[email protected]>--- Documentation/thermal/sysfs-api.txt | 14 ++++++++++++++ drivers/thermal/thermal_sys.c | 26 ++++++++++++++++++++++++++ include/linux/thermal.h | 1 + 3 files changed, 41 insertions(+), 0 deletions(-)Documentation/thermal/sysfs-api.txt +3
-0@@ -55,6 +55,8 @@ temperature) and throttle appropriate devices. .get_trip_type: get the type of certain trip point. .get_trip_temp: get the temperature above which the certain trip point will be fired. + .set_emul_temp: set the emulation temperature which helps in debugging + different threshold temperature points. 1.1.2 void thermal_zone_device_unregister(struct thermal_zone_device *tz)@@ -153,6 +155,7 @@ Thermal zone device sys I/F, created once it's registered: |---trip_point_[0-*]_temp: Trip point temperature |---trip_point_[0-*]_type: Trip point type |---trip_point_[0-*]_hyst: Hysteresis value for this trip point + |---emul_temp: Emulated temperature set node Thermal cooling device sys I/F, created once it's registered: /sys/class/thermal/cooling_device[0-*]:@@ -252,6 +255,17 @@ passive Valid values: 0 (disabled) or greater than 1000 RW, OptionalQuoted 12 lines
Documentation/thermal/sysfs-api.txt passive · line 262
Quoted 5 lines
Documentation/thermal/sysfs-api.txt +5
-0+emul_temp + Interface to set the emulated temperature method in thermal zone + (sensor). After setting this feature thermal zone must report + this temperature and not the actual temperature. The actual + implementation of this emulated temperature is platform specific.can we have a pure software temperature emulation method? say, the generic thermal layer caches the emulated temperature value, and hook it in
update_temperature()?
This is also useful for testing in polling mode, and it does not require platform specific callback support. I meanthermal_ops->set_emul_tempis optional, but thermal emulation is always available for all platforms.Yes It makes sense and we can have pure software emulation and use the cached temperature when no platform call is registered. In my case I needed this in h/w so to have the same sensor trigger interrupts behaviour.
So the code flow can be like this,
Quoted 9 lines
#ifdef
CONFIG_THERMAL_EMULATION
if (thermal_ops->set_emul_temp)
then passemul_tempto platform and use the normal platformthermal_ops->get_temp
else
Store it locally and useemul_tempinstead of calling platformthermal_ops->get_temp
#endif
Quoted 4 lines
No.
We should not support emulation isCONFIG_THERMAL_EMULATIONis cleared. And further more, for pure software emulation, we should check if the real temperature reaches critical trip point.
Yes agreed. Submitted the V2 version with your suggestion.
Thanks,
Amit Daniel
Quoted 93 lines
thanks,
ruiQuoted 88 lines
I will re-submit with this change.
Thanks,
AmitQuoted 72 lines
thanks,
ruiQuoted 69 lines
Documentation/thermal/sysfs-api.txt +6
-0+ This is useful in debugging different temperature threshold and its + associated cooling action. Writing 0 on this node should disable + emulation. + Unit: millidegree Celsius + WO, Optional + ***************************** * Cooling device attributes * *****************************drivers/thermal/thermal_sys.c +26
-0@@ -700,11 +700,31 @@ policy_show(struct device *dev, struct device_attribute *devattr, char *buf)return sprintf (buf,"%s\n" , tz->governor->name); } +static ssize_t +emul_temp_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct thermal_zone_device *tz =to_thermal_zone (dev); +int ret; +unsigned long temperature; + +if (!tz->ops->set_emul_temp) +return -EPERM ; + +if (kstrtoul (buf,10 , &temperature)) +return -EINVAL ; + + ret = tz->ops->set_emul_temp (tz, temperature); + +return ret ? ret : count; +} + static DEVICE_ATTR(type, 0444, type_show, NULL); static DEVICE_ATTR(temp, 0444, temp_show, NULL); static DEVICE_ATTR(mode, 0644, mode_show, mode_store); static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store); static DEVICE_ATTR(policy, S_IRUGO | S_IWUSR, policy_show, policy_store); +static DEVICE_ATTR(emul_temp, S_IWUSR, NULL, emul_temp_store);/* sys I/F for cooling device */ #define to_cooling_device (_dev) \@@ -1592,6 +1612,12 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, goto unregister; } +if (ops->set_emul_temp) { + result =device_create_file (&tz->device, &dev_attr_emul_temp); +if (result) + goto unregister; + } +/* Create policy attribute */ result =device_create_file (&tz->device, &dev_attr_policy);if (result)include/linux/thermal.h +1
-0@@ -123,6 +123,7 @@ struct thermal_zone_device_ops {int (*set_trip_hyst) (struct thermal_zone_device *,int ,unsigned long );int (*get_crit_temp) (struct thermal_zone_device *,unsigned long *); +int (*set_emul_temp) (struct thermal_zone_device *,unsigned long );int (*get_trend) (struct thermal_zone_device *,int ,enum thermal_trend *);Quoted 8 lines
include/linux/thermal.h struct thermal_zone_device_ops { · line 129
Quoted 1 line
include/linux/thermal.h +0
-0int (*notify) (struct thermal_zone_device *, int,--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html