Commit d8e6ba02 authored by Linus Torvalds's avatar Linus Torvalds

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()
parents 7f369a8f dd75558b
...@@ -33,6 +33,13 @@ config THERMAL_STATISTICS ...@@ -33,6 +33,13 @@ config THERMAL_STATISTICS
If in doubt, say N. 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 config THERMAL_EMERGENCY_POWEROFF_DELAY_MS
int "Emergency poweroff delay in milli-seconds" int "Emergency poweroff delay in milli-seconds"
default 0 default 0
......
...@@ -10,6 +10,8 @@ thermal_sys-y += thermal_trip.o thermal_helpers.o ...@@ -10,6 +10,8 @@ thermal_sys-y += thermal_trip.o thermal_helpers.o
# netlink interface to manage the thermal framework # netlink interface to manage the thermal framework
thermal_sys-$(CONFIG_THERMAL_NETLINK) += thermal_netlink.o thermal_sys-$(CONFIG_THERMAL_NETLINK) += thermal_netlink.o
thermal_sys-$(CONFIG_THERMAL_DEBUGFS) += thermal_debugfs.o
# interface to/from other layers providing sensors # interface to/from other layers providing sensors
thermal_sys-$(CONFIG_THERMAL_HWMON) += thermal_hwmon.o thermal_sys-$(CONFIG_THERMAL_HWMON) += thermal_hwmon.o
thermal_sys-$(CONFIG_THERMAL_OF) += thermal_of.o thermal_sys-$(CONFIG_THERMAL_OF) += thermal_of.o
......
...@@ -762,7 +762,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, ...@@ -762,7 +762,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz,
trip = params->trip_switch_on; trip = params->trip_switch_on;
if (trip && tz->temperature < trip->temperature) { if (trip && tz->temperature < trip->temperature) {
update = tz->last_temperature >= trip->temperature; update = tz->passive;
tz->passive = 0; tz->passive = 0;
reset_pid_controller(params); reset_pid_controller(params);
allow_maximum_power(tz, update); allow_maximum_power(tz, update);
......
...@@ -35,7 +35,9 @@ ...@@ -35,7 +35,9 @@
#include <linux/processor.h> #include <linux/processor.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/suspend.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/syscore_ops.h>
#include <linux/topology.h> #include <linux/topology.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
...@@ -571,6 +573,30 @@ static __init int hfi_parse_features(void) ...@@ -571,6 +573,30 @@ static __init int hfi_parse_features(void)
return 0; 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) void __init intel_hfi_init(void)
{ {
struct hfi_instance *hfi_instance; struct hfi_instance *hfi_instance;
...@@ -602,6 +628,8 @@ void __init intel_hfi_init(void) ...@@ -602,6 +628,8 @@ void __init intel_hfi_init(void)
if (!hfi_updates_wq) if (!hfi_updates_wq)
goto err_nomem; goto err_nomem;
register_syscore_ops(&hfi_pm_ops);
return; return;
err_nomem: err_nomem:
......
...@@ -211,7 +211,7 @@ int thermal_zone_device_set_policy(struct thermal_zone_device *tz, ...@@ -211,7 +211,7 @@ int thermal_zone_device_set_policy(struct thermal_zone_device *tz,
mutex_unlock(&tz->lock); mutex_unlock(&tz->lock);
mutex_unlock(&thermal_governor_lock); mutex_unlock(&thermal_governor_lock);
thermal_notify_tz_gov_change(tz->id, policy); thermal_notify_tz_gov_change(tz, policy);
return ret; return ret;
} }
...@@ -381,9 +381,8 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, ...@@ -381,9 +381,8 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
* the threshold and the trip temperature will be equal. * the threshold and the trip temperature will be equal.
*/ */
if (tz->temperature >= trip->temperature) { if (tz->temperature >= trip->temperature) {
thermal_notify_tz_trip_up(tz->id, thermal_notify_tz_trip_up(tz, trip);
thermal_zone_trip_id(tz, trip), thermal_debug_tz_trip_up(tz, trip);
tz->temperature);
trip->threshold = trip->temperature - trip->hysteresis; trip->threshold = trip->temperature - trip->hysteresis;
} else { } else {
trip->threshold = trip->temperature; trip->threshold = trip->temperature;
...@@ -400,9 +399,8 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, ...@@ -400,9 +399,8 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
* the trip. * the trip.
*/ */
if (tz->temperature < trip->temperature - trip->hysteresis) { if (tz->temperature < trip->temperature - trip->hysteresis) {
thermal_notify_tz_trip_down(tz->id, thermal_notify_tz_trip_down(tz, trip);
thermal_zone_trip_id(tz, trip), thermal_debug_tz_trip_down(tz, trip);
tz->temperature);
trip->threshold = trip->temperature; trip->threshold = trip->temperature;
} else { } else {
trip->threshold = trip->temperature - trip->hysteresis; trip->threshold = trip->temperature - trip->hysteresis;
...@@ -434,6 +432,7 @@ static void update_temperature(struct thermal_zone_device *tz) ...@@ -434,6 +432,7 @@ static void update_temperature(struct thermal_zone_device *tz)
trace_thermal_temperature(tz); trace_thermal_temperature(tz);
thermal_genl_sampling_temp(tz->id, temp); thermal_genl_sampling_temp(tz->id, temp);
thermal_debug_update_temp(tz);
} }
static void thermal_zone_device_check(struct work_struct *work) 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, ...@@ -505,9 +504,9 @@ static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
mutex_unlock(&tz->lock); mutex_unlock(&tz->lock);
if (mode == THERMAL_DEVICE_ENABLED) if (mode == THERMAL_DEVICE_ENABLED)
thermal_notify_tz_enable(tz->id); thermal_notify_tz_enable(tz);
else else
thermal_notify_tz_disable(tz->id); thermal_notify_tz_disable(tz);
return ret; return ret;
} }
...@@ -846,7 +845,7 @@ static void thermal_release(struct device *dev) ...@@ -846,7 +845,7 @@ static void thermal_release(struct device *dev)
sizeof("cooling_device") - 1)) { sizeof("cooling_device") - 1)) {
cdev = to_cooling_device(dev); cdev = to_cooling_device(dev);
thermal_cooling_device_destroy_sysfs(cdev); thermal_cooling_device_destroy_sysfs(cdev);
kfree(cdev->type); kfree_const(cdev->type);
ida_free(&thermal_cdev_ida, cdev->id); ida_free(&thermal_cdev_ida, cdev->id);
kfree(cdev); kfree(cdev);
} }
...@@ -918,7 +917,7 @@ __thermal_cooling_device_register(struct device_node *np, ...@@ -918,7 +917,7 @@ __thermal_cooling_device_register(struct device_node *np,
cdev->id = ret; cdev->id = ret;
id = ret; id = ret;
cdev->type = kstrdup(type ? type : "", GFP_KERNEL); cdev->type = kstrdup_const(type ? type : "", GFP_KERNEL);
if (!cdev->type) { if (!cdev->type) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_ida_remove; goto out_ida_remove;
...@@ -964,12 +963,14 @@ __thermal_cooling_device_register(struct device_node *np, ...@@ -964,12 +963,14 @@ __thermal_cooling_device_register(struct device_node *np,
mutex_unlock(&thermal_list_lock); mutex_unlock(&thermal_list_lock);
thermal_debug_cdev_add(cdev);
return cdev; return cdev;
out_cooling_dev: out_cooling_dev:
thermal_cooling_device_destroy_sysfs(cdev); thermal_cooling_device_destroy_sysfs(cdev);
out_cdev_type: out_cdev_type:
kfree(cdev->type); kfree_const(cdev->type);
out_ida_remove: out_ida_remove:
ida_free(&thermal_cdev_ida, id); ida_free(&thermal_cdev_ida, id);
out_kfree_cdev: out_kfree_cdev:
...@@ -1170,6 +1171,8 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) ...@@ -1170,6 +1171,8 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
if (!cdev) if (!cdev)
return; return;
thermal_debug_cdev_remove(cdev);
mutex_lock(&thermal_list_lock); mutex_lock(&thermal_list_lock);
if (!thermal_cooling_device_present(cdev)) { if (!thermal_cooling_device_present(cdev)) {
...@@ -1411,7 +1414,9 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t ...@@ -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)) if (atomic_cmpxchg(&tz->need_update, 1, 0))
thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); 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; return tz;
...@@ -1470,14 +1475,13 @@ EXPORT_SYMBOL_GPL(thermal_zone_device); ...@@ -1470,14 +1475,13 @@ EXPORT_SYMBOL_GPL(thermal_zone_device);
*/ */
void thermal_zone_device_unregister(struct thermal_zone_device *tz) void thermal_zone_device_unregister(struct thermal_zone_device *tz)
{ {
int tz_id;
struct thermal_cooling_device *cdev; struct thermal_cooling_device *cdev;
struct thermal_zone_device *pos = NULL; struct thermal_zone_device *pos = NULL;
if (!tz) if (!tz)
return; return;
tz_id = tz->id; thermal_debug_tz_remove(tz);
mutex_lock(&thermal_list_lock); mutex_lock(&thermal_list_lock);
list_for_each_entry(pos, &thermal_tz_list, node) list_for_each_entry(pos, &thermal_tz_list, node)
...@@ -1514,7 +1518,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) ...@@ -1514,7 +1518,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
put_device(&tz->device); put_device(&tz->device);
thermal_notify_tz_delete(tz_id); thermal_notify_tz_delete(tz);
wait_for_completion(&tz->removal); wait_for_completion(&tz->removal);
kfree(tz); kfree(tz);
...@@ -1636,6 +1640,8 @@ static int __init thermal_init(void) ...@@ -1636,6 +1640,8 @@ static int __init thermal_init(void)
{ {
int result; int result;
thermal_debug_init();
result = thermal_netlink_init(); result = thermal_netlink_init();
if (result) if (result)
goto error; goto error;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/thermal.h> #include <linux/thermal.h>
#include "thermal_netlink.h" #include "thermal_netlink.h"
#include "thermal_debugfs.h"
/* Default Thermal Governor */ /* Default Thermal Governor */
#if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE) #if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE)
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
#ifdef CONFIG_THERMAL_DEBUGFS
void thermal_debug_init(void);
void thermal_debug_cdev_add(struct thermal_cooling_device *cdev);
void thermal_debug_cdev_remove(struct thermal_cooling_device *cdev);
void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev, int state);
void thermal_debug_tz_add(struct thermal_zone_device *tz);
void thermal_debug_tz_remove(struct thermal_zone_device *tz);
void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
const struct thermal_trip *trip);
void thermal_debug_tz_trip_down(struct thermal_zone_device *tz,
const struct thermal_trip *trip);
void thermal_debug_update_temp(struct thermal_zone_device *tz);
#else
static inline void thermal_debug_init(void) {}
static inline void thermal_debug_cdev_add(struct thermal_cooling_device *cdev) {}
static inline void thermal_debug_cdev_remove(struct thermal_cooling_device *cdev) {}
static inline void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev,
int state) {}
static inline void thermal_debug_tz_add(struct thermal_zone_device *tz) {}
static inline void thermal_debug_tz_remove(struct thermal_zone_device *tz) {}
static inline void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
const struct thermal_trip *trip) {};
static inline void thermal_debug_tz_trip_down(struct thermal_zone_device *tz,
const struct thermal_trip *trip) {}
static inline void thermal_debug_update_temp(struct thermal_zone_device *tz) {}
#endif /* CONFIG_THERMAL_DEBUGFS */
...@@ -146,14 +146,23 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) ...@@ -146,14 +146,23 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
} }
EXPORT_SYMBOL_GPL(thermal_zone_get_temp); EXPORT_SYMBOL_GPL(thermal_zone_get_temp);
static void thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev, static int thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev, int state)
int target)
{ {
if (cdev->ops->set_cur_state(cdev, target)) int ret;
return;
/*
* No check is needed for the ops->set_cur_state as the
* registering function checked the ops are correctly set
*/
ret = cdev->ops->set_cur_state(cdev, state);
if (ret)
return ret;
thermal_notify_cdev_state_update(cdev->id, target); thermal_notify_cdev_state_update(cdev, state);
thermal_cooling_device_stats_update(cdev, target); thermal_cooling_device_stats_update(cdev, state);
thermal_debug_cdev_state_update(cdev, state);
return 0;
} }
void __thermal_cdev_update(struct thermal_cooling_device *cdev) void __thermal_cdev_update(struct thermal_cooling_device *cdev)
......
...@@ -148,7 +148,7 @@ static int thermal_genl_event_tz_trip_up(struct param *p) ...@@ -148,7 +148,7 @@ static int thermal_genl_event_tz_trip_up(struct param *p)
return 0; return 0;
} }
static int thermal_genl_event_tz_trip_add(struct param *p) static int thermal_genl_event_tz_trip_change(struct param *p)
{ {
if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id) || if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id) ||
nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, p->trip_id) || nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, p->trip_id) ||
...@@ -160,15 +160,6 @@ static int thermal_genl_event_tz_trip_add(struct param *p) ...@@ -160,15 +160,6 @@ static int thermal_genl_event_tz_trip_add(struct param *p)
return 0; return 0;
} }
static int thermal_genl_event_tz_trip_delete(struct param *p)
{
if (nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_ID, p->tz_id) ||
nla_put_u32(p->msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, p->trip_id))
return -EMSGSIZE;
return 0;
}
static int thermal_genl_event_cdev_add(struct param *p) static int thermal_genl_event_cdev_add(struct param *p)
{ {
if (nla_put_string(p->msg, THERMAL_GENL_ATTR_CDEV_NAME, if (nla_put_string(p->msg, THERMAL_GENL_ATTR_CDEV_NAME,
...@@ -258,9 +249,6 @@ int thermal_genl_event_tz_disable(struct param *p) ...@@ -258,9 +249,6 @@ int thermal_genl_event_tz_disable(struct param *p)
int thermal_genl_event_tz_trip_down(struct param *p) int thermal_genl_event_tz_trip_down(struct param *p)
__attribute__((alias("thermal_genl_event_tz_trip_up"))); __attribute__((alias("thermal_genl_event_tz_trip_up")));
int thermal_genl_event_tz_trip_change(struct param *p)
__attribute__((alias("thermal_genl_event_tz_trip_add")));
static cb_t event_cb[] = { static cb_t event_cb[] = {
[THERMAL_GENL_EVENT_TZ_CREATE] = thermal_genl_event_tz_create, [THERMAL_GENL_EVENT_TZ_CREATE] = thermal_genl_event_tz_create,
[THERMAL_GENL_EVENT_TZ_DELETE] = thermal_genl_event_tz_delete, [THERMAL_GENL_EVENT_TZ_DELETE] = thermal_genl_event_tz_delete,
...@@ -269,8 +257,6 @@ static cb_t event_cb[] = { ...@@ -269,8 +257,6 @@ static cb_t event_cb[] = {
[THERMAL_GENL_EVENT_TZ_TRIP_UP] = thermal_genl_event_tz_trip_up, [THERMAL_GENL_EVENT_TZ_TRIP_UP] = thermal_genl_event_tz_trip_up,
[THERMAL_GENL_EVENT_TZ_TRIP_DOWN] = thermal_genl_event_tz_trip_down, [THERMAL_GENL_EVENT_TZ_TRIP_DOWN] = thermal_genl_event_tz_trip_down,
[THERMAL_GENL_EVENT_TZ_TRIP_CHANGE] = thermal_genl_event_tz_trip_change, [THERMAL_GENL_EVENT_TZ_TRIP_CHANGE] = thermal_genl_event_tz_trip_change,
[THERMAL_GENL_EVENT_TZ_TRIP_ADD] = thermal_genl_event_tz_trip_add,
[THERMAL_GENL_EVENT_TZ_TRIP_DELETE] = thermal_genl_event_tz_trip_delete,
[THERMAL_GENL_EVENT_CDEV_ADD] = thermal_genl_event_cdev_add, [THERMAL_GENL_EVENT_CDEV_ADD] = thermal_genl_event_cdev_add,
[THERMAL_GENL_EVENT_CDEV_DELETE] = thermal_genl_event_cdev_delete, [THERMAL_GENL_EVENT_CDEV_DELETE] = thermal_genl_event_cdev_delete,
[THERMAL_GENL_EVENT_CDEV_STATE_UPDATE] = thermal_genl_event_cdev_state_update, [THERMAL_GENL_EVENT_CDEV_STATE_UPDATE] = thermal_genl_event_cdev_state_update,
...@@ -318,100 +304,93 @@ static int thermal_genl_send_event(enum thermal_genl_event event, ...@@ -318,100 +304,93 @@ static int thermal_genl_send_event(enum thermal_genl_event event,
return ret; return ret;
} }
int thermal_notify_tz_create(int tz_id, const char *name) int thermal_notify_tz_create(const struct thermal_zone_device *tz)
{ {
struct param p = { .tz_id = tz_id, .name = name }; struct param p = { .tz_id = tz->id, .name = tz->type };
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_CREATE, &p); return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_CREATE, &p);
} }
int thermal_notify_tz_delete(int tz_id) int thermal_notify_tz_delete(const struct thermal_zone_device *tz)
{ {
struct param p = { .tz_id = tz_id }; struct param p = { .tz_id = tz->id };
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_DELETE, &p); return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_DELETE, &p);
} }
int thermal_notify_tz_enable(int tz_id) int thermal_notify_tz_enable(const struct thermal_zone_device *tz)
{ {
struct param p = { .tz_id = tz_id }; struct param p = { .tz_id = tz->id };
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_ENABLE, &p); return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_ENABLE, &p);
} }
int thermal_notify_tz_disable(int tz_id) int thermal_notify_tz_disable(const struct thermal_zone_device *tz)
{ {
struct param p = { .tz_id = tz_id }; struct param p = { .tz_id = tz->id };
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_DISABLE, &p); return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_DISABLE, &p);
} }
int thermal_notify_tz_trip_down(int tz_id, int trip_id, int temp) int thermal_notify_tz_trip_down(const struct thermal_zone_device *tz,
const struct thermal_trip *trip)
{ {
struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp }; struct param p = { .tz_id = tz->id,
.trip_id = thermal_zone_trip_id(tz, trip),
.temp = tz->temperature };
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_DOWN, &p); return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_DOWN, &p);
} }
int thermal_notify_tz_trip_up(int tz_id, int trip_id, int temp) int thermal_notify_tz_trip_up(const struct thermal_zone_device *tz,
const struct thermal_trip *trip)
{ {
struct param p = { .tz_id = tz_id, .trip_id = trip_id, .temp = temp }; struct param p = { .tz_id = tz->id,
.trip_id = thermal_zone_trip_id(tz, trip),
.temp = tz->temperature };
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_UP, &p); return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_UP, &p);
} }
int thermal_notify_tz_trip_add(int tz_id, int trip_id, int trip_type, int thermal_notify_tz_trip_change(const struct thermal_zone_device *tz,
int trip_temp, int trip_hyst) const struct thermal_trip *trip)
{
struct param p = { .tz_id = tz_id, .trip_id = trip_id,
.trip_type = trip_type, .trip_temp = trip_temp,
.trip_hyst = trip_hyst };
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_ADD, &p);
}
int thermal_notify_tz_trip_delete(int tz_id, int trip_id)
{
struct param p = { .tz_id = tz_id, .trip_id = trip_id };
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_DELETE, &p);
}
int thermal_notify_tz_trip_change(int tz_id, int trip_id, int trip_type,
int trip_temp, int trip_hyst)
{ {
struct param p = { .tz_id = tz_id, .trip_id = trip_id, struct param p = { .tz_id = tz->id,
.trip_type = trip_type, .trip_temp = trip_temp, .trip_id = thermal_zone_trip_id(tz, trip),
.trip_hyst = trip_hyst }; .trip_type = trip->type,
.trip_temp = trip->temperature,
.trip_hyst = trip->hysteresis };
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_CHANGE, &p); return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_TRIP_CHANGE, &p);
} }
int thermal_notify_cdev_state_update(int cdev_id, int cdev_state) int thermal_notify_cdev_state_update(const struct thermal_cooling_device *cdev,
int state)
{ {
struct param p = { .cdev_id = cdev_id, .cdev_state = cdev_state }; struct param p = { .cdev_id = cdev->id, .cdev_state = state };
return thermal_genl_send_event(THERMAL_GENL_EVENT_CDEV_STATE_UPDATE, &p); return thermal_genl_send_event(THERMAL_GENL_EVENT_CDEV_STATE_UPDATE, &p);
} }
int thermal_notify_cdev_add(int cdev_id, const char *name, int cdev_max_state) int thermal_notify_cdev_add(const struct thermal_cooling_device *cdev)
{ {
struct param p = { .cdev_id = cdev_id, .name = name, struct param p = { .cdev_id = cdev->id, .name = cdev->type,
.cdev_max_state = cdev_max_state }; .cdev_max_state = cdev->max_state };
return thermal_genl_send_event(THERMAL_GENL_EVENT_CDEV_ADD, &p); return thermal_genl_send_event(THERMAL_GENL_EVENT_CDEV_ADD, &p);
} }
int thermal_notify_cdev_delete(int cdev_id) int thermal_notify_cdev_delete(const struct thermal_cooling_device *cdev)
{ {
struct param p = { .cdev_id = cdev_id }; struct param p = { .cdev_id = cdev->id };
return thermal_genl_send_event(THERMAL_GENL_EVENT_CDEV_DELETE, &p); return thermal_genl_send_event(THERMAL_GENL_EVENT_CDEV_DELETE, &p);
} }
int thermal_notify_tz_gov_change(int tz_id, const char *name) int thermal_notify_tz_gov_change(const struct thermal_zone_device *tz,
const char *name)
{ {
struct param p = { .tz_id = tz_id, .name = name }; struct param p = { .tz_id = tz->id, .name = name };
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_GOV_CHANGE, &p); return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_GOV_CHANGE, &p);
} }
......
...@@ -10,25 +10,30 @@ struct thermal_genl_cpu_caps { ...@@ -10,25 +10,30 @@ struct thermal_genl_cpu_caps {
int efficiency; int efficiency;
}; };
struct thermal_zone_device;
struct thermal_trip;
struct thermal_cooling_device;
/* Netlink notification function */ /* Netlink notification function */
#ifdef CONFIG_THERMAL_NETLINK #ifdef CONFIG_THERMAL_NETLINK
int __init thermal_netlink_init(void); int __init thermal_netlink_init(void);
void __init thermal_netlink_exit(void); void __init thermal_netlink_exit(void);
int thermal_notify_tz_create(int tz_id, const char *name); int thermal_notify_tz_create(const struct thermal_zone_device *tz);
int thermal_notify_tz_delete(int tz_id); int thermal_notify_tz_delete(const struct thermal_zone_device *tz);
int thermal_notify_tz_enable(int tz_id); int thermal_notify_tz_enable(const struct thermal_zone_device *tz);
int thermal_notify_tz_disable(int tz_id); int thermal_notify_tz_disable(const struct thermal_zone_device *tz);
int thermal_notify_tz_trip_down(int tz_id, int id, int temp); int thermal_notify_tz_trip_down(const struct thermal_zone_device *tz,
int thermal_notify_tz_trip_up(int tz_id, int id, int temp); const struct thermal_trip *trip);
int thermal_notify_tz_trip_delete(int tz_id, int id); int thermal_notify_tz_trip_up(const struct thermal_zone_device *tz,
int thermal_notify_tz_trip_add(int tz_id, int id, int type, const struct thermal_trip *trip);
int temp, int hyst); int thermal_notify_tz_trip_change(const struct thermal_zone_device *tz,
int thermal_notify_tz_trip_change(int tz_id, int id, int type, const struct thermal_trip *trip);
int temp, int hyst); int thermal_notify_cdev_state_update(const struct thermal_cooling_device *cdev,
int thermal_notify_cdev_state_update(int cdev_id, int state); int state);
int thermal_notify_cdev_add(int cdev_id, const char *name, int max_state); int thermal_notify_cdev_add(const struct thermal_cooling_device *cdev);
int thermal_notify_cdev_delete(int cdev_id); int thermal_notify_cdev_delete(const struct thermal_cooling_device *cdev);
int thermal_notify_tz_gov_change(int tz_id, const char *name); int thermal_notify_tz_gov_change(const struct thermal_zone_device *tz,
const char *name);
int thermal_genl_sampling_temp(int id, int temp); int thermal_genl_sampling_temp(int id, int temp);
int thermal_genl_cpu_capability_event(int count, int thermal_genl_cpu_capability_event(int count,
struct thermal_genl_cpu_caps *caps); struct thermal_genl_cpu_caps *caps);
...@@ -38,70 +43,62 @@ static inline int thermal_netlink_init(void) ...@@ -38,70 +43,62 @@ static inline int thermal_netlink_init(void)
return 0; return 0;
} }
static inline int thermal_notify_tz_create(int tz_id, const char *name) static inline int thermal_notify_tz_create(const struct thermal_zone_device *tz)
{
return 0;
}
static inline int thermal_notify_tz_delete(int tz_id)
{
return 0;
}
static inline int thermal_notify_tz_enable(int tz_id)
{ {
return 0; return 0;
} }
static inline int thermal_notify_tz_disable(int tz_id) static inline int thermal_notify_tz_delete(const struct thermal_zone_device *tz)
{ {
return 0; return 0;
} }
static inline int thermal_notify_tz_trip_down(int tz_id, int id, int temp) static inline int thermal_notify_tz_enable(const struct thermal_zone_device *tz)
{ {
return 0; return 0;
} }
static inline int thermal_notify_tz_trip_up(int tz_id, int id, int temp) static inline int thermal_notify_tz_disable(const struct thermal_zone_device *tz)
{ {
return 0; return 0;
} }
static inline int thermal_notify_tz_trip_delete(int tz_id, int id) static inline int thermal_notify_tz_trip_down(const struct thermal_zone_device *tz,
const struct thermal_trip *trip)
{ {
return 0; return 0;
} }
static inline int thermal_notify_tz_trip_add(int tz_id, int id, int type, static inline int thermal_notify_tz_trip_up(const struct thermal_zone_device *tz,
int temp, int hyst) const struct thermal_trip *trip)
{ {
return 0; return 0;
} }
static inline int thermal_notify_tz_trip_change(int tz_id, int id, int type, static inline int thermal_notify_tz_trip_change(const struct thermal_zone_device *tz,
int temp, int hyst) const struct thermal_trip *trip)
{ {
return 0; return 0;
} }
static inline int thermal_notify_cdev_state_update(int cdev_id, int state) static inline int thermal_notify_cdev_state_update(const struct thermal_cooling_device *cdev,
int state)
{ {
return 0; return 0;
} }
static inline int thermal_notify_cdev_add(int cdev_id, const char *name, static inline int thermal_notify_cdev_add(const struct thermal_cooling_device *cdev)
int max_state)
{ {
return 0; return 0;
} }
static inline int thermal_notify_cdev_delete(int cdev_id) static inline int thermal_notify_cdev_delete(const struct thermal_cooling_device *cdev)
{ {
return 0; return 0;
} }
static inline int thermal_notify_tz_gov_change(int tz_id, const char *name) static inline int thermal_notify_tz_gov_change(const struct thermal_zone_device *tz,
const char *name)
{ {
return 0; return 0;
} }
......
...@@ -155,9 +155,7 @@ int thermal_zone_trip_id(const struct thermal_zone_device *tz, ...@@ -155,9 +155,7 @@ int thermal_zone_trip_id(const struct thermal_zone_device *tz,
void thermal_zone_trip_updated(struct thermal_zone_device *tz, void thermal_zone_trip_updated(struct thermal_zone_device *tz,
const struct thermal_trip *trip) const struct thermal_trip *trip)
{ {
thermal_notify_tz_trip_change(tz->id, thermal_zone_trip_id(tz, trip), thermal_notify_tz_trip_change(tz, trip);
trip->type, trip->temperature,
trip->hysteresis);
__thermal_zone_device_update(tz, THERMAL_TRIP_CHANGED); __thermal_zone_device_update(tz, THERMAL_TRIP_CHANGED);
} }
...@@ -168,8 +166,6 @@ void thermal_zone_set_trip_temp(struct thermal_zone_device *tz, ...@@ -168,8 +166,6 @@ void thermal_zone_set_trip_temp(struct thermal_zone_device *tz,
return; return;
trip->temperature = temp; trip->temperature = temp;
thermal_notify_tz_trip_change(tz->id, thermal_zone_trip_id(tz, trip), thermal_notify_tz_trip_change(tz, trip);
trip->type, trip->temperature,
trip->hysteresis);
} }
EXPORT_SYMBOL_GPL(thermal_zone_set_trip_temp); EXPORT_SYMBOL_GPL(thermal_zone_set_trip_temp);
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
struct thermal_zone_device; struct thermal_zone_device;
struct thermal_cooling_device; struct thermal_cooling_device;
struct thermal_instance; struct thermal_instance;
struct thermal_debugfs;
struct thermal_attr; struct thermal_attr;
enum thermal_trend { enum thermal_trend {
...@@ -102,7 +103,7 @@ struct thermal_cooling_device_ops { ...@@ -102,7 +103,7 @@ struct thermal_cooling_device_ops {
struct thermal_cooling_device { struct thermal_cooling_device {
int id; int id;
char *type; const char *type;
unsigned long max_state; unsigned long max_state;
struct device device; struct device device;
struct device_node *np; struct device_node *np;
...@@ -113,6 +114,9 @@ struct thermal_cooling_device { ...@@ -113,6 +114,9 @@ struct thermal_cooling_device {
struct mutex lock; /* protect thermal_instances list */ struct mutex lock; /* protect thermal_instances list */
struct list_head thermal_instances; struct list_head thermal_instances;
struct list_head node; struct list_head node;
#ifdef CONFIG_THERMAL_DEBUGFS
struct thermal_debugfs *debugfs;
#endif
}; };
/** /**
...@@ -189,6 +193,9 @@ struct thermal_zone_device { ...@@ -189,6 +193,9 @@ struct thermal_zone_device {
struct list_head node; struct list_head node;
struct delayed_work poll_queue; struct delayed_work poll_queue;
enum thermal_notify_event notify_event; enum thermal_notify_event notify_event;
#ifdef CONFIG_THERMAL_DEBUGFS
struct thermal_debugfs *debugfs;
#endif
bool suspended; bool suspended;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment