From: Andrew Morton On Fri, 28 Mar 2008 16:10:11 -0700 (PDT) David Miller wrote: > From: Mariusz Kozlowski > Date: Fri, 28 Mar 2008 23:52:10 +0100 > > > The gregkh-pci-pci-sparc64-use-generic-pci_enable_resources.patch which > > replaces arch-specific code with generic pci_enable_resources() makes my sparc64 > > box unable to boot (that's what quilt bisection says). At first I see these messages: > > Yes, that generic code won't work because of the NULL > r->parent check. > > Alpha, ARM, V32, FRV, IA64, MIPS, MN10300, PARISC, PPC, > SH, V850, X86, and Xtensa are all likely to run into > problems because of this change. > > The only platform that did the check as a test of r->parent > being NULL is Powerpc. > > The rest either didn't check (like sparc64), or tested it by going: > > if (!r->start && r->end) > > So the amount of potential breakage from this change is enormous. Cc: Bjorn Helgaas Cc: Greg KH Signed-off-by: Andrew Morton --- arch/mn10300/unit-asb2305/pci-asb2305.c | 39 ++++++++++++++++++++++ arch/mn10300/unit-asb2305/pci-asb2305.h | 1 arch/mn10300/unit-asb2305/pci.c | 2 - 3 files changed, 41 insertions(+), 1 deletion(-) diff -puN arch/mn10300/unit-asb2305/pci-asb2305.c~revert-gregkh-pci-pci-mn10300-use-generic-pci_enable_resources arch/mn10300/unit-asb2305/pci-asb2305.c --- a/arch/mn10300/unit-asb2305/pci-asb2305.c~revert-gregkh-pci-pci-mn10300-use-generic-pci_enable_resources +++ a/arch/mn10300/unit-asb2305/pci-asb2305.c @@ -218,6 +218,45 @@ void __init pcibios_resource_survey(void pcibios_allocate_resources(1); } +int pcibios_enable_resources(struct pci_dev *dev, int mask) +{ + u16 cmd, old_cmd; + int idx; + struct resource *r; + + pci_read_config_word(dev, PCI_COMMAND, &cmd); + old_cmd = cmd; + + for (idx = 0; idx < 6; idx++) { + /* Only set up the requested stuff */ + if (!(mask & (1 << idx))) + continue; + + r = &dev->resource[idx]; + + if (!r->start && r->end) { + printk(KERN_ERR + "PCI: Device %s not available because of" + " resource collisions\n", + pci_name(dev)); + return -EINVAL; + } + + if (r->flags & IORESOURCE_IO) + cmd |= PCI_COMMAND_IO; + if (r->flags & IORESOURCE_MEM) + cmd |= PCI_COMMAND_MEMORY; + } + + if (dev->resource[PCI_ROM_RESOURCE].start) + cmd |= PCI_COMMAND_MEMORY; + + if (cmd != old_cmd) + pci_write_config_word(dev, PCI_COMMAND, cmd); + + return 0; +} + /* * If we set up a device for bus mastering, we need to check the latency * timer as certain crappy BIOSes forget to set it properly. diff -puN arch/mn10300/unit-asb2305/pci-asb2305.h~revert-gregkh-pci-pci-mn10300-use-generic-pci_enable_resources arch/mn10300/unit-asb2305/pci-asb2305.h --- a/arch/mn10300/unit-asb2305/pci-asb2305.h~revert-gregkh-pci-pci-mn10300-use-generic-pci_enable_resources +++ a/arch/mn10300/unit-asb2305/pci-asb2305.h @@ -34,6 +34,7 @@ extern unsigned int pci_probe; extern unsigned int pcibios_max_latency; extern void pcibios_resource_survey(void); +extern int pcibios_enable_resources(struct pci_dev *dev, int mask); /* pci.c */ diff -puN arch/mn10300/unit-asb2305/pci.c~revert-gregkh-pci-pci-mn10300-use-generic-pci_enable_resources arch/mn10300/unit-asb2305/pci.c --- a/arch/mn10300/unit-asb2305/pci.c~revert-gregkh-pci-pci-mn10300-use-generic-pci_enable_resources +++ a/arch/mn10300/unit-asb2305/pci.c @@ -440,7 +440,7 @@ int pcibios_enable_device(struct pci_dev { int err; - err = pci_enable_resources(dev, mask); + err = pcibios_enable_resources(dev, mask); if (err == 0) pcibios_enable_irq(dev); return err; _