mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 01:43:39 +00:00
mc146818rtc: fix timer interrupt reinjection
commit 369b41359a
broke timer interrupt
reinjection when there is no period change by the guest.
In that case, old_period is 0, which ends up zeroing irq_coalesced
(counter of reinjected interrupts).
The consequence is Windows 7 is unable to synchronize time via NTP.
Easily reproducible by playing a fullscreen video with cirrus and VNC.
Fix by not updating s->irq_coalesced when old_period is 0.
V2: reorganize code (Paolo Bonzini)
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Message-Id: <20191010123008.GA19158@amt.cnet>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
73284563dc
commit
b429de7301
|
@ -203,7 +203,12 @@ periodic_timer_update(RTCState *s, int64_t current_time, uint32_t old_period)
|
||||||
|
|
||||||
period = rtc_periodic_clock_ticks(s);
|
period = rtc_periodic_clock_ticks(s);
|
||||||
|
|
||||||
if (period) {
|
if (!period) {
|
||||||
|
s->irq_coalesced = 0;
|
||||||
|
timer_del(s->periodic_timer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* compute 32 khz clock */
|
/* compute 32 khz clock */
|
||||||
cur_clock =
|
cur_clock =
|
||||||
muldiv64(current_time, RTC_CLOCK_RATE, NANOSECONDS_PER_SECOND);
|
muldiv64(current_time, RTC_CLOCK_RATE, NANOSECONDS_PER_SECOND);
|
||||||
|
@ -220,7 +225,6 @@ periodic_timer_update(RTCState *s, int64_t current_time, uint32_t old_period)
|
||||||
last_periodic_clock = next_periodic_clock - old_period;
|
last_periodic_clock = next_periodic_clock - old_period;
|
||||||
lost_clock = cur_clock - last_periodic_clock;
|
lost_clock = cur_clock - last_periodic_clock;
|
||||||
assert(lost_clock >= 0);
|
assert(lost_clock >= 0);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* s->irq_coalesced can change for two reasons:
|
* s->irq_coalesced can change for two reasons:
|
||||||
|
@ -257,16 +261,13 @@ periodic_timer_update(RTCState *s, int64_t current_time, uint32_t old_period)
|
||||||
*/
|
*/
|
||||||
lost_clock = MIN(lost_clock, period);
|
lost_clock = MIN(lost_clock, period);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assert(lost_clock >= 0 && lost_clock <= period);
|
assert(lost_clock >= 0 && lost_clock <= period);
|
||||||
|
|
||||||
next_irq_clock = cur_clock + period - lost_clock;
|
next_irq_clock = cur_clock + period - lost_clock;
|
||||||
s->next_periodic_time = periodic_clock_to_ns(next_irq_clock) + 1;
|
s->next_periodic_time = periodic_clock_to_ns(next_irq_clock) + 1;
|
||||||
timer_mod(s->periodic_timer, s->next_periodic_time);
|
timer_mod(s->periodic_timer, s->next_periodic_time);
|
||||||
} else {
|
|
||||||
s->irq_coalesced = 0;
|
|
||||||
timer_del(s->periodic_timer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rtc_periodic_timer(void *opaque)
|
static void rtc_periodic_timer(void *opaque)
|
||||||
|
|
Loading…
Reference in a new issue