qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mc146818rtc: fix timer interrupt reinjection
@ 2019-10-09 18:40 Marcelo Tosatti
  2019-10-09 21:13 ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Marcelo Tosatti @ 2019-10-09 18:40 UTC (permalink / raw)
  To: qemu-devel; +Cc: Tai Yunfang, Xiao Guangrong, Vadim Rozenfeld, Paolo Bonzini


commit 369b41359af46bded5799c9ef8be2b641d92e043 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.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 6cb378751b..aabffa8c67 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -241,7 +241,10 @@ periodic_timer_update(RTCState *s, int64_t current_time, uint32_t old_period)
 
             s->period = period;
             lost_clock += old_irq_coalesced * old_period;
-            s->irq_coalesced = lost_clock / s->period;
+            if (old_period) {
+                s->irq_coalesced = lost_clock / s->period;
+            }
+
             lost_clock %= s->period;
             if (old_irq_coalesced != s->irq_coalesced ||
                 old_period != s->period) {




^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-10 12:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-09 18:40 [PATCH] mc146818rtc: fix timer interrupt reinjection Marcelo Tosatti
2019-10-09 21:13 ` Paolo Bonzini
2019-10-10 12:28   ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).