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

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.