ANDROID: GKI: drivers: thermal: Add post suspend evaluate flag to thermal zone devicetree

Thermal core framework subscribes for suspend/resume notification.
On resume notification it re-evaluates each thermal zone for
temperature and cooling state update. For some devices,
a large number of thermal zones are enabled for different mitigations.
Re-evaluating each thermal zone during resume leads to multiple issues
including delay in back to back suspend resume scenario, power penalty
for frequent wake up due to re-setting trip threshold especially
during cold temperature usecases.

Add wake-capable-sensor property to thermal zone devicetree node to
denote that these sensors are wakeup capable. If a thermal zone has
this property defined, thermal framework ignores resume re-evaluation
and can service the threshold notification during the suspend/resume
path.

Test: build
Bug: 149945768
Change-Id: I07edf80ad29009378af4c70e750d01bde6f30806
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
(cherry picked from commit a915ed479e)
[hridya: added some pointer checks]
Signed-off-by: Hridya Valsaraju <hridya@google.com>
This commit is contained in:
Manaf Meethalavalappu Pallikunhi 2019-02-14 18:03:00 +05:30 committed by Hridya Valsaraju
parent 30be971f3f
commit b078dd60e3
4 changed files with 25 additions and 1 deletions

View file

@ -169,6 +169,9 @@ Optional property:
Type: bool thresholds, so the governors may mitigate by ensuring
timing closures and other low temperature operating
issues.
- wake-capable-sensor: Set to true if thermal zone sensor is wake up capable
Type: bool and cooling devices binded to this thermal zone are not
Size: none affected during suspend.
Note: The delay properties are bound to the maximum dT/dt (temperature
derivative over time) in two situations for a thermal zone:

View file

@ -64,6 +64,7 @@ struct __sensor_param {
* @slope: slope of the temperature adjustment curve
* @offset: offset of the temperature adjustment curve
* @default_disable: Keep the thermal zone disabled by default
* @is_wakeable: Ignore post suspend thermal zone re-evaluation
* @tzd: thermal zone device pointer for this sensor
* @ntrips: number of trip points
* @trips: an array of trip points (0..ntrips - 1)
@ -81,6 +82,7 @@ struct __thermal_zone {
int offset;
struct thermal_zone_device *tzd;
bool default_disable;
bool is_wakeable;
/* trip data */
int ntrips;
@ -475,6 +477,13 @@ static int of_thermal_get_crit_temp(struct thermal_zone_device *tz,
return -EINVAL;
}
static bool of_thermal_is_wakeable(struct thermal_zone_device *tz)
{
struct __thermal_zone *data = tz->devdata;
return data->is_wakeable;
}
static struct thermal_zone_device_ops of_thermal_ops = {
.get_mode = of_thermal_get_mode,
.set_mode = of_thermal_set_mode,
@ -488,6 +497,8 @@ static struct thermal_zone_device_ops of_thermal_ops = {
.bind = of_thermal_bind,
.unbind = of_thermal_unbind,
.is_wakeable = of_thermal_is_wakeable,
};
static struct thermal_zone_of_device_ops of_virt_ops = {
@ -1085,6 +1096,8 @@ __init *thermal_of_build_thermal_zone(struct device_node *np)
}
tz->polling_delay = prop;
tz->is_wakeable = of_property_read_bool(np,
"wake-capable-sensor");
/*
* REVIST: for now, the thermal framework supports only
* one sensor per thermal zone. Thus, we are considering

View file

@ -470,7 +470,11 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,
{
int count;
if (atomic_read(&in_suspend))
if (!tz || !tz->ops)
return;
if (atomic_read(&in_suspend) && (!tz->ops->is_wakeable ||
!(tz->ops->is_wakeable(tz))))
return;
if (!tz->ops->get_temp)
@ -1506,6 +1510,9 @@ static int thermal_pm_notify(struct notifier_block *nb,
case PM_POST_SUSPEND:
atomic_set(&in_suspend, 0);
list_for_each_entry(tz, &thermal_tz_list, node) {
if (tz->ops && tz->ops->is_wakeable &&
tz->ops->is_wakeable(tz))
continue;
thermal_zone_device_init(tz);
thermal_zone_device_update(tz,
THERMAL_EVENT_UNSPECIFIED);

View file

@ -116,6 +116,7 @@ struct thermal_zone_device_ops {
enum thermal_trend *);
int (*notify) (struct thermal_zone_device *, int,
enum thermal_trip_type);
bool (*is_wakeable)(struct thermal_zone_device *);
};
struct thermal_cooling_device_ops {