summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2019-06-13 13:27:38 -0600
committerCommit Bot <commit-bot@chromium.org>2019-08-02 17:47:57 +0000
commit73ee352993cc7d2693d9337c2dd15f49f5c3fb3c (patch)
treeb76d27bbfeb2f013a1016394e3fa6c3d1aeffb3e /common
parent253b20718366be744412a73f6c5dd9fb78f163f5 (diff)
downloadchrome-ec-73ee352993cc7d2693d9337c2dd15f49f5c3fb3c.tar.gz
motionsense: prevent loop after missing events
We don't need to loop to figure out when to schedule the next sensor collection event, just schedule it as soon as possible. This eliminates a watchdog reset when we miss scheduling the sensor task and get really far behind. BRANCH=none BUG=b:133190570 TEST=normal operation is fine, based on longs of failing results in bug, this should prevent the watch reset. Change-Id: I3001028ba393b51d1958f0136ba040eaee5e52d1 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1658521 Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1719568 Reviewed-by: Edward Hill <ecgh@chromium.org> Tested-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/motion_sense.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index a46272c604..414b35b95a 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -974,19 +974,21 @@ static inline void increment_sensor_collection(struct motion_sensor_t *sensor,
{
sensor->next_collection += sensor->collection_rate;
- while (time_after(ts->le.lo, sensor->next_collection)) {
+ if (time_after(ts->le.lo, sensor->next_collection)) {
/*
* If we get here it means that we completely missed a sensor
- * collection time and we attempt to recover by incrementing
- * the next collection time until we recover. This should not
- * happen and if it does it means that the ec cannot handle the
- * requested data rate.
+ * collection time and we attempt to recover by scheduling as
+ * soon as possible. This should not happen and if it does it
+ * means that the ec cannot handle the requested data rate.
*/
+ int missed_events =
+ time_until(sensor->next_collection, ts->le.lo) /
+ sensor->collection_rate;
- CPRINTS("%s Missed data collection at %u - rate: %d",
- sensor->name, sensor->next_collection,
+ CPRINTS("%s Missed %d data collections at %u - rate: %d",
+ sensor->name, missed_events, sensor->next_collection,
sensor->collection_rate);
- sensor->next_collection += sensor->collection_rate;
+ sensor->next_collection = ts->le.lo + motion_min_interval;
}
}