diff options
author | Patryk Duda <pdk@semihalf.com> | 2022-01-31 15:36:23 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-02-02 10:32:43 +0000 |
commit | db897e2f88124f8ba840372518635dc58e3595f7 (patch) | |
tree | afebc6dd73c89ed05d8fd61119e29ab61c9b9e05 /zephyr/projects | |
parent | 15310f442b612de17e549a307f25d612d56a2015 (diff) | |
download | chrome-ec-db897e2f88124f8ba840372518635dc58e3595f7.tar.gz |
clock-stm32h7: Handle timer overflow in IDLE task
Like STM32F4, implementation of IDLE task for STM32H7 is also prone to
issues with timer overflow when interrupts are disabled (CL:3347659).
This patch brings this fix to boards based on STM32H7 family.
Description of timer overflow issue in CL:3347659:
STM32F4 microcontroller has 32 bit timer which is used by EC to measure
system uptime (in microseconds) and wake tasks if necessary. In EC
timestamp is defined as two 32 bit values, which combined together give
full 64 bit value. Lower 32 bits are read directly from timer. Higher
32 bits are kept in clksrc_high variable. The variable is updated in
process_timers() function which is called in interrupt context (it's not
an interrupt handler, but it's called by the driver). The function also
sets event timestamp which is supposed to generate interrupt if timer
register matches event timestamp.
When EC switches to IDLE task, interrupts are disabled in order
to prevent task preemption in uncontrolled manner. It is possible that
after interrupts are disabled timer overflow could occur and clksrc_high
variable remains old. Other problem is that event timestamp which is
read using __hw_clock_event_get() and points to timestamp in previous
"epoch". Its value is about 2^32 - HOOK_TICK_INTERVAL (500 ms).
After overflow, t0.le.lo is very low and t0.le.hi remains unincremented.
As a result next_delay variable (which tells for how long RTC alarm is
set) is very high (even above 1 hour). Another important fact is that t0
timestamp is wrong and it is used to calculate value which will be
loaded into the timer after wake. This can potentially lead to very long
wait before running tasks.
This fix checks if timestamp overflow occurs between disabling interrupt
and getting "t0" value. If it happens, interrupts are enabled (to handle
timer overflow) and IDLE enter procedure is repeated.
BUG=b:200828093
BRANCH=none
TEST=make -j buildall
TEST=Run EC on dartmonkey and enable deep sleep. Check if device
crashes.
Signed-off-by: Patryk Duda <pdk@semihalf.com>
Change-Id: I1f2b64da5b8e1ec2f2b2a273f60cab6529863d1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3425365
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'zephyr/projects')
0 files changed, 0 insertions, 0 deletions