Skip to content

Commit 51f2aaf

Browse files
committed
thermal: intel: intel_soc_dts_iosf: Change initialization ordering
The initial configuration of trip points in intel_soc_dts_iosf_init() takes place after registering the sensor thermal zones which is potentially problematic, because it may race with the setting of trip point temperatures via sysfs, as there is no synchronization between it and sys_set_trip_temp(). To address this, change the initialization ordering so that the trip points are configured prior to the registration of thermal zones. Accordingly, change the cleanup ordering in intel_soc_dts_iosf_exit() to remove the thermal zones before resetting the trip points. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
1 parent cbc2805 commit 51f2aaf

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

drivers/thermal/intel/intel_soc_dts_iosf.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -398,30 +398,37 @@ struct intel_soc_dts_sensors *intel_soc_dts_iosf_init(
398398

399399
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
400400
sensors->soc_dts[i].sensors = sensors;
401-
ret = add_dts_thermal_zone(i, &sensors->soc_dts[i],
402-
read_only_trip_count);
403-
if (ret)
404-
goto err_free;
405-
}
406401

407-
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
408402
ret = configure_trip(&sensors->soc_dts[i], 0,
409403
THERMAL_TRIP_PASSIVE, 0);
410404
if (ret)
411-
goto err_remove_zone;
405+
goto err_reset_trips;
412406

413407
ret = configure_trip(&sensors->soc_dts[i], 1,
414408
THERMAL_TRIP_PASSIVE, 0);
409+
if (ret)
410+
goto err_reset_trips;
411+
}
412+
413+
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
414+
ret = add_dts_thermal_zone(i, &sensors->soc_dts[i],
415+
read_only_trip_count);
415416
if (ret)
416417
goto err_remove_zone;
417418
}
418419

419420
return sensors;
421+
420422
err_remove_zone:
421423
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i)
422424
remove_dts_thermal_zone(&sensors->soc_dts[i]);
423425

424-
err_free:
426+
err_reset_trips:
427+
for (i = 0; i < SOC_MAX_DTS_SENSORS; i++) {
428+
configure_trip(&sensors->soc_dts[i], 0, 0, 0);
429+
configure_trip(&sensors->soc_dts[i], 1, 0, 0);
430+
}
431+
425432
kfree(sensors);
426433
return ERR_PTR(ret);
427434
}
@@ -432,9 +439,9 @@ void intel_soc_dts_iosf_exit(struct intel_soc_dts_sensors *sensors)
432439
int i;
433440

434441
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
442+
remove_dts_thermal_zone(&sensors->soc_dts[i]);
435443
configure_trip(&sensors->soc_dts[i], 0, 0, 0);
436444
configure_trip(&sensors->soc_dts[i], 1, 0, 0);
437-
remove_dts_thermal_zone(&sensors->soc_dts[i]);
438445
}
439446
kfree(sensors);
440447
}

0 commit comments

Comments
 (0)