All of lore.kernel.org
 help / color / mirror / Atom feed
From: "zhongjun@sangfor.com.cn" <zhongjun@sangfor.com.cn>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel <qemu-devel@nongnu.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PATCH]MC146818 RTC: Get correct guest time when irq coalesced
Date: Mon, 26 Sep 2016 12:37:11 +0800	[thread overview]
Message-ID: <20160926123710966259185@sangfor.com.cn> (raw)
In-Reply-To: 68f9c490-2d10-8270-f936-949a1e70462e@redhat.com

Hi, Paolo
This is another patch arround RTC. Would you please have a review.

------------------separation-------------------------------------------------

MC146818 RTC: Get correct guest time when irq coalesced

When irq coalesce occurred, irq_coalesced actually store the seconds
that the time sawn in guest lags behind real guest virtual time.
At this time , if guest read cmos for virtual time, it shouldn't see
those delayed seconds, so we must substract irq_coalesced from guest 
virtual time. Otherwise, after seconds queued in irq_coalesced applied
to guest, time in guest will go ahead of time it should be.

---
 hw/timer/mc146818rtc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
index 1df17af..4cb8e5e 100644
--- a/hw/timer/mc146818rtc.c
+++ b/hw/timer/mc146818rtc.c
@@ -549,6 +549,8 @@ static void rtc_set_time(RTCState *s)
     rtc_get_time(s, &tm);
     s->base_rtc = mktimegm(&tm);
     s->last_update = qemu_clock_get_ns(rtc_clock);
+ s->irq_coalesced = 0;
+ s->irq_reinject_on_ack_count = 0;
 
     qapi_event_send_rtc_change(qemu_timedate_diff(&tm), &error_abort);
 }
@@ -585,6 +587,7 @@ static void rtc_update_time(RTCState *s)
 
     guest_nsec = get_guest_rtc_ns(s);
     guest_sec = guest_nsec / NANOSECONDS_PER_SECOND;
+ guest_sec -= s->irq_coalesced;
     gmtime_r(&guest_sec, &ret);
 
     /* Is SET flag of Register B disabled? */
-- 
2.9.0.windows.1

  parent reply	other threads:[~2016-09-26  4:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201609201519044580729@sangfor.com.cn>
2016-09-20  8:17 ` [Qemu-devel] [PATCH]MC146818 RTC: coordinate guest clock base to destination host after migration Paolo Bonzini
2016-09-20  8:34   ` zhongjun
2016-09-20  8:38     ` Paolo Bonzini
2016-09-20 12:54   ` zhongjun
2016-09-20 13:12     ` Paolo Bonzini
2016-09-21  7:36       ` zhongjun
2016-09-21  9:38         ` zhongjun
2016-09-21 15:15         ` Paolo Bonzini
2016-09-22  7:00           ` zhongjun
2016-09-26  3:37           ` [Qemu-devel] [PATCH v2]MC146818 " zhongjun
2016-09-26  7:07             ` Paolo Bonzini
2016-09-26  8:42               ` [Qemu-devel] [PATCH v3]MC146818 " zhongjun
2016-09-26  8:59                 ` Paolo Bonzini
2016-09-26 10:54                   ` [Qemu-devel] [PATCH v4]MC146818 " zhongjun
2016-09-26 11:22                     ` Paolo Bonzini
2016-09-26  4:37           ` zhongjun [this message]
2016-09-26  7:14             ` [Qemu-devel] [PATCH]MC146818 RTC: Get correct guest time when irq coalesced Paolo Bonzini
2016-09-27  3:13               ` zhongjun

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=20160926123710966259185@sangfor.com.cn \
    --to=zhongjun@sangfor.com.cn \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.