linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: intel: Initialize RW trip to THERMAL_TEMP_INVALID
@ 2021-04-30 12:23 Srinivas Pandruvada
  2021-05-12 15:52 ` Srinivas Pandruvada
  0 siblings, 1 reply; 4+ messages in thread
From: Srinivas Pandruvada @ 2021-04-30 12:23 UTC (permalink / raw)
  To: rui.zhang, daniel.lezcano, amitk
  Cc: linux-pm, linux-kernel, Srinivas Pandruvada, stable

After commit 81ad4276b505 ("Thermal: Ignore invalid trip points") all
user_space governor notifications via RW trip point is broken in intel
thermal drivers. This commits marks trip_points with value of 0 during
call to thermal_zone_device_register() as invalid. RW trip points can be
0 as user space will set the correct trip temperature later.

During driver init, x86_package_temp and all int340x drivers sets RW trip
temperature as 0. This results in all these trips marked as invalid by
the thermal core.

To fix this initialize RW trips to THERMAL_TEMP_INVALID instead of 0.

Cc: <stable@vger.kernel.org>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 4 ++++
 drivers/thermal/intel/x86_pkg_temp_thermal.c                 | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
index d1248ba943a4..62c0aa5d0783 100644
--- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
+++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
@@ -237,6 +237,8 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
 	if (ACPI_FAILURE(status))
 		trip_cnt = 0;
 	else {
+		int i;
+
 		int34x_thermal_zone->aux_trips =
 			kcalloc(trip_cnt,
 				sizeof(*int34x_thermal_zone->aux_trips),
@@ -247,6 +249,8 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
 		}
 		trip_mask = BIT(trip_cnt) - 1;
 		int34x_thermal_zone->aux_trip_nr = trip_cnt;
+		for (i = 0; i < trip_cnt; ++i)
+			int34x_thermal_zone->aux_trips[i] = THERMAL_TEMP_INVALID;
 	}
 
 	trip_cnt = int340x_thermal_read_trips(int34x_thermal_zone);
diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c b/drivers/thermal/intel/x86_pkg_temp_thermal.c
index 295742e83960..4d8edc61a78b 100644
--- a/drivers/thermal/intel/x86_pkg_temp_thermal.c
+++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c
@@ -166,7 +166,7 @@ static int sys_get_trip_temp(struct thermal_zone_device *tzd,
 	if (thres_reg_value)
 		*temp = zonedev->tj_max - thres_reg_value * 1000;
 	else
-		*temp = 0;
+		*temp = THERMAL_TEMP_INVALID;
 	pr_debug("sys_get_trip_temp %d\n", *temp);
 
 	return 0;
-- 
2.25.1


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

* Re: [PATCH] thermal: intel: Initialize RW trip to THERMAL_TEMP_INVALID
  2021-04-30 12:23 [PATCH] thermal: intel: Initialize RW trip to THERMAL_TEMP_INVALID Srinivas Pandruvada
@ 2021-05-12 15:52 ` Srinivas Pandruvada
  2021-05-12 15:54   ` Daniel Lezcano
  0 siblings, 1 reply; 4+ messages in thread
From: Srinivas Pandruvada @ 2021-05-12 15:52 UTC (permalink / raw)
  To: rui.zhang, daniel.lezcano, amitk; +Cc: linux-pm, linux-kernel, stable

On Fri, 2021-04-30 at 05:23 -0700, Srinivas Pandruvada wrote:
> After commit 81ad4276b505 ("Thermal: Ignore invalid trip points") all
> user_space governor notifications via RW trip point is broken in
> intel
> thermal drivers. This commits marks trip_points with value of 0
> during
> call to thermal_zone_device_register() as invalid. RW trip points can
> be
> 0 as user space will set the correct trip temperature later.
> 
> During driver init, x86_package_temp and all int340x drivers sets RW
> trip
> temperature as 0. This results in all these trips marked as invalid
> by
> the thermal core.
> 
> To fix this initialize RW trips to THERMAL_TEMP_INVALID instead of 0.
> 
Any chance that we can take care of this issue during 5.13-rc*?

Thanks,
Srinivas

> Cc: <stable@vger.kernel.org>
> Signed-off-by: Srinivas Pandruvada <
> srinivas.pandruvada@linux.intel.com>
> ---
>  drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 4
> ++++
>  drivers/thermal/intel/x86_pkg_temp_thermal.c                 | 2 +-
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git
> a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
> b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
> index d1248ba943a4..62c0aa5d0783 100644
> --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
> +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
> @@ -237,6 +237,8 @@ struct int34x_thermal_zone
> *int340x_thermal_zone_add(struct acpi_device *adev,
>         if (ACPI_FAILURE(status))
>                 trip_cnt = 0;
>         else {
> +               int i;
> +
>                 int34x_thermal_zone->aux_trips =
>                         kcalloc(trip_cnt,
>                                 sizeof(*int34x_thermal_zone-
> >aux_trips),
> @@ -247,6 +249,8 @@ struct int34x_thermal_zone
> *int340x_thermal_zone_add(struct acpi_device *adev,
>                 }
>                 trip_mask = BIT(trip_cnt) - 1;
>                 int34x_thermal_zone->aux_trip_nr = trip_cnt;
> +               for (i = 0; i < trip_cnt; ++i)
> +                       int34x_thermal_zone->aux_trips[i] =
> THERMAL_TEMP_INVALID;
>         }
>  
>         trip_cnt = int340x_thermal_read_trips(int34x_thermal_zone);
> diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c
> b/drivers/thermal/intel/x86_pkg_temp_thermal.c
> index 295742e83960..4d8edc61a78b 100644
> --- a/drivers/thermal/intel/x86_pkg_temp_thermal.c
> +++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c
> @@ -166,7 +166,7 @@ static int sys_get_trip_temp(struct
> thermal_zone_device *tzd,
>         if (thres_reg_value)
>                 *temp = zonedev->tj_max - thres_reg_value * 1000;
>         else
> -               *temp = 0;
> +               *temp = THERMAL_TEMP_INVALID;
>         pr_debug("sys_get_trip_temp %d\n", *temp);
>  
>         return 0;



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

* Re: [PATCH] thermal: intel: Initialize RW trip to THERMAL_TEMP_INVALID
  2021-05-12 15:52 ` Srinivas Pandruvada
@ 2021-05-12 15:54   ` Daniel Lezcano
  2021-05-12 16:02     ` Srinivas Pandruvada
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Lezcano @ 2021-05-12 15:54 UTC (permalink / raw)
  To: Srinivas Pandruvada, rui.zhang, amitk; +Cc: linux-pm, linux-kernel, stable

On 12/05/2021 17:52, Srinivas Pandruvada wrote:
> On Fri, 2021-04-30 at 05:23 -0700, Srinivas Pandruvada wrote:
>> After commit 81ad4276b505 ("Thermal: Ignore invalid trip points") all
>> user_space governor notifications via RW trip point is broken in
>> intel
>> thermal drivers. This commits marks trip_points with value of 0
>> during
>> call to thermal_zone_device_register() as invalid. RW trip points can
>> be
>> 0 as user space will set the correct trip temperature later.
>>
>> During driver init, x86_package_temp and all int340x drivers sets RW
>> trip
>> temperature as 0. This results in all these trips marked as invalid
>> by
>> the thermal core.
>>
>> To fix this initialize RW trips to THERMAL_TEMP_INVALID instead of 0.
>>
> Any chance that we can take care of this issue during 5.13-rc*?

Yes, I will take care of it


>> Cc: <stable@vger.kernel.org>
>> Signed-off-by: Srinivas Pandruvada <
>> srinivas.pandruvada@linux.intel.com>
>> ---
>>  drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 4
>> ++++
>>  drivers/thermal/intel/x86_pkg_temp_thermal.c                 | 2 +-
>>  2 files changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git
>> a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
>> b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
>> index d1248ba943a4..62c0aa5d0783 100644
>> --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
>> +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
>> @@ -237,6 +237,8 @@ struct int34x_thermal_zone
>> *int340x_thermal_zone_add(struct acpi_device *adev,
>>         if (ACPI_FAILURE(status))
>>                 trip_cnt = 0;
>>         else {
>> +               int i;
>> +
>>                 int34x_thermal_zone->aux_trips =
>>                         kcalloc(trip_cnt,
>>                                 sizeof(*int34x_thermal_zone-
>>> aux_trips),
>> @@ -247,6 +249,8 @@ struct int34x_thermal_zone
>> *int340x_thermal_zone_add(struct acpi_device *adev,
>>                 }
>>                 trip_mask = BIT(trip_cnt) - 1;
>>                 int34x_thermal_zone->aux_trip_nr = trip_cnt;
>> +               for (i = 0; i < trip_cnt; ++i)
>> +                       int34x_thermal_zone->aux_trips[i] =
>> THERMAL_TEMP_INVALID;
>>         }
>>  
>>         trip_cnt = int340x_thermal_read_trips(int34x_thermal_zone);
>> diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c
>> b/drivers/thermal/intel/x86_pkg_temp_thermal.c
>> index 295742e83960..4d8edc61a78b 100644
>> --- a/drivers/thermal/intel/x86_pkg_temp_thermal.c
>> +++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c
>> @@ -166,7 +166,7 @@ static int sys_get_trip_temp(struct
>> thermal_zone_device *tzd,
>>         if (thres_reg_value)
>>                 *temp = zonedev->tj_max - thres_reg_value * 1000;
>>         else
>> -               *temp = 0;
>> +               *temp = THERMAL_TEMP_INVALID;
>>         pr_debug("sys_get_trip_temp %d\n", *temp);
>>  
>>         return 0;
> 
> 


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

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

* Re: [PATCH] thermal: intel: Initialize RW trip to THERMAL_TEMP_INVALID
  2021-05-12 15:54   ` Daniel Lezcano
@ 2021-05-12 16:02     ` Srinivas Pandruvada
  0 siblings, 0 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2021-05-12 16:02 UTC (permalink / raw)
  To: Daniel Lezcano, rui.zhang, amitk; +Cc: linux-pm, linux-kernel, stable

On Wed, 2021-05-12 at 17:54 +0200, Daniel Lezcano wrote:
> On 12/05/2021 17:52, Srinivas Pandruvada wrote:
> > On Fri, 2021-04-30 at 05:23 -0700, Srinivas Pandruvada wrote:
> > > After commit 81ad4276b505 ("Thermal: Ignore invalid trip points")
> > > all
> > > user_space governor notifications via RW trip point is broken in
> > > intel
> > > thermal drivers. This commits marks trip_points with value of 0
> > > during
> > > call to thermal_zone_device_register() as invalid. RW trip points
> > > can
> > > be
> > > 0 as user space will set the correct trip temperature later.
> > > 
> > > During driver init, x86_package_temp and all int340x drivers sets
> > > RW
> > > trip
> > > temperature as 0. This results in all these trips marked as
> > > invalid
> > > by
> > > the thermal core.
> > > 
> > > To fix this initialize RW trips to THERMAL_TEMP_INVALID instead
> > > of 0.
> > > 
> > Any chance that we can take care of this issue during 5.13-rc*?
> 
> Yes, I will take care of it

Thanks.

> 
> 
> > > Cc: <stable@vger.kernel.org>
> > > Signed-off-by: Srinivas Pandruvada <
> > > srinivas.pandruvada@linux.intel.com>
> > > ---
> > >  drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 4
> > > ++++
> > >  drivers/thermal/intel/x86_pkg_temp_thermal.c                 | 2
> > > +-
> > >  2 files changed, 5 insertions(+), 1 deletion(-)
> > > 
> > > diff --git
> > > a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
> > > b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
> > > index d1248ba943a4..62c0aa5d0783 100644
> > > ---
> > > a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
> > > +++
> > > b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
> > > @@ -237,6 +237,8 @@ struct int34x_thermal_zone
> > > *int340x_thermal_zone_add(struct acpi_device *adev,
> > >         if (ACPI_FAILURE(status))
> > >                 trip_cnt = 0;
> > >         else {
> > > +               int i;
> > > +
> > >                 int34x_thermal_zone->aux_trips =
> > >                         kcalloc(trip_cnt,
> > >                                 sizeof(*int34x_thermal_zone-
> > > > aux_trips),
> > > @@ -247,6 +249,8 @@ struct int34x_thermal_zone
> > > *int340x_thermal_zone_add(struct acpi_device *adev,
> > >                 }
> > >                 trip_mask = BIT(trip_cnt) - 1;
> > >                 int34x_thermal_zone->aux_trip_nr = trip_cnt;
> > > +               for (i = 0; i < trip_cnt; ++i)
> > > +                       int34x_thermal_zone->aux_trips[i] =
> > > THERMAL_TEMP_INVALID;
> > >         }
> > >  
> > >         trip_cnt =
> > > int340x_thermal_read_trips(int34x_thermal_zone);
> > > diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c
> > > b/drivers/thermal/intel/x86_pkg_temp_thermal.c
> > > index 295742e83960..4d8edc61a78b 100644
> > > --- a/drivers/thermal/intel/x86_pkg_temp_thermal.c
> > > +++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c
> > > @@ -166,7 +166,7 @@ static int sys_get_trip_temp(struct
> > > thermal_zone_device *tzd,
> > >         if (thres_reg_value)
> > >                 *temp = zonedev->tj_max - thres_reg_value * 1000;
> > >         else
> > > -               *temp = 0;
> > > +               *temp = THERMAL_TEMP_INVALID;
> > >         pr_debug("sys_get_trip_temp %d\n", *temp);
> > >  
> > >         return 0;
> > 
> > 
> 
> 



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

end of thread, other threads:[~2021-05-12 18:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-30 12:23 [PATCH] thermal: intel: Initialize RW trip to THERMAL_TEMP_INVALID Srinivas Pandruvada
2021-05-12 15:52 ` Srinivas Pandruvada
2021-05-12 15:54   ` Daniel Lezcano
2021-05-12 16:02     ` Srinivas Pandruvada

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