qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH] qemu spapr-pci: added IRQ list to PCIBus


From: Alexey Kardashevskiy
Subject: [Qemu-devel] [RFC PATCH] qemu spapr-pci: added IRQ list to PCIBus
Date: Sat, 12 May 2012 17:29:53 +1000
User-agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120327 Thunderbird/11.0.1

There is a need for a mechanism to obtain an IRQ line number to
initialize End-Of-Interrupt handler.

There is another proposed solution (commit
b7790763828b732059ad24ba0e64ce327563fe1a "pci: Add callbacks
to support retrieving and updating interrupts") which adds pci_get_irq
callback to every PCI bus to allow an external caller to calculate
IRQ number from IRQ line (ABDD).

However it seems to be too complicated as it affects all PCI buses
while the only user of it is VFIO-PCI so this could be done simpler
by an array of 4 IRQs (lines A, B, C, D) in struct PCIBus which
every platform would initialize in its own way.

Signed-off-by: Alexey Kardashevskiy <address@hidden>
---
 hw/pci.c           |   18 ++++++++++++++++++
 hw/pci.h           |    1 +
 hw/pci_internals.h |    2 ++
 3 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 1f7c924..8c2e193 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1067,6 +1067,24 @@ static void pci_set_irq(void *opaque, int irq_num, int 
level)
     pci_change_irq_level(pci_dev, irq_num, change);
 }

+int pci_get_irq(PCIDevice *pci_dev, int pin)
+{
+    PCIBus *bus;
+    for (;;) {
+        if (!pci_dev)
+            return -ENOSYS;
+        bus = pci_dev->bus;
+        if (!bus)
+            return -ENOSYS;
+        pin = bus->map_irq(pci_dev, pin);
+        if (pin) {
+            return bus->irqs[pin];
+        }
+        pci_dev = bus->parent_dev;
+    }
+    return 0;
+}
+
 /***********************************************************/
 /* monitor info on PCI */

diff --git a/hw/pci.h b/hw/pci.h
index 1273dc3..25b414a 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -257,6 +257,7 @@ uint32_t pci_default_read_config(PCIDevice *d,
                                  uint32_t address, int len);
 void pci_default_write_config(PCIDevice *d,
                               uint32_t address, uint32_t val, int len);
+int pci_get_irq(PCIDevice *pci_dev, int pin);
 void pci_device_save(PCIDevice *s, QEMUFile *f);
 int pci_device_load(PCIDevice *s, QEMUFile *f);
 MemoryRegion *pci_address_space(PCIDevice *dev);
diff --git a/hw/pci_internals.h b/hw/pci_internals.h
index b6b7a0e..2f53039 100644
--- a/hw/pci_internals.h
+++ b/hw/pci_internals.h
@@ -38,6 +38,8 @@ struct PCIBus {
        Keep a count of the number of devices with raised IRQs.  */
     int nirq;
     int *irq_count;
+
+    uint32_t irqs[PCI_NUM_PINS]; /* A, B, C, D */
 };

 struct PCIBridge {

-- 
Alexey



reply via email to

[Prev in Thread] Current Thread [Next in Thread]