From fcd388df8eef2f723cb4ff7277fa44d3754bb966 Mon Sep 17 00:00:00 2001 From: Doug Anderson Date: Tue, 27 Aug 2013 11:24:52 -0700 Subject: pit: Move suspend/resume hook callbacks to a deferred task Putting the suspend/resume hook callbacks on a deferred task allows frequency change notifications to lock mutexes. This is useful in a future change which locks the i2c bus around frequency changes. BRANCH=pit BUG=chrome-os-partner:22093 TEST=With all patches together: - on AP: suspend_stress_test - on EC: battery 10000 50 Change-Id: If5e31040cdc7c95a4c8ba62ee72512cb79617cc9 Signed-off-by: Doug Anderson Previous-Reviewed-on: https://chromium-review.googlesource.com/167100 (cherry picked from commit ce31fda8695f4db1fa91f5bb224c781cf17f91c0) Reviewed-on: https://chromium-review.googlesource.com/167147 Reviewed-by: Randall Spangler --- common/chipset_gaia.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/common/chipset_gaia.c b/common/chipset_gaia.c index a60a9970e8..1d36345612 100644 --- a/common/chipset_gaia.c +++ b/common/chipset_gaia.c @@ -236,8 +236,10 @@ static int check_for_power_off_event(void) return 0; } -void gaia_suspend_event(enum gpio_signal signal) +void gaia_suspend_deferred(void) { + int new_ap_suspended; + if (!ap_on) /* power on/off : not a real suspend / resume */ return; @@ -245,7 +247,13 @@ void gaia_suspend_event(enum gpio_signal signal) * Note: For Snow, suspend state can only be reliably * determined when the AP is on (crosbug.com/p/13200). */ - ap_suspended = !gpio_get_level(GPIO_SUSPEND_L); + new_ap_suspended = !gpio_get_level(GPIO_SUSPEND_L); + + /* We never want to call two suspend or two resumes in a row */ + if (ap_suspended == new_ap_suspended) + return; + + ap_suspended = new_ap_suspended; if (ap_suspended) { if (lid_is_open()) @@ -258,6 +266,13 @@ void gaia_suspend_event(enum gpio_signal signal) powerled_set_state(POWERLED_STATE_ON); hook_notify(HOOK_CHIPSET_RESUME); } + +} +DECLARE_DEFERRED(gaia_suspend_deferred); + +void gaia_suspend_event(enum gpio_signal signal) +{ + hook_call_deferred(gaia_suspend_deferred, 0); } void gaia_power_event(enum gpio_signal signal) -- cgit v1.2.1