summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-kernel/linux/linux-aspeed/0006-DTS_CPU-filter-first-zero-from-RdPkgConfig-10.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-kernel/linux/linux-aspeed/0006-DTS_CPU-filter-first-zero-from-RdPkgConfig-10.patch')
-rw-r--r--meta-openbmc-mods/meta-common/recipes-kernel/linux/linux-aspeed/0006-DTS_CPU-filter-first-zero-from-RdPkgConfig-10.patch66
1 files changed, 66 insertions, 0 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-kernel/linux/linux-aspeed/0006-DTS_CPU-filter-first-zero-from-RdPkgConfig-10.patch b/meta-openbmc-mods/meta-common/recipes-kernel/linux/linux-aspeed/0006-DTS_CPU-filter-first-zero-from-RdPkgConfig-10.patch
new file mode 100644
index 000000000..a498f9c19
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-kernel/linux/linux-aspeed/0006-DTS_CPU-filter-first-zero-from-RdPkgConfig-10.patch
@@ -0,0 +1,66 @@
+From 4d4e68e0eed7ccf899bc1b3799a93ed8eb44270d 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 | 20 ++++++++++++++++++++
+ 1 file changed, 20 insertions(+)
+
+diff --git a/drivers/hwmon/peci-cputemp.c b/drivers/hwmon/peci-cputemp.c
+index 49670bc80530..af1c09741120 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;
+@@ -159,6 +160,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;
+@@ -172,6 +174,24 @@ 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) {
++ dev_err(priv->dev,
++ "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
+