Skip to content

Commit d8e6ba0

Browse files
committed
Merge tag 'thermal-6.8-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull more thermal control updates from Rafael Wysocki: "These add support for debugfs-based diagnostics to the thermal core, simplify the thermal netlink API, fix system-wide PM support in the Intel HFI driver and clean up some code. Specifics: - Add debugfs-based diagnostics support to the thermal core (Daniel Lezcano, Dan Carpenter) - Fix a power allocator thermal governor issue preventing it from resetting cooling devices sometimes (Di Shen) - Simplify the thermal netlink API and clean up related code (Rafael J. Wysocki) - Make the Intel HFI driver support hibernation and deep suspend properly (Ricardo Neri)" * tag 'thermal-6.8-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: thermal/debugfs: Unlock on error path in thermal_debug_tz_trip_up() thermal: intel: hfi: Add syscore callbacks for system-wide PM thermal: gov_power_allocator: avoid inability to reset a cdev thermal: helpers: Rearrange thermal_cdev_set_cur_state() thermal: netlink: Rework notify API for cooling devices thermal: core: Use kstrdup_const() during cooling device registration thermal/debugfs: Add thermal debugfs information for mitigation episodes thermal/debugfs: Add thermal cooling device debugfs information thermal: netlink: Pass thermal zone pointer to notify routines thermal: netlink: Drop thermal_notify_tz_trip_add/delete() thermal: netlink: Pass pointers to thermal_notify_tz_trip_up/down() thermal: netlink: Pass pointers to thermal_notify_tz_trip_change()
2 parents 7f369a8 + dd75558 commit d8e6ba0

File tree

13 files changed

+1026
-127
lines changed

13 files changed

+1026
-127
lines changed

drivers/thermal/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ config THERMAL_STATISTICS
3333

3434
If in doubt, say N.
3535

36+
config THERMAL_DEBUGFS
37+
bool "Thermal subsystem debug support"
38+
depends on DEBUG_FS
39+
help
40+
Say Y to allow the thermal subsystem to collect diagnostic
41+
information that can be accessed via debugfs.
42+
3643
config THERMAL_EMERGENCY_POWEROFF_DELAY_MS
3744
int "Emergency poweroff delay in milli-seconds"
3845
default 0

drivers/thermal/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ thermal_sys-y += thermal_trip.o thermal_helpers.o
1010
# netlink interface to manage the thermal framework
1111
thermal_sys-$(CONFIG_THERMAL_NETLINK) += thermal_netlink.o
1212

13+
thermal_sys-$(CONFIG_THERMAL_DEBUGFS) += thermal_debugfs.o
14+
1315
# interface to/from other layers providing sensors
1416
thermal_sys-$(CONFIG_THERMAL_HWMON) += thermal_hwmon.o
1517
thermal_sys-$(CONFIG_THERMAL_OF) += thermal_of.o

drivers/thermal/gov_power_allocator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz,
762762

763763
trip = params->trip_switch_on;
764764
if (trip && tz->temperature < trip->temperature) {
765-
update = tz->last_temperature >= trip->temperature;
765+
update = tz->passive;
766766
tz->passive = 0;
767767
reset_pid_controller(params);
768768
allow_maximum_power(tz, update);

drivers/thermal/intel/intel_hfi.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
#include <linux/processor.h>
3636
#include <linux/slab.h>
3737
#include <linux/spinlock.h>
38+
#include <linux/suspend.h>
3839
#include <linux/string.h>
40+
#include <linux/syscore_ops.h>
3941
#include <linux/topology.h>
4042
#include <linux/workqueue.h>
4143

@@ -571,6 +573,30 @@ static __init int hfi_parse_features(void)
571573
return 0;
572574
}
573575

576+
static void hfi_do_enable(void)
577+
{
578+
/* This code runs only on the boot CPU. */
579+
struct hfi_cpu_info *info = &per_cpu(hfi_cpu_info, 0);
580+
struct hfi_instance *hfi_instance = info->hfi_instance;
581+
582+
/* No locking needed. There is no concurrency with CPU online. */
583+
hfi_set_hw_table(hfi_instance);
584+
hfi_enable();
585+
}
586+
587+
static int hfi_do_disable(void)
588+
{
589+
/* No locking needed. There is no concurrency with CPU offline. */
590+
hfi_disable();
591+
592+
return 0;
593+
}
594+
595+
static struct syscore_ops hfi_pm_ops = {
596+
.resume = hfi_do_enable,
597+
.suspend = hfi_do_disable,
598+
};
599+
574600
void __init intel_hfi_init(void)
575601
{
576602
struct hfi_instance *hfi_instance;
@@ -602,6 +628,8 @@ void __init intel_hfi_init(void)
602628
if (!hfi_updates_wq)
603629
goto err_nomem;
604630

631+
register_syscore_ops(&hfi_pm_ops);
632+
605633
return;
606634

607635
err_nomem:

drivers/thermal/thermal_core.c

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ int thermal_zone_device_set_policy(struct thermal_zone_device *tz,
211211
mutex_unlock(&tz->lock);
212212
mutex_unlock(&thermal_governor_lock);
213213

214-
thermal_notify_tz_gov_change(tz->id, policy);
214+
thermal_notify_tz_gov_change(tz, policy);
215215

216216
return ret;
217217
}
@@ -381,9 +381,8 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
381381
* the threshold and the trip temperature will be equal.
382382
*/
383383
if (tz->temperature >= trip->temperature) {
384-
thermal_notify_tz_trip_up(tz->id,
385-
thermal_zone_trip_id(tz, trip),
386-
tz->temperature);
384+
thermal_notify_tz_trip_up(tz, trip);
385+
thermal_debug_tz_trip_up(tz, trip);
387386
trip->threshold = trip->temperature - trip->hysteresis;
388387
} else {
389388
trip->threshold = trip->temperature;
@@ -400,9 +399,8 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
400399
* the trip.
401400
*/
402401
if (tz->temperature < trip->temperature - trip->hysteresis) {
403-
thermal_notify_tz_trip_down(tz->id,
404-
thermal_zone_trip_id(tz, trip),
405-
tz->temperature);
402+
thermal_notify_tz_trip_down(tz, trip);
403+
thermal_debug_tz_trip_down(tz, trip);
406404
trip->threshold = trip->temperature;
407405
} else {
408406
trip->threshold = trip->temperature - trip->hysteresis;
@@ -434,6 +432,7 @@ static void update_temperature(struct thermal_zone_device *tz)
434432
trace_thermal_temperature(tz);
435433

436434
thermal_genl_sampling_temp(tz->id, temp);
435+
thermal_debug_update_temp(tz);
437436
}
438437

439438
static void thermal_zone_device_check(struct work_struct *work)
@@ -505,9 +504,9 @@ static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
505504
mutex_unlock(&tz->lock);
506505

507506
if (mode == THERMAL_DEVICE_ENABLED)
508-
thermal_notify_tz_enable(tz->id);
507+
thermal_notify_tz_enable(tz);
509508
else
510-
thermal_notify_tz_disable(tz->id);
509+
thermal_notify_tz_disable(tz);
511510

512511
return ret;
513512
}
@@ -846,7 +845,7 @@ static void thermal_release(struct device *dev)
846845
sizeof("cooling_device") - 1)) {
847846
cdev = to_cooling_device(dev);
848847
thermal_cooling_device_destroy_sysfs(cdev);
849-
kfree(cdev->type);
848+
kfree_const(cdev->type);
850849
ida_free(&thermal_cdev_ida, cdev->id);
851850
kfree(cdev);
852851
}
@@ -918,7 +917,7 @@ __thermal_cooling_device_register(struct device_node *np,
918917
cdev->id = ret;
919918
id = ret;
920919

921-
cdev->type = kstrdup(type ? type : "", GFP_KERNEL);
920+
cdev->type = kstrdup_const(type ? type : "", GFP_KERNEL);
922921
if (!cdev->type) {
923922
ret = -ENOMEM;
924923
goto out_ida_remove;
@@ -964,12 +963,14 @@ __thermal_cooling_device_register(struct device_node *np,
964963

965964
mutex_unlock(&thermal_list_lock);
966965

966+
thermal_debug_cdev_add(cdev);
967+
967968
return cdev;
968969

969970
out_cooling_dev:
970971
thermal_cooling_device_destroy_sysfs(cdev);
971972
out_cdev_type:
972-
kfree(cdev->type);
973+
kfree_const(cdev->type);
973974
out_ida_remove:
974975
ida_free(&thermal_cdev_ida, id);
975976
out_kfree_cdev:
@@ -1170,6 +1171,8 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
11701171
if (!cdev)
11711172
return;
11721173

1174+
thermal_debug_cdev_remove(cdev);
1175+
11731176
mutex_lock(&thermal_list_lock);
11741177

11751178
if (!thermal_cooling_device_present(cdev)) {
@@ -1411,7 +1414,9 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t
14111414
if (atomic_cmpxchg(&tz->need_update, 1, 0))
14121415
thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
14131416

1414-
thermal_notify_tz_create(tz->id, tz->type);
1417+
thermal_notify_tz_create(tz);
1418+
1419+
thermal_debug_tz_add(tz);
14151420

14161421
return tz;
14171422

@@ -1470,14 +1475,13 @@ EXPORT_SYMBOL_GPL(thermal_zone_device);
14701475
*/
14711476
void thermal_zone_device_unregister(struct thermal_zone_device *tz)
14721477
{
1473-
int tz_id;
14741478
struct thermal_cooling_device *cdev;
14751479
struct thermal_zone_device *pos = NULL;
14761480

14771481
if (!tz)
14781482
return;
14791483

1480-
tz_id = tz->id;
1484+
thermal_debug_tz_remove(tz);
14811485

14821486
mutex_lock(&thermal_list_lock);
14831487
list_for_each_entry(pos, &thermal_tz_list, node)
@@ -1514,7 +1518,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
15141518

15151519
put_device(&tz->device);
15161520

1517-
thermal_notify_tz_delete(tz_id);
1521+
thermal_notify_tz_delete(tz);
15181522

15191523
wait_for_completion(&tz->removal);
15201524
kfree(tz);
@@ -1636,6 +1640,8 @@ static int __init thermal_init(void)
16361640
{
16371641
int result;
16381642

1643+
thermal_debug_init();
1644+
16391645
result = thermal_netlink_init();
16401646
if (result)
16411647
goto error;

drivers/thermal/thermal_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/thermal.h>
1414

1515
#include "thermal_netlink.h"
16+
#include "thermal_debugfs.h"
1617

1718
/* Default Thermal Governor */
1819
#if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE)

0 commit comments

Comments
 (0)