summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartin yan <martin.yan@microchip.corp-partner.google.com>2021-09-02 11:15:32 -0400
committerCommit Bot <commit-bot@chromium.org>2021-09-22 17:20:39 +0000
commit2584f19424e68a1461c5cf6c1b8e12f51298a7d6 (patch)
tree37a70890b4f293fdfba8aa5206589815f8bd6fe6
parent36be917aa56ceea5a36837e7ad743927729a511f (diff)
downloadchrome-ec-2584f19424e68a1461c5cf6c1b8e12f51298a7d6.tar.gz
mchp: Check parameter us in void usleep(unsigned us)
Check parameter us in void usleep(unsigned us) under common, to avoid triggering ASSERT(us), it may be a good idea to figure out which caller to pass 0 parameter, but it may be difficult during run-time. remove ASSERT(us) in this usleep() routine BUG=none BRANCH=none TEST=Tested on ADL RVP and MCHP1727 MECC system without parameter 0 checking, ASSERT(us) is triggered as POR: [0.482657 power_chipset_init: power_signal=0x0] [0.484735 SW 0x01] ASSERTION FAILURE 'us' in usleep() at common/timer.c:184 === PROCESS EXCEPTION: 00 ====== xPSR: 000cfb43 === r0 :000000b8 r1 :000e9aa6 r2 :000e9ad0 r3 :000d1a51 r4 :dead6663 r5 :000000b8 r6 :000765f4 r7 :00040314 r8 :00118e00 r9 :000e4aa8 r10:000e456c r11:00000000 r12:00000000 sp :0011b420 lr :00000030 pc :00000030 after checking is added, ASSERT(us) is not hit Signed-off-by: martin yan <martin.yan@microchip.corp-partner.google.com> Change-Id: I2f58ea132da7bf7a5dd315a69675013617eb0a64 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3138620 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--common/timer.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/common/timer.c b/common/timer.c
index 22cff4a325..019753f4db 100644
--- a/common/timer.c
+++ b/common/timer.c
@@ -175,6 +175,10 @@ void usleep(unsigned us)
uint32_t evt = 0;
uint32_t t0;
+ /* If a wait is 0, return immediately. */
+ if (!us)
+ return;
+
if (IS_ENABLED(CONFIG_ZEPHYR)) {
while (us)
us = k_usleep(us);
@@ -196,7 +200,6 @@ void usleep(unsigned us)
return;
}
- ASSERT(us);
do {
evt |= task_wait_event(us);
} while (!(evt & TASK_EVENT_TIMER) &&