Received: from eggs.gnu.org ([2001:4830:134:3::10]:48959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDPsx-0004Cd-Bd for qemu-devel@nongnu.org; Sat, 24 Aug 2013 22:17:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VDPsq-0007rY-IY for qemu-devel@nongnu.org; Sat, 24 Aug 2013 22:16:59 -0400 Received: from mail-ie0-x236.google.com ([2607:f8b0:4001:c03::236]:62603) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDPsq-0007rQ-DA for qemu-devel@nongnu.org; Sat, 24 Aug 2013 22:16:52 -0400 Received: by mail-ie0-f182.google.com with SMTP id aq17so3083989iec.41 for ; Sat, 24 Aug 2013 19:16:52 -0700 (PDT) From: Liu Ping Fan Date: Sun, 25 Aug 2013 10:16:24 +0800 Message-Id: <1377396984-17706-2-git-send-email-pingfank@linux.vnet.ibm.com> In-Reply-To: <1377396984-17706-1-git-send-email-pingfank@linux.vnet.ibm.com> References: <1377396984-17706-1-git-send-email-pingfank@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 2/2] hpet: inverse polarity when pin above ISA_NUM_IRQS List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jan Kiszka , Anthony Liguori , Paolo Bonzini According to hpet spec, hpet irq is high active. But according to ICH spec, there is inversion before the input of ioapic. So the OS will expect low active on this IRQ line.(And this is observed on bare metal). We fold the emulation of this inversion inside the hpet logic. Signed-off-by: Liu Ping Fan --- kernel has a bug with ioapic, refer to https://lkml.org/lkml/2013/8/23/98 With all these patch, linux-2.6/Documentation/timers/hpet_example.c can work on qemu --- hw/timer/hpet.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index cd95d39..a6626e2 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -200,13 +200,23 @@ static void update_irq(struct HPETTimer *timer, int set) if (!set || !timer_enabled(timer) || !hpet_enabled(timer->state)) { s->isr &= ~mask; if (!timer_fsb_route(timer)) { - qemu_irq_lower(s->irqs[route]); + /* fold the ICH PIRQ# pin's internal inversion logic into hpet */ + if (route >= ISA_NUM_IRQS) { + qemu_irq_raise(s->irqs[route]); + } else { + qemu_irq_lower(s->irqs[route]); + } } } else if (timer_fsb_route(timer)) { stl_le_phys(timer->fsb >> 32, timer->fsb & 0xffffffff); } else if (timer->config & HPET_TN_TYPE_LEVEL) { s->isr |= mask; - qemu_irq_raise(s->irqs[route]); + /* fold the ICH PIRQ# pin's internal inversion logic into hpet */ + if (route >= ISA_NUM_IRQS) { + qemu_irq_lower(s->irqs[route]); + } else { + qemu_irq_raise(s->irqs[route]); + } } else { s->isr &= ~mask; qemu_irq_pulse(s->irqs[route]); -- 1.8.1.4