[Skiboot] [PATCH 4/9] SLW: Use wakeup_engine state to handle errors in wakeup engine

Akshay Adiga akshay.adiga at linux.vnet.ibm.com
Thu Jan 4 22:28:01 AEDT 2018


Patch introduces wakeup_engine_state which replaces a bool
has_wakeup_engine. wakeup_engine_state can have 3 states :
- WAKEUP_ENGINE_PRESENT : When everything is good.
- WAKEUP_ENGINE_NOT_PRESENT : When wakeup_engine is not correctly detected.
- WAKEUP_ENGINE_FAILED : If any operation on wakeup_engine failed.

Signed-off-by: Akshay Adiga <akshay.adiga at linux.vnet.ibm.com>
---
 hw/slw.c          | 38 ++++++++++++++------------------------
 include/skiboot.h |  8 ++++++++
 2 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/hw/slw.c b/hw/slw.c
index 02aa67ea..119f1e28 100644
--- a/hw/slw.c
+++ b/hw/slw.c
@@ -40,7 +40,7 @@ static uint32_t slw_saved_reset[MAX_RESET_PATCH_SIZE];
 
 static bool slw_current_le = false;
 
-bool has_wakeup_engine = true;
+enum wakeup_engine_states wakeup_engine_state = WAKEUP_ENGINE_NOT_PRESENT;
 
 /* SLW timer related stuff */
 static bool slw_has_timer;
@@ -931,20 +931,8 @@ void add_cpu_idle_state_properties(void)
 		nr_states = ARRAY_SIZE(power7_cpu_idle_states);
 	}
 
-	/*
-	 * Enable deep idle states only if :
-	 * P8 : slw image is intact
-	 * P9 : homer_base is set
-	 */
-	if (!(proc_chip_quirks & QUIRK_MAMBO_CALLOUTS)) {
-		if (proc_gen == proc_gen_p9)
-			has_wakeup_engine = !!(chip->homer_base);
-		else /* (proc_gen == proc_gen_p8) */
-			has_wakeup_engine = (chip->slw_base && chip->slw_bar_size &&
-					chip->slw_image_size);
-	} else {
-		has_wakeup_engine = false;
-	}
+	if (proc_chip_quirks & QUIRK_MAMBO_CALLOUTS)
+		wakeup_engine_state = WAKEUP_ENGINE_NOT_PRESENT;
 
 	/*
 	 * Currently we can't append strings and cells to dt properties.
@@ -972,7 +960,7 @@ void add_cpu_idle_state_properties(void)
 	if (has_stop_inst) {
 		/* Power 9 / POWER ISA 3.0 */
 		supported_states_mask = OPAL_PM_STOP_INST_FAST;
-		if (has_wakeup_engine)
+		if (wakeup_engine_state == WAKEUP_ENGINE_PRESENT)
 			supported_states_mask |= OPAL_PM_STOP_INST_DEEP;
 	} else {
 		/* Power 7 and Power 8 */
@@ -980,7 +968,7 @@ void add_cpu_idle_state_properties(void)
 		if (can_sleep)
 			supported_states_mask |= OPAL_PM_SLEEP_ENABLED |
 						OPAL_PM_SLEEP_ENABLED_ER1;
-		if (has_wakeup_engine)
+		if (wakeup_engine_state == WAKEUP_ENGINE_PRESENT)
 			supported_states_mask |= OPAL_PM_WINKLE_ENABLED;
 	}
 	for (i = 0; i < nr_states; i++) {
@@ -1476,10 +1464,10 @@ int64_t opal_slw_set_reg(uint64_t cpu_pir, uint64_t sprn, uint64_t val)
 	assert(chip);
 
 	if (proc_gen == proc_gen_p9) {
-		if (!chip->homer_base) {
+		if (wakeup_engine_state != WAKEUP_ENGINE_PRESENT) {
 			log_simple_error(&e_info(OPAL_RC_SLW_REG),
-					 "SLW: HOMER base not set %x\n",
-					 chip->id);
+					 "SLW: wakeup_engine in bad state=%d chip=%x\n",
+					 wakeup_engine_state,chip->id);
 			return OPAL_INTERNAL_ERROR;
 		}
 		rc = p9_stop_save_cpureg((void *)chip->homer_base,
@@ -1710,16 +1698,18 @@ void slw_init(void)
 	if (proc_gen == proc_gen_p8) {
 		for_each_chip(chip) {
 			slw_init_chip_p8(chip);
-			has_wakeup_engine &= slw_image_check_p8(chip);
-			if (has_wakeup_engine)
+			if(slw_image_check_p8(chip))
+				wakeup_engine_state = WAKEUP_ENGINE_PRESENT;
+			if (wakeup_engine_state == WAKEUP_ENGINE_PRESENT)
 				slw_late_init_p8(chip);
 		}
 		slw_init_timer();
 	} else if (proc_gen == proc_gen_p9) {
 		for_each_chip(chip) {
 			slw_init_chip_p9(chip);
-			has_wakeup_engine &= slw_image_check_p9(chip);
-			if (has_wakeup_engine)
+			if(slw_image_check_p9(chip))
+				wakeup_engine_state = WAKEUP_ENGINE_PRESENT;
+			if (wakeup_engine_state == WAKEUP_ENGINE_PRESENT)
 				slw_late_init_p9(chip);
 		}
 	}
diff --git a/include/skiboot.h b/include/skiboot.h
index db913258..90deff78 100644
--- a/include/skiboot.h
+++ b/include/skiboot.h
@@ -297,6 +297,14 @@ extern void prd_register_reserved_memory(void);
 /* Flatten device-tree */
 extern void *create_dtb(const struct dt_node *root, bool exclusive);
 
+/* Track failure in Wakup engine */
+enum wakeup_engine_states {
+	WAKEUP_ENGINE_NOT_PRESENT,
+	WAKEUP_ENGINE_PRESENT,
+	WAKEUP_ENGINE_FAILED
+};
+extern enum wakeup_engine_states wakeup_engine_state;
+
 /* SLW reinit function for switching core settings */
 extern int64_t slw_reinit(uint64_t flags);
 
-- 
2.14.3



More information about the Skiboot mailing list