From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexey Kardashevskiy Subject: [RFC PATCH] qemu spapr-pci: added IRQ list to PCIBus Date: Sat, 12 May 2012 17:29:53 +1000 Message-ID: <4FAE1171.1010806@ozlabs.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, Alex Graf , qemu-devel@nongnu.org, Alex Williamson , anthony@codemonkey.ws, David Gibson To: Alex Williamson Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: kvm.vger.kernel.org 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 --- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ST6m9-0002ZI-2G for qemu-devel@nongnu.org; Sat, 12 May 2012 03:30:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ST6m6-00032W-Ey for qemu-devel@nongnu.org; Sat, 12 May 2012 03:30:00 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:56236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ST6m6-00031y-8d for qemu-devel@nongnu.org; Sat, 12 May 2012 03:29:58 -0400 Received: by dadv2 with SMTP id v2so5467747dad.4 for ; Sat, 12 May 2012 00:29:56 -0700 (PDT) Message-ID: <4FAE1171.1010806@ozlabs.ru> Date: Sat, 12 May 2012 17:29:53 +1000 From: Alexey Kardashevskiy MIME-Version: 1.0 Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [RFC PATCH] qemu spapr-pci: added IRQ list to PCIBus List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: kvm@vger.kernel.org, Alex Graf , qemu-devel@nongnu.org, anthony@codemonkey.ws, 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 --- 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