From patchwork Mon Jul 6 23:39:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 6729001 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 26DABC05AC for ; Mon, 6 Jul 2015 23:49:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5BA072071C for ; Mon, 6 Jul 2015 23:49:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A0602070E for ; Mon, 6 Jul 2015 23:49:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756350AbbGFXlU (ORCPT ); Mon, 6 Jul 2015 19:41:20 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:49720 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756338AbbGFXlR (ORCPT ); Mon, 6 Jul 2015 19:41:17 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t66Nf1sj025405 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 6 Jul 2015 23:41:01 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t66Nf0on014824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 6 Jul 2015 23:41:00 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t66Nf0ef004412; Mon, 6 Jul 2015 23:41:00 GMT Received: from linux-siqj.site.us.oracle.com (/10.132.127.172) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Jul 2015 16:41:00 -0700 From: Yinghai Lu To: Bjorn Helgaas , David Miller , David Ahern , Benjamin Herrenschmidt , Wei Yang , TJ , Yijing Wang Cc: Andrew Morton , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH 15/36] PCI: Bail out early if there is no addon Date: Mon, 6 Jul 2015 16:39:05 -0700 Message-Id: <1436225966-27247-16-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1436225966-27247-1-git-send-email-yinghai@kernel.org> References: <1436225966-27247-1-git-send-email-yinghai@kernel.org> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.6 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 If the bridge does not support hotplug or no child with sriov support we could get out early before try must+optional allocation Also in the loop that update res with optional add info, skip resource that add_size is 0. Signed-off-by: Yinghai Lu --- drivers/pci/setup-bus.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 48f5616..e2aedac 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -466,8 +466,21 @@ static bool __assign_resources_must_add_sorted(struct list_head *head, struct pci_dev_resource *save_res; struct pci_dev_resource *dev_res, *tmp_res; unsigned long fail_type; - resource_size_t add_align; + resource_size_t add_align, add_size; struct resource *res; + int add_count = 0; + + /* check if we have add really */ + list_for_each_entry(dev_res, head, list) { + res = dev_res->res; + tmp_res = res_to_dev_res(realloc_head, res); + if (!tmp_res || !tmp_res->add_size) + continue; + + add_count++; + } + if (!add_count) + return false; /* Save original start, end, flags etc at first */ list_for_each_entry(dev_res, head, list) @@ -479,7 +492,12 @@ static bool __assign_resources_must_add_sorted(struct list_head *head, /* Update res in head list with add_size in realloc_head list */ list_for_each_entry(dev_res, head, list) { res = dev_res->res; - res->end += get_res_add_size(realloc_head, res); + add_size = get_res_add_size(realloc_head, res); + + if (!add_size) + continue; + + res->end += add_size; /* * There are two kinds of additional resources in the list: @@ -573,7 +591,7 @@ static void __assign_resources_sorted(struct list_head *head, LIST_HEAD(local_fail_head); /* Check must+optional add */ - if (realloc_head && !list_empty(realloc_head) && + if (realloc_head && __assign_resources_must_add_sorted(head, realloc_head)) return;