From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KvCsq-0003ap-GL for qemu-devel@nongnu.org; Wed, 29 Oct 2008 11:22:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KvCsp-0003ZV-DS for qemu-devel@nongnu.org; Wed, 29 Oct 2008 11:22:55 -0400 Received: from [199.232.76.173] (port=56329 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KvCso-0003ZP-Ub for qemu-devel@nongnu.org; Wed, 29 Oct 2008 11:22:54 -0400 Received: from mx2.redhat.com ([66.187.237.31]:49523) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KvCso-0004Wp-HL for qemu-devel@nongnu.org; Wed, 29 Oct 2008 11:22:54 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id m9TFMr0H021928 for ; Wed, 29 Oct 2008 11:22:53 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m9TFMrEw004641 for ; Wed, 29 Oct 2008 11:22:53 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id m9TFMqac017683 for ; Wed, 29 Oct 2008 11:22:52 -0400 Received: from dhcp-1-237.local (localhost [127.0.0.1]) by dhcp-1-237.tlv.redhat.com (Postfix) with ESMTP id 2835218D4AF for ; Wed, 29 Oct 2008 17:22:52 +0200 (IST) From: Gleb Natapov Date: Wed, 29 Oct 2008 17:22:52 +0200 Message-ID: <20081029152252.14831.7543.stgit@dhcp-1-237.local> In-Reply-To: <20081029152236.14831.15193.stgit@dhcp-1-237.local> References: <20081029152236.14831.15193.stgit@dhcp-1-237.local> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 3/3] Fix time drift problem under high load when RTC is in use. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Count the number of interrupts that was lost due to interrupt coalescing and re-inject them back when possible. This fixes time drift problem when RTC is used as a time source. Signed-off-by: Gleb Natapov --- hw/mc146818rtc.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index 30bb044..505e117 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -66,6 +66,7 @@ struct RTCState { int64_t next_periodic_time; /* second update */ int64_t next_second_time; + uint32_t irq_coalesced; QEMUTimer *second_timer; QEMUTimer *second_timer2; }; @@ -101,7 +102,8 @@ static void rtc_periodic_timer(void *opaque) rtc_timer_update(s, s->next_periodic_time); s->cmos_data[RTC_REG_C] |= 0xc0; - qemu_irq_raise(s->irq); + if(!qemu_irq_raise(s->irq)) + s->irq_coalesced++; } static void cmos_ioport_write(void *opaque, uint32_t addr, uint32_t data) @@ -360,7 +362,12 @@ static uint32_t cmos_ioport_read(void *opaque, uint32_t addr) case RTC_REG_C: ret = s->cmos_data[s->cmos_index]; qemu_irq_lower(s->irq); - s->cmos_data[RTC_REG_C] = 0x00; + if(!s->irq_coalesced) { + s->cmos_data[RTC_REG_C] = 0x00; + } else { + if(qemu_irq_raise(s->irq)) + s->irq_coalesced--; + } break; default: ret = s->cmos_data[s->cmos_index];