From patchwork Fri Nov 6 00:34:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 57971 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA60Z1EA030793 for ; Fri, 6 Nov 2009 00:35:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757867AbZKFAey (ORCPT ); Thu, 5 Nov 2009 19:34:54 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758816AbZKFAey (ORCPT ); Thu, 5 Nov 2009 19:34:54 -0500 Received: from g1t0026.austin.hp.com ([15.216.28.33]:17427 "EHLO g1t0026.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757867AbZKFAex (ORCPT ); Thu, 5 Nov 2009 19:34:53 -0500 Received: from g1t0038.austin.hp.com (g1t0038.austin.hp.com [16.236.32.44]) by g1t0026.austin.hp.com (Postfix) with ESMTP id 3BEA2C184; Fri, 6 Nov 2009 00:34:59 +0000 (UTC) Received: from ldl (linux.corp.hp.com [15.11.146.101]) by g1t0038.austin.hp.com (Postfix) with ESMTP id DCB19300DB; Fri, 6 Nov 2009 00:34:58 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl (Postfix) with ESMTP id C3FEBCF000E; Thu, 5 Nov 2009 17:34:58 -0700 (MST) Received: from ldl ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EC2LzZiqotFA; Thu, 5 Nov 2009 17:34:58 -0700 (MST) Received: from tigger.helgaas (lart.fc.hp.com [15.11.146.31]) by ldl (Postfix) with ESMTP id ADC7ACF0007; Thu, 5 Nov 2009 17:34:58 -0700 (MST) From: Bjorn Helgaas To: "Ira W. Snyder" Subject: Re: PCI hotplug problems: how to debug? Date: Thu, 5 Nov 2009 18:34:56 -0600 User-Agent: KMail/1.9.10 Cc: linux-pci@vger.kernel.org References: <20091104175250.GA21852@ovro.caltech.edu> <200911051500.41698.bjorn.helgaas@hp.com> <20091105233110.GC24160@ovro.caltech.edu> In-Reply-To: <20091105233110.GC24160@ovro.caltech.edu> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200911051734.57795.bjorn.helgaas@hp.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 1331fcf..2fc835e 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -593,6 +593,29 @@ struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops, if (!bus) kfree(sd); + if (0 && bus->number == 1) { + struct resource *res; + + dev_info(&bus->dev, "test kludge for Trenton\n"); + dev_info(&bus->dev, "resource 1 %pR\n", bus->resource[1]); + dev_info(&bus->dev, "resource 2 %pR\n", bus->resource[2]); + res = kzalloc(sizeof(*res), GFP_KERNEL); + if (res) { + res->start = 0xfeb00000; + res->end = 0xfebfffff; + res->flags = IORESOURCE_MEM; + bus->resource[1] = res; + } + res = kzalloc(sizeof(*res), GFP_KERNEL); + if (res) { + res->start = 0xfbd00000; + res->end = 0xfbffffff; + res->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH; + bus->resource[2] = res; + } + dev_info(&bus->dev, "resource 1 %pR\n", bus->resource[1]); + dev_info(&bus->dev, "resource 2 %pR\n", bus->resource[2]); + } return bus; } diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 5c4ce1b..4d66925 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1101,6 +1101,32 @@ int pci_scan_slot(struct pci_bus *bus, int devfn) return nr; } +static void pci_claim_resources(struct pci_dev *dev) +{ + u16 command; + int i, io_enabled, mem_enabled; + struct resource *r; + + pci_read_config_word(dev, PCI_COMMAND, &command); + io_enabled = (command & PCI_COMMAND_IO); + mem_enabled = (command & PCI_COMMAND_MEMORY); + for (i = 0; i < PCI_ROM_RESOURCE; i++) { + r = &dev->resource[i]; + if (r->parent) + continue; + if (!r->start) + continue; + + if (((r->flags & IORESOURCE_IO) && io_enabled) || + ((r->flags & IORESOURCE_MEM) && mem_enabled)) { + dev_printk(KERN_DEBUG, &dev->dev, + "BAR %d: reserving %pr\n", i, r); + if (pci_claim_resource(dev, i) < 0) + dev_info(&dev->dev, "can't reserve %pR\n", r); + } + } +} + unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus) { unsigned int devfn, pass, max = bus->secondary; @@ -1133,6 +1159,9 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus) max = pci_scan_bridge(bus, dev, max, pass); } + list_for_each_entry(dev, &bus->devices, bus_list) + pci_claim_resources(dev); + /* * We've scanned the bus and so we know all about what's on * the other side of any bridges that may be on this bus plus @@ -1246,6 +1275,7 @@ unsigned int __ref pci_rescan_bus(struct pci_bus *bus) unsigned int max; struct pci_dev *dev; + dev_info(&bus->dev, "rescanning bus\n"); max = pci_scan_child_bus(bus); down_read(&pci_bus_sem); diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 176615e..a12930c 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -64,6 +64,7 @@ int pci_remove_device_safe(struct pci_dev *dev) void pci_remove_bus(struct pci_bus *pci_bus) { + dev_info(&pci_bus->dev, "removing bus\n"); pci_proc_detach_bus(pci_bus); down_write(&pci_bus_sem); @@ -93,6 +94,7 @@ EXPORT_SYMBOL(pci_remove_bus); */ void pci_remove_bus_device(struct pci_dev *dev) { + dev_info(&dev->dev, "removing device\n"); pci_stop_bus_device(dev); if (dev->subordinate) { struct pci_bus *b = dev->subordinate; diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 7d678bb..27b0eb4 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -223,6 +223,7 @@ void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head) if (r->flags & IORESOURCE_PCI_FIXED) continue; + dev_info(&dev->dev, "pdev_sort_resources: res %d %pR parent %pR\n", i, r, r->parent); if (!(r->flags) || r->parent) continue;