Skip to content

Commit b1bf9db

Browse files
committed
thermal: intel: int340x: Rework updating trip points
It is generally invalid to change the trip point indices after they have been exposed via sysfs. Moreover, the thermal objects in the ACPI namespace cannot go away and appear on the fly. In practice, the only thing that can happen when the INT3403_PERF_TRIP_POINT_CHANGED notification is sent by the platform firmware is a change of the return values of those thermal objects. For this reason, add a special function for updating the trip point temperatures after re-evaluating the respective ACPI thermal objects and change int3403_notify() to invoke it instead of int340x_thermal_read_trips() that would change the trip point indices on errors. Also remove the locking from the latter, because it is only called before registering the thermal zone and it cannot race with the zone's callbacks. Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 97efecf commit b1bf9db

File tree

3 files changed

+47
-8
lines changed

3 files changed

+47
-8
lines changed

drivers/thermal/intel/int340x_thermal/int3403_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static void int3403_notify(acpi_handle handle,
6969
THERMAL_TRIP_VIOLATED);
7070
break;
7171
case INT3403_PERF_TRIP_POINT_CHANGED:
72-
int340x_thermal_read_trips(obj->int340x_zone);
72+
int340x_thermal_update_trips(obj->int340x_zone);
7373
int340x_thermal_zone_device_update(obj->int340x_zone,
7474
THERMAL_TRIP_CHANGED);
7575
break;

drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,11 @@ static int int340x_thermal_get_trip_config(acpi_handle handle, char *name,
168168
return 0;
169169
}
170170

171-
int int340x_thermal_read_trips(struct int34x_thermal_zone *int34x_zone)
171+
static int int340x_thermal_read_trips(struct int34x_thermal_zone *int34x_zone)
172172
{
173173
int trip_cnt = int34x_zone->aux_trip_nr;
174174
int i;
175175

176-
mutex_lock(&int34x_zone->trip_mutex);
177-
178176
int34x_zone->crt_trip_id = -1;
179177
if (!int340x_thermal_get_trip_config(int34x_zone->adev->handle, "_CRT",
180178
&int34x_zone->crt_temp))
@@ -202,11 +200,8 @@ int int340x_thermal_read_trips(struct int34x_thermal_zone *int34x_zone)
202200
int34x_zone->act_trips[i].valid = true;
203201
}
204202

205-
mutex_unlock(&int34x_zone->trip_mutex);
206-
207203
return trip_cnt;
208204
}
209-
EXPORT_SYMBOL_GPL(int340x_thermal_read_trips);
210205

211206
static struct thermal_zone_params int340x_thermal_params = {
212207
.governor_name = "user_space",
@@ -309,6 +304,50 @@ void int340x_thermal_zone_remove(struct int34x_thermal_zone
309304
}
310305
EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove);
311306

307+
void int340x_thermal_update_trips(struct int34x_thermal_zone *int34x_zone)
308+
{
309+
acpi_handle zone_handle = int34x_zone->adev->handle;
310+
int i, err;
311+
312+
mutex_lock(&int34x_zone->trip_mutex);
313+
314+
if (int34x_zone->crt_trip_id > 0) {
315+
err = int340x_thermal_get_trip_config(zone_handle, "_CRT",
316+
&int34x_zone->crt_temp);
317+
if (err)
318+
int34x_zone->crt_temp = THERMAL_TEMP_INVALID;
319+
}
320+
321+
if (int34x_zone->hot_trip_id > 0) {
322+
err = int340x_thermal_get_trip_config(zone_handle, "_HOT",
323+
&int34x_zone->hot_temp);
324+
if (err)
325+
int34x_zone->hot_temp = THERMAL_TEMP_INVALID;
326+
}
327+
328+
if (int34x_zone->psv_trip_id > 0) {
329+
err = int340x_thermal_get_trip_config(zone_handle, "_PSV",
330+
&int34x_zone->psv_temp);
331+
if (err)
332+
int34x_zone->psv_temp = THERMAL_TEMP_INVALID;
333+
}
334+
335+
for (i = 0; i < INT340X_THERMAL_MAX_ACT_TRIP_COUNT; i++) {
336+
char name[5] = { '_', 'A', 'C', '0' + i, '\0' };
337+
338+
if (!int34x_zone->act_trips[i].valid)
339+
break;
340+
341+
err = int340x_thermal_get_trip_config(zone_handle, name,
342+
&int34x_zone->act_trips[i].temp);
343+
if (err)
344+
int34x_zone->act_trips[i].temp = THERMAL_TEMP_INVALID;
345+
}
346+
347+
mutex_unlock(&int34x_zone->trip_mutex);
348+
}
349+
EXPORT_SYMBOL_GPL(int340x_thermal_update_trips);
350+
312351
MODULE_AUTHOR("Aaron Lu <[email protected]>");
313352
MODULE_AUTHOR("Srinivas Pandruvada <[email protected]>");
314353
MODULE_DESCRIPTION("Intel INT340x common thermal zone handler");

drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct int34x_thermal_zone {
3838
struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *,
3939
int (*get_temp) (struct thermal_zone_device *, int *));
4040
void int340x_thermal_zone_remove(struct int34x_thermal_zone *);
41-
int int340x_thermal_read_trips(struct int34x_thermal_zone *int34x_zone);
41+
void int340x_thermal_update_trips(struct int34x_thermal_zone *int34x_zone);
4242

4343
static inline void int340x_thermal_zone_set_priv_data(
4444
struct int34x_thermal_zone *tzone, void *priv_data)

0 commit comments

Comments
 (0)