From patchwork Thu Jan 21 06:14:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 74222 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 o0L6HEec009954 for ; Thu, 21 Jan 2010 06:17:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752713Ab0AUGQe (ORCPT ); Thu, 21 Jan 2010 01:16:34 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752734Ab0AUGQd (ORCPT ); Thu, 21 Jan 2010 01:16:33 -0500 Received: from sca-es-mail-1.Sun.COM ([192.18.43.132]:35753 "EHLO sca-es-mail-1.sun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752713Ab0AUGO5 (ORCPT ); Thu, 21 Jan 2010 01:14:57 -0500 Received: from fe-sfbay-09.sun.com ([192.18.43.129]) by sca-es-mail-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id o0L6EuTa011087; Wed, 20 Jan 2010 22:14:56 -0800 (PST) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: TEXT/PLAIN Received: from conversion-daemon.fe-sfbay-09.sun.com by fe-sfbay-09.sun.com (Sun Java(tm) System Messaging Server 7u2-7.04 64bit (built Jul 2 2009)) id <0KWL00N002J64E00@fe-sfbay-09.sun.com>; Wed, 20 Jan 2010 22:14:56 -0800 (PST) Received: from localhost.localdomain ([unknown] [75.36.244.228]) by fe-sfbay-09.sun.com (Sun Java(tm) System Messaging Server 7u2-7.04 64bit (built Jul 2 2009)) with ESMTPSA id <0KWL00BR62OKQXE0@fe-sfbay-09.sun.com>; Wed, 20 Jan 2010 22:14:56 -0800 (PST) Date: Wed, 20 Jan 2010 22:14:15 -0800 From: Yinghai Lu Subject: [PATCH 8/9] pci: pciehp second try to get big range for pcie devices In-reply-to: <1264054456-12694-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: <1264054456-12694-9-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.6.4.2 References: <1264054456-12694-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 8bec70f..a9c4f9e 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -972,12 +972,62 @@ enable_and_dump: void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge) { struct pci_bus *parent = bridge->subordinate; + int tried_times = 0; + 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); + + tried_times++; + + /* any device complain? */ + if (!head.next) + return; + + if (tried_times >= 2) { + /* still fail, don't need to try more */ + free_failed_list(&head); + return; + } + + printk(KERN_DEBUG "PCI: No. %d try to assign unassigned res\n", + tried_times + 1); + + /* + * Try to release leaf bridge's resources that doesn't fit resource of + * child device under that bridge + */ + for (list = head.next; list;) { + struct pci_bus *bus = list->dev->bus; + unsigned long flags = list->flags; + + 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);