From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: kvm@vger.kernel.org, Alex Graf <agraf@suse.de>,
qemu-devel@nongnu.org, anthony@codemonkey.ws,
David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [RFC PATCH] qemu spapr-pci: added IRQ list to PCIBus
Date: Sat, 12 May 2012 17:29:53 +1000 [thread overview]
Message-ID: <4FAE1171.1010806@ozlabs.ru> (raw)
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
next reply other threads:[~2012-05-12 7:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-12 7:29 Alexey Kardashevskiy [this message]
2012-05-14 1:58 ` [Qemu-devel] [RFC PATCH] qemu spapr-pci: added IRQ list to PCIBus 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FAE1171.1010806@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=agraf@suse.de \
--cc=alex.williamson@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=david@gibson.dropbear.id.au \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).