blob: aab6c3cea84e2006b81562e5049ec2de7a672220 (
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
61
62
63
64
|
From 68db4c74c43d4042b0b32bcd133121ab39b9b310 Mon Sep 17 00:00:00 2001
From: Zhikui Ren <zhikui.ren@intel.com>
Date: Tue, 2 Feb 2021 14:49:28 -0800
Subject: [PATCH] DTS_CPU: filter first zero from RdPkgConfig 10
Peci command GetPkgConfig 10 can return 0 (hot) with cc 0x40
after cpu reset. Once pcode run time image is loaded
and it returns 0x8000 as DTS margin data not ready
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 one second.
Signed-off-by: Zhikui Ren <zhikui.ren@intel.com>
---
drivers/hwmon/peci-cputemp.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/drivers/hwmon/peci-cputemp.c b/drivers/hwmon/peci-cputemp.c
index 19002f02bd91..e1860779aa66 100644
--- a/drivers/hwmon/peci-cputemp.c
+++ b/drivers/hwmon/peci-cputemp.c
@@ -17,6 +17,7 @@ struct temp_group {
struct peci_sensor_data die;
u32 die_raw_prev;
struct peci_sensor_data dts;
+ u32 dts_raw_prev;
struct peci_sensor_data tcontrol;
struct peci_sensor_data tthrottle;
struct peci_sensor_data tjmax;
@@ -168,6 +169,7 @@ static int get_dts(struct peci_cputemp *priv)
s32 dts_margin;
u8 pkg_cfg[4];
int ret;
+ bool discard = false;
if (!peci_sensor_need_update(&priv->temp.dts))
return 0;
@@ -181,6 +183,22 @@ static int get_dts(struct peci_cputemp *priv)
dts_margin = le16_to_cpup((__le16 *)pkg_cfg);
+ /* There is a small window (500us) for read dts_margin (RdPkgConfig 10)
+ * to return cc 0x40, and dts_margin of 0 after cpu reset, before runtime
+ * image is loaded to set it to 0x8000 (dts reading not ready).
+ * DTS sensor is polled by user application at a slower rate than this window.
+ * Treat the first zero reading as data not available.
+ * Consecutive zeros will be returned so true hot condition
+ * is not be missed.
+ */
+ if (dts_margin == 0 && priv->temp.dts_raw_prev != 0) {
+ pr_err("peci-cputemp_dts: discard first 0 reading from RdPkgConfig 10\n");
+ discard = true;
+ }
+ priv->temp.dts_raw_prev = dts_margin;
+ if (discard)
+ return -ENODATA;
+
/**
* Processors return a value of DTS reading in 10.6 format
* (10 bits signed decimal, 6 bits fractional).
--
2.17.1
|