blob: b7823ce14cc9b766736a6a241bf4add3a673cc77 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
From 0d202fb06b873c5e258658462ac4fc01a673fd83 Mon Sep 17 00:00:00 2001
From: Zhikui Ren <zhikui.ren@intel.com>
Date: Mon, 11 Jan 2021 16:31:36 -0800
Subject: [PATCH] Die_CPU: filter first zero from GetTemp
Peci command GetTemp can return 0 during CPU reset.
It does not have a have completion code either.
Discard the first zero reading and return -ENODATA.
Consecutive zeros will be returned so that real hot
condition will still be detected and logged but possibly delayed
by the sensor polling period, which is normally 500ms-1s.
Signed-off-by: Zhikui Ren <zhikui.ren@intel.com>
---
drivers/hwmon/peci-cputemp.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/hwmon/peci-cputemp.c b/drivers/hwmon/peci-cputemp.c
index b633ea545644..19002f02bd91 100644
--- a/drivers/hwmon/peci-cputemp.c
+++ b/drivers/hwmon/peci-cputemp.c
@@ -15,6 +15,7 @@
struct temp_group {
struct peci_sensor_data die;
+ u32 die_raw_prev;
struct peci_sensor_data dts;
struct peci_sensor_data tcontrol;
struct peci_sensor_data tthrottle;
@@ -129,6 +130,7 @@ static int get_die_temp(struct peci_cputemp *priv)
{
struct peci_get_temp_msg msg;
int ret;
+ bool discard = false;
if (!peci_sensor_need_update(&priv->temp.die))
return 0;
@@ -139,6 +141,19 @@ static int get_die_temp(struct peci_cputemp *priv)
if (ret)
return ret;
+ /* GET_TEMP command does not have cc and can return zero during
+ * cpu reset. Treat the first zero reading as data not available.
+ * Consecutive zeros will be returned so true hot condition
+ * is not be missed.
+ */
+ if (msg.temp_raw == 0 && priv->temp.die_raw_prev != 0) {
+ pr_err("peci-cputemp_die: discard first 0 reading from GetTemp\n");
+ discard = true;
+ }
+ priv->temp.die_raw_prev = msg.temp_raw;
+ if (discard)
+ return -ENODATA;
+
/* Note that the tjmax should be available before calling it */
priv->temp.die.value = priv->temp.tjmax.value +
(msg.temp_raw * 1000 / 64);
--
2.17.1
|