From: Anthony Liguori <anthony@codemonkey.ws>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"agraf@suse.de" <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH 1/4] xen: introduce mc146818rtcxen
Date: Fri, 18 Nov 2011 08:54:39 -0600 [thread overview]
Message-ID: <4EC671AF.5030805@codemonkey.ws> (raw)
In-Reply-To: <alpine.DEB.2.00.1111181145500.3519@kaball-desktop>
On 11/18/2011 05:46 AM, Stefano Stabellini wrote:
> On Tue, 15 Nov 2011, Stefano Stabellini wrote:
>> On Tue, 15 Nov 2011, Anthony Liguori wrote:
>>> On 11/15/2011 08:51 AM, stefano.stabellini@eu.citrix.com wrote:
>>>> From: Stefano Stabellini<stefano.stabellini@eu.citrix.com>
>>>>
>>>> Xen doesn't need full RTC emulation in Qemu because the RTC is already
>>>> emulated by the hypervisor. In particular we want to avoid the timers
>>>> initialization so that Qemu doesn't need to wake up needlessly.
>>>>
>>>> Signed-off-by: Stefano Stabellini<stefano.stabellini@eu.citrix.com>
>>>
>>> Yuck. There's got to be a better way to do this.
>>
>> Yeah, it is pretty ugly, I was hoping in some good suggestions to
>> improve this patch :)
>>
>>
>>> I think it would be better to name timers and then in Xen specific machine code,
>>> disable the RTC timers.
>>
>> Good idea!
>> I was thinking that I could implement an rtc_stop function in
>> mc146818rtc.c that stops and frees the timers.
>>
>> Now the problem is that from xen-all.c I cannot easily find the
>> ISADevice instance to pass to rtc_stop. Do you think it would be
>> reasonable to call rtc_stop from pc_basic_device_init, inside the same
>> if (!xen_available()) introduce by the next patch?
>>
>> Otherwise I could implement functions to walk the isa bus, similarly to
>> pci_for_each_device.
>>
>
> ping?
Thinking more about it, I think this entire line of thinking is wrong (including
mine) :-)
The problem you're trying to solve is that the RTC fires two 1 second timers
regardless of whether the guest is reading the wall clock time, right? And
since wall clock time is never read from the QEMU RTC in Xen, it's a huge waste?
The Right Solution would be to modify the RTC emulation such that it did a
qemu_get_clock() during read of the CMOS registers in order to ensure the time
was up to date (instead of using 1 second timers).
Then the timers wouldn't even exist anymore.
Regards,
Anthony Liguori
>
>
>> This is just an example:
>>
>> diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
>> index 2aaca2f..568c540 100644
>> --- a/hw/mc146818rtc.c
>> +++ b/hw/mc146818rtc.c
>> @@ -667,6 +667,28 @@ ISADevice *rtc_init(int base_year, qemu_irq intercept_irq)
>> return dev;
>> }
>>
>> +void rtc_stop(ISADevice *dev)
>> +{
>> + RTCState *s = DO_UPCAST(RTCState, dev, dev);
>> +
>> + qemu_del_timer(s->periodic_timer);
>> + qemu_del_timer(s->second_timer);
>> + qemu_del_timer(s->second_timer2);
>> +#ifdef TARGET_I386
>> + if (rtc_td_hack) {
>> + qemu_del_timer(s->coalesced_timer);
>> + }
>> +#endif
>> + qemu_free_timer(s->periodic_timer);
>> + qemu_free_timer(s->second_timer);
>> + qemu_free_timer(s->second_timer2);
>> +#ifdef TARGET_I386
>> + if (rtc_td_hack) {
>> + qemu_free_timer(s->coalesced_timer);
>> + }
>> +#endif
>> +}
>> +
>> static ISADeviceInfo mc146818rtc_info = {
>> .qdev.name = "mc146818rtc",
>> .qdev.size = sizeof(RTCState),
>> diff --git a/hw/mc146818rtc.h b/hw/mc146818rtc.h
>> index 575968c..aa2b8ab 100644
>> --- a/hw/mc146818rtc.h
>> +++ b/hw/mc146818rtc.h
>> @@ -8,5 +8,6 @@
>> ISADevice *rtc_init(int base_year, qemu_irq intercept_irq);
>> void rtc_set_memory(ISADevice *dev, int addr, int val);
>> void rtc_set_date(ISADevice *dev, const struct tm *tm);
>> +void rtc_stop(ISADevice *dev);
>>
>> #endif /* !MC146818RTC_H */
>> diff --git a/hw/pc.c b/hw/pc.c
>> index a0ae981..d734f75 100644
>> --- a/hw/pc.c
>> +++ b/hw/pc.c
>> @@ -1145,6 +1145,8 @@ void pc_basic_device_init(qemu_irq *gsi,
>>
>> if (!xen_available()) {
>> pit = pit_init(0x40, 0);
>> + } else {
>> + rtc_stop(*rtc_state);
>> }
>> pcspk_init(pit);
>>
>>
>
next prev parent reply other threads:[~2011-11-18 14:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-15 14:48 [Qemu-devel] [PATCH 0/4] prevent Qemu from waking up needlessly Stefano Stabellini
2011-11-15 14:51 ` [Qemu-devel] [PATCH 1/4] xen: introduce mc146818rtcxen stefano.stabellini
2011-11-15 14:54 ` Anthony Liguori
2011-11-15 16:57 ` Stefano Stabellini
2011-11-18 11:46 ` Stefano Stabellini
2011-11-18 13:58 ` Anthony Liguori
2011-11-18 14:54 ` Anthony Liguori [this message]
2011-11-20 14:53 ` Avi Kivity
2011-11-21 20:49 ` Anthony Liguori
2011-11-21 11:05 ` Stefano Stabellini
2011-11-21 13:21 ` Paolo Bonzini
2011-11-15 14:51 ` [Qemu-devel] [PATCH 2/4] xen: do not initialize the interval timer emulator stefano.stabellini
2011-11-15 14:51 ` [Qemu-devel] [PATCH 3/4] xen: introduce an event channel for buffered io event notifications stefano.stabellini
2011-11-15 17:13 ` [Qemu-devel] [Xen-devel] " Ian Campbell
2011-11-15 17:20 ` Stefano Stabellini
2011-11-15 17:24 ` Ian Campbell
2011-11-15 14:51 ` [Qemu-devel] [PATCH 4/4] qemu_calculate_timeout: increase minimum timeout to 1h stefano.stabellini
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=4EC671AF.5030805@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=agraf@suse.de \
--cc=qemu-devel@nongnu.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.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).