Patrick Georgi merged this change.

View Change

Approvals: build bot (Jenkins): Verified Patrick Georgi: Looks good to me, approved
device/pci: Replace use of dev_find_slot() for IRQs

Change-Id: I48c0de73338430282ce1a4442bbeb7c867dc174c
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34079
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
---
M src/arch/x86/pirq_routing.c
M src/device/pci_device.c
M src/include/device/pci.h
M src/mainboard/emulation/qemu-i440fx/mainboard.c
M src/mainboard/emulation/qemu-q35/mainboard.c
5 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/src/arch/x86/pirq_routing.c b/src/arch/x86/pirq_routing.c
index 5f80c9d..9d1f591 100644
--- a/src/arch/x86/pirq_routing.c
+++ b/src/arch/x86/pirq_routing.c
@@ -177,7 +177,7 @@
}

/* Bus, device, slots IRQs for {A,B,C,D}. */
- pci_assign_irqs(bus, devfn >> 3, irq_slot);
+ pci_assign_irqs(pcidev_path_on_bus(bus, devfn), irq_slot);
}

for (i = 0; i < CONFIG_MAX_PIRQ_LINKS; i++)
diff --git a/src/device/pci_device.c b/src/device/pci_device.c
index a2af0ec..2c724aa 100644
--- a/src/device/pci_device.c
+++ b/src/device/pci_device.c
@@ -1499,27 +1499,24 @@
*
* This function should be called for each PCI slot in your system.
*
- * @param bus Pointer to the bus structure.
- * @param slot TODO
+ * @param dev Pointer to dev structure.
* @param pIntAtoD An array of IRQ #s that are assigned to PINTA through PINTD
* of this slot. The particular IRQ #s that are passed in depend on the
* routing inside your southbridge and on your board.
*/
-void pci_assign_irqs(unsigned bus, unsigned slot,
- const unsigned char pIntAtoD[4])
+void pci_assign_irqs(struct device *dev, const unsigned char pIntAtoD[4])
{
- unsigned int funct;
- struct device *pdev;
- u8 line, irq;
+ u8 slot, line, irq;

- /* Each slot may contain up to eight functions. */
- for (funct = 0; funct < 8; funct++) {
- pdev = dev_find_slot(bus, (slot << 3) + funct);
+ /* Each device may contain up to eight functions. */
+ slot = dev->path.pci.devfn >> 3;

- if (!pdev)
- continue;
+ for (; dev ; dev = dev->sibling) {

- line = pci_read_config8(pdev, PCI_INTERRUPT_PIN);
+ if (dev->path.pci.devfn >> 3 != slot)
+ break;
+
+ line = pci_read_config8(dev, PCI_INTERRUPT_PIN);

/* PCI spec says all values except 1..4 are reserved. */
if ((line < 1) || (line > 4))
@@ -1527,11 +1524,9 @@

irq = pIntAtoD[line - 1];

- printk(BIOS_DEBUG, "Assigning IRQ %d to %d:%x.%d\n",
- irq, bus, slot, funct);
+ printk(BIOS_DEBUG, "Assigning IRQ %d to %s\n", irq, dev_path(dev));

- pci_write_config8(pdev, PCI_INTERRUPT_LINE,
- pIntAtoD[line - 1]);
+ pci_write_config8(dev, PCI_INTERRUPT_LINE, pIntAtoD[line - 1]);

#ifdef PARANOID_IRQ_ASSIGNMENTS
irq = pci_read_config8(pdev, PCI_INTERRUPT_LINE);
diff --git a/src/include/device/pci.h b/src/include/device/pci.h
index 5f72b55..c08b30a 100644
--- a/src/include/device/pci.h
+++ b/src/include/device/pci.h
@@ -98,8 +98,7 @@

const char *pin_to_str(int pin);
int get_pci_irq_pins(struct device *dev, struct device **parent_bdg);
-void pci_assign_irqs(unsigned int bus, unsigned int slot,
- const unsigned char pIntAtoD[4]);
+void pci_assign_irqs(struct device *dev, const unsigned char pIntAtoD[4]);
const char *get_pci_class_name(struct device *dev);
const char *get_pci_subclass_name(struct device *dev);

diff --git a/src/mainboard/emulation/qemu-i440fx/mainboard.c b/src/mainboard/emulation/qemu-i440fx/mainboard.c
index 4886fe1..0b36897 100644
--- a/src/mainboard/emulation/qemu-i440fx/mainboard.c
+++ b/src/mainboard/emulation/qemu-i440fx/mainboard.c
@@ -41,7 +41,7 @@

/* setup IRQ routing */
for (i = 0; i < 32; i++)
- pci_assign_irqs(0, i, qemu_i440fx_irqs + (i % 4));
+ pci_assign_irqs(pcidev_on_root(i, 0), qemu_i440fx_irqs + (i % 4));
}

static struct device_operations nb_operations = {
diff --git a/src/mainboard/emulation/qemu-q35/mainboard.c b/src/mainboard/emulation/qemu-q35/mainboard.c
index 90a32f4..ae3f96a 100644
--- a/src/mainboard/emulation/qemu-q35/mainboard.c
+++ b/src/mainboard/emulation/qemu-q35/mainboard.c
@@ -61,10 +61,10 @@

/* setup IRQ routing for pci slots */
for (i = 0; i < 25; i++)
- pci_assign_irqs(0, i, qemu_q35_irqs + (i % 4));
+ pci_assign_irqs(pcidev_on_root(i, 0), qemu_q35_irqs + (i % 4));
/* setup IRQ routing southbridge devices */
for (i = 25; i < 32; i++)
- pci_assign_irqs(0, i, qemu_q35_irqs);
+ pci_assign_irqs(pcidev_on_root(i, 0), qemu_q35_irqs);
}

static void qemu_nb_read_resources(struct device *dev)

To view, visit change 34079. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I48c0de73338430282ce1a4442bbeb7c867dc174c
Gerrit-Change-Number: 34079
Gerrit-PatchSet: 3
Gerrit-Owner: Kyösti Mälkki <kyosti.malkki@gmail.com>
Gerrit-Reviewer: Patrick Georgi <pgeorgi@google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@users.sourceforge.net>
Gerrit-MessageType: merged