Blob Blame History Raw
From: Jeff Brasen <jbrasen@nvidia.com>
Date: Fri, 10 Nov 2023 00:03:21 +0530
Subject: ACPI: thermal: Add Thermal fast Sampling Period (_TFP) support
Git-commit: a2ee7581afd59015b8f9ae01fad131aed9f26f01
Patch-mainline: v6.7 or v6.7-rc9 (next release)
References: bsc#1214377

Add support of "Thermal fast Sampling Period (_TFP)" for passive
cooling.

As per the ACPI specification (ACPI 6.5, Section 11.4.17 "_TFP (Thermal
fast Sampling Period)", _TFP overrides _TSP ("Thermal Sampling Period"
if both are present in a Thermal zone.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Co-developed-by: Sumit Gupta <sumitg@nvidia.com>
Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
[ rjw: Changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Ivan T. Ivanov <iivanov@suse.de>
---
 drivers/acpi/thermal.c |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -102,7 +102,7 @@ struct acpi_thermal_passive {
 	struct acpi_handle_list devices;
 	unsigned long tc1;
 	unsigned long tc2;
-	unsigned long tsp;
+	unsigned long delay;
 };
 
 struct acpi_thermal_active {
@@ -286,12 +286,18 @@ static void __acpi_thermal_trips_update(
 				else
 					tz->trips.passive.tc2 = tmp;
 
-				status = acpi_evaluate_integer(tz->device->handle,
-							       "_TSP", NULL, &tmp);
-				if (ACPI_FAILURE(status))
-					tz->trips.passive.trip.valid = false;
-				else
-					tz->trips.passive.tsp = tmp;
+				status = acpi_evaluate_integer(tz->device->handle, 
+							       "_TFP", NULL, &tmp);
+				if (ACPI_SUCCESS(status)) {
+					tz->trips.passive.delay = tmp;
+				} else {
+					status = acpi_evaluate_integer(tz->device->handle,
+								       "_TSP", NULL, &tmp);
+					if (ACPI_FAILURE(status))
+						tz->trips.passive.trip.valid = false;
+					else
+						tz->trips.passive.delay = tmp * 100;
+				}
 			}
 		}
 	}
@@ -696,7 +702,7 @@ static int acpi_thermal_register_thermal
 
 	if (tz->trips.passive.trip.valid) {
 		trip_count++;
-		passive_delay = tz->trips.passive.tsp * 100;
+		passive_delay = tz->trips.passive.delay;
 	}
 
 	for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].trip.valid; i++)