Commit 55cdf0a2 authored by Daniel Lezcano's avatar Daniel Lezcano

thermal: core: Add notifications call in the framework

The generic netlink protocol is implemented but the different
notification functions are not yet connected to the core code.

These changes add the notification calls in the different
corresponding places.
Reviewed-by: default avatarAmit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: default avatarZhang Rui <rui.zhang@intel.com>
Link: https://lore.kernel.org/r/20200706105538.2159-4-daniel.lezcano@linaro.org
parent 1ce50e7d
...@@ -215,6 +215,8 @@ int thermal_zone_device_set_policy(struct thermal_zone_device *tz, ...@@ -215,6 +215,8 @@ 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);
return ret; return ret;
} }
...@@ -415,12 +417,25 @@ static void handle_critical_trips(struct thermal_zone_device *tz, ...@@ -415,12 +417,25 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
static void handle_thermal_trip(struct thermal_zone_device *tz, int trip) static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
{ {
enum thermal_trip_type type; enum thermal_trip_type type;
int trip_temp, hyst = 0;
/* Ignore disabled trip points */ /* Ignore disabled trip points */
if (test_bit(trip, &tz->trips_disabled)) if (test_bit(trip, &tz->trips_disabled))
return; return;
tz->ops->get_trip_temp(tz, trip, &trip_temp);
tz->ops->get_trip_type(tz, trip, &type); tz->ops->get_trip_type(tz, trip, &type);
if (tz->ops->get_trip_hyst)
tz->ops->get_trip_hyst(tz, trip, &hyst);
if (tz->last_temperature != THERMAL_TEMP_INVALID) {
if (tz->last_temperature < trip_temp &&
tz->temperature >= trip_temp)
thermal_notify_tz_trip_up(tz->id, trip);
if (tz->last_temperature >= trip_temp &&
tz->temperature < (trip_temp - hyst))
thermal_notify_tz_trip_down(tz->id, trip);
}
if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT) if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT)
handle_critical_trips(tz, trip, type); handle_critical_trips(tz, trip, type);
...@@ -452,6 +467,8 @@ static void update_temperature(struct thermal_zone_device *tz) ...@@ -452,6 +467,8 @@ static void update_temperature(struct thermal_zone_device *tz)
mutex_unlock(&tz->lock); mutex_unlock(&tz->lock);
trace_thermal_temperature(tz); trace_thermal_temperature(tz);
thermal_genl_sampling_temp(tz->id, temp);
} }
static void thermal_zone_device_init(struct thermal_zone_device *tz) static void thermal_zone_device_init(struct thermal_zone_device *tz)
...@@ -1469,6 +1486,8 @@ thermal_zone_device_register(const char *type, int trips, int mask, ...@@ -1469,6 +1486,8 @@ thermal_zone_device_register(const char *type, int trips, int mask,
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);
return tz; return tz;
unregister: unregister:
...@@ -1540,6 +1559,8 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) ...@@ -1540,6 +1559,8 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
ida_destroy(&tz->ida); ida_destroy(&tz->ida);
mutex_destroy(&tz->lock); mutex_destroy(&tz->lock);
device_unregister(&tz->device); device_unregister(&tz->device);
thermal_notify_tz_delete(tz->id);
} }
EXPORT_SYMBOL_GPL(thermal_zone_device_unregister); EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
......
...@@ -175,6 +175,16 @@ void thermal_zone_set_trips(struct thermal_zone_device *tz) ...@@ -175,6 +175,16 @@ void thermal_zone_set_trips(struct thermal_zone_device *tz)
mutex_unlock(&tz->lock); mutex_unlock(&tz->lock);
} }
static void thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev,
int target)
{
if (cdev->ops->set_cur_state(cdev, target))
return;
thermal_notify_cdev_state_update(cdev->id, target);
thermal_cooling_device_stats_update(cdev, target);
}
void thermal_cdev_update(struct thermal_cooling_device *cdev) void thermal_cdev_update(struct thermal_cooling_device *cdev)
{ {
struct thermal_instance *instance; struct thermal_instance *instance;
...@@ -197,8 +207,7 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev) ...@@ -197,8 +207,7 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)
target = instance->target; target = instance->target;
} }
if (!cdev->ops->set_cur_state(cdev, target)) thermal_cdev_set_cur_state(cdev, target);
thermal_cooling_device_stats_update(cdev, target);
cdev->updated = true; cdev->updated = true;
mutex_unlock(&cdev->lock); mutex_unlock(&cdev->lock);
......
...@@ -112,7 +112,8 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr, ...@@ -112,7 +112,8 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
{ {
struct thermal_zone_device *tz = to_thermal_zone(dev); struct thermal_zone_device *tz = to_thermal_zone(dev);
int trip, ret; int trip, ret;
int temperature; int temperature, hyst = 0;
enum thermal_trip_type type;
if (!tz->ops->set_trip_temp) if (!tz->ops->set_trip_temp)
return -EPERM; return -EPERM;
...@@ -127,6 +128,18 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr, ...@@ -127,6 +128,18 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
if (ret) if (ret)
return ret; return ret;
if (tz->ops->get_trip_hyst) {
ret = tz->ops->get_trip_hyst(tz, trip, &hyst);
if (ret)
return ret;
}
ret = tz->ops->get_trip_type(tz, trip, &type);
if (ret)
return ret;
thermal_notify_tz_trip_change(tz->id, trip, type, temperature, hyst);
thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
return count; return count;
......
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