Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 3995904

Browse files
committed
Merge back thermal control material for v6.11.
2 parents 096597c + b684682 commit 3995904

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

drivers/acpi/thermal.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,17 @@ static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
168168

169169
static int acpi_thermal_temp(struct acpi_thermal *tz, int temp_deci_k)
170170
{
171+
int temp;
172+
171173
if (temp_deci_k == THERMAL_TEMP_INVALID)
172174
return THERMAL_TEMP_INVALID;
173175

174-
return deci_kelvin_to_millicelsius_with_offset(temp_deci_k,
176+
temp = deci_kelvin_to_millicelsius_with_offset(temp_deci_k,
175177
tz->kelvin_offset);
178+
if (temp <= 0)
179+
return THERMAL_TEMP_INVALID;
180+
181+
return temp;
176182
}
177183

178184
static bool acpi_thermal_trip_valid(struct acpi_thermal_trip *acpi_trip)

drivers/thermal/gov_step_wise.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz,
9393
if (instance->initialized && old_target == instance->target)
9494
continue;
9595

96+
if (trip->type == THERMAL_TRIP_PASSIVE) {
97+
/*
98+
* If the target state for this thermal instance
99+
* changes from THERMAL_NO_TARGET to something else,
100+
* ensure that the zone temperature will be updated
101+
* (assuming enabled passive cooling) until it becomes
102+
* THERMAL_NO_TARGET again, or the cooling device may
103+
* not be reset to its initial state.
104+
*/
105+
if (old_target == THERMAL_NO_TARGET &&
106+
instance->target != THERMAL_NO_TARGET)
107+
tz->passive++;
108+
else if (old_target != THERMAL_NO_TARGET &&
109+
instance->target == THERMAL_NO_TARGET)
110+
tz->passive--;
111+
}
112+
96113
instance->initialized = true;
97114

98115
mutex_lock(&instance->cdev->lock);

drivers/thermal/thermal_core.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,9 +999,17 @@ __thermal_cooling_device_register(struct device_node *np,
999999
if (ret)
10001000
goto out_cdev_type;
10011001

1002+
/*
1003+
* The cooling device's current state is only needed for debug
1004+
* initialization below, so a failure to get it does not cause
1005+
* the entire cooling device initialization to fail. However,
1006+
* the debug will not work for the device if its initial state
1007+
* cannot be determined and drivers are responsible for ensuring
1008+
* that this will not happen.
1009+
*/
10021010
ret = cdev->ops->get_cur_state(cdev, &current_state);
10031011
if (ret)
1004-
goto out_cdev_type;
1012+
current_state = ULONG_MAX;
10051013

10061014
thermal_cooling_device_setup_sysfs(cdev);
10071015

@@ -1016,7 +1024,8 @@ __thermal_cooling_device_register(struct device_node *np,
10161024
return ERR_PTR(ret);
10171025
}
10181026

1019-
thermal_debug_cdev_add(cdev, current_state);
1027+
if (current_state <= cdev->max_state)
1028+
thermal_debug_cdev_add(cdev, current_state);
10201029

10211030
/* Add 'this' new cdev to the global cdev list */
10221031
mutex_lock(&thermal_list_lock);

0 commit comments

Comments
 (0)