Commit d8e6ba02 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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()
parents 7f369a8f dd75558b
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -33,6 +33,13 @@ config THERMAL_STATISTICS

	  If in doubt, say N.

config THERMAL_DEBUGFS
	bool "Thermal subsystem debug support"
	depends on DEBUG_FS
	help
	  Say Y to allow the thermal subsystem to collect diagnostic
	  information that can be accessed via debugfs.

config THERMAL_EMERGENCY_POWEROFF_DELAY_MS
	int "Emergency poweroff delay in milli-seconds"
	default 0
+2 −0
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@ thermal_sys-y += thermal_trip.o thermal_helpers.o
# netlink interface to manage the thermal framework
thermal_sys-$(CONFIG_THERMAL_NETLINK)		+= thermal_netlink.o

thermal_sys-$(CONFIG_THERMAL_DEBUGFS)	+= thermal_debugfs.o

# interface to/from other layers providing sensors
thermal_sys-$(CONFIG_THERMAL_HWMON)		+= thermal_hwmon.o
thermal_sys-$(CONFIG_THERMAL_OF)		+= thermal_of.o
+1 −1
Original line number Diff line number Diff line
@@ -762,7 +762,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz,

	trip = params->trip_switch_on;
	if (trip && tz->temperature < trip->temperature) {
		update = tz->last_temperature >= trip->temperature;
		update = tz->passive;
		tz->passive = 0;
		reset_pid_controller(params);
		allow_maximum_power(tz, update);
+28 −0
Original line number Diff line number Diff line
@@ -35,7 +35,9 @@
#include <linux/processor.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/suspend.h>
#include <linux/string.h>
#include <linux/syscore_ops.h>
#include <linux/topology.h>
#include <linux/workqueue.h>

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

static void hfi_do_enable(void)
{
	/* This code runs only on the boot CPU. */
	struct hfi_cpu_info *info = &per_cpu(hfi_cpu_info, 0);
	struct hfi_instance *hfi_instance = info->hfi_instance;

	/* No locking needed. There is no concurrency with CPU online. */
	hfi_set_hw_table(hfi_instance);
	hfi_enable();
}

static int hfi_do_disable(void)
{
	/* No locking needed. There is no concurrency with CPU offline. */
	hfi_disable();

	return 0;
}

static struct syscore_ops hfi_pm_ops = {
	.resume = hfi_do_enable,
	.suspend = hfi_do_disable,
};

void __init intel_hfi_init(void)
{
	struct hfi_instance *hfi_instance;
@@ -602,6 +628,8 @@ void __init intel_hfi_init(void)
	if (!hfi_updates_wq)
		goto err_nomem;

	register_syscore_ops(&hfi_pm_ops);

	return;

err_nomem:
+22 −16
Original line number Diff line number Diff line
@@ -211,7 +211,7 @@ int thermal_zone_device_set_policy(struct thermal_zone_device *tz,
	mutex_unlock(&tz->lock);
	mutex_unlock(&thermal_governor_lock);

	thermal_notify_tz_gov_change(tz->id, policy);
	thermal_notify_tz_gov_change(tz, policy);

	return ret;
}
@@ -381,9 +381,8 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
		 * the threshold and the trip temperature will be equal.
		 */
		if (tz->temperature >= trip->temperature) {
			thermal_notify_tz_trip_up(tz->id,
						  thermal_zone_trip_id(tz, trip),
						  tz->temperature);
			thermal_notify_tz_trip_up(tz, trip);
			thermal_debug_tz_trip_up(tz, trip);
			trip->threshold = trip->temperature - trip->hysteresis;
		} else {
			trip->threshold = trip->temperature;
@@ -400,9 +399,8 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
		 * the trip.
		 */
		if (tz->temperature < trip->temperature - trip->hysteresis) {
			thermal_notify_tz_trip_down(tz->id,
						    thermal_zone_trip_id(tz, trip),
						    tz->temperature);
			thermal_notify_tz_trip_down(tz, trip);
			thermal_debug_tz_trip_down(tz, trip);
			trip->threshold = trip->temperature;
		} else {
			trip->threshold = trip->temperature - trip->hysteresis;
@@ -434,6 +432,7 @@ static void update_temperature(struct thermal_zone_device *tz)
	trace_thermal_temperature(tz);

	thermal_genl_sampling_temp(tz->id, temp);
	thermal_debug_update_temp(tz);
}

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,
	mutex_unlock(&tz->lock);

	if (mode == THERMAL_DEVICE_ENABLED)
		thermal_notify_tz_enable(tz->id);
		thermal_notify_tz_enable(tz);
	else
		thermal_notify_tz_disable(tz->id);
		thermal_notify_tz_disable(tz);

	return ret;
}
@@ -846,7 +845,7 @@ static void thermal_release(struct device *dev)
			    sizeof("cooling_device") - 1)) {
		cdev = to_cooling_device(dev);
		thermal_cooling_device_destroy_sysfs(cdev);
		kfree(cdev->type);
		kfree_const(cdev->type);
		ida_free(&thermal_cdev_ida, cdev->id);
		kfree(cdev);
	}
@@ -918,7 +917,7 @@ __thermal_cooling_device_register(struct device_node *np,
	cdev->id = ret;
	id = ret;

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

	mutex_unlock(&thermal_list_lock);

	thermal_debug_cdev_add(cdev);

	return cdev;

out_cooling_dev:
	thermal_cooling_device_destroy_sysfs(cdev);
out_cdev_type:
	kfree(cdev->type);
	kfree_const(cdev->type);
out_ida_remove:
	ida_free(&thermal_cdev_ida, id);
out_kfree_cdev:
@@ -1170,6 +1171,8 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
	if (!cdev)
		return;

	thermal_debug_cdev_remove(cdev);

	mutex_lock(&thermal_list_lock);

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

	thermal_notify_tz_create(tz->id, tz->type);
	thermal_notify_tz_create(tz);

	thermal_debug_tz_add(tz);

	return tz;

@@ -1470,14 +1475,13 @@ EXPORT_SYMBOL_GPL(thermal_zone_device);
 */
void thermal_zone_device_unregister(struct thermal_zone_device *tz)
{
	int tz_id;
	struct thermal_cooling_device *cdev;
	struct thermal_zone_device *pos = NULL;

	if (!tz)
		return;

	tz_id = tz->id;
	thermal_debug_tz_remove(tz);

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

	put_device(&tz->device);

	thermal_notify_tz_delete(tz_id);
	thermal_notify_tz_delete(tz);

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

	thermal_debug_init();

	result = thermal_netlink_init();
	if (result)
		goto error;
Loading