From 91148de7c836a382e3433e6a7a1d8adc48148799 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Wed, 18 Apr 2018 23:48:18 -0700 Subject: APL/GLK: Move chipset shutdown to chipset task In order to ensure that all chipset init/shutdown operations happen within the context of chipset task for APL/GLK: 1. Update chipset_force_shutdown to only set a flag force_shutdown to indicate that chipset shutdown is requested and wake the chipset task. 2. Make chipset task (within the power state machine) call internal_chipset_shutdown. 3. Make internal_chipset_shutdown reset force_shutdown flag and make a callback to weak function chipset_do_shutdown to trigger chipset shutdown. BUG=b:78259506 BRANCH=None TEST=Verified that "apshutdown" on EC console results in chipset shutdown action being taken within chipset task. Change-Id: If13b65ae47e3dce2e466320cc14c68239563f6ed Signed-off-by: Furquan Shaikh Reviewed-on: https://chromium-review.googlesource.com/1018737 Commit-Ready: Furquan Shaikh Tested-by: Furquan Shaikh Reviewed-by: Jett Rink --- power/apollolake.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'power/apollolake.c') diff --git a/power/apollolake.c b/power/apollolake.c index 69d253c8fd..c1fcbe8e17 100644 --- a/power/apollolake.c +++ b/power/apollolake.c @@ -9,23 +9,42 @@ #include "console.h" #include "gpio.h" #include "intel_x86.h" +#include "task.h" #include "timer.h" /* Console output macros */ #define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args) +/* + * force_shutdown is used to maintain chipset shutdown request. This request + * needs to be handled from within the chipset task. + */ +static int force_shutdown; + __attribute__((weak)) void chipset_do_shutdown(void) { /* Need to implement board specific shutdown */ } -void chipset_force_shutdown(void) +static void internal_chipset_shutdown(void) { CPRINTS("%s()", __func__); + force_shutdown = 0; chipset_do_shutdown(); } +void chipset_force_shutdown(void) +{ + /* + * This function is called from multiple tasks and hence it is racy! But + * since things are going down hard, it does not matter if some task + * misses out. + */ + force_shutdown = 1; + task_wake(TASK_ID_CHIPSET); +} + enum power_state chipset_force_g3(void) { chipset_force_shutdown(); @@ -64,13 +83,17 @@ enum power_state power_handle_state(enum power_state state) if (state == POWER_S5 && !power_has_signals(IN_PGOOD_ALL_CORE)) { /* Required rail went away */ - chipset_force_shutdown(); + internal_chipset_shutdown(); new_state = POWER_S5G3; goto rsmrst_handle; } + /* If force shutdown is requested, perform that. */ + if (force_shutdown) + internal_chipset_shutdown(); + new_state = common_intel_x86_power_handle_state(state); rsmrst_handle: -- cgit v1.2.1