diff mbox series

[v3,3/3] mc146818rtc: fix timer interrupt reinjection

Message ID 20191024122425.2483-4-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series mc146818rtc: fix timer interrupt reinjection | expand

Commit Message

Philippe Mathieu-Daudé Oct. 24, 2019, 12:24 p.m. UTC
From: Marcelo Tosatti <mtosatti@redhat.com>

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>
Message-Id: <20191010123008.GA19158@amt.cnet>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/timer/mc146818rtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 8da7fd1a50..adbc3b9d57 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -224,7 +224,6 @@  periodic_timer_update(RTCState *s, int64_t current_time, uint32_t old_period)
         last_periodic_clock = next_periodic_clock - old_period;
         lost_clock = cur_clock - last_periodic_clock;
         assert(lost_clock >= 0);
-        }
 
         /*
          * s->irq_coalesced can change for two reasons:
@@ -261,6 +260,7 @@  periodic_timer_update(RTCState *s, int64_t current_time, uint32_t old_period)
              */
             lost_clock = MIN(lost_clock, period);
         }
+    }
 
     assert(lost_clock >= 0 && lost_clock <= period);