From patchwork Tue Nov 15 16:57:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 125822 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4F142B71C7 for ; Wed, 16 Nov 2011 03:56:55 +1100 (EST) Received: from localhost ([::1]:51886 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQMJX-000807-If for incoming@patchwork.ozlabs.org; Tue, 15 Nov 2011 11:56:51 -0500 Received: from eggs.gnu.org ([140.186.70.92]:46660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQMJN-0007zp-NU for qemu-devel@nongnu.org; Tue, 15 Nov 2011 11:56:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RQMJJ-0007q0-3R for qemu-devel@nongnu.org; Tue, 15 Nov 2011 11:56:41 -0500 Received: from smtp.ctxuk.citrix.com ([62.200.22.115]:37443 helo=SMTP.EU.CITRIX.COM) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQMJI-0007pl-Or for qemu-devel@nongnu.org; Tue, 15 Nov 2011 11:56:36 -0500 X-IronPort-AV: E=Sophos;i="4.69,516,1315180800"; d="scan'208";a="8946934" Received: from lonpmailmx01.citrite.net ([10.30.203.162]) by LONPIPO01.EU.CITRIX.COM with ESMTP/TLS/RC4-MD5; 15 Nov 2011 16:56:34 +0000 Received: from kaball.uk.xensource.com (10.80.2.59) by LONPMAILMX01.citrite.net (10.30.203.162) with Microsoft SMTP Server id 8.3.137.0; Tue, 15 Nov 2011 16:56:34 +0000 Date: Tue, 15 Nov 2011 16:57:13 +0000 From: Stefano Stabellini X-X-Sender: sstabellini@kaball-desktop To: Anthony Liguori In-Reply-To: <4EC27D0D.3040204@codemonkey.ws> Message-ID: References: <1321368671-1134-1-git-send-email-stefano.stabellini@eu.citrix.com> <4EC27D0D.3040204@codemonkey.ws> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 62.200.22.115 Cc: "agraf@suse.de" , "xen-devel@lists.xensource.com" , "qemu-devel@nongnu.org" , Stefano Stabellini Subject: Re: [Qemu-devel] [PATCH 1/4] xen: introduce mc146818rtcxen X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Tue, 15 Nov 2011, Anthony Liguori wrote: > On 11/15/2011 08:51 AM, stefano.stabellini@eu.citrix.com wrote: > > From: Stefano Stabellini > > > > 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 > > 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. 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);