qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH] qemu spapr-pci: added IRQ list to PCIBus
@ 2012-05-12  7:29 Alexey Kardashevskiy
  2012-05-14  1:58 ` David Gibson
  0 siblings, 1 reply; 8+ messages in thread
From: Alexey Kardashevskiy @ 2012-05-12  7:29 UTC (permalink / raw)
  To: Alex Williamson; +Cc: kvm, Alex Graf, qemu-devel, anthony, David Gibson

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 <aik@ozlabs.ru>
---
 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

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

end of thread, other threads:[~2012-05-17  3:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-12  7:29 [Qemu-devel] [RFC PATCH] qemu spapr-pci: added IRQ list to PCIBus Alexey Kardashevskiy
2012-05-14  1:58 ` David Gibson
2012-05-14  4:21   ` Alexey Kardashevskiy
2012-05-16 20:39     ` Alex Williamson
2012-05-17  2:16       ` Alexey Kardashevskiy
2012-05-17  3:00         ` Benjamin Herrenschmidt
2012-05-17  3:38           ` Alex Williamson
2012-05-17  3:39           ` Alexey Kardashevskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).