From 80c79a5dc31cca9f157cd2f35f435dfa7648ce11 Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Thu, 24 Aug 2023 15:12:19 +0200 Subject: device/device.h: Drop multiple links Multiple links are unused throughout the tree and make the code more confusing as an iteration over all busses is needed to get downstream devices. This also not done consistently e.g. the allocator does not care about multiple links on busses. A better way of dealing multiple links below a device is to feature dummy devices with each their respective bus. This drops the sconfig capability to declare the same device multiple times which was previously used to declare multiple links. Signed-off-by: Arthur Heymans Change-Id: Iab6fe269faef46ae77ed1ea425440cf5c7dbd49b Reviewed-on: https://review.coreboot.org/c/coreboot/+/78328 Reviewed-by: Felix Held Tested-by: build bot (Jenkins) Reviewed-by: Jincheng Li Reviewed-by: Lean Sheng Tan --- src/arch/x86/mpspec.c | 83 +++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 43 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/mpspec.c b/src/arch/x86/mpspec.c index 7744f68e85..3ddee2f6b9 100644 --- a/src/arch/x86/mpspec.c +++ b/src/arch/x86/mpspec.c @@ -282,48 +282,46 @@ void smp_write_intsrc_pci_bridge(struct mp_config_table *mc, int srcbus; int slot; - struct bus *link; unsigned char dstirq_x[4]; - for (link = dev->link_list; link; link = link->next) { + if (!dev->link_list) + return; - child = link->children; - srcbus = link->secondary; + child = dev->link_list->children; + srcbus = dev->link_list->secondary; - while (child) { - if (child->path.type != DEVICE_PATH_PCI) - goto next; + while (child) { + if (child->path.type != DEVICE_PATH_PCI) + goto next; - slot = (child->path.pci.devfn >> 3); - /* round pins */ - for (i = 0; i < 4; i++) - dstirq_x[i] = dstirq[(i + slot) % 4]; - - if ((child->class >> 16) != PCI_BASE_CLASS_BRIDGE) { - /* pci device */ - printk(BIOS_DEBUG, "route irq: %s\n", - dev_path(child)); - for (i = 0; i < 4; i++) - smp_write_intsrc(mc, irqtype, irqflag, - srcbus, (slot<<2)|i, dstapic, - dstirq_x[i]); - goto next; - } + slot = (child->path.pci.devfn >> 3); + /* round pins */ + for (i = 0; i < 4; i++) + dstirq_x[i] = dstirq[(i + slot) % 4]; - switch (child->class>>8) { - case PCI_CLASS_BRIDGE_PCI: - case PCI_CLASS_BRIDGE_PCMCIA: - case PCI_CLASS_BRIDGE_CARDBUS: - printk(BIOS_DEBUG, "route irq bridge: %s\n", - dev_path(child)); - smp_write_intsrc_pci_bridge(mc, irqtype, - irqflag, child, dstapic, dstirq_x); - } + if ((child->class >> 16) != PCI_BASE_CLASS_BRIDGE) { + /* pci device */ + printk(BIOS_DEBUG, "route irq: %s\n", + dev_path(child)); + for (i = 0; i < 4; i++) + smp_write_intsrc(mc, irqtype, irqflag, + srcbus, (slot<<2)|i, dstapic, + dstirq_x[i]); + goto next; + } -next: - child = child->sibling; + switch (child->class>>8) { + case PCI_CLASS_BRIDGE_PCI: + case PCI_CLASS_BRIDGE_PCMCIA: + case PCI_CLASS_BRIDGE_CARDBUS: + printk(BIOS_DEBUG, "route irq bridge: %s\n", + dev_path(child)); + smp_write_intsrc_pci_bridge(mc, irqtype, + irqflag, child, dstapic, dstirq_x); } +next: + child = child->sibling; } } @@ -478,17 +476,16 @@ void mptable_write_buses(struct mp_config_table *mc, int *max_pci_bus, memset(buses, 0, sizeof(buses)); for (dev = all_devices; dev; dev = dev->next) { - struct bus *bus; - for (bus = dev->link_list; bus; bus = bus->next) { - if (bus->secondary > 255) { - printk(BIOS_ERR, - "A bus claims to have a bus ID > 255?!? Aborting"); - return; - } - buses[bus->secondary] = 1; - if (highest < bus->secondary) - highest = bus->secondary; + struct bus *bus = dev->link_list; + if (!bus) + continue; + if (bus->secondary > 255) { + printk(BIOS_ERR, "A bus claims to have a bus ID > 255?!? Aborting\n"); + return; } + buses[bus->secondary] = 1; + if (highest < bus->secondary) + highest = bus->secondary; } for (i = 0; i <= highest; i++) { if (buses[i]) { -- cgit v1.2.3