summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-07-13 10:03:08 +0200
committerGerrit <chrome-bot@google.com>2012-07-13 13:06:16 -0700
commit0939fffdebee1e8326d2b2c898433ab28db1ded1 (patch)
tree033e636cbe77489de87b02b4a54283c32290305c
parent37f19ecc84d506ece33d5c19b5e02b7ab71549dc (diff)
downloadchrome-ec-0939fffdebee1e8326d2b2c898433ab28db1ded1.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/27353 Reviewed-by: Rong Chang <rongchang@chromium.org> Tested-by: Rong Chang <rongchang@chromium.org> Reviewed-by: Che-Liang Chiou <clchiou@chromium.org> Tested-by: Katie Roberts-Hoffman <katierh@chromium.org> Commit-Ready: 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 b4b1c05fbc..4aacf99155 100644
--- a/common/pmu_tps65090_charger.c
+++ b/common/pmu_tps65090_charger.c
@@ -296,5 +296,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);
}
}