diff options
| author | Tao Ren <taoren@fb.com> | 2018-09-19 18:13:31 -0400 |
|---|---|---|
| committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2018-09-24 00:13:31 -0400 |
| commit | 4451d3f59f2a6f95e5d205c2d04ea072955d080d (patch) | |
| tree | 7ff03084e4fd99f675497adfbc66fb67ba335ac7 /drivers | |
| parent | 3b7d96a0dbb6b630878597a1838fc39f808b761b (diff) | |
clocksource/drivers/fttmr010: Fix set_next_event handler
Currently, the aspeed MATCH1 register is updated to <current_count -
cycles> in set_next_event handler, with the assumption that COUNT
register value is preserved when the timer is disabled and it continues
decrementing after the timer is enabled. But the assumption is wrong:
RELOAD register is loaded into COUNT register when the aspeed timer is
enabled, which means the next event may be delayed because timer
interrupt won't be generated until <0xFFFFFFFF - current_count +
cycles>.
The problem can be fixed by updating RELOAD register to <cycles>, and
COUNT register will be re-loaded when the timer is enabled and interrupt
is generated when COUNT register overflows.
The test result on Facebook Backpack-CMM BMC hardware (AST2500) shows
the issue is fixed: without the patch, usleep(100) suspends the process
for several milliseconds (and sometimes even over 40 milliseconds);
after applying the fix, usleep(100) takes averagely 240 microseconds to
return under the same workload level.
Signed-off-by: Tao Ren <taoren@fb.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Lei YU <mine260309@gmail.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/clocksource/timer-fttmr010.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c index c020038ebfab..cf93f6419b51 100644 --- a/drivers/clocksource/timer-fttmr010.c +++ b/drivers/clocksource/timer-fttmr010.c | |||
| @@ -130,13 +130,17 @@ static int fttmr010_timer_set_next_event(unsigned long cycles, | |||
| 130 | cr &= ~fttmr010->t1_enable_val; | 130 | cr &= ~fttmr010->t1_enable_val; |
| 131 | writel(cr, fttmr010->base + TIMER_CR); | 131 | writel(cr, fttmr010->base + TIMER_CR); |
| 132 | 132 | ||
| 133 | /* Setup the match register forward/backward in time */ | 133 | if (fttmr010->count_down) { |
| 134 | cr = readl(fttmr010->base + TIMER1_COUNT); | 134 | /* |
| 135 | if (fttmr010->count_down) | 135 | * ASPEED Timer Controller will load TIMER1_LOAD register |
| 136 | cr -= cycles; | 136 | * into TIMER1_COUNT register when the timer is re-enabled. |
| 137 | else | 137 | */ |
| 138 | cr += cycles; | 138 | writel(cycles, fttmr010->base + TIMER1_LOAD); |
| 139 | writel(cr, fttmr010->base + TIMER1_MATCH1); | 139 | } else { |
| 140 | /* Setup the match register forward in time */ | ||
| 141 | cr = readl(fttmr010->base + TIMER1_COUNT); | ||
| 142 | writel(cr + cycles, fttmr010->base + TIMER1_MATCH1); | ||
| 143 | } | ||
| 140 | 144 | ||
| 141 | /* Start */ | 145 | /* Start */ |
| 142 | cr = readl(fttmr010->base + TIMER_CR); | 146 | cr = readl(fttmr010->base + TIMER_CR); |
