diff mbox series

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

Message ID 20230817093011.1378-2-sumitg@nvidia.com (mailing list archive)
State Changes Requested, archived
Headers show
Series Add support for _TFP and configurable throttle pctg | expand

Commit Message

Sumit Gupta Aug. 17, 2023, 9:30 a.m. UTC
From: Jeff Brasen <jbrasen@nvidia.com>

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

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

Comments

Rafael J. Wysocki Aug. 18, 2023, 6:33 p.m. UTC | #1
On Thu, Aug 17, 2023 at 11:30 AM Sumit Gupta <sumitg@nvidia.com> wrote:
>
> From: Jeff Brasen <jbrasen@nvidia.com>
>
> Add support for Thermal fast Sampling Period (_TFP) for Passive cooling.
> As per UEFI spec,

You mean the ACPI spec I suppose?  It would be good to give the
relevant section number and title.

>  _TFP overrides the "Thermal Sampling Period (_TSP)"
>  if both are present in a Thermal zone.
>
> Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
> Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
> ---
>  drivers/acpi/thermal.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
> index f9f6ebb08fdb..5dee3722509c 100644
> --- a/drivers/acpi/thermal.c
> +++ b/drivers/acpi/thermal.c
> @@ -111,7 +111,7 @@ struct acpi_thermal_passive {
>         unsigned long temperature;
>         unsigned long tc1;
>         unsigned long tc2;
> -       unsigned long tsp;
> +       unsigned long sampling_period;
>         bool valid;
>  };
>
> @@ -289,11 +289,18 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
>                                         tz->trips.passive.tc2 = tmp;
>
>                                 status = acpi_evaluate_integer(tz->device->handle,
> -                                                              "_TSP", NULL, &tmp);
> -                               if (ACPI_FAILURE(status))
> -                                       tz->trips.passive.valid = false;
> -                               else
> -                                       tz->trips.passive.tsp = tmp;
> +                                                              "_TFP", NULL, &tmp);
> +                               if (ACPI_FAILURE(status)) {
> +                                       status = acpi_evaluate_integer(tz->device->handle,
> +                                                                      "_TSP", NULL, &tmp);
> +                                       if (ACPI_FAILURE(status))
> +                                               tz->trips.passive.valid = false;
> +                                       else
> +                                               tz->trips.passive.sampling_period = tmp * 100;
> +
> +                               } else {
> +                                       tz->trips.passive.sampling_period = tmp;
> +                               }
>                         }
>                 }
>         }
> @@ -765,7 +772,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
>         if (tz->trips.passive.valid)
>                 tz->thermal_zone = thermal_zone_device_register("acpitz", trips, 0, tz,
>                                                                 &acpi_thermal_zone_ops, NULL,
> -                                                               tz->trips.passive.tsp * 100,
> +                                                               tz->trips.passive.sampling_period,
>                                                                 tz->polling_frequency * 100);
>         else
>                 tz->thermal_zone =
> --

So this needs to be rebased on top of the current linux-next branch in
linux-pm.git or on top of the acpi-thermal branch in there.
Sumit Gupta Aug. 21, 2023, 11:48 a.m. UTC | #2
On 19/08/23 00:03, Rafael J. Wysocki wrote:
> External email: Use caution opening links or attachments
> 
> 
> On Thu, Aug 17, 2023 at 11:30 AM Sumit Gupta <sumitg@nvidia.com> wrote:
>>
>> From: Jeff Brasen <jbrasen@nvidia.com>
>>
>> Add support for Thermal fast Sampling Period (_TFP) for Passive cooling.
>> As per UEFI spec,
> 
> You mean the ACPI spec I suppose?  It would be good to give the
> relevant section number and title.
> 

Yes, It's the ACPI Spec 6.4. Section and title are "11.4.17. _TFP 
(Thermal fast Sampling Period)". I will add it in description in v2.
Thank you for correcting.

>>   _TFP overrides the "Thermal Sampling Period (_TSP)"
>>   if both are present in a Thermal zone.
>>
>> Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
>> Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
>> ---
>>   drivers/acpi/thermal.c | 21 ++++++++++++++-------
>>   1 file changed, 14 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
>> index f9f6ebb08fdb..5dee3722509c 100644
>> --- a/drivers/acpi/thermal.c
>> +++ b/drivers/acpi/thermal.c
>> @@ -111,7 +111,7 @@ struct acpi_thermal_passive {
>>          unsigned long temperature;
>>          unsigned long tc1;
>>          unsigned long tc2;
>> -       unsigned long tsp;
>> +       unsigned long sampling_period;
>>          bool valid;
>>   };
>>
>> @@ -289,11 +289,18 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
>>                                          tz->trips.passive.tc2 = tmp;
>>
>>                                  status = acpi_evaluate_integer(tz->device->handle,
>> -                                                              "_TSP", NULL, &tmp);
>> -                               if (ACPI_FAILURE(status))
>> -                                       tz->trips.passive.valid = false;
>> -                               else
>> -                                       tz->trips.passive.tsp = tmp;
>> +                                                              "_TFP", NULL, &tmp);
>> +                               if (ACPI_FAILURE(status)) {
>> +                                       status = acpi_evaluate_integer(tz->device->handle,
>> +                                                                      "_TSP", NULL, &tmp);
>> +                                       if (ACPI_FAILURE(status))
>> +                                               tz->trips.passive.valid = false;
>> +                                       else
>> +                                               tz->trips.passive.sampling_period = tmp * 100;
>> +
>> +                               } else {
>> +                                       tz->trips.passive.sampling_period = tmp;
>> +                               }
>>                          }
>>                  }
>>          }
>> @@ -765,7 +772,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
>>          if (tz->trips.passive.valid)
>>                  tz->thermal_zone = thermal_zone_device_register("acpitz", trips, 0, tz,
>>                                                                  &acpi_thermal_zone_ops, NULL,
>> -                                                               tz->trips.passive.tsp * 100,
>> +                                                               tz->trips.passive.sampling_period,
>>                                                                  tz->polling_frequency * 100);
>>          else
>>                  tz->thermal_zone =
>> --
> 
> So this needs to be rebased on top of the current linux-next branch in
> linux-pm.git or on top of the acpi-thermal branch in there.

Will rebase and send v2.

Thank you,
Sumit Gupta
diff mbox series

Patch

diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index f9f6ebb08fdb..5dee3722509c 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -111,7 +111,7 @@  struct acpi_thermal_passive {
 	unsigned long temperature;
 	unsigned long tc1;
 	unsigned long tc2;
-	unsigned long tsp;
+	unsigned long sampling_period;
 	bool valid;
 };
 
@@ -289,11 +289,18 @@  static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
 					tz->trips.passive.tc2 = tmp;
 
 				status = acpi_evaluate_integer(tz->device->handle,
-							       "_TSP", NULL, &tmp);
-				if (ACPI_FAILURE(status))
-					tz->trips.passive.valid = false;
-				else
-					tz->trips.passive.tsp = tmp;
+							       "_TFP", NULL, &tmp);
+				if (ACPI_FAILURE(status)) {
+					status = acpi_evaluate_integer(tz->device->handle,
+								       "_TSP", NULL, &tmp);
+					if (ACPI_FAILURE(status))
+						tz->trips.passive.valid = false;
+					else
+						tz->trips.passive.sampling_period = tmp * 100;
+
+				} else {
+					tz->trips.passive.sampling_period = tmp;
+				}
 			}
 		}
 	}
@@ -765,7 +772,7 @@  static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
 	if (tz->trips.passive.valid)
 		tz->thermal_zone = thermal_zone_device_register("acpitz", trips, 0, tz,
 								&acpi_thermal_zone_ops, NULL,
-								tz->trips.passive.tsp * 100,
+								tz->trips.passive.sampling_period,
 								tz->polling_frequency * 100);
 	else
 		tz->thermal_zone =