* [PATCH v2 01/11] thermal/acpi: Remove the intermediate acpi_thermal_trip structure
[not found] <20230203174429.3375691-1-daniel.lezcano@linaro.org>
@ 2023-02-03 17:44 ` Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 02/11] thermal/acpi: Change to a common " Daniel Lezcano
` (9 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Daniel Lezcano @ 2023-02-03 17:44 UTC (permalink / raw)
To: rjw
Cc: daniel.lezcano, linux-acpi, linux-pm, Rafael J. Wysocki,
Zhang Rui, Len Brown, open list
The struct acpi_thermal_trips() contains the critical, hot, passive
and active trip points structure. In order to use the generic thermal
trips which is a simple array, let's move out those fields in the
struct acpi_thermal instead of having them encapsulated in an
intermediate structure.
No functional changes, just simplification of code.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/acpi/thermal.c | 197 +++++++++++++++++++++--------------------
1 file changed, 100 insertions(+), 97 deletions(-)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 0b4b844f9d4c..0dbce190cacc 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -166,7 +166,10 @@ struct acpi_thermal {
volatile u8 zombie;
struct acpi_thermal_flags flags;
struct acpi_thermal_state state;
- struct acpi_thermal_trips trips;
+ struct acpi_thermal_critical critical;
+ struct acpi_thermal_hot hot;
+ struct acpi_thermal_passive passive;
+ struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE];
struct acpi_handle_list devices;
struct thermal_zone_device *thermal_zone;
int kelvin_offset; /* in millidegrees */
@@ -271,7 +274,8 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
/* Critical Shutdown */
if (flag & ACPI_TRIPS_CRITICAL) {
status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &tmp);
- tz->trips.critical.temperature = tmp;
+ tz->critical.temperature = tmp;
+
/*
* Treat freezing temperatures as invalid as well; some
* BIOSes return really low values and cause reboots at startup.
@@ -279,31 +283,32 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
* ... so lets discard those as invalid.
*/
if (ACPI_FAILURE(status)) {
- tz->trips.critical.flags.valid = 0;
+ tz->critical.flags.valid = 0;
acpi_handle_debug(tz->device->handle,
"No critical threshold\n");
} else if (tmp <= 2732) {
pr_info(FW_BUG "Invalid critical threshold (%llu)\n", tmp);
- tz->trips.critical.flags.valid = 0;
+ tz->critical.flags.valid = 0;
} else {
- tz->trips.critical.flags.valid = 1;
+ tz->critical.flags.valid = 1;
acpi_handle_debug(tz->device->handle,
"Found critical threshold [%lu]\n",
- tz->trips.critical.temperature);
+ tz->critical.temperature);
}
- if (tz->trips.critical.flags.valid) {
+
+ if (tz->critical.flags.valid) {
if (crt == -1) {
- tz->trips.critical.flags.valid = 0;
+ tz->critical.flags.valid = 0;
} else if (crt > 0) {
unsigned long crt_k = celsius_to_deci_kelvin(crt);
/*
* Allow override critical threshold
*/
- if (crt_k > tz->trips.critical.temperature)
+ if (crt_k > tz->critical.temperature)
pr_info("Critical threshold %d C\n", crt);
- tz->trips.critical.temperature = crt_k;
+ tz->critical.temperature = crt_k;
}
}
}
@@ -312,22 +317,22 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
if (flag & ACPI_TRIPS_HOT) {
status = acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, &tmp);
if (ACPI_FAILURE(status)) {
- tz->trips.hot.flags.valid = 0;
+ tz->hot.flags.valid = 0;
acpi_handle_debug(tz->device->handle,
"No hot threshold\n");
} else {
- tz->trips.hot.temperature = tmp;
- tz->trips.hot.flags.valid = 1;
+ tz->hot.temperature = tmp;
+ tz->hot.flags.valid = 1;
acpi_handle_debug(tz->device->handle,
"Found hot threshold [%lu]\n",
- tz->trips.hot.temperature);
+ tz->hot.temperature);
}
}
/* Passive (optional) */
- if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) ||
+ if (((flag & ACPI_TRIPS_PASSIVE) && tz->passive.flags.valid) ||
flag == ACPI_TRIPS_INIT) {
- valid = tz->trips.passive.flags.valid;
+ valid = tz->passive.flags.valid;
if (psv == -1) {
status = AE_SUPPORT;
} else if (psv > 0) {
@@ -339,72 +344,70 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
}
if (ACPI_FAILURE(status)) {
- tz->trips.passive.flags.valid = 0;
+ tz->passive.flags.valid = 0;
} else {
- tz->trips.passive.temperature = tmp;
- tz->trips.passive.flags.valid = 1;
+ tz->passive.temperature = tmp;
+ tz->passive.flags.valid = 1;
if (flag == ACPI_TRIPS_INIT) {
status = acpi_evaluate_integer(tz->device->handle,
"_TC1", NULL, &tmp);
if (ACPI_FAILURE(status))
- tz->trips.passive.flags.valid = 0;
+ tz->passive.flags.valid = 0;
else
- tz->trips.passive.tc1 = tmp;
-
+ tz->passive.tc1 = tmp;
status = acpi_evaluate_integer(tz->device->handle,
"_TC2", NULL, &tmp);
if (ACPI_FAILURE(status))
- tz->trips.passive.flags.valid = 0;
+ tz->passive.flags.valid = 0;
else
- tz->trips.passive.tc2 = tmp;
-
+ tz->passive.tc2 = tmp;
status = acpi_evaluate_integer(tz->device->handle,
"_TSP", NULL, &tmp);
if (ACPI_FAILURE(status))
- tz->trips.passive.flags.valid = 0;
+ tz->passive.flags.valid = 0;
else
- tz->trips.passive.tsp = tmp;
+ tz->passive.tsp = tmp;
}
}
}
- if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.flags.valid) {
+ if ((flag & ACPI_TRIPS_DEVICES) && tz->passive.flags.valid) {
memset(&devices, 0, sizeof(struct acpi_handle_list));
status = acpi_evaluate_reference(tz->device->handle, "_PSL",
NULL, &devices);
if (ACPI_FAILURE(status)) {
acpi_handle_info(tz->device->handle,
"Invalid passive threshold\n");
- tz->trips.passive.flags.valid = 0;
+ tz->passive.flags.valid = 0;
} else {
- tz->trips.passive.flags.valid = 1;
+ tz->passive.flags.valid = 1;
}
- if (memcmp(&tz->trips.passive.devices, &devices,
+ if (memcmp(&tz->passive.devices, &devices,
sizeof(struct acpi_handle_list))) {
- memcpy(&tz->trips.passive.devices, &devices,
+ memcpy(&tz->passive.devices, &devices,
sizeof(struct acpi_handle_list));
ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device");
}
}
if ((flag & ACPI_TRIPS_PASSIVE) || (flag & ACPI_TRIPS_DEVICES)) {
- if (valid != tz->trips.passive.flags.valid)
+ if (valid != tz->passive.flags.valid)
ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "state");
}
/* Active (optional) */
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
- valid = tz->trips.active[i].flags.valid;
+ valid = tz->active[i].flags.valid;
if (act == -1)
break; /* disable all active trip points */
if (flag == ACPI_TRIPS_INIT || ((flag & ACPI_TRIPS_ACTIVE) &&
- tz->trips.active[i].flags.valid)) {
+ tz->active[i].flags.valid)) {
status = acpi_evaluate_integer(tz->device->handle,
name, NULL, &tmp);
if (ACPI_FAILURE(status)) {
- tz->trips.active[i].flags.valid = 0;
+ tz->active[i].flags.valid = 0;
if (i == 0)
break;
@@ -412,50 +415,50 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
break;
if (i == 1)
- tz->trips.active[0].temperature = celsius_to_deci_kelvin(act);
+ tz->active[0].temperature = celsius_to_deci_kelvin(act);
else
/*
* Don't allow override higher than
* the next higher trip point
*/
- tz->trips.active[i-1].temperature =
- (tz->trips.active[i-2].temperature <
+ tz->active[i - 1].temperature =
+ (tz->active[i - 2].temperature <
celsius_to_deci_kelvin(act) ?
- tz->trips.active[i-2].temperature :
+ tz->active[i - 2].temperature :
celsius_to_deci_kelvin(act));
break;
} else {
- tz->trips.active[i].temperature = tmp;
- tz->trips.active[i].flags.valid = 1;
+ tz->active[i].temperature = tmp;
+ tz->active[i].flags.valid = 1;
}
}
name[2] = 'L';
- if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid) {
+ if ((flag & ACPI_TRIPS_DEVICES) && tz->active[i].flags.valid ) {
memset(&devices, 0, sizeof(struct acpi_handle_list));
status = acpi_evaluate_reference(tz->device->handle,
name, NULL, &devices);
if (ACPI_FAILURE(status)) {
acpi_handle_info(tz->device->handle,
"Invalid active%d threshold\n", i);
- tz->trips.active[i].flags.valid = 0;
+ tz->active[i].flags.valid = 0;
} else {
- tz->trips.active[i].flags.valid = 1;
+ tz->active[i].flags.valid = 1;
}
- if (memcmp(&tz->trips.active[i].devices, &devices,
+ if (memcmp(&tz->active[i].devices, &devices,
sizeof(struct acpi_handle_list))) {
- memcpy(&tz->trips.active[i].devices, &devices,
+ memcpy(&tz->active[i].devices, &devices,
sizeof(struct acpi_handle_list));
ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device");
}
}
if ((flag & ACPI_TRIPS_ACTIVE) || (flag & ACPI_TRIPS_DEVICES))
- if (valid != tz->trips.active[i].flags.valid)
+ if (valid != tz->active[i].flags.valid)
ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "state");
- if (!tz->trips.active[i].flags.valid)
+ if (!tz->active[i].flags.valid)
break;
}
@@ -480,12 +483,12 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
if (ret)
return ret;
- valid = tz->trips.critical.flags.valid |
- tz->trips.hot.flags.valid |
- tz->trips.passive.flags.valid;
+ valid = tz->critical.flags.valid |
+ tz->hot.flags.valid |
+ tz->passive.flags.valid;
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
- valid |= tz->trips.active[i].flags.valid;
+ valid |= tz->active[i].flags.valid;
if (!valid) {
pr_warn(FW_BUG "No valid trip found\n");
@@ -522,7 +525,7 @@ static int thermal_get_trip_type(struct thermal_zone_device *thermal,
if (!tz || trip < 0)
return -EINVAL;
- if (tz->trips.critical.flags.valid) {
+ if (tz->critical.flags.valid) {
if (!trip) {
*type = THERMAL_TRIP_CRITICAL;
return 0;
@@ -530,7 +533,7 @@ static int thermal_get_trip_type(struct thermal_zone_device *thermal,
trip--;
}
- if (tz->trips.hot.flags.valid) {
+ if (tz->hot.flags.valid) {
if (!trip) {
*type = THERMAL_TRIP_HOT;
return 0;
@@ -538,7 +541,7 @@ static int thermal_get_trip_type(struct thermal_zone_device *thermal,
trip--;
}
- if (tz->trips.passive.flags.valid) {
+ if (tz->passive.flags.valid) {
if (!trip) {
*type = THERMAL_TRIP_PASSIVE;
return 0;
@@ -546,7 +549,7 @@ static int thermal_get_trip_type(struct thermal_zone_device *thermal,
trip--;
}
- for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].flags.valid; i++) {
+ for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->active[i].flags.valid; i++) {
if (!trip) {
*type = THERMAL_TRIP_ACTIVE;
return 0;
@@ -566,30 +569,30 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
if (!tz || trip < 0)
return -EINVAL;
- if (tz->trips.critical.flags.valid) {
+ if (tz->critical.flags.valid) {
if (!trip) {
*temp = deci_kelvin_to_millicelsius_with_offset(
- tz->trips.critical.temperature,
+ tz->critical.temperature,
tz->kelvin_offset);
return 0;
}
trip--;
}
- if (tz->trips.hot.flags.valid) {
+ if (tz->hot.flags.valid) {
if (!trip) {
*temp = deci_kelvin_to_millicelsius_with_offset(
- tz->trips.hot.temperature,
+ tz->hot.temperature,
tz->kelvin_offset);
return 0;
}
trip--;
}
- if (tz->trips.passive.flags.valid) {
+ if (tz->passive.flags.valid) {
if (!trip) {
*temp = deci_kelvin_to_millicelsius_with_offset(
- tz->trips.passive.temperature,
+ tz->passive.temperature,
tz->kelvin_offset);
return 0;
}
@@ -597,10 +600,10 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
}
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
- tz->trips.active[i].flags.valid; i++) {
+ tz->active[i].flags.valid; i++) {
if (!trip) {
*temp = deci_kelvin_to_millicelsius_with_offset(
- tz->trips.active[i].temperature,
+ tz->active[i].temperature,
tz->kelvin_offset);
return 0;
}
@@ -615,9 +618,9 @@ static int thermal_get_crit_temp(struct thermal_zone_device *thermal,
{
struct acpi_thermal *tz = thermal->devdata;
- if (tz->trips.critical.flags.valid) {
+ if (tz->critical.flags.valid) {
*temperature = deci_kelvin_to_millicelsius_with_offset(
- tz->trips.critical.temperature,
+ tz->critical.temperature,
tz->kelvin_offset);
return 0;
}
@@ -655,8 +658,8 @@ static int thermal_get_trend(struct thermal_zone_device *thermal,
* tz->temperature has already been updated by generic thermal layer,
* before this callback being invoked
*/
- i = tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature) +
- tz->trips.passive.tc2 * (tz->temperature - tz->trips.passive.temperature);
+ i = (tz->passive.tc1 * (tz->temperature - tz->last_temperature)) +
+ (tz->passive.tc2 * (tz->temperature - tz->passive.temperature));
if (i > 0)
*trend = THERMAL_TREND_RAISING;
@@ -701,16 +704,16 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
int trip = -1;
int result = 0;
- if (tz->trips.critical.flags.valid)
+ if (tz->critical.flags.valid)
trip++;
- if (tz->trips.hot.flags.valid)
+ if (tz->hot.flags.valid)
trip++;
- if (tz->trips.passive.flags.valid) {
+ if (tz->passive.flags.valid) {
trip++;
- for (i = 0; i < tz->trips.passive.devices.count; i++) {
- handle = tz->trips.passive.devices.handles[i];
+ for (i = 0; i < tz->passive.devices.count; i++) {
+ handle = tz->passive.devices.handles[i];
dev = acpi_fetch_acpi_dev(handle);
if (dev != device)
continue;
@@ -732,12 +735,12 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
}
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
- if (!tz->trips.active[i].flags.valid)
+ if (!tz->active[i].flags.valid)
break;
trip++;
- for (j = 0; j < tz->trips.active[i].devices.count; j++) {
- handle = tz->trips.active[i].devices.handles[j];
+ for (j = 0; j < tz->active[i].devices.count; j++) {
+ handle = tz->active[i].devices.handles[j];
dev = acpi_fetch_acpi_dev(handle);
if (dev != device)
continue;
@@ -794,28 +797,29 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
acpi_status status;
int i;
- if (tz->trips.critical.flags.valid)
+ if (tz->critical.flags.valid)
trips++;
- if (tz->trips.hot.flags.valid)
+ if (tz->hot.flags.valid)
trips++;
- if (tz->trips.passive.flags.valid)
+ if (tz->passive.flags.valid)
trips++;
- for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].flags.valid;
+ for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->active[i].flags.valid;
i++, trips++);
- if (tz->trips.passive.flags.valid)
- tz->thermal_zone = thermal_zone_device_register("acpitz", trips, 0, tz,
- &acpi_thermal_zone_ops, NULL,
- tz->trips.passive.tsp * 100,
- tz->polling_frequency * 100);
+ if (tz->passive.flags.valid)
+ tz->thermal_zone =
+ thermal_zone_device_register("acpitz", trips, 0, tz,
+ &acpi_thermal_zone_ops, NULL,
+ tz->passive.tsp*100,
+ tz->polling_frequency*100);
else
tz->thermal_zone =
thermal_zone_device_register("acpitz", trips, 0, tz,
- &acpi_thermal_zone_ops, NULL,
- 0, tz->polling_frequency * 100);
+ &acpi_thermal_zone_ops, NULL,
+ 0, tz->polling_frequency * 100);
if (IS_ERR(tz->thermal_zone))
return -ENODEV;
@@ -985,8 +989,8 @@ static int acpi_thermal_get_info(struct acpi_thermal *tz)
*/
static void acpi_thermal_guess_offset(struct acpi_thermal *tz)
{
- if (tz->trips.critical.flags.valid &&
- (tz->trips.critical.temperature % 5) == 1)
+ if (tz->critical.flags.valid &&
+ (tz->critical.temperature % 5) == 1)
tz->kelvin_offset = 273100;
else
tz->kelvin_offset = 273200;
@@ -1094,20 +1098,19 @@ static int acpi_thermal_resume(struct device *dev)
return -EINVAL;
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
- if (!tz->trips.active[i].flags.valid)
+ if (!tz->active[i].flags.valid)
break;
-
- tz->trips.active[i].flags.enabled = 1;
- for (j = 0; j < tz->trips.active[i].devices.count; j++) {
+ tz->active[i].flags.enabled = 1;
+ for (j = 0; j < tz->active[i].devices.count; j++) {
result = acpi_bus_update_power(
- tz->trips.active[i].devices.handles[j],
+ tz->active[i].devices.handles[j],
&power_state);
if (result || (power_state != ACPI_STATE_D0)) {
- tz->trips.active[i].flags.enabled = 0;
+ tz->active[i].flags.enabled = 0;
break;
}
}
- tz->state.active |= tz->trips.active[i].flags.enabled;
+ tz->state.active |= tz->active[i].flags.enabled;
}
acpi_queue_thermal_check(tz);
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 02/11] thermal/acpi: Change to a common acpi_thermal_trip structure
[not found] <20230203174429.3375691-1-daniel.lezcano@linaro.org>
2023-02-03 17:44 ` [PATCH v2 01/11] thermal/acpi: Remove the intermediate acpi_thermal_trip structure Daniel Lezcano
@ 2023-02-03 17:44 ` Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 03/11] thermal/acpi: Convert the acpi thermal trips to an array Daniel Lezcano
` (8 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Daniel Lezcano @ 2023-02-03 17:44 UTC (permalink / raw)
To: rjw
Cc: daniel.lezcano, linux-acpi, linux-pm, Rafael J. Wysocki,
Zhang Rui, Len Brown, open list
The acpi trip point definition are very similar whatever their
types. Instead of creating a different structure for each trip type,
let's define and use a common one.
With this change we move a step forward to the generic trip point.
No functional changes.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/acpi/thermal.c | 35 ++++++-----------------------------
1 file changed, 6 insertions(+), 29 deletions(-)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 0dbce190cacc..e27b0b71fcf8 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -119,36 +119,13 @@ struct acpi_thermal_state_flags {
u8 reserved:6;
};
-struct acpi_thermal_critical {
- struct acpi_thermal_state_flags flags;
- unsigned long temperature;
-};
-
-struct acpi_thermal_hot {
- struct acpi_thermal_state_flags flags;
- unsigned long temperature;
-};
-
-struct acpi_thermal_passive {
+struct acpi_thermal_trip {
struct acpi_thermal_state_flags flags;
+ struct acpi_handle_list devices;
unsigned long temperature;
unsigned long tc1;
unsigned long tc2;
unsigned long tsp;
- struct acpi_handle_list devices;
-};
-
-struct acpi_thermal_active {
- struct acpi_thermal_state_flags flags;
- unsigned long temperature;
- struct acpi_handle_list devices;
-};
-
-struct acpi_thermal_trips {
- struct acpi_thermal_critical critical;
- struct acpi_thermal_hot hot;
- struct acpi_thermal_passive passive;
- struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE];
};
struct acpi_thermal_flags {
@@ -166,10 +143,10 @@ struct acpi_thermal {
volatile u8 zombie;
struct acpi_thermal_flags flags;
struct acpi_thermal_state state;
- struct acpi_thermal_critical critical;
- struct acpi_thermal_hot hot;
- struct acpi_thermal_passive passive;
- struct acpi_thermal_active active[ACPI_THERMAL_MAX_ACTIVE];
+ struct acpi_thermal_trip critical;
+ struct acpi_thermal_trip hot;
+ struct acpi_thermal_trip passive;
+ struct acpi_thermal_trip active[ACPI_THERMAL_MAX_ACTIVE];
struct acpi_handle_list devices;
struct thermal_zone_device *thermal_zone;
int kelvin_offset; /* in millidegrees */
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 03/11] thermal/acpi: Convert the acpi thermal trips to an array
[not found] <20230203174429.3375691-1-daniel.lezcano@linaro.org>
2023-02-03 17:44 ` [PATCH v2 01/11] thermal/acpi: Remove the intermediate acpi_thermal_trip structure Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 02/11] thermal/acpi: Change to a common " Daniel Lezcano
@ 2023-02-03 17:44 ` Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 04/11] thermal/acpi: Move the active trip points to the same array Daniel Lezcano
` (7 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Daniel Lezcano @ 2023-02-03 17:44 UTC (permalink / raw)
To: rjw
Cc: daniel.lezcano, linux-acpi, linux-pm, Rafael J. Wysocki,
Zhang Rui, Len Brown, open list
Instead of having multiple trip points in the structure fields for
each trip type, let's create an array of trip points.
No functional changes.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/acpi/thermal.c | 130 ++++++++++++++++++++++-------------------
1 file changed, 69 insertions(+), 61 deletions(-)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index e27b0b71fcf8..6b07de78c4c6 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -104,6 +104,15 @@ static struct acpi_driver acpi_thermal_driver = {
.drv.pm = &acpi_thermal_pm,
};
+enum {
+ ACPI_THERMAL_TRIP_CRITICAL,
+ ACPI_THERMAL_TRIP_HOT,
+ ACPI_THERMAL_TRIP_PASSIVE,
+ ACPI_THERMAL_TRIP_ACTIVE
+};
+
+#define ACPI_THERMAL_TRIP_MAX (ACPI_THERMAL_TRIP_ACTIVE + ACPI_THERMAL_MAX_ACTIVE)
+
struct acpi_thermal_state {
u8 critical:1;
u8 hot:1;
@@ -143,9 +152,7 @@ struct acpi_thermal {
volatile u8 zombie;
struct acpi_thermal_flags flags;
struct acpi_thermal_state state;
- struct acpi_thermal_trip critical;
- struct acpi_thermal_trip hot;
- struct acpi_thermal_trip passive;
+ struct acpi_thermal_trip trips[ACPI_THERMAL_TRIP_MAX];
struct acpi_thermal_trip active[ACPI_THERMAL_MAX_ACTIVE];
struct acpi_handle_list devices;
struct thermal_zone_device *thermal_zone;
@@ -251,7 +258,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
/* Critical Shutdown */
if (flag & ACPI_TRIPS_CRITICAL) {
status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &tmp);
- tz->critical.temperature = tmp;
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature = tmp;
/*
* Treat freezing temperatures as invalid as well; some
@@ -260,32 +267,32 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
* ... so lets discard those as invalid.
*/
if (ACPI_FAILURE(status)) {
- tz->critical.flags.valid = 0;
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid = 0;
acpi_handle_debug(tz->device->handle,
"No critical threshold\n");
} else if (tmp <= 2732) {
pr_info(FW_BUG "Invalid critical threshold (%llu)\n", tmp);
- tz->critical.flags.valid = 0;
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid = 0;
} else {
- tz->critical.flags.valid = 1;
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid = 1;
acpi_handle_debug(tz->device->handle,
"Found critical threshold [%lu]\n",
- tz->critical.temperature);
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature);
}
- if (tz->critical.flags.valid) {
+ if (tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid) {
if (crt == -1) {
- tz->critical.flags.valid = 0;
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid = 0;
} else if (crt > 0) {
unsigned long crt_k = celsius_to_deci_kelvin(crt);
/*
* Allow override critical threshold
*/
- if (crt_k > tz->critical.temperature)
+ if (crt_k > tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature)
pr_info("Critical threshold %d C\n", crt);
- tz->critical.temperature = crt_k;
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature = crt_k;
}
}
}
@@ -294,22 +301,22 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
if (flag & ACPI_TRIPS_HOT) {
status = acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, &tmp);
if (ACPI_FAILURE(status)) {
- tz->hot.flags.valid = 0;
+ tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid = 0;
acpi_handle_debug(tz->device->handle,
"No hot threshold\n");
} else {
- tz->hot.temperature = tmp;
- tz->hot.flags.valid = 1;
+ tz->trips[ACPI_THERMAL_TRIP_HOT].temperature = tmp;
+ tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid = 1;
acpi_handle_debug(tz->device->handle,
"Found hot threshold [%lu]\n",
- tz->hot.temperature);
+ tz->trips[ACPI_THERMAL_TRIP_HOT].temperature);
}
}
/* Passive (optional) */
- if (((flag & ACPI_TRIPS_PASSIVE) && tz->passive.flags.valid) ||
+ if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid) ||
flag == ACPI_TRIPS_INIT) {
- valid = tz->passive.flags.valid;
+ valid = tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid;
if (psv == -1) {
status = AE_SUPPORT;
} else if (psv > 0) {
@@ -321,53 +328,53 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
}
if (ACPI_FAILURE(status)) {
- tz->passive.flags.valid = 0;
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 0;
} else {
- tz->passive.temperature = tmp;
- tz->passive.flags.valid = 1;
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].temperature = tmp;
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 1;
if (flag == ACPI_TRIPS_INIT) {
status = acpi_evaluate_integer(tz->device->handle,
"_TC1", NULL, &tmp);
if (ACPI_FAILURE(status))
- tz->passive.flags.valid = 0;
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 0;
else
- tz->passive.tc1 = tmp;
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].tc1 = tmp;
status = acpi_evaluate_integer(tz->device->handle,
"_TC2", NULL, &tmp);
if (ACPI_FAILURE(status))
- tz->passive.flags.valid = 0;
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 0;
else
- tz->passive.tc2 = tmp;
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].tc2 = tmp;
status = acpi_evaluate_integer(tz->device->handle,
"_TSP", NULL, &tmp);
if (ACPI_FAILURE(status))
- tz->passive.flags.valid = 0;
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 0;
else
- tz->passive.tsp = tmp;
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].tsp = tmp;
}
}
}
- if ((flag & ACPI_TRIPS_DEVICES) && tz->passive.flags.valid) {
+ if ((flag & ACPI_TRIPS_DEVICES) && tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid) {
memset(&devices, 0, sizeof(struct acpi_handle_list));
status = acpi_evaluate_reference(tz->device->handle, "_PSL",
NULL, &devices);
if (ACPI_FAILURE(status)) {
acpi_handle_info(tz->device->handle,
"Invalid passive threshold\n");
- tz->passive.flags.valid = 0;
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 0;
} else {
- tz->passive.flags.valid = 1;
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 1;
}
- if (memcmp(&tz->passive.devices, &devices,
+ if (memcmp(&tz->trips[ACPI_THERMAL_TRIP_PASSIVE].devices, &devices,
sizeof(struct acpi_handle_list))) {
- memcpy(&tz->passive.devices, &devices,
+ memcpy(&tz->trips[ACPI_THERMAL_TRIP_PASSIVE].devices, &devices,
sizeof(struct acpi_handle_list));
ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device");
}
}
if ((flag & ACPI_TRIPS_PASSIVE) || (flag & ACPI_TRIPS_DEVICES)) {
- if (valid != tz->passive.flags.valid)
+ if (valid != tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid)
ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "state");
}
@@ -460,9 +467,9 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
if (ret)
return ret;
- valid = tz->critical.flags.valid |
- tz->hot.flags.valid |
- tz->passive.flags.valid;
+ valid = tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid |
+ tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid |
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid;
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
valid |= tz->active[i].flags.valid;
@@ -502,7 +509,7 @@ static int thermal_get_trip_type(struct thermal_zone_device *thermal,
if (!tz || trip < 0)
return -EINVAL;
- if (tz->critical.flags.valid) {
+ if (tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid) {
if (!trip) {
*type = THERMAL_TRIP_CRITICAL;
return 0;
@@ -510,7 +517,7 @@ static int thermal_get_trip_type(struct thermal_zone_device *thermal,
trip--;
}
- if (tz->hot.flags.valid) {
+ if (tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid) {
if (!trip) {
*type = THERMAL_TRIP_HOT;
return 0;
@@ -518,7 +525,7 @@ static int thermal_get_trip_type(struct thermal_zone_device *thermal,
trip--;
}
- if (tz->passive.flags.valid) {
+ if (tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid) {
if (!trip) {
*type = THERMAL_TRIP_PASSIVE;
return 0;
@@ -546,30 +553,30 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
if (!tz || trip < 0)
return -EINVAL;
- if (tz->critical.flags.valid) {
+ if (tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid) {
if (!trip) {
*temp = deci_kelvin_to_millicelsius_with_offset(
- tz->critical.temperature,
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature,
tz->kelvin_offset);
return 0;
}
trip--;
}
- if (tz->hot.flags.valid) {
+ if (tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid) {
if (!trip) {
*temp = deci_kelvin_to_millicelsius_with_offset(
- tz->hot.temperature,
+ tz->trips[ACPI_THERMAL_TRIP_HOT].temperature,
tz->kelvin_offset);
return 0;
}
trip--;
}
- if (tz->passive.flags.valid) {
+ if (tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid) {
if (!trip) {
*temp = deci_kelvin_to_millicelsius_with_offset(
- tz->passive.temperature,
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].temperature,
tz->kelvin_offset);
return 0;
}
@@ -595,9 +602,9 @@ static int thermal_get_crit_temp(struct thermal_zone_device *thermal,
{
struct acpi_thermal *tz = thermal->devdata;
- if (tz->critical.flags.valid) {
+ if (tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid) {
*temperature = deci_kelvin_to_millicelsius_with_offset(
- tz->critical.temperature,
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature,
tz->kelvin_offset);
return 0;
}
@@ -635,8 +642,9 @@ static int thermal_get_trend(struct thermal_zone_device *thermal,
* tz->temperature has already been updated by generic thermal layer,
* before this callback being invoked
*/
- i = (tz->passive.tc1 * (tz->temperature - tz->last_temperature)) +
- (tz->passive.tc2 * (tz->temperature - tz->passive.temperature));
+ i = (tz->trips[ACPI_THERMAL_TRIP_PASSIVE].tc1 * (tz->temperature - tz->last_temperature)) +
+ (tz->trips[ACPI_THERMAL_TRIP_PASSIVE].tc2 *
+ (tz->temperature - tz->trips[ACPI_THERMAL_TRIP_PASSIVE].temperature));
if (i > 0)
*trend = THERMAL_TREND_RAISING;
@@ -681,16 +689,16 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
int trip = -1;
int result = 0;
- if (tz->critical.flags.valid)
+ if (tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid)
trip++;
- if (tz->hot.flags.valid)
+ if (tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid)
trip++;
- if (tz->passive.flags.valid) {
+ if (tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid) {
trip++;
- for (i = 0; i < tz->passive.devices.count; i++) {
- handle = tz->passive.devices.handles[i];
+ for (i = 0; i < tz->trips[ACPI_THERMAL_TRIP_PASSIVE].devices.count; i++) {
+ handle = tz->trips[ACPI_THERMAL_TRIP_PASSIVE].devices.handles[i];
dev = acpi_fetch_acpi_dev(handle);
if (dev != device)
continue;
@@ -774,23 +782,23 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
acpi_status status;
int i;
- if (tz->critical.flags.valid)
+ if (tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid)
trips++;
- if (tz->hot.flags.valid)
+ if (tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid)
trips++;
- if (tz->passive.flags.valid)
+ if (tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid)
trips++;
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->active[i].flags.valid;
i++, trips++);
- if (tz->passive.flags.valid)
+ if (tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid)
tz->thermal_zone =
thermal_zone_device_register("acpitz", trips, 0, tz,
&acpi_thermal_zone_ops, NULL,
- tz->passive.tsp*100,
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].tsp*100,
tz->polling_frequency*100);
else
tz->thermal_zone =
@@ -966,8 +974,8 @@ static int acpi_thermal_get_info(struct acpi_thermal *tz)
*/
static void acpi_thermal_guess_offset(struct acpi_thermal *tz)
{
- if (tz->critical.flags.valid &&
- (tz->critical.temperature % 5) == 1)
+ if (tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid &&
+ (tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature % 5) == 1)
tz->kelvin_offset = 273100;
else
tz->kelvin_offset = 273200;
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 04/11] thermal/acpi: Move the active trip points to the same array
[not found] <20230203174429.3375691-1-daniel.lezcano@linaro.org>
` (2 preceding siblings ...)
2023-02-03 17:44 ` [PATCH v2 03/11] thermal/acpi: Convert the acpi thermal trips to an array Daniel Lezcano
@ 2023-02-03 17:44 ` Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 05/11] thermal/acpi: Optimize get_trip_points() Daniel Lezcano
` (6 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Daniel Lezcano @ 2023-02-03 17:44 UTC (permalink / raw)
To: rjw
Cc: daniel.lezcano, linux-acpi, linux-pm, Rafael J. Wysocki,
Zhang Rui, Len Brown, open list
This change does the second pass to move the active trip points in the
thermal trip array.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/acpi/thermal.c | 71 +++++++++++++++++++++---------------------
1 file changed, 35 insertions(+), 36 deletions(-)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 6b07de78c4c6..903f0e3d95f5 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -153,7 +153,6 @@ struct acpi_thermal {
struct acpi_thermal_flags flags;
struct acpi_thermal_state state;
struct acpi_thermal_trip trips[ACPI_THERMAL_TRIP_MAX];
- struct acpi_thermal_trip active[ACPI_THERMAL_MAX_ACTIVE];
struct acpi_handle_list devices;
struct thermal_zone_device *thermal_zone;
int kelvin_offset; /* in millidegrees */
@@ -379,19 +378,19 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
}
/* Active (optional) */
- for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
+ for (i = ACPI_THERMAL_TRIP_ACTIVE; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
- valid = tz->active[i].flags.valid;
+ valid = tz->trips[i].flags.valid;
if (act == -1)
break; /* disable all active trip points */
if (flag == ACPI_TRIPS_INIT || ((flag & ACPI_TRIPS_ACTIVE) &&
- tz->active[i].flags.valid)) {
+ tz->trips[i].flags.valid)) {
status = acpi_evaluate_integer(tz->device->handle,
name, NULL, &tmp);
if (ACPI_FAILURE(status)) {
- tz->active[i].flags.valid = 0;
+ tz->trips[i].flags.valid = 0;
if (i == 0)
break;
@@ -399,50 +398,50 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
break;
if (i == 1)
- tz->active[0].temperature = celsius_to_deci_kelvin(act);
+ tz->trips[0].temperature = celsius_to_deci_kelvin(act);
else
/*
* Don't allow override higher than
* the next higher trip point
*/
- tz->active[i - 1].temperature =
- (tz->active[i - 2].temperature <
+ tz->trips[i - 1].temperature =
+ (tz->trips[i - 2].temperature <
celsius_to_deci_kelvin(act) ?
- tz->active[i - 2].temperature :
+ tz->trips[i - 2].temperature :
celsius_to_deci_kelvin(act));
break;
} else {
- tz->active[i].temperature = tmp;
- tz->active[i].flags.valid = 1;
+ tz->trips[i].temperature = tmp;
+ tz->trips[i].flags.valid = 1;
}
}
name[2] = 'L';
- if ((flag & ACPI_TRIPS_DEVICES) && tz->active[i].flags.valid ) {
+ if ((flag & ACPI_TRIPS_DEVICES) && tz->trips[i].flags.valid ) {
memset(&devices, 0, sizeof(struct acpi_handle_list));
status = acpi_evaluate_reference(tz->device->handle,
name, NULL, &devices);
if (ACPI_FAILURE(status)) {
acpi_handle_info(tz->device->handle,
"Invalid active%d threshold\n", i);
- tz->active[i].flags.valid = 0;
+ tz->trips[i].flags.valid = 0;
} else {
- tz->active[i].flags.valid = 1;
+ tz->trips[i].flags.valid = 1;
}
- if (memcmp(&tz->active[i].devices, &devices,
+ if (memcmp(&tz->trips[i].devices, &devices,
sizeof(struct acpi_handle_list))) {
- memcpy(&tz->active[i].devices, &devices,
+ memcpy(&tz->trips[i].devices, &devices,
sizeof(struct acpi_handle_list));
ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device");
}
}
if ((flag & ACPI_TRIPS_ACTIVE) || (flag & ACPI_TRIPS_DEVICES))
- if (valid != tz->active[i].flags.valid)
+ if (valid != tz->trips[i].flags.valid)
ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "state");
- if (!tz->active[i].flags.valid)
+ if (!tz->trips[i].flags.valid)
break;
}
@@ -471,8 +470,8 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid |
tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid;
- for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
- valid |= tz->active[i].flags.valid;
+ for (i = ACPI_THERMAL_TRIP_ACTIVE; i < ACPI_THERMAL_MAX_ACTIVE; i++)
+ valid |= tz->trips[i].flags.valid;
if (!valid) {
pr_warn(FW_BUG "No valid trip found\n");
@@ -533,7 +532,7 @@ static int thermal_get_trip_type(struct thermal_zone_device *thermal,
trip--;
}
- for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->active[i].flags.valid; i++) {
+ for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips[i].flags.valid; i++) {
if (!trip) {
*type = THERMAL_TRIP_ACTIVE;
return 0;
@@ -583,11 +582,11 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
trip--;
}
- for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
- tz->active[i].flags.valid; i++) {
+ for (i = ACPI_THERMAL_TRIP_ACTIVE; i < ACPI_THERMAL_MAX_ACTIVE &&
+ tz->trips[i].flags.valid; i++) {
if (!trip) {
*temp = deci_kelvin_to_millicelsius_with_offset(
- tz->active[i].temperature,
+ tz->trips[i].temperature,
tz->kelvin_offset);
return 0;
}
@@ -719,13 +718,13 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
}
}
- for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
- if (!tz->active[i].flags.valid)
+ for (i = ACPI_THERMAL_TRIP_ACTIVE; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
+ if (!tz->trips[i].flags.valid)
break;
trip++;
- for (j = 0; j < tz->active[i].devices.count; j++) {
- handle = tz->active[i].devices.handles[j];
+ for (j = 0; j < tz->trips[i].devices.count; j++) {
+ handle = tz->trips[i].devices.handles[j];
dev = acpi_fetch_acpi_dev(handle);
if (dev != device)
continue;
@@ -791,7 +790,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
if (tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid)
trips++;
- for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->active[i].flags.valid;
+ for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips[i].flags.valid;
i++, trips++);
if (tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid)
@@ -1082,20 +1081,20 @@ static int acpi_thermal_resume(struct device *dev)
if (!tz)
return -EINVAL;
- for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
- if (!tz->active[i].flags.valid)
+ for (i = ACPI_THERMAL_TRIP_ACTIVE; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
+ if (!tz->trips[i].flags.valid)
break;
- tz->active[i].flags.enabled = 1;
- for (j = 0; j < tz->active[i].devices.count; j++) {
+ tz->trips[i].flags.enabled = 1;
+ for (j = 0; j < tz->trips[i].devices.count; j++) {
result = acpi_bus_update_power(
- tz->active[i].devices.handles[j],
+ tz->trips[i].devices.handles[j],
&power_state);
if (result || (power_state != ACPI_STATE_D0)) {
- tz->active[i].flags.enabled = 0;
+ tz->trips[i].flags.enabled = 0;
break;
}
}
- tz->state.active |= tz->active[i].flags.enabled;
+ tz->state.active |= tz->trips[i].flags.enabled;
}
acpi_queue_thermal_check(tz);
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 05/11] thermal/acpi: Optimize get_trip_points()
[not found] <20230203174429.3375691-1-daniel.lezcano@linaro.org>
` (3 preceding siblings ...)
2023-02-03 17:44 ` [PATCH v2 04/11] thermal/acpi: Move the active trip points to the same array Daniel Lezcano
@ 2023-02-03 17:44 ` Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 06/11] thermal/acpi: Encapsulate in functions the trip initialization Daniel Lezcano
` (5 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Daniel Lezcano @ 2023-02-03 17:44 UTC (permalink / raw)
To: rjw
Cc: daniel.lezcano, linux-acpi, linux-pm, Rafael J. Wysocki,
Zhang Rui, Len Brown, open list
The function has two purposes. Initialize the trip points by reading
the ACPI table and then doing a check trip points exists.
This check will go through all the trip points and at the end if a
valid trip point is found, the parsing is considered valid.
Instead of checking all the trip points, exit when a valid trip point
is found.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/acpi/thermal.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 903f0e3d95f5..c4fd583fbf5c 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -461,23 +461,20 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
{
- int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT);
+ int i, ret;
+ ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT);
if (ret)
return ret;
- valid = tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid |
- tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid |
- tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid;
+ for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
+ if (tz->trips[i].flags.valid)
+ return 0;
+ }
- for (i = ACPI_THERMAL_TRIP_ACTIVE; i < ACPI_THERMAL_MAX_ACTIVE; i++)
- valid |= tz->trips[i].flags.valid;
+ pr_warn(FW_BUG "No valid trip found\n");
- if (!valid) {
- pr_warn(FW_BUG "No valid trip found\n");
- return -ENODEV;
- }
- return 0;
+ return -ENODEV;
}
/* sys I/F for generic thermal sysfs support */
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 06/11] thermal/acpi: Encapsulate in functions the trip initialization
[not found] <20230203174429.3375691-1-daniel.lezcano@linaro.org>
` (4 preceding siblings ...)
2023-02-03 17:44 ` [PATCH v2 05/11] thermal/acpi: Optimize get_trip_points() Daniel Lezcano
@ 2023-02-03 17:44 ` Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 07/11] thermal/acpi: Simplifify the condition check Daniel Lezcano
` (4 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Daniel Lezcano @ 2023-02-03 17:44 UTC (permalink / raw)
To: rjw
Cc: daniel.lezcano, linux-acpi, linux-pm, Rafael J. Wysocki,
Zhang Rui, Len Brown, open list
The thermal trip update function is a bit difficult to read, it is
very long and has everything put in there to initialize the trip
points. In order to improve its readability, let's encapuslate the
different parts into dedicated functions. So we can act individually
per trip type changes and will make easier to review the next changes.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/acpi/thermal.c | 257 ++++++++++++++++++++++++-----------------
1 file changed, 154 insertions(+), 103 deletions(-)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index c4fd583fbf5c..a3a8130c955f 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -246,113 +246,120 @@ do { \
"Please report to linux-acpi@vger.kernel.org\n", str); \
} while (0)
-static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
+static int acpi_thermal_trips_update_critical(struct acpi_thermal *tz, int flag)
{
- acpi_status status;
+ acpi_status status = AE_OK;
unsigned long long tmp;
- struct acpi_handle_list devices;
- int valid = 0;
- int i;
- /* Critical Shutdown */
- if (flag & ACPI_TRIPS_CRITICAL) {
- status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &tmp);
- tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature = tmp;
-
- /*
- * Treat freezing temperatures as invalid as well; some
- * BIOSes return really low values and cause reboots at startup.
- * Below zero (Celsius) values clearly aren't right for sure..
- * ... so lets discard those as invalid.
- */
- if (ACPI_FAILURE(status)) {
- tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid = 0;
- acpi_handle_debug(tz->device->handle,
- "No critical threshold\n");
- } else if (tmp <= 2732) {
- pr_info(FW_BUG "Invalid critical threshold (%llu)\n", tmp);
+ status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &tmp);
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature = tmp;
+ /*
+ * Treat freezing temperatures as invalid as well; some
+ * BIOSes return really low values and cause reboots at startup.
+ * Below zero (Celsius) values clearly aren't right for sure..
+ * ... so lets discard those as invalid.
+ */
+ if (ACPI_FAILURE(status)) {
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid = 0;
+ acpi_handle_debug(tz->device->handle,
+ "No critical threshold\n");
+ } else if (tmp <= 2732) {
+ pr_info(FW_BUG "Invalid critical threshold (%llu)\n", tmp);
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid = 0;
+ } else {
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid = 1;
+ acpi_handle_debug(tz->device->handle,
+ "Found critical threshold [%lu]\n",
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature);
+ }
+ if (tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid == 1) {
+ if (crt == -1) {
tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid = 0;
- } else {
- tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid = 1;
- acpi_handle_debug(tz->device->handle,
- "Found critical threshold [%lu]\n",
- tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature);
- }
-
- if (tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid) {
- if (crt == -1) {
- tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid = 0;
- } else if (crt > 0) {
- unsigned long crt_k = celsius_to_deci_kelvin(crt);
+ } else if (crt > 0) {
+ unsigned long crt_k = celsius_to_deci_kelvin(crt);
- /*
- * Allow override critical threshold
- */
- if (crt_k > tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature)
- pr_info("Critical threshold %d C\n", crt);
+ /*
+ * Allow override critical threshold
+ */
+ if (crt_k > tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature)
+ pr_info("Critical threshold %d C\n", crt);
- tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature = crt_k;
- }
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature = crt_k;
}
}
- /* Critical Sleep (optional) */
- if (flag & ACPI_TRIPS_HOT) {
- status = acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, &tmp);
- if (ACPI_FAILURE(status)) {
- tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid = 0;
- acpi_handle_debug(tz->device->handle,
- "No hot threshold\n");
- } else {
- tz->trips[ACPI_THERMAL_TRIP_HOT].temperature = tmp;
- tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid = 1;
- acpi_handle_debug(tz->device->handle,
- "Found hot threshold [%lu]\n",
- tz->trips[ACPI_THERMAL_TRIP_HOT].temperature);
- }
+ return 0;
+}
+
+static int acpi_thermal_trips_update_hot(struct acpi_thermal *tz, int flag)
+{
+ acpi_status status = AE_OK;
+ unsigned long long tmp;
+
+ status = acpi_evaluate_integer(tz->device->handle,
+ "_HOT", NULL, &tmp);
+ if (ACPI_FAILURE(status)) {
+ tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid = 0;
+ acpi_handle_debug(tz->device->handle,
+ "No hot threshold\n");
+ } else {
+ tz->trips[ACPI_THERMAL_TRIP_HOT].temperature = tmp;
+ tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid = 1;
+ acpi_handle_debug(tz->device->handle,
+ "Found hot threshold [%lu]\n",
+ tz->trips[ACPI_THERMAL_TRIP_HOT].temperature);
}
- /* Passive (optional) */
- if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid) ||
- flag == ACPI_TRIPS_INIT) {
- valid = tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid;
- if (psv == -1) {
- status = AE_SUPPORT;
- } else if (psv > 0) {
- tmp = celsius_to_deci_kelvin(psv);
- status = AE_OK;
- } else {
- status = acpi_evaluate_integer(tz->device->handle,
- "_PSV", NULL, &tmp);
- }
+ return 0;
+}
- if (ACPI_FAILURE(status)) {
- tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 0;
- } else {
- tz->trips[ACPI_THERMAL_TRIP_PASSIVE].temperature = tmp;
- tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 1;
- if (flag == ACPI_TRIPS_INIT) {
- status = acpi_evaluate_integer(tz->device->handle,
- "_TC1", NULL, &tmp);
- if (ACPI_FAILURE(status))
- tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 0;
- else
- tz->trips[ACPI_THERMAL_TRIP_PASSIVE].tc1 = tmp;
- status = acpi_evaluate_integer(tz->device->handle,
- "_TC2", NULL, &tmp);
- if (ACPI_FAILURE(status))
- tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 0;
- else
- tz->trips[ACPI_THERMAL_TRIP_PASSIVE].tc2 = tmp;
- status = acpi_evaluate_integer(tz->device->handle,
- "_TSP", NULL, &tmp);
- if (ACPI_FAILURE(status))
- tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 0;
- else
- tz->trips[ACPI_THERMAL_TRIP_PASSIVE].tsp = tmp;
- }
+static int acpi_thermal_trips_update_passive(struct acpi_thermal *tz, int flag)
+{
+ acpi_status status;
+ unsigned long long tmp;
+ struct acpi_handle_list devices;
+ int valid = 0;
+
+ valid = tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid;
+ if (psv == -1) {
+ status = AE_SUPPORT;
+ } else if (psv > 0) {
+ tmp = celsius_to_deci_kelvin(psv);
+ status = AE_OK;
+ } else {
+ status = acpi_evaluate_integer(tz->device->handle, "_PSV", NULL, &tmp);
+ }
+
+ if (ACPI_FAILURE(status))
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 0;
+ else {
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].temperature = tmp;
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 1;
+ if (flag == ACPI_TRIPS_INIT) {
+ status = acpi_evaluate_integer(
+ tz->device->handle, "_TC1",
+ NULL, &tmp);
+ if (ACPI_FAILURE(status))
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 0;
+ else
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].tc1 = tmp;
+ status = acpi_evaluate_integer(
+ tz->device->handle, "_TC2",
+ NULL, &tmp);
+ if (ACPI_FAILURE(status))
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 0;
+ else
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].tc2 = tmp;
+ status = acpi_evaluate_integer(
+ tz->device->handle, "_TSP",
+ NULL, &tmp);
+ if (ACPI_FAILURE(status))
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid = 0;
+ else
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].tsp = tmp;
}
}
+
if ((flag & ACPI_TRIPS_DEVICES) && tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid) {
memset(&devices, 0, sizeof(struct acpi_handle_list));
status = acpi_evaluate_reference(tz->device->handle, "_PSL",
@@ -372,12 +379,23 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device");
}
}
+
if ((flag & ACPI_TRIPS_PASSIVE) || (flag & ACPI_TRIPS_DEVICES)) {
if (valid != tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid)
ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "state");
}
- /* Active (optional) */
+ return 0;
+}
+
+static int acpi_thermal_trips_update_active(struct acpi_thermal *tz, int flag)
+{
+ acpi_status status = AE_OK;
+ unsigned long long tmp;
+ struct acpi_handle_list devices;
+ int valid = 0;
+ int i;
+
for (i = ACPI_THERMAL_TRIP_ACTIVE; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
valid = tz->trips[i].flags.valid;
@@ -445,17 +463,50 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
break;
}
- if (flag & ACPI_TRIPS_DEVICES) {
- memset(&devices, 0, sizeof(devices));
- status = acpi_evaluate_reference(tz->device->handle, "_TZD",
- NULL, &devices);
- if (ACPI_SUCCESS(status) &&
- memcmp(&tz->devices, &devices, sizeof(devices))) {
- tz->devices = devices;
- ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device");
- }
+ return 0;
+}
+
+static int acpi_thermal_trips_update_devices(struct acpi_thermal *tz, int flag)
+{
+ acpi_status status = AE_OK;
+ struct acpi_handle_list devices;
+
+ memset(&devices, 0, sizeof(devices));
+ status = acpi_evaluate_reference(tz->device->handle, "_TZD", NULL, &devices);
+ if (ACPI_SUCCESS(status)
+ && memcmp(&tz->devices, &devices, sizeof(devices))) {
+ tz->devices = devices;
+ ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device");
+ }
+
+ return 0;
+}
+
+static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
+{
+ /* Critical Shutdown */
+ if (flag & ACPI_TRIPS_CRITICAL) {
+ acpi_thermal_trips_update_critical(tz, flag);
}
+ /* Critical Sleep (optional) */
+ if (flag & ACPI_TRIPS_HOT) {
+ acpi_thermal_trips_update_hot(tz, flag);
+ }
+
+ /* Passive (optional) */
+ if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid) ||
+ (flag == ACPI_TRIPS_INIT)) {
+ acpi_thermal_trips_update_passive(tz, flag);
+ }
+
+ /* Active (optional) */
+ acpi_thermal_trips_update_active(tz, flag);
+
+ if (flag & ACPI_TRIPS_DEVICES) {
+ acpi_thermal_trips_update_devices(tz, flag);
+ }
+
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 07/11] thermal/acpi: Simplifify the condition check
[not found] <20230203174429.3375691-1-daniel.lezcano@linaro.org>
` (5 preceding siblings ...)
2023-02-03 17:44 ` [PATCH v2 06/11] thermal/acpi: Encapsulate in functions the trip initialization Daniel Lezcano
@ 2023-02-03 17:44 ` Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 08/11] thermal/acpi: Remove active and enabled flags Daniel Lezcano
` (3 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Daniel Lezcano @ 2023-02-03 17:44 UTC (permalink / raw)
To: rjw
Cc: daniel.lezcano, linux-acpi, linux-pm, Rafael J. Wysocki,
Zhang Rui, Len Brown, open list
The condition:
if ((flag == ACPI_TRIPS_INIT) || ((flag & ACPI_TRIPS_ACTIVE))
and on the other side: ACPI_TRIPS_INIT (... | ACPI_TRIPS_ACTIVE)
So if the first predicate is true, the second is also true.
The 'valid' flag for the trip point is also checked before, so it is
pointless to redo the same check again and again as it is unchanged.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/acpi/thermal.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index a3a8130c955f..c7c2b3d63e90 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -321,6 +321,9 @@ static int acpi_thermal_trips_update_passive(struct acpi_thermal *tz, int flag)
int valid = 0;
valid = tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid;
+ if (!valid)
+ return 0;
+
if (psv == -1) {
status = AE_SUPPORT;
} else if (psv > 0) {
@@ -398,13 +401,16 @@ static int acpi_thermal_trips_update_active(struct acpi_thermal *tz, int flag)
for (i = ACPI_THERMAL_TRIP_ACTIVE; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
+
valid = tz->trips[i].flags.valid;
if (act == -1)
break; /* disable all active trip points */
- if (flag == ACPI_TRIPS_INIT || ((flag & ACPI_TRIPS_ACTIVE) &&
- tz->trips[i].flags.valid)) {
+ if (!tz->trips[i].flags.valid)
+ continue;
+
+ if (flag & ACPI_TRIPS_ACTIVE) {
status = acpi_evaluate_integer(tz->device->handle,
name, NULL, &tmp);
if (ACPI_FAILURE(status)) {
@@ -436,7 +442,7 @@ static int acpi_thermal_trips_update_active(struct acpi_thermal *tz, int flag)
}
name[2] = 'L';
- if ((flag & ACPI_TRIPS_DEVICES) && tz->trips[i].flags.valid ) {
+ if (flag & ACPI_TRIPS_DEVICES) {
memset(&devices, 0, sizeof(struct acpi_handle_list));
status = acpi_evaluate_reference(tz->device->handle,
name, NULL, &devices);
@@ -455,6 +461,7 @@ static int acpi_thermal_trips_update_active(struct acpi_thermal *tz, int flag)
ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device");
}
}
+
if ((flag & ACPI_TRIPS_ACTIVE) || (flag & ACPI_TRIPS_DEVICES))
if (valid != tz->trips[i].flags.valid)
ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "state");
@@ -495,8 +502,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
}
/* Passive (optional) */
- if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid) ||
- (flag == ACPI_TRIPS_INIT)) {
+ if (flag & ACPI_TRIPS_PASSIVE) {
acpi_thermal_trips_update_passive(tz, flag);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 08/11] thermal/acpi: Remove active and enabled flags
[not found] <20230203174429.3375691-1-daniel.lezcano@linaro.org>
` (6 preceding siblings ...)
2023-02-03 17:44 ` [PATCH v2 07/11] thermal/acpi: Simplifify the condition check Daniel Lezcano
@ 2023-02-03 17:44 ` Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 09/11] thermal/acpi: Convert the units to milli Celsuis Daniel Lezcano
` (2 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Daniel Lezcano @ 2023-02-03 17:44 UTC (permalink / raw)
To: rjw
Cc: daniel.lezcano, linux-acpi, linux-pm, Rafael J. Wysocki,
Zhang Rui, Len Brown, open list
The 'active' field in the struct acpi_thermal_state is never used.
The 'enabled' field of the structure acpi_thermal_state_flags is
assigned but never used.
Remove them.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/acpi/thermal.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index c7c2b3d63e90..316a16ac1a09 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -117,14 +117,12 @@ struct acpi_thermal_state {
u8 critical:1;
u8 hot:1;
u8 passive:1;
- u8 active:1;
u8 reserved:4;
int active_index;
};
struct acpi_thermal_state_flags {
u8 valid:1;
- u8 enabled:1;
u8 reserved:6;
};
@@ -1138,17 +1136,14 @@ static int acpi_thermal_resume(struct device *dev)
for (i = ACPI_THERMAL_TRIP_ACTIVE; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
if (!tz->trips[i].flags.valid)
break;
- tz->trips[i].flags.enabled = 1;
+
for (j = 0; j < tz->trips[i].devices.count; j++) {
result = acpi_bus_update_power(
tz->trips[i].devices.handles[j],
&power_state);
- if (result || (power_state != ACPI_STATE_D0)) {
- tz->trips[i].flags.enabled = 0;
+ if (result || (power_state != ACPI_STATE_D0))
break;
- }
}
- tz->state.active |= tz->trips[i].flags.enabled;
}
acpi_queue_thermal_check(tz);
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 09/11] thermal/acpi: Convert the units to milli Celsuis
[not found] <20230203174429.3375691-1-daniel.lezcano@linaro.org>
` (7 preceding siblings ...)
2023-02-03 17:44 ` [PATCH v2 08/11] thermal/acpi: Remove active and enabled flags Daniel Lezcano
@ 2023-02-03 17:44 ` Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 10/11] thermal/acpi: Rewrite the trip point intialization to use the generic thermal trip Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 11/11] thermal/acpi: Use the thermal framework ACPI API Daniel Lezcano
10 siblings, 0 replies; 13+ messages in thread
From: Daniel Lezcano @ 2023-02-03 17:44 UTC (permalink / raw)
To: rjw
Cc: daniel.lezcano, linux-acpi, linux-pm, Daniel Lezcano,
Rafael J. Wysocki, Zhang Rui, Len Brown, open list
From: Daniel Lezcano <daniel.lezcano@kernel.org>
The trip points are storing the temperature using the Deci Kelvin
units but the thermal framework expects milli Celsius.
In order to migrate to the generic trip points where the temperature
unit is millicelsius. Let's change the unit, so the resulting code
will be compatible with thermal framework used unit.
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/acpi/thermal.c | 56 ++++++++++++++++++------------------------
1 file changed, 24 insertions(+), 32 deletions(-)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 316a16ac1a09..9122d1c44777 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -177,9 +177,9 @@ static int acpi_thermal_get_temperature(struct acpi_thermal *tz)
if (ACPI_FAILURE(status))
return -ENODEV;
- tz->temperature = tmp;
+ tz->temperature = deci_kelvin_to_millicelsius(tmp);
- acpi_handle_debug(tz->device->handle, "Temperature is %lu dK\n",
+ acpi_handle_debug(tz->device->handle, "Temperature is %lu m°C\n",
tz->temperature);
return 0;
@@ -250,7 +250,7 @@ static int acpi_thermal_trips_update_critical(struct acpi_thermal *tz, int flag)
unsigned long long tmp;
status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &tmp);
- tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature = tmp;
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature = deci_kelvin_to_millicelsius(tmp);
/*
* Treat freezing temperatures as invalid as well; some
* BIOSes return really low values and cause reboots at startup.
@@ -261,7 +261,7 @@ static int acpi_thermal_trips_update_critical(struct acpi_thermal *tz, int flag)
tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid = 0;
acpi_handle_debug(tz->device->handle,
"No critical threshold\n");
- } else if (tmp <= 2732) {
+ } else if (tmp <= 0) {
pr_info(FW_BUG "Invalid critical threshold (%llu)\n", tmp);
tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid = 0;
} else {
@@ -274,15 +274,15 @@ static int acpi_thermal_trips_update_critical(struct acpi_thermal *tz, int flag)
if (crt == -1) {
tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid = 0;
} else if (crt > 0) {
- unsigned long crt_k = celsius_to_deci_kelvin(crt);
+ crt *= MILLIDEGREE_PER_DEGREE;
/*
* Allow override critical threshold
*/
- if (crt_k > tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature)
- pr_info("Critical threshold %d C\n", crt);
+ if (crt > tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature)
+ pr_info("Critical threshold %d m°C\n", crt);
- tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature = crt_k;
+ tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature = crt;
}
}
@@ -325,10 +325,11 @@ static int acpi_thermal_trips_update_passive(struct acpi_thermal *tz, int flag)
if (psv == -1) {
status = AE_SUPPORT;
} else if (psv > 0) {
- tmp = celsius_to_deci_kelvin(psv);
+ tmp = psv * MILLIDEGREE_PER_DEGREE;
status = AE_OK;
} else {
status = acpi_evaluate_integer(tz->device->handle, "_PSV", NULL, &tmp);
+ tmp = deci_kelvin_to_millicelsius(tmp);
}
if (ACPI_FAILURE(status))
@@ -411,6 +412,7 @@ static int acpi_thermal_trips_update_active(struct acpi_thermal *tz, int flag)
if (flag & ACPI_TRIPS_ACTIVE) {
status = acpi_evaluate_integer(tz->device->handle,
name, NULL, &tmp);
+ tmp = deci_kelvin_to_millicelsius(tmp);
if (ACPI_FAILURE(status)) {
tz->trips[i].flags.valid = 0;
if (i == 0)
@@ -420,7 +422,7 @@ static int acpi_thermal_trips_update_active(struct acpi_thermal *tz, int flag)
break;
if (i == 1)
- tz->trips[0].temperature = celsius_to_deci_kelvin(act);
+ tz->trips[0].temperature = act * MILLIDEGREE_PER_DEGREE;
else
/*
* Don't allow override higher than
@@ -428,9 +430,9 @@ static int acpi_thermal_trips_update_active(struct acpi_thermal *tz, int flag)
*/
tz->trips[i - 1].temperature =
(tz->trips[i - 2].temperature <
- celsius_to_deci_kelvin(act) ?
+ act * MILLIDEGREE_PER_DEGREE ?
tz->trips[i - 2].temperature :
- celsius_to_deci_kelvin(act));
+ act * MILLIDEGREE_PER_DEGREE);
break;
} else {
@@ -546,8 +548,8 @@ static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp)
if (result)
return result;
- *temp = deci_kelvin_to_millicelsius_with_offset(tz->temperature,
- tz->kelvin_offset);
+ *temp = tz->temperature;
+
return 0;
}
@@ -606,9 +608,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
if (tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid) {
if (!trip) {
- *temp = deci_kelvin_to_millicelsius_with_offset(
- tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature,
- tz->kelvin_offset);
+ *temp = tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature;
return 0;
}
trip--;
@@ -616,9 +616,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
if (tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid) {
if (!trip) {
- *temp = deci_kelvin_to_millicelsius_with_offset(
- tz->trips[ACPI_THERMAL_TRIP_HOT].temperature,
- tz->kelvin_offset);
+ *temp = tz->trips[ACPI_THERMAL_TRIP_HOT].temperature;
return 0;
}
trip--;
@@ -626,9 +624,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
if (tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid) {
if (!trip) {
- *temp = deci_kelvin_to_millicelsius_with_offset(
- tz->trips[ACPI_THERMAL_TRIP_PASSIVE].temperature,
- tz->kelvin_offset);
+ *temp = tz->trips[ACPI_THERMAL_TRIP_PASSIVE].temperature;
return 0;
}
trip--;
@@ -637,9 +633,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,
for (i = ACPI_THERMAL_TRIP_ACTIVE; i < ACPI_THERMAL_MAX_ACTIVE &&
tz->trips[i].flags.valid; i++) {
if (!trip) {
- *temp = deci_kelvin_to_millicelsius_with_offset(
- tz->trips[i].temperature,
- tz->kelvin_offset);
+ *temp = tz->trips[i].temperature;
return 0;
}
trip--;
@@ -654,9 +648,7 @@ static int thermal_get_crit_temp(struct thermal_zone_device *thermal,
struct acpi_thermal *tz = thermal->devdata;
if (tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid) {
- *temperature = deci_kelvin_to_millicelsius_with_offset(
- tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature,
- tz->kelvin_offset);
+ *temperature = tz->trips[ACPI_THERMAL_TRIP_CRITICAL].temperature;
return 0;
}
@@ -675,8 +667,8 @@ static int thermal_get_trend(struct thermal_zone_device *thermal,
if (type == THERMAL_TRIP_ACTIVE) {
int trip_temp;
- int temp = deci_kelvin_to_millicelsius_with_offset(
- tz->temperature, tz->kelvin_offset);
+ int temp = tz->temperature;
+
if (thermal_get_trip_temp(thermal, trip, &trip_temp))
return -EINVAL;
@@ -1090,7 +1082,7 @@ static int acpi_thermal_add(struct acpi_device *device)
INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn);
pr_info("%s [%s] (%ld C)\n", acpi_device_name(device),
- acpi_device_bid(device), deci_kelvin_to_celsius(tz->temperature));
+ acpi_device_bid(device), tz->temperature);
goto end;
free_memory:
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 10/11] thermal/acpi: Rewrite the trip point intialization to use the generic thermal trip
[not found] <20230203174429.3375691-1-daniel.lezcano@linaro.org>
` (8 preceding siblings ...)
2023-02-03 17:44 ` [PATCH v2 09/11] thermal/acpi: Convert the units to milli Celsuis Daniel Lezcano
@ 2023-02-03 17:44 ` Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 11/11] thermal/acpi: Use the thermal framework ACPI API Daniel Lezcano
10 siblings, 0 replies; 13+ messages in thread
From: Daniel Lezcano @ 2023-02-03 17:44 UTC (permalink / raw)
To: rjw
Cc: daniel.lezcano, linux-acpi, linux-pm, Rafael J. Wysocki,
Zhang Rui, Len Brown, open list
We can use the thermal trip points defined in the thermal.h.
Let's initialize them properly and when the code will be moved to the
generic thermal structure, we will be able to remove the specific acpi
trip points.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/acpi/thermal.c | 238 ++++++++++++++++++++++++++++++++++++-----
1 file changed, 212 insertions(+), 26 deletions(-)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 9122d1c44777..f89236cd4fcd 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -153,6 +153,8 @@ struct acpi_thermal {
struct acpi_thermal_trip trips[ACPI_THERMAL_TRIP_MAX];
struct acpi_handle_list devices;
struct thermal_zone_device *thermal_zone;
+ struct thermal_trip *_trips;
+ int num_trips;
int kelvin_offset; /* in millidegrees */
struct work_struct thermal_check_work;
struct mutex thermal_check_lock;
@@ -244,6 +246,198 @@ do { \
"Please report to linux-acpi@vger.kernel.org\n", str); \
} while (0)
+static void acpi_thermal_trips_override(struct thermal_trip *trip, int temperature)
+{
+ if (temperature > trip->temperature)
+ pr_info("Overriding temperature %d->%d m°C\n",
+ trip->temperature, temperature);
+
+ trip->temperature = temperature;
+}
+
+static struct thermal_trip *acpi_thermal_trips_alloc_critical(struct acpi_thermal *tz,
+ struct thermal_trip *trips,
+ int *num_trips)
+{
+ acpi_status status = AE_OK;
+ unsigned long long temp;
+
+ /*
+ * Module parameters disable the critical trip point
+ */
+ if (crt < 0)
+ goto out;
+
+ status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &temp);
+ if (ACPI_FAILURE(status)) {
+ acpi_handle_debug(tz->device->handle, "No critical threshold\n");
+ goto out;
+ }
+
+ if (temp <= 2732) {
+ pr_info(FW_BUG "Invalid critical threshold (%llu)\n", temp);
+ goto out;
+ }
+
+ trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
+ if (!trips)
+ goto out;
+
+ memset(&trips[*num_trips], 0, sizeof(*trips));
+
+ trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
+ trips[*num_trips].type = THERMAL_TRIP_CRITICAL;
+
+ if (crt > 0)
+ acpi_thermal_trips_override(&trips[*num_trips], crt * MILLI);
+
+ (*num_trips)++;
+out:
+ return trips;
+}
+
+static struct thermal_trip *acpi_thermal_trips_alloc_hot(struct acpi_thermal *tz,
+ struct thermal_trip *trips,
+ int *num_trips)
+{
+ acpi_status status;
+ unsigned long long temp;
+
+ status = acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, &temp);
+ if (ACPI_FAILURE(status)) {
+ acpi_handle_debug(tz->device->handle, "No hot threshold\n");
+ goto out;
+ }
+
+ trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
+ if (!trips)
+ goto out;
+
+ memset(&trips[*num_trips], 0, sizeof(*trips));
+
+ trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
+ trips[*num_trips].type = THERMAL_TRIP_HOT;
+
+ (*num_trips)++;
+out:
+ return trips;
+}
+
+static struct thermal_trip *acpi_thermal_trips_alloc_passive(struct acpi_thermal *tz,
+ struct thermal_trip *trips,
+ int *num_trips)
+{
+ struct acpi_handle_list devices;
+ acpi_status status;
+ unsigned long long temp;
+
+ /*
+ * Module parameters disable all passive trip points
+ */
+ if (psv < 0)
+ goto out;
+
+ status = acpi_evaluate_integer(tz->device->handle, "_PSV", NULL, &temp);
+ if (ACPI_FAILURE(status)) {
+ acpi_handle_debug(tz->device->handle, "No passive threshold\n");
+ goto out;
+ }
+
+ status = acpi_evaluate_reference(tz->device->handle, "_PSL", NULL, &devices);
+ if (ACPI_FAILURE(status)) {
+ acpi_handle_debug(tz->device->handle, "No passive device associated\n");
+ goto out;
+ }
+
+ trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
+ if (!trips)
+ goto out;
+
+ memset(&trips[*num_trips], 0, sizeof(*trips));
+
+ trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
+ trips[*num_trips].type = THERMAL_TRIP_PASSIVE;
+
+ (*num_trips)++;
+out:
+ return trips;
+}
+
+static struct thermal_trip *acpi_thermal_trips_alloc_active(struct acpi_thermal *tz,
+ struct thermal_trip *trips,
+ int *num_trips)
+{
+ struct acpi_handle_list devices;
+ acpi_status status;
+ unsigned long long temp;
+ int i;
+
+ /*
+ * Module parameters disable all active trip points
+ */
+ if (act < 0)
+ return trips;
+
+ for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
+ char name[5];
+
+ sprintf(name, "_AC%d", i);
+
+ status = acpi_evaluate_integer(tz->device->handle, name, NULL, &temp);
+ if (ACPI_FAILURE(status))
+ break;
+
+ sprintf(name, "_AL%d", i);
+
+ status = acpi_evaluate_reference(tz->device->handle, name, NULL, &devices);
+ if (ACPI_FAILURE(status)) {
+ acpi_handle_info(tz->device->handle, "No _AL%d defined for _AC%d\n", i, i);
+ break;
+ }
+
+ trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
+ if (!trips)
+ break;
+
+ memset(&trips[*num_trips], 0, sizeof(*trips));
+
+ trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
+ trips[*num_trips].type = THERMAL_TRIP_ACTIVE;
+
+ (*num_trips)++;
+ }
+
+ /*
+ * We found at least one trip point and we have an override option
+ */
+ if (i && act) {
+ /*
+ * Regarding the ACPI specification AC0 is the highest active
+ * temperature trip point. We will override this one.
+ */
+ acpi_thermal_trips_override(&trips[*num_trips], act * MILLI);
+ }
+
+ return trips;
+}
+
+static struct thermal_trip *acpi_thermal_trips_alloc(struct acpi_thermal *tz, int *num_trips)
+{
+ struct thermal_trip *trips = NULL;
+
+ *num_trips = 0;
+
+ trips = acpi_thermal_trips_alloc_critical(tz, trips, num_trips);
+
+ trips = acpi_thermal_trips_alloc_hot(tz, trips, num_trips);
+
+ trips = acpi_thermal_trips_alloc_passive(tz, trips, num_trips);
+
+ trips = acpi_thermal_trips_alloc_active(tz, trips, num_trips);
+
+ return trips;
+}
+
static int acpi_thermal_trips_update_critical(struct acpi_thermal *tz, int flag)
{
acpi_status status = AE_OK;
@@ -398,7 +592,7 @@ static int acpi_thermal_trips_update_active(struct acpi_thermal *tz, int flag)
int valid = 0;
int i;
- for (i = ACPI_THERMAL_TRIP_ACTIVE; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
+ for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
valid = tz->trips[i].flags.valid;
@@ -820,35 +1014,20 @@ static struct thermal_zone_device_ops acpi_thermal_zone_ops = {
static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
{
- int trips = 0;
int result;
acpi_status status;
- int i;
-
- if (tz->trips[ACPI_THERMAL_TRIP_CRITICAL].flags.valid)
- trips++;
-
- if (tz->trips[ACPI_THERMAL_TRIP_HOT].flags.valid)
- trips++;
-
- if (tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid)
- trips++;
-
- for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips[i].flags.valid;
- i++, trips++);
if (tz->trips[ACPI_THERMAL_TRIP_PASSIVE].flags.valid)
tz->thermal_zone =
- thermal_zone_device_register("acpitz", trips, 0, tz,
- &acpi_thermal_zone_ops, NULL,
- tz->trips[ACPI_THERMAL_TRIP_PASSIVE].tsp*100,
- tz->polling_frequency*100);
+ thermal_zone_device_register_with_trips("acpitz", tz->_trips, tz->num_trips, 0, tz,
+ &acpi_thermal_zone_ops, NULL,
+ tz->trips[ACPI_THERMAL_TRIP_PASSIVE].tsp*100,
+ tz->polling_frequency*100);
else
tz->thermal_zone =
- thermal_zone_device_register("acpitz", trips, 0, tz,
- &acpi_thermal_zone_ops, NULL,
- 0, tz->polling_frequency * 100);
-
+ thermal_zone_device_register_with_trips("acpitz", tz->_trips, tz->num_trips, 0, tz,
+ &acpi_thermal_zone_ops, NULL,
+ 0, tz->polling_frequency*100);
if (IS_ERR(tz->thermal_zone))
return -ENODEV;
@@ -1051,8 +1230,8 @@ static void acpi_thermal_check_fn(struct work_struct *work)
static int acpi_thermal_add(struct acpi_device *device)
{
- struct acpi_thermal *tz;
- int result;
+ struct acpi_thermal *tz = NULL;
+ int result = 0;
if (!device)
return -EINVAL;
@@ -1073,9 +1252,13 @@ static int acpi_thermal_add(struct acpi_device *device)
acpi_thermal_guess_offset(tz);
+ tz->_trips = acpi_thermal_trips_alloc(tz, &tz->num_trips);
+ if (!tz->_trips)
+ goto free_trips;
+
result = acpi_thermal_register_thermal_zone(tz);
if (result)
- goto free_memory;
+ goto free_trips;
refcount_set(&tz->thermal_check_count, 3);
mutex_init(&tz->thermal_check_lock);
@@ -1085,6 +1268,8 @@ static int acpi_thermal_add(struct acpi_device *device)
acpi_device_bid(device), tz->temperature);
goto end;
+free_trips:
+ kfree(tz->_trips);
free_memory:
kfree(tz);
end:
@@ -1101,6 +1286,7 @@ static void acpi_thermal_remove(struct acpi_device *device)
flush_workqueue(acpi_thermal_pm_queue);
tz = acpi_driver_data(device);
+ kfree(tz->trips);
acpi_thermal_unregister_thermal_zone(tz);
kfree(tz);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 11/11] thermal/acpi: Use the thermal framework ACPI API
[not found] <20230203174429.3375691-1-daniel.lezcano@linaro.org>
` (9 preceding siblings ...)
2023-02-03 17:44 ` [PATCH v2 10/11] thermal/acpi: Rewrite the trip point intialization to use the generic thermal trip Daniel Lezcano
@ 2023-02-03 17:44 ` Daniel Lezcano
2023-02-04 5:10 ` kernel test robot
2023-02-04 7:54 ` kernel test robot
10 siblings, 2 replies; 13+ messages in thread
From: Daniel Lezcano @ 2023-02-03 17:44 UTC (permalink / raw)
To: rjw
Cc: daniel.lezcano, linux-acpi, linux-pm, Daniel Lezcano,
Rafael J. Wysocki, Zhang Rui, Len Brown, open list
From: Daniel Lezcano <daniel.lezcano@kernel.org>
The thermal framework has a set of functions to fill the trip
points. Those functions are already used by the int340x and the quark
Intel's platform.
Reuse these functions in order to consolidate the generic trip points
usage across the thermal ACPI user.
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/acpi/thermal.c | 85 +++++++++++++++++++-----------------------
1 file changed, 38 insertions(+), 47 deletions(-)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index f89236cd4fcd..5e4d93c67b75 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -259,8 +259,11 @@ static struct thermal_trip *acpi_thermal_trips_alloc_critical(struct acpi_therma
struct thermal_trip *trips,
int *num_trips)
{
- acpi_status status = AE_OK;
- unsigned long long temp;
+ struct thermal_trip trip = {
+ .type = THERMAL_TRIP_CRITICAL,
+ };
+
+ int ret;
/*
* Module parameters disable the critical trip point
@@ -268,14 +271,12 @@ static struct thermal_trip *acpi_thermal_trips_alloc_critical(struct acpi_therma
if (crt < 0)
goto out;
- status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &temp);
- if (ACPI_FAILURE(status)) {
- acpi_handle_debug(tz->device->handle, "No critical threshold\n");
+ ret = thermal_acpi_critical_trip_temp(tz->device->handle, &trip.temperature);
+ if (ret)
goto out;
- }
-
- if (temp <= 2732) {
- pr_info(FW_BUG "Invalid critical threshold (%llu)\n", temp);
+
+ if (trip.temperature <= 0) {
+ pr_info(FW_BUG "Invalid critical threshold (%d)\n", trip.temperature);
goto out;
}
@@ -283,10 +284,7 @@ static struct thermal_trip *acpi_thermal_trips_alloc_critical(struct acpi_therma
if (!trips)
goto out;
- memset(&trips[*num_trips], 0, sizeof(*trips));
-
- trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
- trips[*num_trips].type = THERMAL_TRIP_CRITICAL;
+ trips[*num_trips] = trip; /* structure copy */
if (crt > 0)
acpi_thermal_trips_override(&trips[*num_trips], crt * MILLI);
@@ -300,23 +298,21 @@ static struct thermal_trip *acpi_thermal_trips_alloc_hot(struct acpi_thermal *tz
struct thermal_trip *trips,
int *num_trips)
{
- acpi_status status;
- unsigned long long temp;
+ struct thermal_trip trip = {
+ .type = THERMAL_TRIP_HOT,
+ };
- status = acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, &temp);
- if (ACPI_FAILURE(status)) {
- acpi_handle_debug(tz->device->handle, "No hot threshold\n");
+ int ret;
+
+ ret = thermal_acpi_hot_trip_temp(tz->device->handle, &trip.temperature);
+ if (ret)
goto out;
- }
trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
if (!trips)
goto out;
- memset(&trips[*num_trips], 0, sizeof(*trips));
-
- trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
- trips[*num_trips].type = THERMAL_TRIP_HOT;
+ trips[*num_trips] = trip; /* structure copy */
(*num_trips)++;
out:
@@ -327,9 +323,12 @@ static struct thermal_trip *acpi_thermal_trips_alloc_passive(struct acpi_thermal
struct thermal_trip *trips,
int *num_trips)
{
- struct acpi_handle_list devices;
acpi_status status;
- unsigned long long temp;
+ struct acpi_handle_list devices;
+ struct thermal_trip trip = {
+ .type = THERMAL_TRIP_PASSIVE
+ };
+ int ret;
/*
* Module parameters disable all passive trip points
@@ -337,26 +336,21 @@ static struct thermal_trip *acpi_thermal_trips_alloc_passive(struct acpi_thermal
if (psv < 0)
goto out;
- status = acpi_evaluate_integer(tz->device->handle, "_PSV", NULL, &temp);
- if (ACPI_FAILURE(status)) {
- acpi_handle_debug(tz->device->handle, "No passive threshold\n");
+ ret = thermal_acpi_passive_trip_temp(tz->device->handle, &trip.temperature);
+ if (ret)
goto out;
- }
-
+
status = acpi_evaluate_reference(tz->device->handle, "_PSL", NULL, &devices);
if (ACPI_FAILURE(status)) {
acpi_handle_debug(tz->device->handle, "No passive device associated\n");
goto out;
}
-
+
trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
if (!trips)
goto out;
- memset(&trips[*num_trips], 0, sizeof(*trips));
-
- trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
- trips[*num_trips].type = THERMAL_TRIP_PASSIVE;
+ trips[*num_trips] = trip; /* structure copy */
(*num_trips)++;
out:
@@ -367,10 +361,9 @@ static struct thermal_trip *acpi_thermal_trips_alloc_active(struct acpi_thermal
struct thermal_trip *trips,
int *num_trips)
{
- struct acpi_handle_list devices;
acpi_status status;
- unsigned long long temp;
- int i;
+ struct acpi_handle_list devices;
+ int i, ret;
/*
* Module parameters disable all active trip points
@@ -379,12 +372,13 @@ static struct thermal_trip *acpi_thermal_trips_alloc_active(struct acpi_thermal
return trips;
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
+ struct thermal_trip trip = {
+ .type = THERMAL_TRIP_ACTIVE,
+ };
char name[5];
- sprintf(name, "_AC%d", i);
-
- status = acpi_evaluate_integer(tz->device->handle, name, NULL, &temp);
- if (ACPI_FAILURE(status))
+ ret = thermal_acpi_active_trip_temp(tz->device->handle, i , &trip.temperature);
+ if (ret)
break;
sprintf(name, "_AL%d", i);
@@ -394,16 +388,13 @@ static struct thermal_trip *acpi_thermal_trips_alloc_active(struct acpi_thermal
acpi_handle_info(tz->device->handle, "No _AL%d defined for _AC%d\n", i, i);
break;
}
-
+
trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
if (!trips)
break;
- memset(&trips[*num_trips], 0, sizeof(*trips));
+ trips[*num_trips] = trip; /* structure copy */
- trips[*num_trips].temperature = deci_kelvin_to_millicelsius(temp);
- trips[*num_trips].type = THERMAL_TRIP_ACTIVE;
-
(*num_trips)++;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 11/11] thermal/acpi: Use the thermal framework ACPI API
2023-02-03 17:44 ` [PATCH v2 11/11] thermal/acpi: Use the thermal framework ACPI API Daniel Lezcano
@ 2023-02-04 5:10 ` kernel test robot
2023-02-04 7:54 ` kernel test robot
1 sibling, 0 replies; 13+ messages in thread
From: kernel test robot @ 2023-02-04 5:10 UTC (permalink / raw)
To: Daniel Lezcano, rjw
Cc: oe-kbuild-all, daniel.lezcano, linux-acpi, linux-pm,
Daniel Lezcano, Rafael J. Wysocki, Zhang Rui, Len Brown,
linux-kernel
Hi Daniel,
I love your patch! Yet something to improve:
[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on linus/master v6.2-rc6 next-20230203]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Daniel-Lezcano/thermal-acpi-Remove-the-intermediate-acpi_thermal_trip-structure/20230204-015126
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link: https://lore.kernel.org/r/20230203174429.3375691-12-daniel.lezcano%40linaro.org
patch subject: [PATCH v2 11/11] thermal/acpi: Use the thermal framework ACPI API
config: i386-randconfig-a003 (https://download.01.org/0day-ci/archive/20230204/202302041301.JFOakwDi-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/2c921da06a8ac8f9e047f1a683146e1c5561534a
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Daniel-Lezcano/thermal-acpi-Remove-the-intermediate-acpi_thermal_trip-structure/20230204-015126
git checkout 2c921da06a8ac8f9e047f1a683146e1c5561534a
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 olddefconfig
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
drivers/acpi/thermal.c: In function 'acpi_thermal_trips_alloc_critical':
>> drivers/acpi/thermal.c:274:15: error: implicit declaration of function 'thermal_acpi_critical_trip_temp' [-Werror=implicit-function-declaration]
274 | ret = thermal_acpi_critical_trip_temp(tz->device->handle, &trip.temperature);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/acpi/thermal.c: In function 'acpi_thermal_trips_alloc_hot':
>> drivers/acpi/thermal.c:307:15: error: implicit declaration of function 'thermal_acpi_hot_trip_temp'; did you mean 'thermal_zone_get_crit_temp'? [-Werror=implicit-function-declaration]
307 | ret = thermal_acpi_hot_trip_temp(tz->device->handle, &trip.temperature);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| thermal_zone_get_crit_temp
drivers/acpi/thermal.c: In function 'acpi_thermal_trips_alloc_passive':
>> drivers/acpi/thermal.c:339:15: error: implicit declaration of function 'thermal_acpi_passive_trip_temp' [-Werror=implicit-function-declaration]
339 | ret = thermal_acpi_passive_trip_temp(tz->device->handle, &trip.temperature);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/acpi/thermal.c: In function 'acpi_thermal_trips_alloc_active':
>> drivers/acpi/thermal.c:380:23: error: implicit declaration of function 'thermal_acpi_active_trip_temp' [-Werror=implicit-function-declaration]
380 | ret = thermal_acpi_active_trip_temp(tz->device->handle, i , &trip.temperature);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/thermal_acpi_critical_trip_temp +274 drivers/acpi/thermal.c
257
258 static struct thermal_trip *acpi_thermal_trips_alloc_critical(struct acpi_thermal *tz,
259 struct thermal_trip *trips,
260 int *num_trips)
261 {
262 struct thermal_trip trip = {
263 .type = THERMAL_TRIP_CRITICAL,
264 };
265
266 int ret;
267
268 /*
269 * Module parameters disable the critical trip point
270 */
271 if (crt < 0)
272 goto out;
273
> 274 ret = thermal_acpi_critical_trip_temp(tz->device->handle, &trip.temperature);
275 if (ret)
276 goto out;
277
278 if (trip.temperature <= 0) {
279 pr_info(FW_BUG "Invalid critical threshold (%d)\n", trip.temperature);
280 goto out;
281 }
282
283 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
284 if (!trips)
285 goto out;
286
287 trips[*num_trips] = trip; /* structure copy */
288
289 if (crt > 0)
290 acpi_thermal_trips_override(&trips[*num_trips], crt * MILLI);
291
292 (*num_trips)++;
293 out:
294 return trips;
295 }
296
297 static struct thermal_trip *acpi_thermal_trips_alloc_hot(struct acpi_thermal *tz,
298 struct thermal_trip *trips,
299 int *num_trips)
300 {
301 struct thermal_trip trip = {
302 .type = THERMAL_TRIP_HOT,
303 };
304
305 int ret;
306
> 307 ret = thermal_acpi_hot_trip_temp(tz->device->handle, &trip.temperature);
308 if (ret)
309 goto out;
310
311 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
312 if (!trips)
313 goto out;
314
315 trips[*num_trips] = trip; /* structure copy */
316
317 (*num_trips)++;
318 out:
319 return trips;
320 }
321
322 static struct thermal_trip *acpi_thermal_trips_alloc_passive(struct acpi_thermal *tz,
323 struct thermal_trip *trips,
324 int *num_trips)
325 {
326 acpi_status status;
327 struct acpi_handle_list devices;
328 struct thermal_trip trip = {
329 .type = THERMAL_TRIP_PASSIVE
330 };
331 int ret;
332
333 /*
334 * Module parameters disable all passive trip points
335 */
336 if (psv < 0)
337 goto out;
338
> 339 ret = thermal_acpi_passive_trip_temp(tz->device->handle, &trip.temperature);
340 if (ret)
341 goto out;
342
343 status = acpi_evaluate_reference(tz->device->handle, "_PSL", NULL, &devices);
344 if (ACPI_FAILURE(status)) {
345 acpi_handle_debug(tz->device->handle, "No passive device associated\n");
346 goto out;
347 }
348
349 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
350 if (!trips)
351 goto out;
352
353 trips[*num_trips] = trip; /* structure copy */
354
355 (*num_trips)++;
356 out:
357 return trips;
358 }
359
360 static struct thermal_trip *acpi_thermal_trips_alloc_active(struct acpi_thermal *tz,
361 struct thermal_trip *trips,
362 int *num_trips)
363 {
364 acpi_status status;
365 struct acpi_handle_list devices;
366 int i, ret;
367
368 /*
369 * Module parameters disable all active trip points
370 */
371 if (act < 0)
372 return trips;
373
374 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
375 struct thermal_trip trip = {
376 .type = THERMAL_TRIP_ACTIVE,
377 };
378 char name[5];
379
> 380 ret = thermal_acpi_active_trip_temp(tz->device->handle, i , &trip.temperature);
381 if (ret)
382 break;
383
384 sprintf(name, "_AL%d", i);
385
386 status = acpi_evaluate_reference(tz->device->handle, name, NULL, &devices);
387 if (ACPI_FAILURE(status)) {
388 acpi_handle_info(tz->device->handle, "No _AL%d defined for _AC%d\n", i, i);
389 break;
390 }
391
392 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
393 if (!trips)
394 break;
395
396 trips[*num_trips] = trip; /* structure copy */
397
398 (*num_trips)++;
399 }
400
401 /*
402 * We found at least one trip point and we have an override option
403 */
404 if (i && act) {
405 /*
406 * Regarding the ACPI specification AC0 is the highest active
407 * temperature trip point. We will override this one.
408 */
409 acpi_thermal_trips_override(&trips[*num_trips], act * MILLI);
410 }
411
412 return trips;
413 }
414
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 11/11] thermal/acpi: Use the thermal framework ACPI API
2023-02-03 17:44 ` [PATCH v2 11/11] thermal/acpi: Use the thermal framework ACPI API Daniel Lezcano
2023-02-04 5:10 ` kernel test robot
@ 2023-02-04 7:54 ` kernel test robot
1 sibling, 0 replies; 13+ messages in thread
From: kernel test robot @ 2023-02-04 7:54 UTC (permalink / raw)
To: Daniel Lezcano, rjw
Cc: llvm, oe-kbuild-all, daniel.lezcano, linux-acpi, linux-pm,
Daniel Lezcano, Rafael J. Wysocki, Zhang Rui, Len Brown,
linux-kernel
Hi Daniel,
I love your patch! Yet something to improve:
[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on linus/master v6.2-rc6 next-20230203]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Daniel-Lezcano/thermal-acpi-Remove-the-intermediate-acpi_thermal_trip-structure/20230204-015126
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link: https://lore.kernel.org/r/20230203174429.3375691-12-daniel.lezcano%40linaro.org
patch subject: [PATCH v2 11/11] thermal/acpi: Use the thermal framework ACPI API
config: i386-randconfig-a002 (https://download.01.org/0day-ci/archive/20230204/202302041525.ZDaLecDd-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/2c921da06a8ac8f9e047f1a683146e1c5561534a
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Daniel-Lezcano/thermal-acpi-Remove-the-intermediate-acpi_thermal_trip-structure/20230204-015126
git checkout 2c921da06a8ac8f9e047f1a683146e1c5561534a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> drivers/acpi/thermal.c:274:8: error: implicit declaration of function 'thermal_acpi_critical_trip_temp' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = thermal_acpi_critical_trip_temp(tz->device->handle, &trip.temperature);
^
>> drivers/acpi/thermal.c:307:8: error: implicit declaration of function 'thermal_acpi_hot_trip_temp' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = thermal_acpi_hot_trip_temp(tz->device->handle, &trip.temperature);
^
drivers/acpi/thermal.c:307:8: note: did you mean 'thermal_zone_get_crit_temp'?
include/linux/thermal.h:347:5: note: 'thermal_zone_get_crit_temp' declared here
int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp);
^
>> drivers/acpi/thermal.c:339:8: error: implicit declaration of function 'thermal_acpi_passive_trip_temp' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = thermal_acpi_passive_trip_temp(tz->device->handle, &trip.temperature);
^
>> drivers/acpi/thermal.c:380:9: error: implicit declaration of function 'thermal_acpi_active_trip_temp' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
ret = thermal_acpi_active_trip_temp(tz->device->handle, i , &trip.temperature);
^
4 errors generated.
vim +/thermal_acpi_critical_trip_temp +274 drivers/acpi/thermal.c
257
258 static struct thermal_trip *acpi_thermal_trips_alloc_critical(struct acpi_thermal *tz,
259 struct thermal_trip *trips,
260 int *num_trips)
261 {
262 struct thermal_trip trip = {
263 .type = THERMAL_TRIP_CRITICAL,
264 };
265
266 int ret;
267
268 /*
269 * Module parameters disable the critical trip point
270 */
271 if (crt < 0)
272 goto out;
273
> 274 ret = thermal_acpi_critical_trip_temp(tz->device->handle, &trip.temperature);
275 if (ret)
276 goto out;
277
278 if (trip.temperature <= 0) {
279 pr_info(FW_BUG "Invalid critical threshold (%d)\n", trip.temperature);
280 goto out;
281 }
282
283 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
284 if (!trips)
285 goto out;
286
287 trips[*num_trips] = trip; /* structure copy */
288
289 if (crt > 0)
290 acpi_thermal_trips_override(&trips[*num_trips], crt * MILLI);
291
292 (*num_trips)++;
293 out:
294 return trips;
295 }
296
297 static struct thermal_trip *acpi_thermal_trips_alloc_hot(struct acpi_thermal *tz,
298 struct thermal_trip *trips,
299 int *num_trips)
300 {
301 struct thermal_trip trip = {
302 .type = THERMAL_TRIP_HOT,
303 };
304
305 int ret;
306
> 307 ret = thermal_acpi_hot_trip_temp(tz->device->handle, &trip.temperature);
308 if (ret)
309 goto out;
310
311 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
312 if (!trips)
313 goto out;
314
315 trips[*num_trips] = trip; /* structure copy */
316
317 (*num_trips)++;
318 out:
319 return trips;
320 }
321
322 static struct thermal_trip *acpi_thermal_trips_alloc_passive(struct acpi_thermal *tz,
323 struct thermal_trip *trips,
324 int *num_trips)
325 {
326 acpi_status status;
327 struct acpi_handle_list devices;
328 struct thermal_trip trip = {
329 .type = THERMAL_TRIP_PASSIVE
330 };
331 int ret;
332
333 /*
334 * Module parameters disable all passive trip points
335 */
336 if (psv < 0)
337 goto out;
338
> 339 ret = thermal_acpi_passive_trip_temp(tz->device->handle, &trip.temperature);
340 if (ret)
341 goto out;
342
343 status = acpi_evaluate_reference(tz->device->handle, "_PSL", NULL, &devices);
344 if (ACPI_FAILURE(status)) {
345 acpi_handle_debug(tz->device->handle, "No passive device associated\n");
346 goto out;
347 }
348
349 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
350 if (!trips)
351 goto out;
352
353 trips[*num_trips] = trip; /* structure copy */
354
355 (*num_trips)++;
356 out:
357 return trips;
358 }
359
360 static struct thermal_trip *acpi_thermal_trips_alloc_active(struct acpi_thermal *tz,
361 struct thermal_trip *trips,
362 int *num_trips)
363 {
364 acpi_status status;
365 struct acpi_handle_list devices;
366 int i, ret;
367
368 /*
369 * Module parameters disable all active trip points
370 */
371 if (act < 0)
372 return trips;
373
374 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
375 struct thermal_trip trip = {
376 .type = THERMAL_TRIP_ACTIVE,
377 };
378 char name[5];
379
> 380 ret = thermal_acpi_active_trip_temp(tz->device->handle, i , &trip.temperature);
381 if (ret)
382 break;
383
384 sprintf(name, "_AL%d", i);
385
386 status = acpi_evaluate_reference(tz->device->handle, name, NULL, &devices);
387 if (ACPI_FAILURE(status)) {
388 acpi_handle_info(tz->device->handle, "No _AL%d defined for _AC%d\n", i, i);
389 break;
390 }
391
392 trips = krealloc(trips, sizeof(*trips) * (*num_trips + 1), GFP_KERNEL);
393 if (!trips)
394 break;
395
396 trips[*num_trips] = trip; /* structure copy */
397
398 (*num_trips)++;
399 }
400
401 /*
402 * We found at least one trip point and we have an override option
403 */
404 if (i && act) {
405 /*
406 * Regarding the ACPI specification AC0 is the highest active
407 * temperature trip point. We will override this one.
408 */
409 acpi_thermal_trips_override(&trips[*num_trips], act * MILLI);
410 }
411
412 return trips;
413 }
414
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-02-04 7:55 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20230203174429.3375691-1-daniel.lezcano@linaro.org>
2023-02-03 17:44 ` [PATCH v2 01/11] thermal/acpi: Remove the intermediate acpi_thermal_trip structure Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 02/11] thermal/acpi: Change to a common " Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 03/11] thermal/acpi: Convert the acpi thermal trips to an array Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 04/11] thermal/acpi: Move the active trip points to the same array Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 05/11] thermal/acpi: Optimize get_trip_points() Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 06/11] thermal/acpi: Encapsulate in functions the trip initialization Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 07/11] thermal/acpi: Simplifify the condition check Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 08/11] thermal/acpi: Remove active and enabled flags Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 09/11] thermal/acpi: Convert the units to milli Celsuis Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 10/11] thermal/acpi: Rewrite the trip point intialization to use the generic thermal trip Daniel Lezcano
2023-02-03 17:44 ` [PATCH v2 11/11] thermal/acpi: Use the thermal framework ACPI API Daniel Lezcano
2023-02-04 5:10 ` kernel test robot
2023-02-04 7:54 ` kernel test robot
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).