From patchwork Mon Sep 14 15:49:23 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 33589 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 6AB49B7C07 for ; Tue, 15 Sep 2009 02:03:19 +1000 (EST) Received: from localhost ([127.0.0.1]:50984 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MnE1L-00046W-IK for incoming@patchwork.ozlabs.org; Mon, 14 Sep 2009 12:03:15 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MnDoD-0004eW-SQ for qemu-devel@nongnu.org; Mon, 14 Sep 2009 11:49:42 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MnDo8-0004ZN-5P for qemu-devel@nongnu.org; Mon, 14 Sep 2009 11:49:40 -0400 Received: from [199.232.76.173] (port=54816 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MnDo7-0004Yr-9U for qemu-devel@nongnu.org; Mon, 14 Sep 2009 11:49:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17667) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MnDo6-0007VW-N8 for qemu-devel@nongnu.org; Mon, 14 Sep 2009 11:49:35 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8EFnXXL001228 for ; Mon, 14 Sep 2009 11:49:34 -0400 Received: from zweiblum.home.kraxel.org (vpn1-5-94.ams2.redhat.com [10.36.5.94]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n8EFnUDE009909; Mon, 14 Sep 2009 11:49:31 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 5D9F8700E7; Mon, 14 Sep 2009 17:49:25 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 14 Sep 2009 17:49:23 +0200 Message-Id: <1252943364-32705-9-git-send-email-kraxel@redhat.com> In-Reply-To: <1252943364-32705-1-git-send-email-kraxel@redhat.com> References: <1252943364-32705-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 8/9] isa: refine irq reservations 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 There are a few cases where IRQ sharing on the ISA bus is used and possible. In general only devices of the same kind can do that. A few use cases: * serial lines 1+3 share irq 4 * serial lines 2+4 share irq 3 * parallel ports share irq 7 * ppc/prep: ide ports share irq 13 This patch refines the irq reservation mechanism for the isa bus to handle those cases. It keeps track of the driver which owns the IRQ in question and allows irq sharing for devices handled by the same driver. Signed-off-by: Gerd Hoffmann --- hw/isa-bus.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/hw/isa-bus.c b/hw/isa-bus.c index 4ecc0f8..1d2ca90 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -26,6 +26,7 @@ struct ISABus { BusState qbus; qemu_irq *irqs; uint32_t assigned; + DeviceInfo *irq_owner[16]; }; static ISABus *isabus; @@ -71,7 +72,9 @@ qemu_irq isa_reserve_irq(int isairq) exit(1); } if (isabus->assigned & (1 << isairq)) { - fprintf(stderr, "isa irq %d already assigned\n", isairq); + DeviceInfo *owner = isabus->irq_owner[isairq]; + fprintf(stderr, "isa irq %d already assigned (%s)\n", + isairq, owner ? owner->name : "unknown"); exit(1); } isabus->assigned |= (1 << isairq); @@ -82,10 +85,17 @@ void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq) { assert(dev->nirqs < ARRAY_SIZE(dev->isairq)); if (isabus->assigned & (1 << isairq)) { - fprintf(stderr, "isa irq %d already assigned\n", isairq); - exit(1); + DeviceInfo *owner = isabus->irq_owner[isairq]; + if (owner == dev->qdev.info) { + /* irq sharing is ok in case the same driver handles both */; + } else { + fprintf(stderr, "isa irq %d already assigned (%s)\n", + isairq, owner ? owner->name : "unknown"); + exit(1); + } } isabus->assigned |= (1 << isairq); + isabus->irq_owner[isairq] = dev->qdev.info; dev->isairq[dev->nirqs] = isairq; *p = isabus->irqs[isairq]; dev->nirqs++;