From patchwork Fri Sep 11 12:01:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 33454 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4BBEBB7067 for ; Fri, 11 Sep 2009 22:53:34 +1000 (EST) Received: from localhost ([127.0.0.1]:60507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mm5d5-0001Ca-JQ for incoming@patchwork.ozlabs.org; Fri, 11 Sep 2009 08:53:31 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mm4rj-0005iF-Ei for qemu-devel@nongnu.org; Fri, 11 Sep 2009 08:04:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mm4rd-0005gc-PM for qemu-devel@nongnu.org; Fri, 11 Sep 2009 08:04:33 -0400 Received: from [199.232.76.173] (port=35058 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mm4rd-0005gO-2l for qemu-devel@nongnu.org; Fri, 11 Sep 2009 08:04:29 -0400 Received: from thoth.sbs.de ([192.35.17.2]:17275) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mm4rc-0007VN-40 for qemu-devel@nongnu.org; Fri, 11 Sep 2009 08:04:28 -0400 Received: from mail3.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id n8BC4PAv012309; Fri, 11 Sep 2009 14:04:25 +0200 Received: from [139.25.109.167] (mchn012c.ww002.siemens.net [139.25.109.167] (may be forged)) by mail3.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id n8BC4Of2007344; Fri, 11 Sep 2009 14:04:25 +0200 Resent-From: Jan Kiszka Resent-To: Anthony Liguori Resent-Cc: qemu-devel , Glauber Costa , Blue Swirl , Dor Laor , Jamie Lokier Resent-Date: Fri, 11 Sep 2009 14:03:00 +0200 Resent-Message-Id: <4AAA3C74.9000802@siemens.com> Resent-User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 From: Jan Kiszka To: Anthony Liguori Date: Fri, 11 Sep 2009 14:01:31 +0200 Message-ID: <20090911120131.25269.11919.stgit@mchn012c.ww002.siemens.net> In-Reply-To: <20090911120130.25269.86775.stgit@mchn012c.ww002.siemens.net> References: <20090911120130.25269.86775.stgit@mchn012c.ww002.siemens.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Resent-Date: Fri, 11 Sep 2009 08:04:33 -0400 Cc: Blue Swirl , Glauber Costa , Dor Laor , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH v2 4/4] MC146818: Switch to host_clock X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Move the RTC emuation, including all its timer IRQ sources, over to host_clock. This aligns MC146818 with most other RTC emulation that already use the host's system time. It allows guests, specifically x86, to use the RTC as a reference clock, provided the host clock is synchronized against an accurate reference, e.g. via NTP. The guest then no longer needs to run NTP-like services, which is useful for network-less guest configurations or for guests that cannot be changed easily to add NTP support. Signed-off-by: Jan Kiszka --- hw/mc146818rtc.c | 35 ++++++++++++++++------------------- 1 files changed, 16 insertions(+), 19 deletions(-) diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index a1ff9ba..7b9f110 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -108,8 +108,8 @@ static void rtc_coalesced_timer_update(RTCState *s) } else { /* divide each RTC interval to 2 - 8 smaller intervals */ int c = MIN(s->irq_coalesced, 7) + 1; - int64_t next_clock = qemu_get_clock(vm_clock) + - muldiv64(s->period / c, ticks_per_sec, 32768); + int64_t next_clock = qemu_get_clock(host_clock) + + muldiv64(s->period / c, ticks_per_sec, 32768); qemu_mod_timer(s->coalesced_timer, next_clock); } } @@ -232,7 +232,7 @@ static void cmos_ioport_write(void *opaque, uint32_t addr, uint32_t data) /* UIP bit is read only */ s->cmos_data[RTC_REG_A] = (data & ~REG_A_UIP) | (s->cmos_data[RTC_REG_A] & REG_A_UIP); - rtc_timer_update(s, qemu_get_clock(vm_clock)); + rtc_timer_update(s, qemu_get_clock(host_clock)); break; case RTC_REG_B: if (data & REG_B_SET) { @@ -246,7 +246,7 @@ static void cmos_ioport_write(void *opaque, uint32_t addr, uint32_t data) } } s->cmos_data[RTC_REG_B] = data; - rtc_timer_update(s, qemu_get_clock(vm_clock)); + rtc_timer_update(s, qemu_get_clock(host_clock)); break; case RTC_REG_C: case RTC_REG_D: @@ -605,18 +605,17 @@ static int rtc_initfn(ISADevice *dev) rtc_set_date_from_host(s); - s->periodic_timer = qemu_new_timer(vm_clock, - rtc_periodic_timer, s); + s->periodic_timer = qemu_new_timer(host_clock, rtc_periodic_timer, s); #ifdef TARGET_I386 if (rtc_td_hack) - s->coalesced_timer = qemu_new_timer(vm_clock, rtc_coalesced_timer, s); + s->coalesced_timer = + qemu_new_timer(host_clock, rtc_coalesced_timer, s); #endif - s->second_timer = qemu_new_timer(vm_clock, - rtc_update_second, s); - s->second_timer2 = qemu_new_timer(vm_clock, - rtc_update_second2, s); + s->second_timer = qemu_new_timer(host_clock, rtc_update_second, s); + s->second_timer2 = qemu_new_timer(host_clock, rtc_update_second2, s); - s->next_second_time = qemu_get_clock(vm_clock) + (ticks_per_sec * 99) / 100; + s->next_second_time = + qemu_get_clock(host_clock) + (ticks_per_sec * 99) / 100; qemu_mod_timer(s->second_timer2, s->next_second_time); register_ioport_write(base, 2, 1, cmos_ioport_write, s); @@ -747,14 +746,12 @@ RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, s->base_year = base_year; rtc_set_date_from_host(s); - s->periodic_timer = qemu_new_timer(vm_clock, - rtc_periodic_timer, s); - s->second_timer = qemu_new_timer(vm_clock, - rtc_update_second, s); - s->second_timer2 = qemu_new_timer(vm_clock, - rtc_update_second2, s); + s->periodic_timer = qemu_new_timer(host_clock, rtc_periodic_timer, s); + s->second_timer = qemu_new_timer(host_clock, rtc_update_second, s); + s->second_timer2 = qemu_new_timer(host_clock, rtc_update_second2, s); - s->next_second_time = qemu_get_clock(vm_clock) + (ticks_per_sec * 99) / 100; + s->next_second_time = + qemu_get_clock(host_clock) + (ticks_per_sec * 99) / 100; qemu_mod_timer(s->second_timer2, s->next_second_time); io_memory = cpu_register_io_memory(rtc_mm_read, rtc_mm_write, s);