diff mbox

[3/3] arm_mptimer: Respect IT bit state

Message ID 1435877531-24983-4-git-send-email-digetx@gmail.com
State New
Headers show

Commit Message

Dmitry Osipenko July 2, 2015, 10:52 p.m. UTC
Timer fires interrupt regardless of current IT(interrupt enable) bit state.
Fix it by making timer to respect IT state.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 hw/timer/arm_mptimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Peter Crosthwaite July 4, 2015, 7:39 p.m. UTC | #1
On Thu, Jul 2, 2015 at 3:52 PM, Dmitry Osipenko <digetx@gmail.com> wrote:
> Timer fires interrupt regardless of current IT(interrupt enable) bit state.
> Fix it by making timer to respect IT state.
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  hw/timer/arm_mptimer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/timer/arm_mptimer.c b/hw/timer/arm_mptimer.c
> index 58e17c4..82c4462 100644
> --- a/hw/timer/arm_mptimer.c
> +++ b/hw/timer/arm_mptimer.c
> @@ -38,7 +38,7 @@ static inline int get_current_cpu(ARMMPTimerState *s)
>
>  static inline void timerblock_update_irq(TimerBlock *tb)
>  {
> -    qemu_set_irq(tb->irq, tb->status);
> +    qemu_set_irq(tb->irq, tb->status && (tb->control & 4));

You also need to trigger timerblock_update_irq on change of state for
the control bit itself. "case 8: /* Control.  */" in the _write
handler needs to call this fn.

Regards,
Peter

>  }
>
>  /* Return conversion factor from mpcore timer ticks to qemu timer ticks.  */
> --
> 2.4.4
>
>
Dmitry Osipenko July 4, 2015, 7:58 p.m. UTC | #2
Hello Peter,

04.07.2015 22:39, Peter Crosthwaite пишет:
>
> You also need to trigger timerblock_update_irq on change of state for
> the control bit itself. "case 8: /* Control.  */" in the _write
> handler needs to call this fn.
>

Right, as it will mask/unmask interrupt line. Good catch, thanks.
diff mbox

Patch

diff --git a/hw/timer/arm_mptimer.c b/hw/timer/arm_mptimer.c
index 58e17c4..82c4462 100644
--- a/hw/timer/arm_mptimer.c
+++ b/hw/timer/arm_mptimer.c
@@ -38,7 +38,7 @@  static inline int get_current_cpu(ARMMPTimerState *s)
 
 static inline void timerblock_update_irq(TimerBlock *tb)
 {
-    qemu_set_irq(tb->irq, tb->status);
+    qemu_set_irq(tb->irq, tb->status && (tb->control & 4));
 }
 
 /* Return conversion factor from mpcore timer ticks to qemu timer ticks.  */