qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: Tai Yunfang <yunfangtai@tencent.com>,
	Xiao Guangrong <guangrong.xiao@gmail.com>,
	Vadim Rozenfeld <vrozenfe@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [PATCH] mc146818rtc: fix timer interrupt reinjection
Date: Wed, 9 Oct 2019 15:40:14 -0300	[thread overview]
Message-ID: <20191009184011.GA26234@amt.cnet> (raw)


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) {




             reply	other threads:[~2019-10-09 20:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-09 18:40 Marcelo Tosatti [this message]
2019-10-09 21:13 ` [PATCH] mc146818rtc: fix timer interrupt reinjection Paolo Bonzini
2019-10-10 12:28   ` Marcelo Tosatti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191009184011.GA26234@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=guangrong.xiao@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vrozenfe@redhat.com \
    --cc=yunfangtai@tencent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).