From patchwork Thu Feb 25 02:12:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 8417061 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8C539C0554 for ; Thu, 25 Feb 2016 02:29:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BD602201CD for ; Thu, 25 Feb 2016 02:29:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C9DBE2034A for ; Thu, 25 Feb 2016 02:28:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759515AbcBYCSj (ORCPT ); Wed, 24 Feb 2016 21:18:39 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:39690 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759363AbcBYCSh (ORCPT ); Wed, 24 Feb 2016 21:18:37 -0500 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u1P2DFLR019021 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Feb 2016 02:13:16 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u1P2DFZR013680 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 25 Feb 2016 02:13:15 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u1P2DFjo016647; Thu, 25 Feb 2016 02:13:15 GMT Received: from userv0022.oracle.com (/10.132.126.176) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 24 Feb 2016 18:13:14 -0800 From: Yinghai Lu To: Bjorn Helgaas , David Miller , Benjamin Herrenschmidt , Wei Yang , TJ , Yijing Wang , Khalid Aziz Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH v10 20/59] PCI: Treat optional as required in first try for bridge rescan Date: Wed, 24 Feb 2016 18:12:11 -0800 Message-Id: <1456366370-28995-21-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1456366370-28995-1-git-send-email-yinghai@kernel.org> References: <1456366370-28995-1-git-send-email-yinghai@kernel.org> X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For rescan bridge/bus that children are removed before, we should treat optional as required just like root bus the boot time in 19aa7ee432ce (PCI: make re-allocation try harder by reassigning ranges higher in the heirarchy). The reason: allocate required and expand to optional path do not put failed resource to fail list, so will lose required info before next try. So we are using following way: 1. First and following try before last try: We don't keep realloc list so treat every optional as required. allocate for required+optional and put failed in the fail list. then size info (include must and optonal separatedly) will be kept for next try. 2. last try: a: try to allocate required+optional to see if all get allocated. b: try to allocate required then expand to optional. Signed-off-by: Yinghai Lu --- drivers/pci/setup-bus.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 4741cc9..10f1146 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1846,25 +1846,34 @@ void __init pci_assign_unassigned_resources(void) void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge) { struct pci_bus *parent = bridge->subordinate; - LIST_HEAD(add_list); /* list of resources that + LIST_HEAD(realloc_head); /* list of resources that want additional resources */ + struct list_head *add_list = NULL; int tried_times = 0; LIST_HEAD(fail_head); struct pci_dev_resource *fail_res; int retval; unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH | IORESOURCE_MEM_64; + int pci_try_num = 2; again: - __pci_bus_size_bridges(parent, &add_list); - __pci_bridge_assign_resources(bridge, &add_list, &fail_head); - pci_bus_check_realloc(&add_list); + /* + * last try will use add_list, otherwise will try good to have as + * must have, so can realloc parent bridge resource + */ + if (tried_times + 1 == pci_try_num) + add_list = &realloc_head; + __pci_bus_size_bridges(parent, add_list); + __pci_bridge_assign_resources(bridge, add_list, &fail_head); + if (add_list) + pci_bus_check_realloc(add_list); tried_times++; if (list_empty(&fail_head)) goto enable_all; - if (tried_times >= 2) { + if (tried_times >= pci_try_num) { /* still fail, don't need to try more */ free_list(&fail_head); goto enable_all;