From 313ece47903e154e3fc46eb041c75556e6652771 Mon Sep 17 00:00:00 2001 From: Akshay Adiga Date: Thu, 4 Jan 2018 16:58:01 +0530 Subject: SLW: Use wakeup_engine state to handle errors in wakeup engine 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 Signed-off-by: Stewart Smith --- 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 af31ccb6..fab32a0c 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; @@ -947,20 +947,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. @@ -988,7 +976,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 */ @@ -996,7 +984,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++) { @@ -1492,10 +1480,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, @@ -1726,16 +1714,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 8141b617..689bbb1c 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -302,6 +302,14 @@ extern void prd_fsp_occ_load_start(u32 proc); /* 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); -- cgit v1.2.1