From patchwork Thu Apr 28 14:24:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Obergfell X-Patchwork-Id: 93225 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 DD200B6EF2 for ; Fri, 29 Apr 2011 00:25:32 +1000 (EST) Received: from localhost ([::1]:60670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFS9p-0004de-Vb for incoming@patchwork.ozlabs.org; Thu, 28 Apr 2011 10:25:29 -0400 Received: from eggs.gnu.org ([140.186.70.92]:53678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFS9M-0004YY-72 for qemu-devel@nongnu.org; Thu, 28 Apr 2011 10:25:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QFS9L-0006w4-5g for qemu-devel@nongnu.org; Thu, 28 Apr 2011 10:25:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59406) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFS9K-0006vz-SY for qemu-devel@nongnu.org; Thu, 28 Apr 2011 10:24:59 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3SEOwVu007932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 28 Apr 2011 10:24:58 -0400 Received: from localhost.localdomain (vpn2-9-111.ams2.redhat.com [10.36.9.111]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p3SEOmh3018437; Thu, 28 Apr 2011 10:24:56 -0400 From: Ulrich Obergfell To: qemu-devel@nongnu.org Date: Thu, 28 Apr 2011 16:24:59 +0200 Message-Id: <1304000700-3640-5-git-send-email-uobergfe@redhat.com> In-Reply-To: <1304000700-3640-1-git-send-email-uobergfe@redhat.com> References: <1304000700-3640-1-git-send-email-uobergfe@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com, kvm@vger.kernel.org, jan.kiszka@siemens.com, uobergfe@redhat.com, gcosta@redhat.com, avi@redhat.com Subject: [Qemu-devel] [PATCH v3 4/5] hpet 'driftfix': add code in update_irq() to detect coalesced interrupts (x86 apic only) 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 update_irq() uses a similar method as in 'rtc_td_hack' to detect coalesced interrupts. The function entry addresses are retrieved from 'target_get_irq_delivered' and 'target_reset_irq_delivered'. This change can be replaced if a generic feedback infrastructure to track coalesced IRQs for periodic, clock providing devices becomes available. Signed-off-by: Ulrich Obergfell --- hw/hpet.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hw/hpet.c b/hw/hpet.c index 7ab6e62..35466ae 100644 --- a/hw/hpet.c +++ b/hw/hpet.c @@ -31,6 +31,7 @@ #include "hpet_emul.h" #include "sysbus.h" #include "mc146818rtc.h" +#include "sysemu.h" //#define HPET_DEBUG #ifdef HPET_DEBUG @@ -175,11 +176,12 @@ static inline uint64_t hpet_calculate_diff(HPETTimer *t, uint64_t current) } } -static void update_irq(struct HPETTimer *timer, int set) +static int update_irq(struct HPETTimer *timer, int set) { uint64_t mask; HPETState *s; int route; + int irq_delivered = 1; if (timer->tn <= 1 && hpet_in_legacy_mode(timer->state)) { /* if LegacyReplacementRoute bit is set, HPET specification requires @@ -204,8 +206,17 @@ static void update_irq(struct HPETTimer *timer, int set) qemu_irq_raise(s->irqs[route]); } else { s->isr &= ~mask; - qemu_irq_pulse(s->irqs[route]); + if (s->driftfix && target_get_irq_delivered + && target_reset_irq_delivered) { + target_reset_irq_delivered(); + qemu_irq_raise(s->irqs[route]); + irq_delivered = target_get_irq_delivered(); + qemu_irq_lower(s->irqs[route]); + } else { + qemu_irq_pulse(s->irqs[route]); + } } + return irq_delivered; } static void hpet_pre_save(void *opaque)