diff mbox series

occ-sensors: Check if OCC is reset while readinginband sensors

Message ID 1557826432-29066-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com
State Accepted
Headers show
Series occ-sensors: Check if OCC is reset while readinginband sensors | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (c8b5e8a95caf029ffe73ea18769fdd7f2da48ab4)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Shilpasri G Bhat May 14, 2019, 9:33 a.m. UTC
OCC may not be able to mark the sensor buffer as invalid while going
down RESET. If OCC never comes back we will continue to read the stale
sensor data. So verify if OCC is reset while reading the sensor values
and propagate the appropriate error.

Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
---
 hw/occ-sensor.c | 3 +++
 hw/occ.c        | 5 +++++
 include/occ.h   | 2 ++
 3 files changed, 10 insertions(+)

Comments

Stewart Smith May 21, 2019, 3:18 a.m. UTC | #1
Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com> writes:
> OCC may not be able to mark the sensor buffer as invalid while going
> down RESET. If OCC never comes back we will continue to read the stale
> sensor data. So verify if OCC is reset while reading the sensor values
> and propagate the appropriate error.
>
> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
> ---
>  hw/occ-sensor.c | 3 +++
>  hw/occ.c        | 5 +++++
>  include/occ.h   | 2 ++
>  3 files changed, 10 insertions(+)

Merged to master as of 92fd4f48014d34cb13d2c5e7de8e7b6dc1f28324
diff mbox series

Patch

diff --git a/hw/occ-sensor.c b/hw/occ-sensor.c
index c062f64..0337294 100644
--- a/hw/occ-sensor.c
+++ b/hw/occ-sensor.c
@@ -265,6 +265,9 @@  int occ_sensor_read(u32 handle, u64 *data)
 	if (attr > MAX_SENSOR_ATTR)
 		return OPAL_PARAMETER;
 
+	if (is_occ_reset())
+		return OPAL_HARDWARE;
+
 	hb = get_sensor_header_block(occ_num);
 
 	if (hb->valid != 1)
diff --git a/hw/occ.c b/hw/occ.c
index 5dc05d3..2713604 100644
--- a/hw/occ.c
+++ b/hw/occ.c
@@ -875,6 +875,11 @@  static inline u8 get_cpu_throttle(struct proc_chip *chip)
 	};
 }
 
+bool is_occ_reset(void)
+{
+	return occ_reset;
+}
+
 static void occ_throttle_poll(void *data __unused)
 {
 	struct proc_chip *chip;
diff --git a/include/occ.h b/include/occ.h
index a46b921..6b831e0 100644
--- a/include/occ.h
+++ b/include/occ.h
@@ -50,6 +50,8 @@  extern void occ_add_sensor_groups(struct dt_node *sg, u32  *phandles,
 
 extern int occ_sensor_group_enable(u32 group_hndl, int token, bool enable);
 
+extern bool is_occ_reset(void);
+
 /*
  * OCC Sensor Data
  *