linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] thermal: add sysfs_notify on some attributes
@ 2016-02-24  4:11 Srikar Srimath Tirumala
  2016-02-24 20:24 ` Pandruvada, Srinivas
  0 siblings, 1 reply; 3+ messages in thread
From: Srikar Srimath Tirumala @ 2016-02-24  4:11 UTC (permalink / raw)
  To: srikars, linux-pm, linux-tegra, linux-kernel

Add a sysfs_notify on thermal_zone*/temp and cooling_device*/
cur_state whenever a passive or critical trip is triggered.

This change allows usermode apps to register itself to get notified,
when certain thermal conditions occur and reduce their workload.
This workload throttling can reduce\prevent throttling of hardware
clocks while allowing some other critical apps to run longer reliably.

Signed-off-by: Srikar Srimath Tirumala <srikars@nvidia.com>
---
 drivers/thermal/thermal_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index a0a8fd1..d8d257d 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -567,6 +567,8 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
 
 	for (count = 0; count < tz->trips; count++)
 		handle_thermal_trip(tz, count);
+
+	sysfs_notify(&tz->device.kobj, NULL, "temp");
 }
 EXPORT_SYMBOL_GPL(thermal_zone_device_update);
 
@@ -1638,6 +1640,7 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)
 	cdev->updated = true;
 	trace_cdev_update(cdev, target);
 	dev_dbg(&cdev->device, "set to state %lu\n", target);
+	sysfs_notify(&cdev->device.kobj, NULL, "cur_state");
 }
 EXPORT_SYMBOL(thermal_cdev_update);
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC][PATCH] thermal: add sysfs_notify on some attributes
  2016-02-24  4:11 [RFC][PATCH] thermal: add sysfs_notify on some attributes Srikar Srimath Tirumala
@ 2016-02-24 20:24 ` Pandruvada, Srinivas
       [not found]   ` <1456345360.3860.9.camel-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Pandruvada, Srinivas @ 2016-02-24 20:24 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org, srikars@nvidia.com,
	linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org

On Tue, 2016-02-23 at 20:11 -0800, Srikar Srimath Tirumala wrote:
> Add a sysfs_notify on thermal_zone*/temp and cooling_device*/
> cur_state whenever a passive or critical trip is triggered.
> 
> This change allows usermode apps to register itself to get notified,
> when certain thermal conditions occur and reduce their workload.
> This workload throttling can reduce\prevent throttling of hardware
> clocks while allowing some other critical apps to run longer
> reliably.
> Signed-off-by: Srikar Srimath Tirumala <srikars@nvidia.com>
> ---
>  drivers/thermal/thermal_core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/thermal/thermal_core.c
> b/drivers/thermal/thermal_core.c
> index a0a8fd1..d8d257d 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -567,6 +567,8 @@ void thermal_zone_device_update(struct
> thermal_zone_device *tz)
>  
>  	for (count = 0; count < tz->trips; count++)
>  		handle_thermal_trip(tz, count);
> +
> +	sysfs_notify(&tz->device.kobj, NULL, "temp");
When user space governor is used this will result in two notifications
to user space.
Also you want when a trip is violated. For some driver there will be
too many calls from irq thread, so you may want in handle_thermal_trip
when a trip is violated.

Thanks,
Srinivas
>  }
>  EXPORT_SYMBOL_GPL(thermal_zone_device_update);
>  
> @@ -1638,6 +1640,7 @@ void thermal_cdev_update(struct
> thermal_cooling_device *cdev)
>  	cdev->updated = true;
>  	trace_cdev_update(cdev, target);
>  	dev_dbg(&cdev->device, "set to state %lu\n", target);
> +	sysfs_notify(&cdev->device.kobj, NULL, "cur_state");
>  }
>  EXPORT_SYMBOL(thermal_cdev_update);
>  

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC][PATCH] thermal: add sysfs_notify on some attributes
       [not found]   ` <1456345360.3860.9.camel-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2016-02-26  0:24     ` Srikar Srimath Tirumala
  0 siblings, 0 replies; 3+ messages in thread
From: Srikar Srimath Tirumala @ 2016-02-26  0:24 UTC (permalink / raw)
  To: Pandruvada, Srinivas,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
  Cc: mlongnecker-DDmLM1+adcrQT0dZR+AlfA

On 02/24/2016 12:24 PM, Pandruvada, Srinivas wrote:
> On Tue, 2016-02-23 at 20:11 -0800, Srikar Srimath Tirumala wrote:
>> Add a sysfs_notify on thermal_zone*/temp and cooling_device*/
>> cur_state whenever a passive or critical trip is triggered.
>>
>> This change allows usermode apps to register itself to get notified,
>> when certain thermal conditions occur and reduce their workload.
>> This workload throttling can reduce\prevent throttling of hardware
>> clocks while allowing some other critical apps to run longer
>> reliably.
>> Signed-off-by: Srikar Srimath Tirumala <srikars-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>> ---
>>   drivers/thermal/thermal_core.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/thermal/thermal_core.c
>> b/drivers/thermal/thermal_core.c
>> index a0a8fd1..d8d257d 100644
>> --- a/drivers/thermal/thermal_core.c
>> +++ b/drivers/thermal/thermal_core.c
>> @@ -567,6 +567,8 @@ void thermal_zone_device_update(struct
>> thermal_zone_device *tz)
>>
>>   	for (count = 0; count < tz->trips; count++)
>>   		handle_thermal_trip(tz, count);
>> +
>> +	sysfs_notify(&tz->device.kobj, NULL, "temp");
> When user space governor is used this will result in two notifications
> to user space.
Agreed, when the first trip point is violated it would result in two
notifications. But this change was also supposed to address the cooling
cur state change that results from governor throttling after a trip
point is violated. I realize this intent was not communicated well in
the commit message, Patch V2 will fix it.
> Also you want when a trip is violated. For some driver there will be
> too many calls from irq thread, so you may want in handle_thermal_trip
> when a trip is violated.
Agreed, Patch V2 will do the notify only once per thermal zone and only
when there is a trip violation.
>
> Thanks,
> Srinivas
>>   }
>>   EXPORT_SYMBOL_GPL(thermal_zone_device_update);
>>
>> @@ -1638,6 +1640,7 @@ void thermal_cdev_update(struct
>> thermal_cooling_device *cdev)
>>   	cdev->updated = true;
>>   	trace_cdev_update(cdev, target);
>>   	dev_dbg(&cdev->device, "set to state %lu\n", target);
>> +	sysfs_notify(&cdev->device.kobj, NULL, "cur_state");
>>   }
>>   EXPORT_SYMBOL(thermal_cdev_update);
>>
Thanks for your inputs Srinivas, please take a look at Patch V2 that
addresses your comments.
Best Regards
Srikar

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-26  0:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-24  4:11 [RFC][PATCH] thermal: add sysfs_notify on some attributes Srikar Srimath Tirumala
2016-02-24 20:24 ` Pandruvada, Srinivas
     [not found]   ` <1456345360.3860.9.camel-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-02-26  0:24     ` Srikar Srimath Tirumala

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).