Skip to content

Commit 33703fe

Browse files
zhang-ruiDinh Nguyen
authored andcommitted
Thermal: Ignore invalid trip points
[ Upstream commit 81ad427 ] In some cases, platform thermal driver may report invalid trip points, thermal core should not take any action for these trip points. This fixed a regression that bogus trip point starts to screw up thermal control on some Lenovo laptops, after commit bb431ba Author: Zhang Rui <[email protected]> Date: Fri Oct 30 16:31:47 2015 +0800 Thermal: initialize thermal zone device correctly After thermal zone device registered, as we have not read any temperature before, thus tz->temperature should not be 0, which actually means 0C, and thermal trend is not available. In this case, we need specially handling for the first thermal_zone_device_update(). Both thermal core framework and step_wise governor is enhanced to handle this. And since the step_wise governor is the only one that uses trends, so it's the only thermal governor that needs to be updated. Tested-by: Manuel Krause <[email protected]> Tested-by: szegad <[email protected]> Tested-by: prash <[email protected]> Tested-by: amish <[email protected]> Tested-by: Matthias <[email protected]> Reviewed-by: Javi Merino <[email protected]> Signed-off-by: Zhang Rui <[email protected]> Signed-off-by: Chen Yu <[email protected]> CC: <[email protected]> #3.18+ Link: https://bugzilla.redhat.com/show_bug.cgi?id=1317190 Link: https://bugzilla.kernel.org/show_bug.cgi?id=114551 Signed-off-by: Zhang Rui <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent e6dcc17 commit 33703fe

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

drivers/thermal/thermal_core.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
391391
{
392392
enum thermal_trip_type type;
393393

394+
/* Ignore disabled trip points */
395+
if (test_bit(trip, &tz->trips_disabled))
396+
return;
397+
394398
tz->ops->get_trip_type(tz, trip, &type);
395399

396400
if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT)
@@ -1487,6 +1491,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
14871491
{
14881492
struct thermal_zone_device *tz;
14891493
enum thermal_trip_type trip_type;
1494+
int trip_temp;
14901495
int result;
14911496
int count;
14921497
int passive = 0;
@@ -1557,9 +1562,15 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
15571562
goto unregister;
15581563

15591564
for (count = 0; count < trips; count++) {
1560-
tz->ops->get_trip_type(tz, count, &trip_type);
1565+
if (tz->ops->get_trip_type(tz, count, &trip_type))
1566+
set_bit(count, &tz->trips_disabled);
15611567
if (trip_type == THERMAL_TRIP_PASSIVE)
15621568
passive = 1;
1569+
if (tz->ops->get_trip_temp(tz, count, &trip_temp))
1570+
set_bit(count, &tz->trips_disabled);
1571+
/* Check for bogus trip points */
1572+
if (trip_temp == 0)
1573+
set_bit(count, &tz->trips_disabled);
15631574
}
15641575

15651576
if (!passive) {

include/linux/thermal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ struct thermal_attr {
146146
* @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis
147147
* @devdata: private pointer for device private data
148148
* @trips: number of trip points the thermal zone supports
149+
* @trips_disabled; bitmap for disabled trips
149150
* @passive_delay: number of milliseconds to wait between polls when
150151
* performing passive cooling. Currenty only used by the
151152
* step-wise governor
@@ -182,6 +183,7 @@ struct thermal_zone_device {
182183
struct thermal_attr *trip_hyst_attrs;
183184
void *devdata;
184185
int trips;
186+
unsigned long trips_disabled; /* bitmap for disabled trips */
185187
int passive_delay;
186188
int polling_delay;
187189
int temperature;

0 commit comments

Comments
 (0)