qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/2] arm_mptimer: Fix timer shutdown and mode ch


From: Dmitry Osipenko
Subject: Re: [Qemu-devel] [PATCH 1/2] arm_mptimer: Fix timer shutdown and mode change
Date: Sun, 05 Jul 2015 23:00:50 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

05.07.2015 22:07, Peter Crosthwaite пишет:
-        if (((old & 1) == 0) && (value & 1)) {
-            if (tb->count == 0 && (tb->control & 2)) {
+        if (value & 1) {
+            if ((old & 1) && (tb->count != 0)) {
+                /* Do nothing if timer is ticking right now.  */
+                break;
+            }
+            if (tb->control & 2) {

So when the timer was previously disabled (!(old & 1)) and the count
is non-zero this will cause a spurious auto-reload. I don't this
causes a bug today because the code as-is doesn't support arbitrary
count values, but it is a developer trap should the assumption that
tb->count equals either 0 or the reload value not hold true.


tb->count can be either 0 or tb->load, so it shouldn't hurt to re-load it here.

                  tb->count = tb->load;
              }
              timerblock_reload(tb, 1);
+        } else if (old & 1) {
+            /* Shutdown the timer.  */
+            timer_del(tb->timer);

In general, this seems to now dup the code paths for control and
load/counter writes. Both now have a del and reload call for various
changes-of state. I had a go to see if I can consolidate. Turns out,
doing so should implement timer pause and resumption while fixing both
of your bugs, I'll send some patches.

Yeah, still there is some room for optimizations.

Well, I think it would be more reasonable to implement pausing with a conversion to ptimer use, since it should result in a cleaner and simpler code.

--
Dmitry



reply via email to

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