From d1337a3237c2303e2aa338b3a55e4d225c277be9 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Sat, 2 Oct 2004 03:57:48 -0700 Subject: [PATCH] [PATCH] Fix booting on some recent G5s Some recent G5s have a problem with PCI/HT probing. They crash (machine check) during the probe of some slot numbers, it seems to be related to some functions beeing disabled by the firmware inside the K2 ASIC. This patch limits the config space accesses to devices that are present in the OF device-tree. This fixes the problem and shouldn't "add" any limitation. If you plug a "random" PCI card with no OF driver, the firmware will still build a node for it with the default set of properties created from the config space. Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Linus Torvalds --- arch/ppc/platforms/pmac_pci.c | 7 +++++++ arch/ppc64/kernel/pmac_pci.c | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/ppc/platforms/pmac_pci.c b/arch/ppc/platforms/pmac_pci.c index 28614c40b165f..4e53bea90e5e9 100644 --- a/arch/ppc/platforms/pmac_pci.c +++ b/arch/ppc/platforms/pmac_pci.c @@ -316,6 +316,10 @@ u3_ht_read_config(struct pci_bus *bus, unsigned int devfn, int offset, unsigned int addr; int i; + struct device_node *np = pci_busdev_to_OF_node(bus, devfn); + if (np == NULL) + return PCIBIOS_DEVICE_NOT_FOUND; + /* * When a device in K2 is powered down, we die on config * cycle accesses. Fix that here. @@ -363,6 +367,9 @@ u3_ht_write_config(struct pci_bus *bus, unsigned int devfn, int offset, unsigned int addr; int i; + struct device_node *np = pci_busdev_to_OF_node(bus, devfn); + if (np == NULL) + return PCIBIOS_DEVICE_NOT_FOUND; /* * When a device in K2 is powered down, we die on config * cycle accesses. Fix that here. diff --git a/arch/ppc64/kernel/pmac_pci.c b/arch/ppc64/kernel/pmac_pci.c index 9af5c0947dc91..9e1a069554e7f 100644 --- a/arch/ppc64/kernel/pmac_pci.c +++ b/arch/ppc64/kernel/pmac_pci.c @@ -271,7 +271,7 @@ static int __pmac u3_ht_read_config(struct pci_bus *bus, unsigned int devfn, int offset, int len, u32 *val) { struct pci_controller *hose; - struct device_node *busdn; + struct device_node *busdn, *dn; unsigned long addr; if (bus->self) @@ -284,6 +284,16 @@ static int __pmac u3_ht_read_config(struct pci_bus *bus, unsigned int devfn, if (hose == NULL) return PCIBIOS_DEVICE_NOT_FOUND; + /* We only allow config cycles to devices that are in OF device-tree + * as we are apparently having some weird things going on with some + * revs of K2 on recent G5s + */ + for (dn = busdn->child; dn; dn = dn->sibling) + if (dn->devfn == devfn) + break; + if (dn == NULL) + return PCIBIOS_DEVICE_NOT_FOUND; + addr = u3_ht_cfg_access(hose, bus->number, devfn, offset); if (!addr) return PCIBIOS_DEVICE_NOT_FOUND; -- 2.53.0