summaryrefslogtreecommitdiff
path: root/core/nds32
diff options
context:
space:
mode:
authorDino Li <Dino.Li@ite.com.tw>2020-07-22 12:01:54 +0800
committerCommit Bot <commit-bot@chromium.org>2020-07-24 06:01:34 +0000
commit87f63dc7a0c5b13a46e453a7d5e3747ffa8925b9 (patch)
tree79f0a96f58cc70295dd9e95d541a34838102db0e /core/nds32
parent7d4f4bf3ea9b002f5935ba0b98698999cd9d94e7 (diff)
downloadchrome-ec-87f63dc7a0c5b13a46e453a7d5e3747ffa8925b9.tar.gz
core: nds32/riscv-rv32i: fix issue of time in exceptions is negative
If 32-bit counter is overflowed in ISR, the high word of the system time (clksrc_high) can't be updated until return from interrupt. So we will get a negative delta time if the overflow occurs between getting start time and end time. This patch fixes the issue. BUG=b:161768286 BRANCH=none TEST=Making a overflow emulation to see what delta time we will get: s = __hw_clock_source_read() = 0xfffffff0; e = __hw_clock_source_read() = 123; e - s = 139; Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Change-Id: I91e6c4d83de3e074388c1a4fc926b05e791b7b47 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2311997 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'core/nds32')
-rw-r--r--core/nds32/task.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/core/nds32/task.c b/core/nds32/task.c
index e92e418fba..74b7501acc 100644
--- a/core/nds32/task.c
+++ b/core/nds32/task.c
@@ -52,10 +52,10 @@ static const char * const task_names[] = {
#ifdef CONFIG_TASK_PROFILING
static int task_will_switch;
-static uint64_t exc_sub_time;
+static uint32_t exc_sub_time;
static uint64_t task_start_time; /* Time task scheduling started */
-static uint64_t exc_start_time; /* Time of task->exception transition */
-static uint64_t exc_end_time; /* Time of exception->task transition */
+static uint32_t exc_start_time; /* Time of task->exception transition */
+static uint32_t exc_end_time; /* Time of exception->task transition */
static uint64_t exc_total_time; /* Total time in exceptions */
static uint32_t svc_calls; /* Number of service calls */
static uint32_t task_switches; /* Number of times active task changed */
@@ -330,7 +330,7 @@ static inline void __schedule(int desched, int resched, int swirq)
void update_exc_start_time(void)
{
#ifdef CONFIG_TASK_PROFILING
- exc_start_time = get_time().val;
+ exc_start_time = get_time().le.lo;
#endif
}
@@ -367,14 +367,14 @@ void __ram_code start_irq_handler(void)
void end_irq_handler(void)
{
#ifdef CONFIG_TASK_PROFILING
- uint64_t t, p;
+ uint32_t t, p;
/*
* save r0 and fp (fp for restore r0-r5, r15, fp, lp and sp
* while interrupt exit.
*/
asm volatile ("smw.adm $r0, [$sp], $r0, 8");
- t = get_time().val;
+ t = get_time().le.lo;
p = t - exc_start_time;
exc_total_time += p;
@@ -767,7 +767,8 @@ void task_pre_init(void)
int task_start(void)
{
#ifdef CONFIG_TASK_PROFILING
- task_start_time = exc_end_time = get_time().val;
+ task_start_time = get_time().val;
+ exc_end_time = get_time().le.lo;
#endif
return __task_start();