qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] arm_mptimer: Fix timer shutdown


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] arm_mptimer: Fix timer shutdown
Date: Thu, 2 Jul 2015 10:27:36 +0100

On 1 July 2015 at 22:15, Dmitry Osipenko <address@hidden> wrote:
> Timer, running in periodic mode, can't be stopped or coming one-shot tick
> won't be canceled because timer control code just doesn't handle timer
> disabling. Fix it by checking enable bit and deleting timer if bit isn't set.
>
> Signed-off-by: Dmitry Osipenko <address@hidden>
> ---
>  hw/timer/arm_mptimer.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/hw/timer/arm_mptimer.c b/hw/timer/arm_mptimer.c
> index 8b93b3c..917a10f 100644
> --- a/hw/timer/arm_mptimer.c
> +++ b/hw/timer/arm_mptimer.c
> @@ -127,6 +127,9 @@ static void timerblock_write(void *opaque, hwaddr addr,
>                  tb->count = tb->load;
>              }
>              timerblock_reload(tb, 1);
> +        } else if (!(value & 1)) {
> +            /* Shutdown timer.  */
> +            timer_del(tb->timer);
>          }
>          break;
>      case 12: /* Interrupt status.  */

Thanks; this does look like a bug. This change will mean we
call timer_del() even if the timer was already disabled,
though, so I think it would be slightly better to rearrange
the existing logic something like this:

  if ((old & 1) != (value & 1)) {
     if (value & 1) {
         if (tb->count == 0 && (tb->control & 2)) {
             tb->count = tb->load;
         }
         timerblock_reload(tb, 1);
     } else {
         timer_del(tb->timer);
     }
  }

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]