From patchwork Mon May 9 07:03:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Obergfell X-Patchwork-Id: 768402 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4973VdT013589 for ; Mon, 9 May 2011 07:03:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752756Ab1EIHD2 (ORCPT ); Mon, 9 May 2011 03:03:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50591 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752422Ab1EIHD1 (ORCPT ); Mon, 9 May 2011 03:03:27 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4973EE6009082 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 9 May 2011 03:03:15 -0400 Received: from localhost.localdomain (vpn2-9-235.ams2.redhat.com [10.36.9.235]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p49732Hl030518; Mon, 9 May 2011 03:03:12 -0400 From: Ulrich Obergfell To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, uobergfe@redhat.com, gcosta@redhat.com, avi@redhat.com, mtosatti@redhat.com, aliguori@us.ibm.com, jan.kiszka@siemens.com Subject: [PATCH v4 4/5] hpet 'driftfix': add code in update_irq() to detect coalesced interrupts (x86 apic only) Date: Mon, 9 May 2011 09:03:20 +0200 Message-Id: <1304924601-3848-5-git-send-email-uobergfe@redhat.com> In-Reply-To: <1304924601-3848-1-git-send-email-uobergfe@redhat.com> References: <1304924601-3848-1-git-send-email-uobergfe@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 09 May 2011 07:03:31 +0000 (UTC) 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 | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/hpet.c b/hw/hpet.c index 7ab6e62..e57c654 100644 --- a/hw/hpet.c +++ b/hw/hpet.c @@ -175,11 +175,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 +205,16 @@ 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_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)