summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-07-13 10:03:08 +0200
committerKatie Roberts-Hoffman <katierh@chromium.org>2012-07-13 11:08:08 -0700
commit270f798aa80ac959e1db0a6fee4ccae200afa097 (patch)
treecd367ec10d99be49a9886c7bece4442e79c12f41
parentd6086835e3231472f2075df53a86828fcfd6b5d5 (diff)
downloadchrome-ec-270f798aa80ac959e1db0a6fee4ccae200afa097.tar.gz
charger: Add delay in tasker task to avoid lockup
The charger task relies on calc_next_state() performing a delay before returning. My reading of the code suggests that this doesn't happen always. For example: When pre-charging: if (battery_temperature(&batt_temp) == EC_SUCCESS) return ST_CHARGING; When discharging and capacity is low: /* Check remaining charge % */ if (battery_state_of_charge(&capacity) == 0 && capacity < 10) return notify_battery_low(); I would like to suggest that the code be refactored to more like: int next_checkms = 5000; /* next time to check battery */ while (1) { int action = ACTION_NONE; err = get_state(&state); if (!err) { action = calculate_action(&state); err = perform_action(action, &next_check_ms); } usleep(next_check_ms * 1000); } so that the delays are really clear, the state is all read at once, there is no reliance on earlier state, and we always delay even on error. In the meantime, this CL inserts a mandatory 5 second delay in the loop, which should prevent the charger task lockup. BUG=chrome-os-partner:11285 TEST=manual (please do this test before committing) 1. boot to kernel, see that battery can be seen 2. suspend and resume device 3. see that the charger loop does not cause an EC watchdog reset and AP power off/reset. There should be no watchdog warning message on the EC console. Change-Id: I141e374933c4dc0ec60bcdccf96443f57067c585 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27371 Reviewed-by: Jon Kliegman <kliegs@chromium.org> Reviewed-by: Katie Roberts-Hoffman <katierh@chromium.org> Tested-by: Katie Roberts-Hoffman <katierh@chromium.org>
-rw-r--r--common/pmu_tps65090_charger.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c
index 28bcfafe0b..554ec32830 100644
--- a/common/pmu_tps65090_charger.c
+++ b/common/pmu_tps65090_charger.c
@@ -295,5 +295,8 @@ void pmu_charger_task(void)
state_list[next_state]);
state = next_state;
}
+
+ /* TODO(sjg@chromium.org): root cause crosbug.com/p/11285 */
+ usleep(5000 * 1000);
}
}