From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAnLb-0001zG-0y for qemu-devel@nongnu.org; Thu, 02 Jul 2015 18:52:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAnLa-0001h4-9w for qemu-devel@nongnu.org; Thu, 02 Jul 2015 18:52:46 -0400 Received: from mail-la0-x232.google.com ([2a00:1450:4010:c03::232]:36184) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAnLZ-0001h0-PR for qemu-devel@nongnu.org; Thu, 02 Jul 2015 18:52:45 -0400 Received: by lagc2 with SMTP id c2so70302057lag.3 for ; Thu, 02 Jul 2015 15:52:45 -0700 (PDT) From: Dmitry Osipenko Date: Fri, 3 Jul 2015 01:52:10 +0300 Message-Id: <1435877531-24983-3-git-send-email-digetx@gmail.com> In-Reply-To: <1435877531-24983-1-git-send-email-digetx@gmail.com> References: <1435877531-24983-1-git-send-email-digetx@gmail.com> Subject: [Qemu-devel] [PATCH 2/3] arm_mptimer: Fix ONE-SHOT -> PERIODIC mode change List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Paolo Bonzini , Peter Crosthwaite , QEMU Developers Timer won't start periodic ticking if ONE-SHOT -> PERIODIC mode change happened after one-shot tick was completed. Fix it by starting ticking only if timer was disabled previously and isn't ticking right now. Signed-off-by: Dmitry Osipenko --- hw/timer/arm_mptimer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/timer/arm_mptimer.c b/hw/timer/arm_mptimer.c index e230063..58e17c4 100644 --- a/hw/timer/arm_mptimer.c +++ b/hw/timer/arm_mptimer.c @@ -122,11 +122,16 @@ static void timerblock_write(void *opaque, hwaddr addr, case 8: /* Control. */ old = tb->control; tb->control = value; - if ((old & 1) == (value & 1)) { + /* Don't do anything if timer already disabled. */ + if (((old & 1) == 0) && ((value & 1) == 0)) { break; } if (value & 1) { - if (tb->count == 0 && (tb->control & 2)) { + /* Don't do anything if timer already ticking. */ + if (((old & 1) != 0) && (tb->count != 0)) { + break; + } + if (tb->control & 2) { tb->count = tb->load; } timerblock_reload(tb, 1); -- 2.4.4