[v6,1/2] ACPI: thermal: Add Thermal fast Sampling Period (_TFP) support

Message ID 20231109183322.28039-2-sumitg@nvidia.com
State New
Headers
Series Add support for _TFP and change throttle pctg |

Commit Message

Sumit Gupta Nov. 9, 2023, 6:33 p.m. UTC
  From: Jeff Brasen <jbrasen@nvidia.com>

Add support of "Thermal fast Sampling Period (_TFP)" for Passive cooling.
As per [1], _TFP overrides the "Thermal Sampling Period (_TSP)" if both
are present in a Thermal zone.

[1] ACPI Specification 6.4 - section 11.4.17. _TFP (Thermal fast Sampling
    Period)"

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Co-developed-by: Sumit Gupta <sumitg@nvidia.com>
Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
---
 drivers/acpi/thermal.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
  

Comments

Rafael J. Wysocki Nov. 21, 2023, 7:59 p.m. UTC | #1
On Thu, Nov 9, 2023 at 7:34 PM Sumit Gupta <sumitg@nvidia.com> wrote:
>
> From: Jeff Brasen <jbrasen@nvidia.com>
>
> Add support of "Thermal fast Sampling Period (_TFP)" for Passive cooling.
> As per [1], _TFP overrides the "Thermal Sampling Period (_TSP)" if both
> are present in a Thermal zone.
>
> [1] ACPI Specification 6.4 - section 11.4.17. _TFP (Thermal fast Sampling
>     Period)"
>
> Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
> Co-developed-by: Sumit Gupta <sumitg@nvidia.com>
> Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
> ---
>  drivers/acpi/thermal.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
> index f74d81abdbfc..3b75eb2260d7 100644
> --- a/drivers/acpi/thermal.c
> +++ b/drivers/acpi/thermal.c
> @@ -90,7 +90,7 @@ struct acpi_thermal_passive {
>         struct acpi_thermal_trip trip;
>         unsigned long tc1;
>         unsigned long tc2;
> -       unsigned long tsp;
> +       unsigned long delay;
>  };
>
>  struct acpi_thermal_active {
> @@ -404,11 +404,17 @@ static bool passive_trip_params_init(struct acpi_thermal *tz)
>
>         tz->trips.passive.tc2 = tmp;
>
> +       status = acpi_evaluate_integer(tz->device->handle, "_TFP", NULL, &tmp);
> +       if (ACPI_SUCCESS(status)) {
> +               tz->trips.passive.delay = tmp;
> +               return true;
> +       }
> +
>         status = acpi_evaluate_integer(tz->device->handle, "_TSP", NULL, &tmp);
>         if (ACPI_FAILURE(status))
>                 return false;
>
> -       tz->trips.passive.tsp = tmp;
> +       tz->trips.passive.delay = tmp * 100;
>
>         return true;
>  }
> @@ -904,7 +910,7 @@ static int acpi_thermal_add(struct acpi_device *device)
>
>         acpi_trip = &tz->trips.passive.trip;
>         if (acpi_thermal_trip_valid(acpi_trip)) {
> -               passive_delay = tz->trips.passive.tsp * 100;
> +               passive_delay = tz->trips.passive.delay;
>
>                 trip->type = THERMAL_TRIP_PASSIVE;
>                 trip->temperature = acpi_thermal_temp(tz, acpi_trip->temp_dk);
> --

So does the second patch in the series really depend on this one?

If not, I can apply it I think.
  
Sumit Gupta Nov. 22, 2023, 12:55 p.m. UTC | #2
On 22/11/23 01:29, Rafael J. Wysocki wrote:
> External email: Use caution opening links or attachments
> 
> 
> On Thu, Nov 9, 2023 at 7:34 PM Sumit Gupta <sumitg@nvidia.com> wrote:
>>
>> From: Jeff Brasen <jbrasen@nvidia.com>
>>
>> Add support of "Thermal fast Sampling Period (_TFP)" for Passive cooling.
>> As per [1], _TFP overrides the "Thermal Sampling Period (_TSP)" if both
>> are present in a Thermal zone.
>>
>> [1] ACPI Specification 6.4 - section 11.4.17. _TFP (Thermal fast Sampling
>>      Period)"
>>
>> Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
>> Co-developed-by: Sumit Gupta <sumitg@nvidia.com>
>> Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
>> ---
>>   drivers/acpi/thermal.c | 12 +++++++++---
>>   1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
>> index f74d81abdbfc..3b75eb2260d7 100644
>> --- a/drivers/acpi/thermal.c
>> +++ b/drivers/acpi/thermal.c
>> @@ -90,7 +90,7 @@ struct acpi_thermal_passive {
>>          struct acpi_thermal_trip trip;
>>          unsigned long tc1;
>>          unsigned long tc2;
>> -       unsigned long tsp;
>> +       unsigned long delay;
>>   };
>>
>>   struct acpi_thermal_active {
>> @@ -404,11 +404,17 @@ static bool passive_trip_params_init(struct acpi_thermal *tz)
>>
>>          tz->trips.passive.tc2 = tmp;
>>
>> +       status = acpi_evaluate_integer(tz->device->handle, "_TFP", NULL, &tmp);
>> +       if (ACPI_SUCCESS(status)) {
>> +               tz->trips.passive.delay = tmp;
>> +               return true;
>> +       }
>> +
>>          status = acpi_evaluate_integer(tz->device->handle, "_TSP", NULL, &tmp);
>>          if (ACPI_FAILURE(status))
>>                  return false;
>>
>> -       tz->trips.passive.tsp = tmp;
>> +       tz->trips.passive.delay = tmp * 100;
>>
>>          return true;
>>   }
>> @@ -904,7 +910,7 @@ static int acpi_thermal_add(struct acpi_device *device)
>>
>>          acpi_trip = &tz->trips.passive.trip;
>>          if (acpi_thermal_trip_valid(acpi_trip)) {
>> -               passive_delay = tz->trips.passive.tsp * 100;
>> +               passive_delay = tz->trips.passive.delay;
>>
>>                  trip->type = THERMAL_TRIP_PASSIVE;
>>                  trip->temperature = acpi_thermal_temp(tz, acpi_trip->temp_dk);
>> --
> 
> So does the second patch in the series really depend on this one?
> 
> If not, I can apply it I think.

Yes, this patch can be applied independently. Thank you!

Best Regards,
Sumit Gupta
  
Rafael J. Wysocki Nov. 22, 2023, 1:34 p.m. UTC | #3
On Wed, Nov 22, 2023 at 1:55 PM Sumit Gupta <sumitg@nvidia.com> wrote:
>
>
>
> On 22/11/23 01:29, Rafael J. Wysocki wrote:
> > External email: Use caution opening links or attachments
> >
> >
> > On Thu, Nov 9, 2023 at 7:34 PM Sumit Gupta <sumitg@nvidia.com> wrote:
> >>
> >> From: Jeff Brasen <jbrasen@nvidia.com>
> >>
> >> Add support of "Thermal fast Sampling Period (_TFP)" for Passive cooling.
> >> As per [1], _TFP overrides the "Thermal Sampling Period (_TSP)" if both
> >> are present in a Thermal zone.
> >>
> >> [1] ACPI Specification 6.4 - section 11.4.17. _TFP (Thermal fast Sampling
> >>      Period)"
> >>
> >> Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
> >> Co-developed-by: Sumit Gupta <sumitg@nvidia.com>
> >> Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
> >> ---
> >>   drivers/acpi/thermal.c | 12 +++++++++---
> >>   1 file changed, 9 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
> >> index f74d81abdbfc..3b75eb2260d7 100644
> >> --- a/drivers/acpi/thermal.c
> >> +++ b/drivers/acpi/thermal.c
> >> @@ -90,7 +90,7 @@ struct acpi_thermal_passive {
> >>          struct acpi_thermal_trip trip;
> >>          unsigned long tc1;
> >>          unsigned long tc2;
> >> -       unsigned long tsp;
> >> +       unsigned long delay;
> >>   };
> >>
> >>   struct acpi_thermal_active {
> >> @@ -404,11 +404,17 @@ static bool passive_trip_params_init(struct acpi_thermal *tz)
> >>
> >>          tz->trips.passive.tc2 = tmp;
> >>
> >> +       status = acpi_evaluate_integer(tz->device->handle, "_TFP", NULL, &tmp);
> >> +       if (ACPI_SUCCESS(status)) {
> >> +               tz->trips.passive.delay = tmp;
> >> +               return true;
> >> +       }
> >> +
> >>          status = acpi_evaluate_integer(tz->device->handle, "_TSP", NULL, &tmp);
> >>          if (ACPI_FAILURE(status))
> >>                  return false;
> >>
> >> -       tz->trips.passive.tsp = tmp;
> >> +       tz->trips.passive.delay = tmp * 100;
> >>
> >>          return true;
> >>   }
> >> @@ -904,7 +910,7 @@ static int acpi_thermal_add(struct acpi_device *device)
> >>
> >>          acpi_trip = &tz->trips.passive.trip;
> >>          if (acpi_thermal_trip_valid(acpi_trip)) {
> >> -               passive_delay = tz->trips.passive.tsp * 100;
> >> +               passive_delay = tz->trips.passive.delay;
> >>
> >>                  trip->type = THERMAL_TRIP_PASSIVE;
> >>                  trip->temperature = acpi_thermal_temp(tz, acpi_trip->temp_dk);
> >> --
> >
> > So does the second patch in the series really depend on this one?
> >
> > If not, I can apply it I think.
>
> Yes, this patch can be applied independently. Thank you!

OK, applied as 6.8 material (with some changelog edits), thanks!
  

Patch

diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index f74d81abdbfc..3b75eb2260d7 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -90,7 +90,7 @@  struct acpi_thermal_passive {
 	struct acpi_thermal_trip trip;
 	unsigned long tc1;
 	unsigned long tc2;
-	unsigned long tsp;
+	unsigned long delay;
 };
 
 struct acpi_thermal_active {
@@ -404,11 +404,17 @@  static bool passive_trip_params_init(struct acpi_thermal *tz)
 
 	tz->trips.passive.tc2 = tmp;
 
+	status = acpi_evaluate_integer(tz->device->handle, "_TFP", NULL, &tmp);
+	if (ACPI_SUCCESS(status)) {
+		tz->trips.passive.delay = tmp;
+		return true;
+	}
+
 	status = acpi_evaluate_integer(tz->device->handle, "_TSP", NULL, &tmp);
 	if (ACPI_FAILURE(status))
 		return false;
 
-	tz->trips.passive.tsp = tmp;
+	tz->trips.passive.delay = tmp * 100;
 
 	return true;
 }
@@ -904,7 +910,7 @@  static int acpi_thermal_add(struct acpi_device *device)
 
 	acpi_trip = &tz->trips.passive.trip;
 	if (acpi_thermal_trip_valid(acpi_trip)) {
-		passive_delay = tz->trips.passive.tsp * 100;
+		passive_delay = tz->trips.passive.delay;
 
 		trip->type = THERMAL_TRIP_PASSIVE;
 		trip->temperature = acpi_thermal_temp(tz, acpi_trip->temp_dk);