All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] IRQ sharing in PCI bus
@ 2006-09-23 17:25 andrzej zaborowski
  2006-09-23 17:38 ` Fabrice Bellard
  2006-09-24  0:20 ` Paul Brook
  0 siblings, 2 replies; 6+ messages in thread
From: andrzej zaborowski @ 2006-09-23 17:25 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 292 bytes --]

This allows multiple PCI devices on a bus to use the same IRQ lines.
The signals from all devices are ORed. It will only work if the guest
OS'es drivers supports that.

Linux guest required that to have scsi disks and usb devices working
at the same time on an emulated Versatile PB machine.

[-- Attachment #2: qemu-pci-irq-sharing.patch --]
[-- Type: application/octet-stream, Size: 1901 bytes --]

diff -pNaur qemu-cvs-ts-orig/hw/pci.c qemu-cvs-ts/hw/pci.c
--- qemu-cvs-ts-orig/hw/pci.c	2006-08-17 10:46:34.000000000 +0000
+++ qemu-cvs-ts/hw/pci.c	2006-09-23 17:02:41.000000000 +0000
@@ -34,6 +34,7 @@ struct PCIBus {
     SetIRQFunc *low_set_irq;
     void *irq_opaque;
     PCIDevice *devices[256];
+    int irq_count[4];
 };
 
 static void pci_update_mappings(PCIDevice *d);
@@ -49,6 +50,7 @@ PCIBus *pci_register_bus(pci_set_irq_fn 
     bus->set_irq = set_irq;
     bus->irq_opaque = pic;
     bus->devfn_min = devfn_min;
+    memset(bus->irq_count, 0, sizeof(bus->irq_count));
     first_bus = bus;
     return bus;
 }
@@ -100,6 +102,7 @@ PCIDevice *pci_register_device(PCIBus *b
     pci_dev->bus = bus;
     pci_dev->devfn = devfn;
     pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
+    memset(pci_dev->irq_state, 0, sizeof(pci_dev->irq_state));
 
     if (!config_read)
         config_read = pci_default_read_config;
@@ -404,7 +407,10 @@ uint32_t pci_data_read(void *opaque, uin
 void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level)
 {
     PCIBus *bus = pci_dev->bus;
-    bus->set_irq(pci_dev, bus->irq_opaque, irq_num, level);
+    bus->irq_count[irq_num] += level - pci_dev->irq_state[irq_num];
+    pci_dev->irq_state[irq_num] = level;
+    bus->set_irq(pci_dev, bus->irq_opaque,
+                 irq_num, !!bus->irq_count[irq_num]);
 }
 
 /***********************************************************/
diff -pNaur qemu-cvs-ts-orig/vl.h qemu-cvs-ts/vl.h
--- qemu-cvs-ts-orig/vl.h	2006-09-18 01:15:29.000000000 +0000
+++ qemu-cvs-ts/vl.h	2006-09-23 17:15:21.000000000 +0000
@@ -733,6 +733,9 @@ struct PCIDevice {
     PCIConfigWriteFunc *config_write;
     /* ??? This is a PC-specific hack, and should be removed.  */
     int irq_index;
+
+    /* remember last irq levels */
+    int irq_state[4];
 };
 
 PCIDevice *pci_register_device(PCIBus *bus, const char *name,

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] IRQ sharing in PCI bus
  2006-09-23 17:25 [Qemu-devel] [PATCH] IRQ sharing in PCI bus andrzej zaborowski
@ 2006-09-23 17:38 ` Fabrice Bellard
  2006-09-23 17:43   ` Paul Brook
  2006-09-24  0:20 ` Paul Brook
  1 sibling, 1 reply; 6+ messages in thread
From: Fabrice Bellard @ 2006-09-23 17:38 UTC (permalink / raw)
  To: balrogg, qemu-devel

andrzej zaborowski wrote:
> This allows multiple PCI devices on a bus to use the same IRQ lines.
> The signals from all devices are ORed. It will only work if the guest
> OS'es drivers supports that.
> 
> Linux guest required that to have scsi disks and usb devices working
> at the same time on an emulated Versatile PB machine.

PCI IRQ sharing is already implemented, at least for piix3. You should 
look at that code and try to fix the related code in other PCI controllers.

Regards,

Fabrice.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] IRQ sharing in PCI bus
  2006-09-23 17:38 ` Fabrice Bellard
@ 2006-09-23 17:43   ` Paul Brook
  2006-09-23 17:53     ` Fabrice Bellard
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Brook @ 2006-09-23 17:43 UTC (permalink / raw)
  To: qemu-devel

On Saturday 23 September 2006 18:38, Fabrice Bellard wrote:
> andrzej zaborowski wrote:
> > This allows multiple PCI devices on a bus to use the same IRQ lines.
> > The signals from all devices are ORed. It will only work if the guest
> > OS'es drivers supports that.
> >
> > Linux guest required that to have scsi disks and usb devices working
> > at the same time on an emulated Versatile PB machine.
>
> PCI IRQ sharing is already implemented, at least for piix3. You should
> look at that code and try to fix the related code in other PCI controllers.

Seems silly to implement this several times rather than once in generic code.

Paul

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] IRQ sharing in PCI bus
  2006-09-23 17:43   ` Paul Brook
@ 2006-09-23 17:53     ` Fabrice Bellard
  0 siblings, 0 replies; 6+ messages in thread
From: Fabrice Bellard @ 2006-09-23 17:53 UTC (permalink / raw)
  To: Paul Brook; +Cc: qemu-devel

Paul Brook wrote:
> On Saturday 23 September 2006 18:38, Fabrice Bellard wrote:
> 
>>andrzej zaborowski wrote:
>>
>>>This allows multiple PCI devices on a bus to use the same IRQ lines.
>>>The signals from all devices are ORed. It will only work if the guest
>>>OS'es drivers supports that.
>>>
>>>Linux guest required that to have scsi disks and usb devices working
>>>at the same time on an emulated Versatile PB machine.
>>
>>PCI IRQ sharing is already implemented, at least for piix3. You should
>>look at that code and try to fix the related code in other PCI controllers.
> 
> 
> Seems silly to implement this several times rather than once in generic code.

Right. My comment did not exclude that :-)

Fabrice.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] IRQ sharing in PCI bus
  2006-09-23 17:25 [Qemu-devel] [PATCH] IRQ sharing in PCI bus andrzej zaborowski
  2006-09-23 17:38 ` Fabrice Bellard
@ 2006-09-24  0:20 ` Paul Brook
  2006-09-24  6:19   ` Blue Swirl
  1 sibling, 1 reply; 6+ messages in thread
From: Paul Brook @ 2006-09-24  0:20 UTC (permalink / raw)
  To: qemu-devel, balrogg

On Saturday 23 September 2006 18:25, andrzej zaborowski wrote:
> This allows multiple PCI devices on a bus to use the same IRQ lines.

You patch was missing the mapping from device to bus IRQ lines. I applied a 
fix that includes this, and removes the hacks for PPC IRQ routing.

As mentioned in the comments for the new code it looks like sparc64 IRQs are 
totally busted. I couldn't figure out out what the correct implementation was 
supposed to be, so I made something up.

Paul

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] IRQ sharing in PCI bus
  2006-09-24  0:20 ` Paul Brook
@ 2006-09-24  6:19   ` Blue Swirl
  0 siblings, 0 replies; 6+ messages in thread
From: Blue Swirl @ 2006-09-24  6:19 UTC (permalink / raw)
  To: paul, qemu-devel, balrogg

>As mentioned in the comments for the new code it looks like sparc64 IRQs 
>are
>totally busted. I couldn't figure out out what the correct implementation 
>was
>supposed to be, so I made something up.

Sparc64 IRQs are completely unimplemented. I've postponed that until I get 
OpenBIOS to the point where it can do something sensible about this. The 
current OpenBIOS status is that the Unix port runs nicely on native HW, but 
under Qemu the bootable version crashes during Forth execution. But I'd say 
we are not too far from a working BIOS.

If you are interested, the IRQ definitions can be found in Sun document 
805-0087 (UltraSPARC IIi User's Manual, 
http://www.sun.com/processors/manuals/805-0087.pdf), pages 107-126 for 
interrupt controller and 291-334 for PCI/IOMMU/interrupt definitions.

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-09-24  6:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-23 17:25 [Qemu-devel] [PATCH] IRQ sharing in PCI bus andrzej zaborowski
2006-09-23 17:38 ` Fabrice Bellard
2006-09-23 17:43   ` Paul Brook
2006-09-23 17:53     ` Fabrice Bellard
2006-09-24  0:20 ` Paul Brook
2006-09-24  6:19   ` Blue Swirl

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.