diff mbox

[3/3] thermal: of: notify sensor driver on trip updates

Message ID 1417050989-25405-3-git-send-email-navneetk@nvidia.com (mailing list archive)
State Changes Requested
Delegated to: Eduardo Valentin
Headers show

Commit Message

navneet kumar Nov. 27, 2014, 1:16 a.m. UTC
From: navneet kumar <navneetk@nvidia.com>

some thermal sensor hardwares include logic which
can raise interrupts at certain programmed temperature
thresholds.

Drivers for such sensors should be able to learn the
appropriate threshold temperatures for interrupts by querying
the thermal framework.

This change provides a mechanism to allow a sensor driver to
update it's thresholds when userspace changes a trip point
temperature.

While this behavior may not make sense in thermal zones
with more than one sensor, no such examples exist in
the kernel.

Signed-off-by: navneet kumar <navneetk@nvidia.com>
---
 drivers/thermal/of-thermal.c | 7 +++++++
 include/linux/thermal.h      | 1 +
 2 files changed, 8 insertions(+)

Comments

Eduardo Valentin Nov. 27, 2014, 2:32 p.m. UTC | #1
Hello Navneet,

On Wed, Nov 26, 2014 at 05:16:29PM -0800, Navneet Kumar wrote:
> From: navneet kumar <navneetk@nvidia.com>
> 
> some thermal sensor hardwares include logic which
> can raise interrupts at certain programmed temperature
> thresholds.
> 
> Drivers for such sensors should be able to learn the
> appropriate threshold temperatures for interrupts by querying
> the thermal framework.
> 
> This change provides a mechanism to allow a sensor driver to
> update it's thresholds when userspace changes a trip point
> temperature.
> 
> While this behavior may not make sense in thermal zones
> with more than one sensor, no such examples exist in
> the kernel.
> 
> Signed-off-by: navneet kumar <navneetk@nvidia.com>
> ---
>  drivers/thermal/of-thermal.c | 7 +++++++
>  include/linux/thermal.h      | 1 +
>  2 files changed, 8 insertions(+)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index 3d47a0cf3825..3568e4a586dc 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -258,6 +258,9 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
>  	/* thermal framework should take care of data->mask & (1 << trip) */
>  	data->trips[trip].temperature = temp;
>  
> +	if (data->sops.trip_update)
> +		data->sops.trip_update(data->sensor_data, trip);
> +
>  	return 0;
>  }
>  
> @@ -285,6 +288,9 @@ static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip,
>  	/* thermal framework should take care of data->mask & (1 << trip) */
>  	data->trips[trip].hysteresis = hyst;
>  
> +	if (data->sops.trip_update)
> +		data->sops.trip_update(data->sensor_data, trip);
> +
>  	return 0;
>  }
>  
> @@ -500,6 +506,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
>  
>  	tz->sops.get_temp = NULL;
>  	tz->sops.get_trend = NULL;
> +	tz->sops.trip_update = NULL;
>  	tz->sensor_data = NULL;
>  	mutex_unlock(&tzd->lock);
>  }
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 58341c56a01f..b93e65815175 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -292,6 +292,7 @@ struct thermal_genl_event {
>  struct thermal_of_sensor_ops {
>  	int (*get_temp)(void *, long *);
>  	int (*get_trend)(void *, long *);
> +	int (*trip_update)(void *, int);

First thing I ask you is to update your work on top of my -linus branch,
as I already mentioned. Reasoning is that part of the changes you are
sending is already there.

As for this new callback, I am fine with it as long as it is also
available for drivers that do not use of-thermal. Once again, of-thermal
is not a competitor of thermal core. It will never be. It is not a new
thermal API. 

That said, it does not make sense to have functionality in of-thermal that
do not belong to thermal core. Exceptions are, of course, for helping
doing the same operations we already have in thermal core.

All the best,

Eduardo Valentin

>  };
>  
>  /* Function declarations */
> -- 
> 1.8.1.5
>
navneet kumar Dec. 1, 2014, 8:45 p.m. UTC | #2
Hi Eduardo,

On 11/27/2014 06:32 AM, Eduardo Valentin wrote:
> * PGP Signed by an unknown key
> 
> Hello Navneet,
> 
> On Wed, Nov 26, 2014 at 05:16:29PM -0800, Navneet Kumar wrote:
>> From: navneet kumar <navneetk@nvidia.com>
>>
>> some thermal sensor hardwares include logic which
>> can raise interrupts at certain programmed temperature
>> thresholds.
>>
>> Drivers for such sensors should be able to learn the
>> appropriate threshold temperatures for interrupts by querying
>> the thermal framework.
>>
>> This change provides a mechanism to allow a sensor driver to
>> update it's thresholds when userspace changes a trip point
>> temperature.
>>
>> While this behavior may not make sense in thermal zones
>> with more than one sensor, no such examples exist in
>> the kernel.
>>
>> Signed-off-by: navneet kumar <navneetk@nvidia.com>
>> ---
>>  drivers/thermal/of-thermal.c | 7 +++++++
>>  include/linux/thermal.h      | 1 +
>>  2 files changed, 8 insertions(+)
>>
>> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
>> index 3d47a0cf3825..3568e4a586dc 100644
>> --- a/drivers/thermal/of-thermal.c
>> +++ b/drivers/thermal/of-thermal.c
>> @@ -258,6 +258,9 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
>>  	/* thermal framework should take care of data->mask & (1 << trip) */
>>  	data->trips[trip].temperature = temp;
>>  
>> +	if (data->sops.trip_update)
>> +		data->sops.trip_update(data->sensor_data, trip);
>> +
>>  	return 0;
>>  }
>>  
>> @@ -285,6 +288,9 @@ static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip,
>>  	/* thermal framework should take care of data->mask & (1 << trip) */
>>  	data->trips[trip].hysteresis = hyst;
>>  
>> +	if (data->sops.trip_update)
>> +		data->sops.trip_update(data->sensor_data, trip);
>> +
>>  	return 0;
>>  }
>>  
>> @@ -500,6 +506,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
>>  
>>  	tz->sops.get_temp = NULL;
>>  	tz->sops.get_trend = NULL;
>> +	tz->sops.trip_update = NULL;
>>  	tz->sensor_data = NULL;
>>  	mutex_unlock(&tzd->lock);
>>  }
>> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
>> index 58341c56a01f..b93e65815175 100644
>> --- a/include/linux/thermal.h
>> +++ b/include/linux/thermal.h
>> @@ -292,6 +292,7 @@ struct thermal_genl_event {
>>  struct thermal_of_sensor_ops {
>>  	int (*get_temp)(void *, long *);
>>  	int (*get_trend)(void *, long *);
>> +	int (*trip_update)(void *, int);
> 
> First thing I ask you is to update your work on top of my -linus branch,
> as I already mentioned. Reasoning is that part of the changes you are
> sending is already there.
will do.
> 
> As for this new callback, I am fine with it as long as it is also
> available for drivers that do not use of-thermal. Once again, of-thermal
> is not a competitor of thermal core. It will never be. It is not a new
> thermal API. 
I agree that this callback is not a part of the thermal_core functionality.
However, when a driver registers directly with the thermal_core (doesn't use
of-thermal), it 'owns' the set_trip_XX callbacks in the first place; which is
the sole purpose of using the 'trip_update' callback in of-thermal.

Adding an additional 'update' to the thermal_core ops would be a no-op. right?
> 
> That said, it does not make sense to have functionality in of-thermal that
> do not belong to thermal core. Exceptions are, of course, for helping
> doing the same operations we already have in thermal core.
> 
> All the best,
> 
> Eduardo Valentin
> 
>>  };
>>  
>>  /* Function declarations */
>> -- 
>> 1.8.1.5
>>
> 
> * Unknown Key
> * 0x7DA4E256
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eduardo Valentin Dec. 1, 2014, 9:23 p.m. UTC | #3
On Mon, Dec 01, 2014 at 12:45:52PM -0800, navneet kumar wrote:
> Hi Eduardo,
> 
> On 11/27/2014 06:32 AM, Eduardo Valentin wrote:
> > * PGP Signed by an unknown key
> > 
> > Hello Navneet,
> > 
> > On Wed, Nov 26, 2014 at 05:16:29PM -0800, Navneet Kumar wrote:
> >> From: navneet kumar <navneetk@nvidia.com>
> >>
> >> some thermal sensor hardwares include logic which
> >> can raise interrupts at certain programmed temperature
> >> thresholds.
> >>
> >> Drivers for such sensors should be able to learn the
> >> appropriate threshold temperatures for interrupts by querying
> >> the thermal framework.
> >>
> >> This change provides a mechanism to allow a sensor driver to
> >> update it's thresholds when userspace changes a trip point
> >> temperature.
> >>
> >> While this behavior may not make sense in thermal zones
> >> with more than one sensor, no such examples exist in
> >> the kernel.
> >>
> >> Signed-off-by: navneet kumar <navneetk@nvidia.com>
> >> ---
> >>  drivers/thermal/of-thermal.c | 7 +++++++
> >>  include/linux/thermal.h      | 1 +
> >>  2 files changed, 8 insertions(+)
> >>
> >> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> >> index 3d47a0cf3825..3568e4a586dc 100644
> >> --- a/drivers/thermal/of-thermal.c
> >> +++ b/drivers/thermal/of-thermal.c
> >> @@ -258,6 +258,9 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
> >>  	/* thermal framework should take care of data->mask & (1 << trip) */
> >>  	data->trips[trip].temperature = temp;
> >>  
> >> +	if (data->sops.trip_update)
> >> +		data->sops.trip_update(data->sensor_data, trip);
> >> +
> >>  	return 0;
> >>  }
> >>  
> >> @@ -285,6 +288,9 @@ static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip,
> >>  	/* thermal framework should take care of data->mask & (1 << trip) */
> >>  	data->trips[trip].hysteresis = hyst;
> >>  
> >> +	if (data->sops.trip_update)
> >> +		data->sops.trip_update(data->sensor_data, trip);
> >> +
> >>  	return 0;
> >>  }
> >>  
> >> @@ -500,6 +506,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
> >>  
> >>  	tz->sops.get_temp = NULL;
> >>  	tz->sops.get_trend = NULL;
> >> +	tz->sops.trip_update = NULL;
> >>  	tz->sensor_data = NULL;
> >>  	mutex_unlock(&tzd->lock);
> >>  }
> >> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> >> index 58341c56a01f..b93e65815175 100644
> >> --- a/include/linux/thermal.h
> >> +++ b/include/linux/thermal.h
> >> @@ -292,6 +292,7 @@ struct thermal_genl_event {
> >>  struct thermal_of_sensor_ops {
> >>  	int (*get_temp)(void *, long *);
> >>  	int (*get_trend)(void *, long *);
> >> +	int (*trip_update)(void *, int);
> > 
> > First thing I ask you is to update your work on top of my -linus branch,
> > as I already mentioned. Reasoning is that part of the changes you are
> > sending is already there.
> will do.
> > 
> > As for this new callback, I am fine with it as long as it is also
> > available for drivers that do not use of-thermal. Once again, of-thermal
> > is not a competitor of thermal core. It will never be. It is not a new
> > thermal API. 
> I agree that this callback is not a part of the thermal_core functionality.
> However, when a driver registers directly with the thermal_core (doesn't use
> of-thermal), it 'owns' the set_trip_XX callbacks in the first place; which is
> the sole purpose of using the 'trip_update' callback in of-thermal.
> 
> Adding an additional 'update' to the thermal_core ops would be a no-op. right?

Yes, you are right. Now I understand your point. 

Can we then re-use the .set_trips nomenclature?

Cheers,

> > 
> > That said, it does not make sense to have functionality in of-thermal that
> > do not belong to thermal core. Exceptions are, of course, for helping
> > doing the same operations we already have in thermal core.
> > 
> > All the best,
> > 
> > Eduardo Valentin
> > 
> >>  };
> >>  
> >>  /* Function declarations */
> >> -- 
> >> 1.8.1.5
> >>
> > 
> > * Unknown Key
> > * 0x7DA4E256
> >
navneet kumar Dec. 1, 2014, 10:35 p.m. UTC | #4
On 12/01/2014 01:23 PM, Eduardo Valentin wrote:
> * PGP Signed by an unknown key
> 
> On Mon, Dec 01, 2014 at 12:45:52PM -0800, navneet kumar wrote:
>> Hi Eduardo,
>>
>> On 11/27/2014 06:32 AM, Eduardo Valentin wrote:
>>>> Old Signed by an unknown key
>>>
>>> Hello Navneet,
>>>
>>> On Wed, Nov 26, 2014 at 05:16:29PM -0800, Navneet Kumar wrote:
>>>> From: navneet kumar <navneetk@nvidia.com>
>>>>
>>>> some thermal sensor hardwares include logic which
>>>> can raise interrupts at certain programmed temperature
>>>> thresholds.
>>>>
>>>> Drivers for such sensors should be able to learn the
>>>> appropriate threshold temperatures for interrupts by querying
>>>> the thermal framework.
>>>>
>>>> This change provides a mechanism to allow a sensor driver to
>>>> update it's thresholds when userspace changes a trip point
>>>> temperature.
>>>>
>>>> While this behavior may not make sense in thermal zones
>>>> with more than one sensor, no such examples exist in
>>>> the kernel.
>>>>
>>>> Signed-off-by: navneet kumar <navneetk@nvidia.com>
>>>> ---
>>>>  drivers/thermal/of-thermal.c | 7 +++++++
>>>>  include/linux/thermal.h      | 1 +
>>>>  2 files changed, 8 insertions(+)
>>>>
>>>> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
>>>> index 3d47a0cf3825..3568e4a586dc 100644
>>>> --- a/drivers/thermal/of-thermal.c
>>>> +++ b/drivers/thermal/of-thermal.c
>>>> @@ -258,6 +258,9 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
>>>>  	/* thermal framework should take care of data->mask & (1 << trip) */
>>>>  	data->trips[trip].temperature = temp;
>>>>  
>>>> +	if (data->sops.trip_update)
>>>> +		data->sops.trip_update(data->sensor_data, trip);
>>>> +
>>>>  	return 0;
>>>>  }
>>>>  
>>>> @@ -285,6 +288,9 @@ static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip,
>>>>  	/* thermal framework should take care of data->mask & (1 << trip) */
>>>>  	data->trips[trip].hysteresis = hyst;
>>>>  
>>>> +	if (data->sops.trip_update)
>>>> +		data->sops.trip_update(data->sensor_data, trip);
>>>> +
>>>>  	return 0;
>>>>  }
>>>>  
>>>> @@ -500,6 +506,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
>>>>  
>>>>  	tz->sops.get_temp = NULL;
>>>>  	tz->sops.get_trend = NULL;
>>>> +	tz->sops.trip_update = NULL;
>>>>  	tz->sensor_data = NULL;
>>>>  	mutex_unlock(&tzd->lock);
>>>>  }
>>>> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
>>>> index 58341c56a01f..b93e65815175 100644
>>>> --- a/include/linux/thermal.h
>>>> +++ b/include/linux/thermal.h
>>>> @@ -292,6 +292,7 @@ struct thermal_genl_event {
>>>>  struct thermal_of_sensor_ops {
>>>>  	int (*get_temp)(void *, long *);
>>>>  	int (*get_trend)(void *, long *);
>>>> +	int (*trip_update)(void *, int);
>>>
>>> First thing I ask you is to update your work on top of my -linus branch,
>>> as I already mentioned. Reasoning is that part of the changes you are
>>> sending is already there.
>> will do.
>>>
>>> As for this new callback, I am fine with it as long as it is also
>>> available for drivers that do not use of-thermal. Once again, of-thermal
>>> is not a competitor of thermal core. It will never be. It is not a new
>>> thermal API. 
>> I agree that this callback is not a part of the thermal_core functionality.
>> However, when a driver registers directly with the thermal_core (doesn't use
>> of-thermal), it 'owns' the set_trip_XX callbacks in the first place; which is
>> the sole purpose of using the 'trip_update' callback in of-thermal.
>>
>> Adding an additional 'update' to the thermal_core ops would be a no-op. right?
> 
> Yes, you are right. Now I understand your point. 
> 
> Can we then re-use the .set_trips nomenclature?
Sorry, I fail to understand. Are you suggesting to re-use the interface for set_trip 'temp' as well as 'hyst'?
If so, is it just to maintain the commonality across thermal_core and of-thermal interfaces?

The way i see it, the driver just needs to get some kind of 'update' that 'something' changed with
a trip point; and can later query the trips from of-thermal. (Lukasz's patch helps with that).
Functionality-wise, using two callbacks seems excessive. But i may be wrong :-)

> 
> Cheers,
> 
>>>
>>> That said, it does not make sense to have functionality in of-thermal that
>>> do not belong to thermal core. Exceptions are, of course, for helping
>>> doing the same operations we already have in thermal core.
>>>
>>> All the best,
>>>
>>> Eduardo Valentin
>>>
>>>>  };
>>>>  
>>>>  /* Function declarations */
>>>> -- 
>>>> 1.8.1.5
>>>>
>>>
>>> * Unknown Key
>>> * 0x7DA4E256
>>>
> 
> * Unknown Key
> * 0x7DA4E256
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 3d47a0cf3825..3568e4a586dc 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -258,6 +258,9 @@  static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
 	/* thermal framework should take care of data->mask & (1 << trip) */
 	data->trips[trip].temperature = temp;
 
+	if (data->sops.trip_update)
+		data->sops.trip_update(data->sensor_data, trip);
+
 	return 0;
 }
 
@@ -285,6 +288,9 @@  static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip,
 	/* thermal framework should take care of data->mask & (1 << trip) */
 	data->trips[trip].hysteresis = hyst;
 
+	if (data->sops.trip_update)
+		data->sops.trip_update(data->sensor_data, trip);
+
 	return 0;
 }
 
@@ -500,6 +506,7 @@  void thermal_zone_of_sensor_unregister(struct device *dev,
 
 	tz->sops.get_temp = NULL;
 	tz->sops.get_trend = NULL;
+	tz->sops.trip_update = NULL;
 	tz->sensor_data = NULL;
 	mutex_unlock(&tzd->lock);
 }
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 58341c56a01f..b93e65815175 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -292,6 +292,7 @@  struct thermal_genl_event {
 struct thermal_of_sensor_ops {
 	int (*get_temp)(void *, long *);
 	int (*get_trend)(void *, long *);
+	int (*trip_update)(void *, int);
 };
 
 /* Function declarations */