diff mbox

Re: [RFC] prep: enable irq sharing on ide again

Message ID 4D591085.9020906@redhat.com
State New
Headers show

Commit Message

Gerd Hoffmann Feb. 14, 2011, 11:22 a.m. UTC
On 02/08/11 00:26, Alexander Graf wrote:
> The new ISA infrastructure checks for potential irq sharing bugs on
> interrupt lines, because usually irq lines on isa can't be shared.
>
> The PREP spec however mandates that the irq lines for both IDE ports
> are shared and according to Aurelien this also used to work just fine.
>
> So let's add a way to enable this sharing again, so we don't introduce
> unnecessary regressions over older versions of Qemu.

Had a patch for that, got shoot down for reasons I don't remember, 
attached for reference.  It basically allows IRQ sharing in case the two 
devices sharing the IRQ are of the same kind.  In that case you usually 
have a single guest driver handling both devices and IRQ sharing works 
most of the time.

I don't mind much which approach we take ...

cheers,
   Gerd
From 44d7b59ee9cc8a57e9999a7b6ecdf53798d2c74d Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Fri, 11 Sep 2009 13:43:46 +0200
Subject: [PATCH] isa: refine irq reservations

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 <kraxel@redhat.com>
---
 hw/isa-bus.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

Comments

Alexander Graf Feb. 14, 2011, 11:34 a.m. UTC | #1
Gerd Hoffmann wrote:
> On 02/08/11 00:26, Alexander Graf wrote:
>> The new ISA infrastructure checks for potential irq sharing bugs on
>> interrupt lines, because usually irq lines on isa can't be shared.
>>
>> The PREP spec however mandates that the irq lines for both IDE ports
>> are shared and according to Aurelien this also used to work just fine.
>>
>> So let's add a way to enable this sharing again, so we don't introduce
>> unnecessary regressions over older versions of Qemu.
>
> Had a patch for that, got shoot down for reasons I don't remember,
> attached for reference.  It basically allows IRQ sharing in case the
> two devices sharing the IRQ are of the same kind.  In that case you
> usually have a single guest driver handling both devices and IRQ
> sharing works most of the time.
>
> I don't mind much which approach we take ...

I'm very indifferent myself :). This is not an issue we should waste too
much time/effort on.


Alex
Jan Kiszka Feb. 14, 2011, 11:40 a.m. UTC | #2
On 2011-02-14 12:22, Gerd Hoffmann wrote:
> On 02/08/11 00:26, Alexander Graf wrote:
>> The new ISA infrastructure checks for potential irq sharing bugs on
>> interrupt lines, because usually irq lines on isa can't be shared.
>>
>> The PREP spec however mandates that the irq lines for both IDE ports
>> are shared and according to Aurelien this also used to work just fine.
>>
>> So let's add a way to enable this sharing again, so we don't introduce
>> unnecessary regressions over older versions of Qemu.
> 
> Had a patch for that, got shoot down for reasons I don't remember,
> attached for reference.  It basically allows IRQ sharing in case the two
> devices sharing the IRQ are of the same kind.  In that case you usually
> have a single guest driver handling both devices and IRQ sharing works
> most of the time.

Yeah, 3x -serial XXX is also broken for x86 targets as the third device
shares its IRQ with the first - like on real HW...

Jan
diff mbox

Patch

diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 4e306de..a99e793 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;
 target_phys_addr_t isa_mem_base = 0;
@@ -72,7 +73,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);
@@ -83,10 +86,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++;