From: Paolo Bonzini <pbonzini@redhat.com>
To: "Zhang, Yang Z" <yang.z.zhang@intel.com>
Cc: "'aliguori@us.ibm.com'" <aliguori@us.ibm.com>,
"'qemu-devel@nongnu.org'" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v6 2/7] RTC: Update the RTC clock only when reading it
Date: Thu, 17 May 2012 12:38:51 +0200 [thread overview]
Message-ID: <4FB4D53B.5090101@redhat.com> (raw)
In-Reply-To: <A9667DDFB95DB7438FA9D7D576C3D87E13A7EC@SHSMSX101.ccr.corp.intel.com>
Note: I haven't tested this series yet. Thanks for finding the problem!
Il 17/05/2012 04:28, Zhang, Yang Z ha scritto:
> Use offset instead of timer to calculate guest rtc. Guest rtc is calculated by (base_rtc + guest_time_now - guest_time_last_update_rtc + offset).
> Base_rtc means the rtc value of last update.
> Guest_time_now means the guest time that access happens.
> Guest_time_last_update means the guest time of last update rtc.
> Offset is used when divider reset happened or set bit is changed.
>
> +static void rtc_set_offset(RTCState *s, bool running, bool div_reset)
> +{
> + if (div_reset)
> + s->offset = 500000;
> + else if (!running)
> + s->offset = s->old_guest_usec % USEC_PER_SEC;
> +}
This is probably clearer if you just inline it at the appropriate
places---especially because rtc_set_offset(s, 0, 0) is a no-op.
> -static void rtc_update_second(void *opaque)
> -{
> - RTCState *s = opaque;
> - int64_t delay;
> -
> - /* if the oscillator is not in normal operation, we do not update */
> - if ((s->cmos_data[RTC_REG_A] & 0x70) != 0x20) {
> - s->next_second_time += get_ticks_per_sec();
> - qemu_mod_timer(s->second_timer, s->next_second_time);
> - } else {
> - rtc_next_second(&s->current_tm);
> -
> - if (!(s->cmos_data[RTC_REG_B] & REG_B_SET)) {
> - /* update in progress bit */
> - s->cmos_data[RTC_REG_A] |= REG_A_UIP;
> - }
> - /* should be 244 us = 8 / 32768 seconds, but currently the
> - timers do not have the necessary resolution. */
> - delay = (get_ticks_per_sec() * 1) / 100;
> - if (delay < 1)
> - delay = 1;
> - qemu_mod_timer(s->second_timer2,
> - s->next_second_time + delay);
> - }
> -}
This patch breaks REG_A_UIP. You can squash patches 2 and 3 together to
avoid this problem.
Paolo
prev parent reply other threads:[~2012-05-17 10:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-17 2:28 [Qemu-devel] [PATCH v6 2/7] RTC: Update the RTC clock only when reading it Zhang, Yang Z
2012-05-17 10:38 ` Paolo Bonzini [this message]
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=4FB4D53B.5090101@redhat.com \
--to=pbonzini@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=yang.z.zhang@intel.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 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.