Skip to content

Commit 20d6932

Browse files
Lorenzo Pieralisibjorn-helgaas
authored andcommitted
sh/PCI: Replace pci_fixup_irqs() call with host bridge IRQ mapping hooks
The pci_fixup_irqs() function allocates IRQs for all PCI devices present in a system; those PCI devices possibly belong to different PCI bus trees (and possibly rooted at different host bridges) and may well be enabled (ie probed and bound to a driver) by the time pci_fixup_irqs() is called when probing a given host bridge driver. Furthermore, current kernel code relying on pci_fixup_irqs() to assign legacy PCI IRQs to devices does not work at all for hotplugged devices in that the code carrying out the IRQ fixup is called at host bridge driver probe time, which just cannot take into account devices hotplugged after the system has booted. The introduction of map/swizzle function hooks in struct pci_host_bridge allows us to define per-bridge map/swizzle functions that can be used at device probe time in PCI core code to allocate IRQs for a given device (through pci_assign_irq()). Convert PCI host bridge initialization code to the pci_scan_root_bus_bridge() API (that allows to pass a struct pci_host_bridge with initialized map/swizzle pointers) and remove the pci_fixup_irqs() call from arch code. Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Cc: Rich Felker <dalias@libc.org> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
1 parent 2b8ff9f commit 20d6932

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

arch/sh/drivers/pci/pci.c

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ static void pcibios_scanbus(struct pci_channel *hose)
3939
LIST_HEAD(resources);
4040
struct resource *res;
4141
resource_size_t offset;
42-
int i;
43-
struct pci_bus *bus;
42+
int i, ret;
43+
struct pci_host_bridge *bridge;
44+
45+
bridge = pci_alloc_host_bridge(0);
46+
if (!bridge)
47+
return;
4448

4549
for (i = 0; i < hose->nr_resources; i++) {
4650
res = hose->resources + i;
@@ -52,29 +56,36 @@ static void pcibios_scanbus(struct pci_channel *hose)
5256
pci_add_resource_offset(&resources, res, offset);
5357
}
5458

55-
bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
56-
&resources);
57-
hose->bus = bus;
59+
list_splice_init(&resources, &bridge->windows);
60+
bridge->dev.parent = NULL;
61+
bridge->sysdata = hose;
62+
bridge->busnr = next_busno;
63+
bridge->ops = hose->pci_ops;
64+
bridge->swizzle_irq = pci_common_swizzle;
65+
bridge->map_irq = pcibios_map_platform_irq;
66+
67+
ret = pci_scan_root_bus_bridge(bridge);
68+
if (ret) {
69+
pci_free_host_bridge(bridge);
70+
return;
71+
}
72+
73+
hose->bus = bridge->bus;
5874

5975
need_domain_info = need_domain_info || hose->index;
6076
hose->need_domain_info = need_domain_info;
6177

62-
if (!bus) {
63-
pci_free_resource_list(&resources);
64-
return;
65-
}
66-
67-
next_busno = bus->busn_res.end + 1;
78+
next_busno = hose->bus->busn_res.end + 1;
6879
/* Don't allow 8-bit bus number overflow inside the hose -
6980
reserve some space for bridges. */
7081
if (next_busno > 224) {
7182
next_busno = 0;
7283
need_domain_info = 1;
7384
}
7485

75-
pci_bus_size_bridges(bus);
76-
pci_bus_assign_resources(bus);
77-
pci_bus_add_devices(bus);
86+
pci_bus_size_bridges(hose->bus);
87+
pci_bus_assign_resources(hose->bus);
88+
pci_bus_add_devices(hose->bus);
7889
}
7990

8091
/*
@@ -144,8 +155,6 @@ static int __init pcibios_init(void)
144155
for (hose = hose_head; hose; hose = hose->next)
145156
pcibios_scanbus(hose);
146157

147-
pci_fixup_irqs(pci_common_swizzle, pcibios_map_platform_irq);
148-
149158
dma_debug_add_bus(&pci_bus_type);
150159

151160
pci_initialized = 1;

0 commit comments

Comments
 (0)