summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2016-10-20 14:59:53 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2016-10-21 00:57:28 +0000
commit4163e81a2d8a77a3d82e97dcb0d56ccba3e2aa46 (patch)
treec30f01766720b9109cdbddaa9a71e43cea315600
parentd21368f1fde3bedbf4a05c3a487ec95c2c374a41 (diff)
downloadchrome-ec-4163e81a2d8a77a3d82e97dcb0d56ccba3e2aa46.tar.gz
task: Don't propagate TASK_EVENT_TIMER between between waits
In __wait_evt(), if a timer expiration occurs after we read event status, before the timer is canceled, then TASK_EVENT_TIMER will be propagated to the next task wait, likely leading to premature timeout. Prevent this by clearing TASK_EVENT_TIMER after canceling our timer. BUG=chrome-os-partner:58658 BRANCH=gru TEST=Manual on gru, run 'pd # hard' for 12 hours with charger attached, verify no TCPC I2C read errors occur. Change-Id: Iac2f05a768b4ef29f82e7c3eb899f4c7dd5c3744 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/401503
-rw-r--r--core/cortex-m/task.c5
-rw-r--r--core/cortex-m0/task.c5
-rw-r--r--core/minute-ia/task.c5
-rw-r--r--core/nds32/task.c5
4 files changed, 16 insertions, 4 deletions
diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c
index aaa263581c..112c32299d 100644
--- a/core/cortex-m/task.c
+++ b/core/cortex-m/task.c
@@ -374,8 +374,11 @@ static uint32_t __wait_evt(int timeout_us, task_id_t resched)
__schedule(1, resched);
resched = TASK_ID_IDLE;
}
- if (timeout_us > 0)
+ if (timeout_us > 0) {
timer_cancel(me);
+ /* Ensure timer event is clear, we no longer care about it */
+ atomic_clear(&tsk->events, TASK_EVENT_TIMER);
+ }
return evt;
}
diff --git a/core/cortex-m0/task.c b/core/cortex-m0/task.c
index b5f9aef40c..3bbee70cae 100644
--- a/core/cortex-m0/task.c
+++ b/core/cortex-m0/task.c
@@ -361,8 +361,11 @@ static uint32_t __wait_evt(int timeout_us, task_id_t resched)
__schedule(1, resched);
resched = TASK_ID_IDLE;
}
- if (timeout_us > 0)
+ if (timeout_us > 0) {
timer_cancel(me);
+ /* Ensure timer event is clear, we no longer care about it */
+ atomic_clear(&tsk->events, TASK_EVENT_TIMER);
+ }
return evt;
}
diff --git a/core/minute-ia/task.c b/core/minute-ia/task.c
index fec005e0a0..0d131ae318 100644
--- a/core/minute-ia/task.c
+++ b/core/minute-ia/task.c
@@ -353,8 +353,11 @@ static uint32_t __wait_evt(int timeout_us, task_id_t resched)
__schedule(1, resched);
resched = TASK_ID_IDLE;
}
- if (timeout_us > 0)
+ if (timeout_us > 0) {
timer_cancel(me);
+ /* Ensure timer event is clear, we no longer care about it */
+ atomic_clear(&tsk->events, TASK_EVENT_TIMER);
+ }
return evt;
}
diff --git a/core/nds32/task.c b/core/nds32/task.c
index dc83cba088..36f7849f2b 100644
--- a/core/nds32/task.c
+++ b/core/nds32/task.c
@@ -434,8 +434,11 @@ static uint32_t __wait_evt(int timeout_us, task_id_t resched)
__schedule(1, resched, 0);
resched = TASK_ID_IDLE;
}
- if (timeout_us > 0)
+ if (timeout_us > 0) {
timer_cancel(me);
+ /* Ensure timer event is clear, we no longer care about it */
+ atomic_clear(&tsk->events, TASK_EVENT_TIMER);
+ }
return evt;
}