aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2013-02-15 14:11:41 -0700
committerKevin O'Connor <kevin@koconnor.net>2013-02-24 12:01:56 -0500
commit985a9d3b019f0c50b0a0751fe3d7feb672ef4c0e (patch)
tree3b21171bcddad2bce22ae3db40c7f6ffa2264cf2
parent2b577261e1d216b8cf2a57b095c4a753faf41455 (diff)
downloadseabios-985a9d3b019f0c50b0a0751fe3d7feb672ef4c0e.zip
seabios-985a9d3b019f0c50b0a0751fe3d7feb672ef4c0e.tar.gz
seabios-985a9d3b019f0c50b0a0751fe3d7feb672ef4c0e.tar.bz2
seabios q35: Add new PCI slot to irq routing function
q35/ich9 doesn't use the same interrupt mapping function as i440fx/piix. PIRQA:D and PIRQE:H are programmed identically, but we start at index 0, not index -1. Slots 25 through 31 are also programmed independently. When running qemu w/o this patch, a device at address 0:6.0 will have its PCI interrupt line register programmed with irq 10 (as seen by info pci), but it actually uses irq 11 (as reported the guest). Half of the interrupt lines are misprogrammedi like this. Functionally, a fully emulated qemu guest doesn't care much, but when we try to use device assignment, we really need to know the correct irqs. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
-rw-r--r--src/pciinit.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/pciinit.c b/src/pciinit.c
index 857e8af..c670a2b 100644
--- a/src/pciinit.c
+++ b/src/pciinit.c
@@ -91,8 +91,10 @@ const u8 pci_irqs[4] = {
10, 10, 11, 11
};
+static int (*pci_slot_get_irq)(struct pci_device *pci, int pin);
+
// Return the global irq number corresponding to a host bus device irq pin.
-static int pci_slot_get_irq(struct pci_device *pci, int pin)
+static int piix_pci_slot_get_irq(struct pci_device *pci, int pin)
{
int slot_addend = 0;
@@ -104,6 +106,31 @@ static int pci_slot_get_irq(struct pci_device *pci, int pin)
return pci_irqs[(pin - 1 + slot_addend) & 3];
}
+static int mch_pci_slot_get_irq(struct pci_device *pci, int pin)
+{
+ int irq, slot, pin_addend = 0;
+
+ while (pci->parent != NULL) {
+ pin_addend += pci_bdf_to_dev(pci->bdf);
+ pci = pci->parent;
+ }
+ slot = pci_bdf_to_dev(pci->bdf);
+
+ switch (slot) {
+ /* Slots 0-24 rotate slot:pin mapping similar to piix above, but
+ with a different starting index - see q35-acpi-dsdt.dsl */
+ case 0 ... 24:
+ irq = pci_irqs[(pin - 1 + pin_addend + slot) & 3];
+ break;
+ /* Slots 25-31 all use LNKA mapping (or LNKE, but A:D = E:H) */
+ case 25 ... 31:
+ irq = pci_irqs[(pin - 1 + pin_addend) & 3];
+ break;
+ }
+
+ return irq;
+}
+
/* PIIX3/PIIX4 PCI to ISA bridge */
static void piix_isa_bridge_init(struct pci_device *pci, void *arg)
{
@@ -292,6 +319,8 @@ void i440fx_mem_addr_init(struct pci_device *dev, void *arg)
pcimem_start = 0x80000000;
else if (RamSize <= 0xc0000000)
pcimem_start = 0xc0000000;
+
+ pci_slot_get_irq = piix_pci_slot_get_irq;
}
void mch_mem_addr_init(struct pci_device *dev, void *arg)
@@ -310,6 +339,8 @@ void mch_mem_addr_init(struct pci_device *dev, void *arg)
/* setup pci i/o window (above mmconfig) */
pcimem_start = addr + size;
+
+ pci_slot_get_irq = mch_pci_slot_get_irq;
}
static const struct pci_device_id pci_platform_tbl[] = {