From patchwork Tue Oct 27 20:55:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 7502751 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 96B499F327 for ; Tue, 27 Oct 2015 21:10:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B885920987 for ; Tue, 27 Oct 2015 21:10:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C49E22097E for ; Tue, 27 Oct 2015 21:10:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752467AbbJ0VJ5 (ORCPT ); Tue, 27 Oct 2015 17:09:57 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:39989 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965802AbbJ0VCH (ORCPT ); Tue, 27 Oct 2015 17:02:07 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t9RKutG0003073 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 27 Oct 2015 20:56:56 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t9RKutqZ003391 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 27 Oct 2015 20:56:55 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t9RKuta9002444; Tue, 27 Oct 2015 20:56:55 GMT Received: from aserv0021.oracle.com (/10.132.126.176) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 27 Oct 2015 13:56:54 -0700 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 v8 43/61] PCI: Move saved required resource list out of required+optional assigning Date: Tue, 27 Oct 2015 13:55:35 -0700 Message-Id: <1445979353-1728-44-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1445979353-1728-1-git-send-email-yinghai@kernel.org> References: <1445979353-1728-1-git-send-email-yinghai@kernel.org> X-Source-IP: userv0021.oracle.com [156.151.31.71] 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 We will need to share saved required list for alt_size support, so move it out from required+optional assigning. Signed-off-by: Yinghai Lu --- drivers/pci/setup-bus.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 5143ea2..ede619c 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -456,6 +456,9 @@ static bool has_addon(struct list_head *head, int add_count = 0; struct pci_dev_resource *dev_res, *tmp_res; + if (!realloc_head) + return false; + /* check if we have add really */ list_for_each_entry(dev_res, head, list) { tmp_res = res_to_dev_res(realloc_head, dev_res->res); @@ -492,9 +495,9 @@ static void restore_resource(struct pci_dev_resource *save_res, } static bool __assign_resources_required_optional_sorted(struct list_head *head, + struct list_head *save_head, struct list_head *realloc_head) { - LIST_HEAD(save_head); LIST_HEAD(local_fail_head); struct pci_dev_resource *save_res; struct pci_dev_resource *dev_res, *tmp_res; @@ -502,12 +505,6 @@ static bool __assign_resources_required_optional_sorted(struct list_head *head, resource_size_t add_align, add_size; struct resource *res; - if (!has_addon(head, realloc_head)) - return false; - - if (!save_resources(head, &save_head)) - return false; - /* Update res in head list with add_size in realloc_head list */ list_for_each_entry(dev_res, head, list) { res = dev_res->res; @@ -548,7 +545,6 @@ static bool __assign_resources_required_optional_sorted(struct list_head *head, /* Remove head list from realloc_head list */ list_for_each_entry(dev_res, head, list) remove_from_list(realloc_head, dev_res->res); - free_list(&save_head); free_list(head); return true; @@ -562,7 +558,7 @@ static bool __assign_resources_required_optional_sorted(struct list_head *head, if (res->parent && !pci_need_to_release(fail_type, res)) { /* remove it from realloc_head list */ remove_from_list(realloc_head, res); - remove_from_list(&save_head, res); + remove_from_list(save_head, res); list_del(&dev_res->list); kfree(dev_res); } @@ -581,11 +577,9 @@ static bool __assign_resources_required_optional_sorted(struct list_head *head, } } /* Restore start/end/flags from saved list */ - list_for_each_entry(save_res, &save_head, list) + list_for_each_entry(save_res, save_head, list) restore_resource(save_res, save_res->res); - free_list(&save_head); - return false; } @@ -603,16 +597,24 @@ static void __assign_resources_sorted(struct list_head *head, * then try to reassign add_size for some resources. */ + LIST_HEAD(save_head); + /* Check required+optional add */ - if (realloc_head && - __assign_resources_required_optional_sorted(head, realloc_head)) + if (has_addon(head, realloc_head) && + save_resources(head, &save_head) && + __assign_resources_required_optional_sorted(head, &save_head, + realloc_head)) { + free_list(&save_head); return; + } sort_resources(head); /* Satisfy the must-have resource requests */ assign_requested_resources_sorted(head, fail_head); + free_list(&save_head); + /* Try to satisfy any additional optional resource requests */ if (realloc_head)