From patchwork Sat Jan 16 02:41:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 73266 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0G2hXt8007181 for ; Sat, 16 Jan 2010 02:43:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758767Ab0APCnc (ORCPT ); Fri, 15 Jan 2010 21:43:32 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758757Ab0APCnc (ORCPT ); Fri, 15 Jan 2010 21:43:32 -0500 Received: from sca-es-mail-1.Sun.COM ([192.18.43.132]:57732 "EHLO sca-es-mail-1.sun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758235Ab0APCnZ (ORCPT ); Fri, 15 Jan 2010 21:43:25 -0500 Received: from fe-sfbay-10.sun.com ([192.18.43.129]) by sca-es-mail-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id o0G2hEDE009762; Fri, 15 Jan 2010 18:43:24 -0800 (PST) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: TEXT/PLAIN Received: from conversion-daemon.fe-sfbay-10.sun.com by fe-sfbay-10.sun.com (Sun Java(tm) System Messaging Server 7u2-7.04 64bit (built Jul 2 2009)) id <0KWB00500J6JYC00@fe-sfbay-10.sun.com>; Fri, 15 Jan 2010 18:43:16 -0800 (PST) Received: from localhost.localdomain ([unknown] [10.6.76.26]) by fe-sfbay-10.sun.com (Sun Java(tm) System Messaging Server 7u2-7.04 64bit (built Jul 2 2009)) with ESMTPSA id <0KWB00EKPJJTDA60@fe-sfbay-10.sun.com>; Fri, 15 Jan 2010 18:43:15 -0800 (PST) Date: Fri, 15 Jan 2010 18:41:58 -0800 From: Yinghai Lu Subject: [PATCH 08/11] pci: pciehp second try to get big range for pcie devices In-reply-to: <1263609721-3921-1-git-send-email-yinghai@kernel.org> To: Jesse Barnes , Ingo Molnar , Linus Torvalds , Ivan Kokshaysky , Kenji Kaneshige , Alex Chiang , Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Yinghai Lu Message-id: <1263609721-3921-9-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.6.4.2 References: <1263609721-3921-1-git-send-email-yinghai@kernel.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index c348882..2ff34ca 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1009,12 +1009,60 @@ void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge) { struct pci_bus *bus; struct pci_bus *parent = bridge->subordinate; + bool second_tried = false; + struct resource_list_x head, *list; int retval; + unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM | + IORESOURCE_PREFETCH; + + head.next = NULL; +again: pci_bus_size_bridges(parent); - __pci_bridge_assign_resources(bridge, NULL); + __pci_bridge_assign_resources(bridge, &head); retval = pci_reenable_device(bridge); pci_set_master(bridge); pci_enable_bridges(parent); + + /* any device complain? */ + if (!head.next) + return; + + if (second_tried) { + /* still fail, don't need to try more */ + free_failed_list(&head); + return; + } + + second_tried = true; + printk(KERN_DEBUG "PCI: second try to assign unassigned res\n"); + + /* + * Try to release leaf bridge's resources that doesn't fit resource of + * child device under that bridge + */ + for (list = head.next; list;) { + unsigned long flags = list->flags; + + bus = list->dev->bus; + pci_bus_release_bridge_resources(bus, flags & type_mask, + whole_subtree); + list = list->next; + } + /* retore size and flags */ + for (list = head.next; list;) { + struct resource *res = list->res; + + res->start = list->start; + res->end = list->end; + res->flags = list->flags; + if (list->dev->subordinate) + res->flags = 0; + + list = list->next; + } + free_failed_list(&head); + + goto again; } EXPORT_SYMBOL_GPL(pci_assign_unassigned_bridge_resources);