All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: thermal: Reset previous low and high trip during thermal zone init
@ 2021-11-02 20:00 Manaf Meethalavalappu Pallikunhi
  2021-11-05  9:46 ` manafm
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Manaf Meethalavalappu Pallikunhi @ 2021-11-02 20:00 UTC (permalink / raw)
  To: Zhang Rui, Daniel Lezcano, Amit Kucheria, Thara Gopinath
  Cc: linux-pm, linux-kernel, Manaf Meethalavalappu Pallikunhi

During the suspend is in process, thermal_zone_device_update bails out
thermal zone re-evaluation for any sensor trip violation without
setting next valid trip to that sensor. It assumes during resume
it will re-evaluate same thermal zone and update trip. But when it is
in suspend temperature goes down and on resume path while updating
thermal zone if temperature is less than previously violated trip,
thermal zone set trip function evaluates the same previous high and
previous low trip as new high and low trip. Since there is no change
in high/low trip, it bails out from thermal zone set trip API without
setting any trip. It leads to a case where sensor high trip or low
trip is disabled forever even though thermal zone has a valid high
or low trip.

During thermal zone device init, reset thermal zone previous high
and low trip. It resolves above mentioned scenario.

Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
---
 drivers/thermal/thermal_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 21db445..2b7a0b4 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -477,6 +477,8 @@ static void thermal_zone_device_init(struct thermal_zone_device *tz)
 {
 	struct thermal_instance *pos;
 	tz->temperature = THERMAL_TEMP_INVALID;
+	tz->prev_low_trip = -INT_MAX;
+	tz->prev_high_trip = INT_MAX;
 	list_for_each_entry(pos, &tz->thermal_instances, tz_node)
 		pos->initialized = false;
 }
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


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

* Re: [PATCH] drivers: thermal: Reset previous low and high trip during thermal zone init
  2021-11-02 20:00 [PATCH] drivers: thermal: Reset previous low and high trip during thermal zone init Manaf Meethalavalappu Pallikunhi
@ 2021-11-05  9:46 ` manafm
  2021-11-05 15:22 ` Rafael J. Wysocki
  2021-11-05 18:48 ` Thara Gopinath
  2 siblings, 0 replies; 6+ messages in thread
From: manafm @ 2021-11-05  9:46 UTC (permalink / raw)
  To: Zhang Rui, Daniel Lezcano, Amit Kucheria, Thara Gopinath
  Cc: linux-pm, linux-kernel


Gentle reminder.

On 2021-11-03 01:30, Manaf Meethalavalappu Pallikunhi wrote:
> During the suspend is in process, thermal_zone_device_update bails out
> thermal zone re-evaluation for any sensor trip violation without
> setting next valid trip to that sensor. It assumes during resume
> it will re-evaluate same thermal zone and update trip. But when it is
> in suspend temperature goes down and on resume path while updating
> thermal zone if temperature is less than previously violated trip,
> thermal zone set trip function evaluates the same previous high and
> previous low trip as new high and low trip. Since there is no change
> in high/low trip, it bails out from thermal zone set trip API without
> setting any trip. It leads to a case where sensor high trip or low
> trip is disabled forever even though thermal zone has a valid high
> or low trip.
> 
> During thermal zone device init, reset thermal zone previous high
> and low trip. It resolves above mentioned scenario.
> 
> Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
> ---
>  drivers/thermal/thermal_core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/thermal/thermal_core.c 
> b/drivers/thermal/thermal_core.c
> index 21db445..2b7a0b4 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -477,6 +477,8 @@ static void thermal_zone_device_init(struct
> thermal_zone_device *tz)
>  {
>  	struct thermal_instance *pos;
>  	tz->temperature = THERMAL_TEMP_INVALID;
> +	tz->prev_low_trip = -INT_MAX;
> +	tz->prev_high_trip = INT_MAX;
>  	list_for_each_entry(pos, &tz->thermal_instances, tz_node)
>  		pos->initialized = false;
>  }

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

* Re: [PATCH] drivers: thermal: Reset previous low and high trip during thermal zone init
  2021-11-02 20:00 [PATCH] drivers: thermal: Reset previous low and high trip during thermal zone init Manaf Meethalavalappu Pallikunhi
  2021-11-05  9:46 ` manafm
@ 2021-11-05 15:22 ` Rafael J. Wysocki
  2021-11-05 17:46   ` manafm
  2021-11-05 18:48 ` Thara Gopinath
  2 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2021-11-05 15:22 UTC (permalink / raw)
  To: Manaf Meethalavalappu Pallikunhi, Daniel Lezcano
  Cc: Zhang Rui, Amit Kucheria, Thara Gopinath, Linux PM,
	Linux Kernel Mailing List

On Tue, Nov 2, 2021 at 9:01 PM Manaf Meethalavalappu Pallikunhi
<manafm@codeaurora.org> wrote:
>
> During the suspend is in process, thermal_zone_device_update bails out
> thermal zone re-evaluation for any sensor trip violation without
> setting next valid trip to that sensor. It assumes during resume
> it will re-evaluate same thermal zone and update trip. But when it is
> in suspend temperature goes down and on resume path while updating
> thermal zone if temperature is less than previously violated trip,
> thermal zone set trip function evaluates the same previous high and
> previous low trip as new high and low trip. Since there is no change
> in high/low trip, it bails out from thermal zone set trip API without
> setting any trip. It leads to a case where sensor high trip or low
> trip is disabled forever even though thermal zone has a valid high
> or low trip.
>
> During thermal zone device init, reset thermal zone previous high
> and low trip. It resolves above mentioned scenario.

Makes sense to me.

Daniel?

> Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
> ---
>  drivers/thermal/thermal_core.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 21db445..2b7a0b4 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -477,6 +477,8 @@ static void thermal_zone_device_init(struct thermal_zone_device *tz)
>  {
>         struct thermal_instance *pos;
>         tz->temperature = THERMAL_TEMP_INVALID;
> +       tz->prev_low_trip = -INT_MAX;

Why not use INT_MIN instead?

> +       tz->prev_high_trip = INT_MAX;
>         list_for_each_entry(pos, &tz->thermal_instances, tz_node)
>                 pos->initialized = false;
>  }
> --

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

* Re: [PATCH] drivers: thermal: Reset previous low and high trip during thermal zone init
  2021-11-05 15:22 ` Rafael J. Wysocki
@ 2021-11-05 17:46   ` manafm
  0 siblings, 0 replies; 6+ messages in thread
From: manafm @ 2021-11-05 17:46 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Daniel Lezcano, Zhang Rui, Amit Kucheria, Thara Gopinath,
	Linux PM, Linux Kernel Mailing List

On 2021-11-05 20:52, Rafael J. Wysocki wrote:
> On Tue, Nov 2, 2021 at 9:01 PM Manaf Meethalavalappu Pallikunhi
> <manafm@codeaurora.org> wrote:
>> 
>> During the suspend is in process, thermal_zone_device_update bails out
>> thermal zone re-evaluation for any sensor trip violation without
>> setting next valid trip to that sensor. It assumes during resume
>> it will re-evaluate same thermal zone and update trip. But when it is
>> in suspend temperature goes down and on resume path while updating
>> thermal zone if temperature is less than previously violated trip,
>> thermal zone set trip function evaluates the same previous high and
>> previous low trip as new high and low trip. Since there is no change
>> in high/low trip, it bails out from thermal zone set trip API without
>> setting any trip. It leads to a case where sensor high trip or low
>> trip is disabled forever even though thermal zone has a valid high
>> or low trip.
>> 
>> During thermal zone device init, reset thermal zone previous high
>> and low trip. It resolves above mentioned scenario.
> 
> Makes sense to me.
> 
> Daniel?
> 
>> Signed-off-by: Manaf Meethalavalappu Pallikunhi 
>> <manafm@codeaurora.org>
>> ---
>>  drivers/thermal/thermal_core.c | 2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> diff --git a/drivers/thermal/thermal_core.c 
>> b/drivers/thermal/thermal_core.c
>> index 21db445..2b7a0b4 100644
>> --- a/drivers/thermal/thermal_core.c
>> +++ b/drivers/thermal/thermal_core.c
>> @@ -477,6 +477,8 @@ static void thermal_zone_device_init(struct 
>> thermal_zone_device *tz)
>>  {
>>         struct thermal_instance *pos;
>>         tz->temperature = THERMAL_TEMP_INVALID;
>> +       tz->prev_low_trip = -INT_MAX;
> 
> Why not use INT_MIN instead?
> 
The thermal_zone_set_trips API uses -INT_MAX as default low trip to 
start trip aggregation. I used the same default values here as well.

>> +       tz->prev_high_trip = INT_MAX;
>>         list_for_each_entry(pos, &tz->thermal_instances, tz_node)
>>                 pos->initialized = false;
>>  }
>> --

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

* Re: [PATCH] drivers: thermal: Reset previous low and high trip during thermal zone init
  2021-11-02 20:00 [PATCH] drivers: thermal: Reset previous low and high trip during thermal zone init Manaf Meethalavalappu Pallikunhi
  2021-11-05  9:46 ` manafm
  2021-11-05 15:22 ` Rafael J. Wysocki
@ 2021-11-05 18:48 ` Thara Gopinath
  2021-11-16 19:31   ` Rafael J. Wysocki
  2 siblings, 1 reply; 6+ messages in thread
From: Thara Gopinath @ 2021-11-05 18:48 UTC (permalink / raw)
  To: Manaf Meethalavalappu Pallikunhi, Zhang Rui, Daniel Lezcano,
	Amit Kucheria
  Cc: linux-pm, linux-kernel



On 11/2/21 4:00 PM, Manaf Meethalavalappu Pallikunhi wrote:
> During the suspend is in process, thermal_zone_device_update bails out
> thermal zone re-evaluation for any sensor trip violation without
> setting next valid trip to that sensor. It assumes during resume
> it will re-evaluate same thermal zone and update trip. But when it is
> in suspend temperature goes down and on resume path while updating
> thermal zone if temperature is less than previously violated trip,
> thermal zone set trip function evaluates the same previous high and
> previous low trip as new high and low trip. Since there is no change
> in high/low trip, it bails out from thermal zone set trip API without
> setting any trip. It leads to a case where sensor high trip or low
> trip is disabled forever even though thermal zone has a valid high
> or low trip.
> 
> During thermal zone device init, reset thermal zone previous high
> and low trip. It resolves above mentioned scenario.
> 
> Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>

Reviewed-by: Thara Gopinath <thara.gopinath@linaro.org>

-- 
Warm Regards
Thara (She/Her/Hers)

> ---
>   drivers/thermal/thermal_core.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 21db445..2b7a0b4 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -477,6 +477,8 @@ static void thermal_zone_device_init(struct thermal_zone_device *tz)
>   {
>   	struct thermal_instance *pos;
>   	tz->temperature = THERMAL_TEMP_INVALID;
> +	tz->prev_low_trip = -INT_MAX;
> +	tz->prev_high_trip = INT_MAX;
>   	list_for_each_entry(pos, &tz->thermal_instances, tz_node)
>   		pos->initialized = false;
>   }
> 



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

* Re: [PATCH] drivers: thermal: Reset previous low and high trip during thermal zone init
  2021-11-05 18:48 ` Thara Gopinath
@ 2021-11-16 19:31   ` Rafael J. Wysocki
  0 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2021-11-16 19:31 UTC (permalink / raw)
  To: Thara Gopinath, Manaf Meethalavalappu Pallikunhi
  Cc: Zhang Rui, Daniel Lezcano, Amit Kucheria, Linux PM,
	Linux Kernel Mailing List

On Fri, Nov 5, 2021 at 7:49 PM Thara Gopinath <thara.gopinath@linaro.org> wrote:
>
>
>
> On 11/2/21 4:00 PM, Manaf Meethalavalappu Pallikunhi wrote:
> > During the suspend is in process, thermal_zone_device_update bails out
> > thermal zone re-evaluation for any sensor trip violation without
> > setting next valid trip to that sensor. It assumes during resume
> > it will re-evaluate same thermal zone and update trip. But when it is
> > in suspend temperature goes down and on resume path while updating
> > thermal zone if temperature is less than previously violated trip,
> > thermal zone set trip function evaluates the same previous high and
> > previous low trip as new high and low trip. Since there is no change
> > in high/low trip, it bails out from thermal zone set trip API without
> > setting any trip. It leads to a case where sensor high trip or low
> > trip is disabled forever even though thermal zone has a valid high
> > or low trip.
> >
> > During thermal zone device init, reset thermal zone previous high
> > and low trip. It resolves above mentioned scenario.
> >
> > Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
>
> Reviewed-by: Thara Gopinath <thara.gopinath@linaro.org>
>
> --
> Warm Regards
> Thara (She/Her/Hers)
>
> > ---
> >   drivers/thermal/thermal_core.c | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> > index 21db445..2b7a0b4 100644
> > --- a/drivers/thermal/thermal_core.c
> > +++ b/drivers/thermal/thermal_core.c
> > @@ -477,6 +477,8 @@ static void thermal_zone_device_init(struct thermal_zone_device *tz)
> >   {
> >       struct thermal_instance *pos;
> >       tz->temperature = THERMAL_TEMP_INVALID;
> > +     tz->prev_low_trip = -INT_MAX;
> > +     tz->prev_high_trip = INT_MAX;
> >       list_for_each_entry(pos, &tz->thermal_instances, tz_node)
> >               pos->initialized = false;
> >   }

Applied as 5.16-rc2 material, thanks!

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

end of thread, other threads:[~2021-11-16 19:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02 20:00 [PATCH] drivers: thermal: Reset previous low and high trip during thermal zone init Manaf Meethalavalappu Pallikunhi
2021-11-05  9:46 ` manafm
2021-11-05 15:22 ` Rafael J. Wysocki
2021-11-05 17:46   ` manafm
2021-11-05 18:48 ` Thara Gopinath
2021-11-16 19:31   ` Rafael J. Wysocki

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.