mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-27 12:02:04 -06:00
Revert "hw/ptimer: Perform counter wrap around if timer already expired"
Software should see timer counter wraparound only after IRQ being triggered.
This fixes regression introduced by the commit 5a50307
("hw/ptimer: Perform
counter wrap around if timer already expired"), resulting in monotonic timer
jumping backwards on SPARC emulated machine running NetBSD guest OS, as
reported by Mark Cave-Ayland.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Message-id: 20160708132206.2080-1-digetx@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
f58b39d2d5
commit
56215da394
1 changed files with 2 additions and 7 deletions
|
@ -93,7 +93,7 @@ uint64_t ptimer_get_count(ptimer_state *s)
|
||||||
bool oneshot = (s->enabled == 2);
|
bool oneshot = (s->enabled == 2);
|
||||||
|
|
||||||
/* Figure out the current counter value. */
|
/* Figure out the current counter value. */
|
||||||
if (s->period == 0 || (expired && (oneshot || use_icount))) {
|
if (expired) {
|
||||||
/* Prevent timer underflowing if it should already have
|
/* Prevent timer underflowing if it should already have
|
||||||
triggered. */
|
triggered. */
|
||||||
counter = 0;
|
counter = 0;
|
||||||
|
@ -120,7 +120,7 @@ uint64_t ptimer_get_count(ptimer_state *s)
|
||||||
backwards.
|
backwards.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rem = expired ? now - next : next - now;
|
rem = next - now;
|
||||||
div = period;
|
div = period;
|
||||||
|
|
||||||
clz1 = clz64(rem);
|
clz1 = clz64(rem);
|
||||||
|
@ -140,11 +140,6 @@ uint64_t ptimer_get_count(ptimer_state *s)
|
||||||
div += 1;
|
div += 1;
|
||||||
}
|
}
|
||||||
counter = rem / div;
|
counter = rem / div;
|
||||||
|
|
||||||
if (expired && counter != 0) {
|
|
||||||
/* Wrap around periodic counter. */
|
|
||||||
counter = s->limit - (counter - 1) % s->limit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
counter = s->delta;
|
counter = s->delta;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue