arm_timer: reload timer when enabled
PATCH 1/2 arm_timer: reload timer when enabled
Reload the timer when TimerControl is written, if the timer is to be enabled. Otherwise, if an earlier write to TimerLoad was done while periodic mode was not set, s->delta may incorrectly still have the value of the maximum limit instead of the value written to TimerLoad.
This problem is evident on versatileap on current linux-next, which enables TIMER_CTRL_32BIT before writing to TimerLoad and then enabling periodic mode and starting the timer. This causes the first periodic tick to be scheduled to occur after 0xffffffff periods, leading to a perceived hang while the kernel waits for the first timer tick.
--- hw/arm_timer.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/arm_timer.c +1 -1
@@ -113,7 +113,7 @@ static void arm_timer_write(void *opaque, target_phys_addr_t offset,case 1 : freq >>=4 ;break ;case 2 : freq >>=8 ;break ; } -arm_timer_recalibrate (s,0 ); +arm_timer_recalibrate (s, s->control &TIMER_CTRL_ENABLE );ptimer_set_freq (s->timer, freq);if (s->control &TIMER_CTRL_ENABLE ) {/* Restart the timer if still enabled. */
Signature · 1 line
1.7.0.4
PATCH 2/2 arm_timer: fix oneshot mode
In oneshot mode, the delta needs to come from the TimerLoad register, not the maximum limit.
--- hw/arm_timer.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/arm_timer.c +1 -1
@@ -71,7 +71,7 @@ static void arm_timer_recalibrate(arm_timer_state *s, int reload) {uint32_t limit; -if ((s->control &TIMER_CTRL_PERIODIC ) ==0 ) { +if ((s->control & (TIMER_CTRL_PERIODIC |TIMER_CTRL_ONESHOT )) ==0 ) {/* Free running. */ if (s->control &TIMER_CTRL_32BIT ) limit =0xffffffff ;
Signature · 1 line
1.7.0.4
Aurelien Jarno
AppliedRe: [Qemu-devel] [PATCH 2/2] arm_timer: fix oneshot mode
Quoted 4 lines · Rabin Vincent
In oneshot mode, the delta needs to come from the TimerLoad register, not the maximum limit.
Signed-off-by Rabin Vincent <[email protected]>
Thanks, applied.
Quoted 23 lines
--- hw/arm_timer.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)hw/arm_timer.c +1
-1@@ -71,7 +71,7 @@ static void arm_timer_recalibrate(arm_timer_state *s, int reload) {uint32_t limit; -if ((s->control &TIMER_CTRL_PERIODIC ) ==0 ) { +if ((s->control & (TIMER_CTRL_PERIODIC |TIMER_CTRL_ONESHOT )) ==0 ) {/* Free running. */ if (s->control &TIMER_CTRL_32BIT ) limit =0xffffffff ;Signature · 1 line
1.7.0.4
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Quoted 5 lines · Rabin Vincent
Reload the timer when TimerControl is written, if the timer is to be enabled. Otherwise, if an earlier write to TimerLoad was done while periodic mode was not set,
s->deltamay incorrectly still have the value of the maximum limit instead of the value written to TimerLoad.
Quoted 7 lines
This problem is evident on versatileap on current linux-next, which enables
TIMER_CTRL_32BITbefore writing to TimerLoad and then enabling periodic mode and starting the timer. This causes the first periodic tick to be scheduled to occur after0xffffffffperiods, leading to a perceived hang while the kernel waits for the first timer tick.Signed-off-by Rabin Vincent <[email protected]>
Could these patches please be applied? What was then linux-next is now current Linux mainline, and it doesn't boot without this patch.
Rabin
Aurelien Jarno
AppliedQuoted 5 lines · Rabin Vincent
Reload the timer when TimerControl is written, if the timer is to be enabled. Otherwise, if an earlier write to TimerLoad was done while periodic mode was not set,
s->deltamay incorrectly still have the value of the maximum limit instead of the value written to TimerLoad.
Quoted 7 lines
This problem is evident on versatileap on current linux-next, which enables
TIMER_CTRL_32BITbefore writing to TimerLoad and then enabling periodic mode and starting the timer. This causes the first periodic tick to be scheduled to occur after0xffffffffperiods, leading to a perceived hang while the kernel waits for the first timer tick.Signed-off-by Rabin Vincent <[email protected]>
Thanks, applied.
Quoted 23 lines
--- hw/arm_timer.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)hw/arm_timer.c +1
-1@@ -113,7 +113,7 @@ static void arm_timer_write(void *opaque, target_phys_addr_t offset,case 1 : freq >>=4 ;break ;case 2 : freq >>=8 ;break ; } -arm_timer_recalibrate (s,0 ); +arm_timer_recalibrate (s, s->control &TIMER_CTRL_ENABLE );ptimer_set_freq (s->timer, freq);if (s->control &TIMER_CTRL_ENABLE ) {/* Restart the timer if still enabled. */ Signature · 1 line
1.7.0.4
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net