Skip to content

Commit 8b4bd25

Browse files
atenartdlezcano
authored andcommitted
thermal/drivers/int340x: Do not set a wrong tcc offset on resume
After upgrading to Linux 5.13.3 I noticed my laptop would shutdown due to overheat (when it should not). It turned out this was due to commit fe6a6de ("thermal/drivers/int340x/processor_thermal: Fix tcc setting"). What happens is this drivers uses a global variable to keep track of the tcc offset (tcc_offset_save) and uses it on resume. The issue is this variable is initialized to 0, but is only set in tcc_offset_degree_celsius_store, i.e. when the tcc offset is explicitly set by userspace. If that does not happen, the resume path will set the offset to 0 (in my case the h/w default being 3, the offset would become too low after a suspend/resume cycle). The issue did not arise before commit fe6a6de, as the function setting the offset would return if the offset was 0. This is no longer the case (rightfully). Fix this by not applying the offset if it wasn't saved before, reverting back to the old logic. A better approach will come later, but this will be easier to apply to stable kernels. The logic to restore the offset after a resume was there long before commit fe6a6de, but as a value of 0 was considered invalid I'm referencing the commit that made the issue possible in the Fixes tag instead. Fixes: fe6a6de ("thermal/drivers/int340x/processor_thermal: Fix tcc setting") Cc: [email protected] Cc: Srinivas Pandruvada <[email protected]> Signed-off-by: Antoine Tenart <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Reviewed-by: Srinivas Pandruvada <[email protected]> Tested-by: Srinivas Pandruvada <srinivas.pI [email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6880fa6 commit 8b4bd25

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/thermal/intel/int340x_thermal/processor_thermal_device.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static int tcc_offset_update(unsigned int tcc)
107107
return 0;
108108
}
109109

110-
static unsigned int tcc_offset_save;
110+
static int tcc_offset_save = -1;
111111

112112
static ssize_t tcc_offset_degree_celsius_store(struct device *dev,
113113
struct device_attribute *attr, const char *buf,
@@ -352,7 +352,8 @@ int proc_thermal_resume(struct device *dev)
352352
proc_dev = dev_get_drvdata(dev);
353353
proc_thermal_read_ppcc(proc_dev);
354354

355-
tcc_offset_update(tcc_offset_save);
355+
if (tcc_offset_save >= 0)
356+
tcc_offset_update(tcc_offset_save);
356357

357358
return 0;
358359
}

0 commit comments

Comments
 (0)