From patchwork Fri Dec 11 05:06:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 7825131 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 8B980BEEE1 for ; Fri, 11 Dec 2015 05:17:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 872F420573 for ; Fri, 11 Dec 2015 05:17:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5EDC92056E for ; Fri, 11 Dec 2015 05:17:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754284AbbLKFQy (ORCPT ); Fri, 11 Dec 2015 00:16:54 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:48335 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751419AbbLKFND (ORCPT ); Fri, 11 Dec 2015 00:13:03 -0500 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 tBB57nLf007373 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 11 Dec 2015 05:07:49 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 tBB57nBU026153 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 11 Dec 2015 05:07:49 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id tBB57mcI003017; Fri, 11 Dec 2015 05:07:49 GMT Received: from linux-siqj.site (/69.181.250.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 10 Dec 2015 21:07:48 -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 v9 35/60] PCI: Add __add_to_list() Date: Thu, 10 Dec 2015 21:06:31 -0800 Message-Id: <1449810416-2950-36-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1449810416-2950-1-git-send-email-yinghai@kernel.org> References: <1449810416-2950-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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 alt_size support, we will add more entries to realloc list. Add new __add_to_list() to take alt_size, alt_align. And simplify add_to_list() not to take add/alt input. Signed-off-by: Yinghai Lu --- drivers/pci/setup-bus.c | 51 ++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 715e627..936564f 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -66,6 +66,8 @@ struct pci_dev_resource { resource_size_t end; resource_size_t add_size; resource_size_t min_align; + resource_size_t alt_size; + resource_size_t alt_align; unsigned long flags; }; @@ -88,15 +90,16 @@ static void free_list(struct list_head *head) * @add_size: additional size to be optionally added * to the resource */ -static int add_to_list(struct list_head *head, +static int __add_to_list(struct list_head *head, struct pci_dev *dev, struct resource *res, - resource_size_t add_size, resource_size_t min_align) + resource_size_t add_size, resource_size_t min_align, + resource_size_t alt_size, resource_size_t alt_align) { struct pci_dev_resource *tmp; tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); if (!tmp) { - pr_warn("add_to_list: kmalloc() failed!\n"); + pr_warn("__add_to_list: kmalloc() failed!\n"); return -ENOMEM; } @@ -107,12 +110,20 @@ static int add_to_list(struct list_head *head, tmp->flags = res->flags; tmp->add_size = add_size; tmp->min_align = min_align; + tmp->alt_size = alt_size; + tmp->alt_align = alt_align; list_add(&tmp->list, head); return 0; } +static int add_to_list(struct list_head *head, + struct pci_dev *dev, struct resource *res) +{ + return __add_to_list(head, dev, res, 0, 0, 0, 0); +} + static void remove_from_list(struct list_head *head, struct resource *res) { @@ -378,9 +389,7 @@ static void assign_requested_resources_sorted(struct list_head *head, if (resource_size(res) && pci_assign_resource(dev_res->dev, idx)) { if (fail_head) - add_to_list(fail_head, dev_res->dev, res, - 0 /* don't care */, - 0 /* don't care */); + add_to_list(fail_head, dev_res->dev, res); reset_resource(res); } } @@ -466,7 +475,7 @@ static void __assign_resources_sorted(struct list_head *head, /* Save original start, end, flags etc at first */ list_for_each_entry(dev_res, head, list) { - if (add_to_list(&save_head, dev_res->dev, dev_res->res, 0, 0)) { + if (add_to_list(&save_head, dev_res->dev, dev_res->res)) { free_list(&save_head); goto requested_and_reassign; } @@ -1057,8 +1066,8 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, b_res->end = b_res->start + size0 - 1; b_res->flags |= IORESOURCE_STARTALIGN; if (size1 > size0 && realloc_head) { - add_to_list(realloc_head, bus->self, b_res, size1-size0, - min_align); + __add_to_list(realloc_head, bus->self, b_res, + size1 - size0, min_align, 0, 0); dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window %pR to %pR add_size %llx\n", b_res, &bus->busn_res, (unsigned long long)size1-size0); @@ -1262,7 +1271,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, add_to_align_test_list(&align_test_add_list, align, r_size); r->end = r->start - 1; - add_to_list(realloc_head, dev, r, r_size, 0/* don't care */); + __add_to_list(realloc_head, dev, r, + r_size, align, 0, 0); sum_add_size += r_size; if (align > max_add_align) max_add_align = align; @@ -1333,8 +1343,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, b_res->end = size0 + min_align - 1; b_res->flags |= IORESOURCE_STARTALIGN; if (size1 > size0 && realloc_head) { - add_to_list(realloc_head, bus->self, b_res, size1 - size0, - min_add_align); + __add_to_list(realloc_head, bus->self, b_res, size1 - size0, + min_add_align, 0, 0); dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window %pR to %pR add_size %llx add_align %llx\n", b_res, &bus->busn_res, (unsigned long long) (size1 - size0), @@ -1371,8 +1381,8 @@ static void pci_bus_size_cardbus(struct pci_bus *bus, b_res[0].flags |= IORESOURCE_IO | IORESOURCE_STARTALIGN; if (realloc_head) { b_res[0].end -= pci_cardbus_io_size; - add_to_list(realloc_head, bridge, b_res, pci_cardbus_io_size, - pci_cardbus_io_size); + __add_to_list(realloc_head, bridge, b_res, + pci_cardbus_io_size, pci_cardbus_io_size, 0, 0); } handle_b_res_1: @@ -1383,8 +1393,8 @@ handle_b_res_1: b_res[1].flags |= IORESOURCE_IO | IORESOURCE_STARTALIGN; if (realloc_head) { b_res[1].end -= pci_cardbus_io_size; - add_to_list(realloc_head, bridge, b_res+1, pci_cardbus_io_size, - pci_cardbus_io_size); + __add_to_list(realloc_head, bridge, b_res + 1, + pci_cardbus_io_size, pci_cardbus_io_size, 0, 0); } handle_b_res_2: @@ -1421,8 +1431,9 @@ handle_b_res_2: IORESOURCE_STARTALIGN; if (realloc_head) { b_res[2].end -= pci_cardbus_mem_size; - add_to_list(realloc_head, bridge, b_res+2, - pci_cardbus_mem_size, pci_cardbus_mem_size); + __add_to_list(realloc_head, bridge, b_res + 2, + pci_cardbus_mem_size, pci_cardbus_mem_size, + 0, 0); } /* reduce that to half */ @@ -1437,8 +1448,8 @@ handle_b_res_3: b_res[3].flags |= IORESOURCE_MEM | IORESOURCE_STARTALIGN; if (realloc_head) { b_res[3].end -= b_res_3_size; - add_to_list(realloc_head, bridge, b_res+3, b_res_3_size, - pci_cardbus_mem_size); + __add_to_list(realloc_head, bridge, b_res + 3, + b_res_3_size, pci_cardbus_mem_size, 0, 0); } handle_done: