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>
This commit is contained in:
Kyösti Mälkki 2019-07-04 21:39:28 +03:00 committed by Patrick Georgi
parent 8da51ca2c3
commit c19d6a6ce5
5 changed files with 17 additions and 23 deletions

View File

@ -177,7 +177,7 @@ static void pirq_route_irqs(unsigned long addr)
} }
/* Bus, device, slots IRQs for {A,B,C,D}. */ /* 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++) for (i = 0; i < CONFIG_MAX_PIRQ_LINKS; i++)

View File

@ -1499,27 +1499,24 @@ int get_pci_irq_pins(struct device *dev, struct device **parent_bdg)
* *
* This function should be called for each PCI slot in your system. * This function should be called for each PCI slot in your system.
* *
* @param bus Pointer to the bus structure. * @param dev Pointer to dev structure.
* @param slot TODO
* @param pIntAtoD An array of IRQ #s that are assigned to PINTA through PINTD * @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 * of this slot. The particular IRQ #s that are passed in depend on the
* routing inside your southbridge and on your board. * routing inside your southbridge and on your board.
*/ */
void pci_assign_irqs(unsigned bus, unsigned slot, void pci_assign_irqs(struct device *dev, const unsigned char pIntAtoD[4])
const unsigned char pIntAtoD[4])
{ {
unsigned int funct; u8 slot, line, irq;
struct device *pdev;
u8 line, irq;
/* Each slot may contain up to eight functions. */ /* Each device may contain up to eight functions. */
for (funct = 0; funct < 8; funct++) { slot = dev->path.pci.devfn >> 3;
pdev = dev_find_slot(bus, (slot << 3) + funct);
if (!pdev) for (; dev ; dev = dev->sibling) {
continue;
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. */ /* PCI spec says all values except 1..4 are reserved. */
if ((line < 1) || (line > 4)) if ((line < 1) || (line > 4))
@ -1527,11 +1524,9 @@ void pci_assign_irqs(unsigned bus, unsigned slot,
irq = pIntAtoD[line - 1]; irq = pIntAtoD[line - 1];
printk(BIOS_DEBUG, "Assigning IRQ %d to %d:%x.%d\n", printk(BIOS_DEBUG, "Assigning IRQ %d to %s\n", irq, dev_path(dev));
irq, bus, slot, funct);
pci_write_config8(pdev, PCI_INTERRUPT_LINE, pci_write_config8(dev, PCI_INTERRUPT_LINE, pIntAtoD[line - 1]);
pIntAtoD[line - 1]);
#ifdef PARANOID_IRQ_ASSIGNMENTS #ifdef PARANOID_IRQ_ASSIGNMENTS
irq = pci_read_config8(pdev, PCI_INTERRUPT_LINE); irq = pci_read_config8(pdev, PCI_INTERRUPT_LINE);

View File

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

View File

@ -41,7 +41,7 @@ static void qemu_nb_init(struct device *dev)
/* setup IRQ routing */ /* setup IRQ routing */
for (i = 0; i < 32; i++) 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 = { static struct device_operations nb_operations = {

View File

@ -61,10 +61,10 @@ static void qemu_nb_init(struct device *dev)
/* setup IRQ routing for pci slots */ /* setup IRQ routing for pci slots */
for (i = 0; i < 25; i++) 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 */ /* setup IRQ routing southbridge devices */
for (i = 25; i < 32; i++) 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) static void qemu_nb_read_resources(struct device *dev)