From patchwork Tue Jun 26 18:53:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 167439 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A1685B6F13 for ; Wed, 27 Jun 2012 04:55:18 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753061Ab2FZSzC (ORCPT ); Tue, 26 Jun 2012 14:55:02 -0400 Received: from acsinet15.oracle.com ([141.146.126.227]:29988 "EHLO acsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758842Ab2FZSzA (ORCPT ); Tue, 26 Jun 2012 14:55:00 -0400 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q5QIso94003517 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 26 Jun 2012 18:54:51 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q5QIsoBl012994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 26 Jun 2012 18:54:50 GMT Received: from abhmt110.oracle.com (abhmt110.oracle.com [141.146.116.62]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q5QIsoLB006696; Tue, 26 Jun 2012 13:54:50 -0500 Received: from linux-siqj.site (/10.132.126.50) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 26 Jun 2012 11:54:50 -0700 From: Yinghai Lu To: Bjorn Helgaas , Benjamin Herrenschmidt , Tony Luck , David Miller , x86 Cc: Dominik Brodowski , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Yinghai Lu Subject: [PATCH -v12 05/15] PCI: Probe safe range that we can use for unassigned bridge. Date: Tue, 26 Jun 2012 11:53:59 -0700 Message-Id: <1340736849-14875-6-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1340736849-14875-1-git-send-email-yinghai@kernel.org> References: <1340736849-14875-1-git-send-email-yinghai@kernel.org> X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Try to allocate from parent bus busn_res. If we can not find any big enough, will try to extend parent bus top. even the extending is through allocating, after allocating will pad the range to parent buses top. When extending happens, We will record the parent_res, so could use it as stopper for really extend/shrink top later. -v4: Use generic probe_resource() Signed-off-by: Yinghai Lu --- drivers/pci/probe.c | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 44c42ae..75bca6f 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -717,6 +717,34 @@ static void __devinit pci_bus_shrink_top(struct pci_bus *parent, pci_bus_extend_top(parent, -size, parent_res); } +static int __devinit pci_bridge_probe_busn_res(struct pci_bus *bus, + struct pci_dev *dev, struct resource *busn_res, + resource_size_t needed_size, struct resource **p) +{ + int ret; + int old_size = resource_size(&bus->busn_res); + int skip_nr = 1; + int domain_limit = 0xff; + int stop_flags = IORESOURCE_PCI_FIXED; + + ret = probe_resource(&bus->busn_res, busn_res, needed_size, + p, skip_nr, domain_limit, stop_flags); + + if (ret) + return ret; + + busn_res->flags = IORESOURCE_BUS; + + if (*p) { + /* extend parent bus top*/ + int new_size = resource_size(&bus->busn_res); + + pci_bus_extend_top(bus, new_size - old_size, *p); + } + + return ret; +} + /* * If it's a bridge, configure it and scan the bus behind it. * For CardBus bridges, we don't scan behind as the devices will