From: Paolo Bonzini <pbonzini@redhat.com>
To: "Zhang, Yang Z" <yang.z.zhang@intel.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
Jan Kiszka <jan.kiszka@web.de>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"aliguori@us.ibm.com" <aliguori@us.ibm.com>,
Marcelo Tosatti <mtosatti@redhat.com>
Subject: Re: [PATCH v2 4/4] RTC:Add UIP(update in progress) check logic
Date: Mon, 20 Feb 2012 08:40:04 +0100 [thread overview]
Message-ID: <4F41F8D4.9080500@redhat.com> (raw)
In-Reply-To: <A9667DDFB95DB7438FA9D7D576C3D87E072009@SHSMSX101.ccr.corp.intel.com>
On 02/20/2012 01:25 AM, Zhang, Yang Z wrote:
> When time base is 32kHz, the update cycle takes 1984us at the end
> of every second. And the update cycle begins 244us later after UIP
> is set. So the UIP is set in 2228us at end of every second.
I think we can keep UIP set only for 244us, since our update cycle is
instantaneous. Otherwise looks good, thanks!
Paolo
> Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
>
> ---
> hw/mc146818rtc.c | 26 ++++++++++++++++++++++++++
> 1 files changed, 26 insertions(+), 0 deletions(-)
>
> diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
> index 2445c6b..d4be8e9 100644
> --- a/hw/mc146818rtc.c
> +++ b/hw/mc146818rtc.c
> @@ -601,6 +601,29 @@ static void rtc_calibrate_time(RTCState *s)
> s->current_tm = *ret;
> }
>
> +static int update_in_progress(RTCState *s)
> +{
> + struct timeval tv_now;
> + int64_t host_usec, offset_usec, guest_usec;
> +
> + if (s->cmos_data[RTC_REG_B] & REG_B_SET) {
> + return 0;
> + }
> +
> + gettimeofday(&tv_now, NULL);
> + host_usec = tv_now.tv_sec * USEC_PER_SEC + tv_now.tv_usec;
> + offset_usec = s->offset_sec * USEC_PER_SEC + s->offset_usec;
> + guest_usec = host_usec + offset_usec;
> +
> + /* UIP bit will be set at last 2228us of every second.
> + * Only consider oscillator in 32.768kHz*/
> + if ((guest_usec % USEC_PER_SEC) >= (USEC_PER_SEC - 2228)) {
> + return 1;
> + }
WARNING: multiple messages have this Message-ID (diff)
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Zhang, Yang Z" <yang.z.zhang@intel.com>
Cc: "aliguori@us.ibm.com" <aliguori@us.ibm.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Jan Kiszka <jan.kiszka@web.de>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [Qemu-devel] [PATCH v2 4/4] RTC:Add UIP(update in progress) check logic
Date: Mon, 20 Feb 2012 08:40:04 +0100 [thread overview]
Message-ID: <4F41F8D4.9080500@redhat.com> (raw)
In-Reply-To: <A9667DDFB95DB7438FA9D7D576C3D87E072009@SHSMSX101.ccr.corp.intel.com>
On 02/20/2012 01:25 AM, Zhang, Yang Z wrote:
> When time base is 32kHz, the update cycle takes 1984us at the end
> of every second. And the update cycle begins 244us later after UIP
> is set. So the UIP is set in 2228us at end of every second.
I think we can keep UIP set only for 244us, since our update cycle is
instantaneous. Otherwise looks good, thanks!
Paolo
> Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
>
> ---
> hw/mc146818rtc.c | 26 ++++++++++++++++++++++++++
> 1 files changed, 26 insertions(+), 0 deletions(-)
>
> diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
> index 2445c6b..d4be8e9 100644
> --- a/hw/mc146818rtc.c
> +++ b/hw/mc146818rtc.c
> @@ -601,6 +601,29 @@ static void rtc_calibrate_time(RTCState *s)
> s->current_tm = *ret;
> }
>
> +static int update_in_progress(RTCState *s)
> +{
> + struct timeval tv_now;
> + int64_t host_usec, offset_usec, guest_usec;
> +
> + if (s->cmos_data[RTC_REG_B] & REG_B_SET) {
> + return 0;
> + }
> +
> + gettimeofday(&tv_now, NULL);
> + host_usec = tv_now.tv_sec * USEC_PER_SEC + tv_now.tv_usec;
> + offset_usec = s->offset_sec * USEC_PER_SEC + s->offset_usec;
> + guest_usec = host_usec + offset_usec;
> +
> + /* UIP bit will be set at last 2228us of every second.
> + * Only consider oscillator in 32.768kHz*/
> + if ((guest_usec % USEC_PER_SEC) >= (USEC_PER_SEC - 2228)) {
> + return 1;
> + }
next prev parent reply other threads:[~2012-02-20 7:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-20 0:25 [PATCH v2 4/4] RTC:Add UIP(update in progress) check logic Zhang, Yang Z
2012-02-20 0:25 ` [Qemu-devel] " Zhang, Yang Z
2012-02-20 7:40 ` Paolo Bonzini [this message]
2012-02-20 7:40 ` Paolo Bonzini
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=4F41F8D4.9080500@redhat.com \
--to=pbonzini@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=jan.kiszka@web.de \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.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.