qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "zhongjun@sangfor.com.cn" <zhongjun@sangfor.com.cn>,
	qemu-devel <qemu-devel@nongnu.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH]MC146818 RTC: Get correct guest time when irq coalesced
Date: Mon, 26 Sep 2016 09:14:09 +0200	[thread overview]
Message-ID: <c448794a-87fa-21e2-9304-9ed14e79f219@redhat.com> (raw)
In-Reply-To: <20160926123710966259185@sangfor.com.cn>



On 26/09/2016 06:37, zhongjun@sangfor.com.cn wrote:
> 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.

No, it's not seconds.  It depends on the interval of the periodic interrupt.

In any case this approach is not acceptable, unfortunately; it causes
the time to go backwards for the guest as soon as an interrupt is coalesced.

What is the guest that you're seeing issues with?

Thanks,

Paolo

> ---
>  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? */
> 

  reply	other threads:[~2016-09-26  7:15 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           ` [Qemu-devel] [PATCH]MC146818 RTC: Get correct guest time when irq coalesced zhongjun
2016-09-26  7:14             ` Paolo Bonzini [this message]
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=c448794a-87fa-21e2-9304-9ed14e79f219@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhongjun@sangfor.com.cn \
    /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).