From patchwork Thu Oct 8 21:39:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 527938 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 98BB0140E45 for ; Fri, 9 Oct 2015 08:45:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752064AbbJHVpY (ORCPT ); Thu, 8 Oct 2015 17:45:24 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:29970 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965260AbbJHVpV (ORCPT ); Thu, 8 Oct 2015 17:45:21 -0400 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t98Le6OM002883 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 8 Oct 2015 21:40:07 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t98Le6Gv028390 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 8 Oct 2015 21:40:06 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t98Le6Lb015942; Thu, 8 Oct 2015 21:40:06 GMT Received: from linux-siqj.site (/10.132.127.48) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 08 Oct 2015 14:40:06 -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 v7 48/60] PCI: Don't add too much io port for hotplug bridge with old size Date: Thu, 8 Oct 2015 14:39:07 -0700 Message-Id: <1444340359-8011-49-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1444340359-8011-1-git-send-email-yinghai@kernel.org> References: <1444340359-8011-1-git-send-email-yinghai@kernel.org> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Now we add too much for hotplug bridge io port. For example, when hotplug bridge has two children bridges, every child bridge will need 0x1000, so size1 will be 0x2000 and size is 0. The min_size for the hotplug bridge is 0x100. with old version calculate_iosize, we get 0x3000 for final size as we are using size to compare with min_size at first. That is not right, we should have 0x2000. We can check size+size1 with min_size for io port, and just add size1 to size without passing extra size1 into calculate_iosize(). Signed-off-by: Yinghai Lu --- drivers/pci/setup-bus.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 4e7f0aa..d4e8da1 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1106,7 +1106,6 @@ static struct resource *find_free_bus_resource(struct pci_bus *bus, static resource_size_t calculate_iosize(resource_size_t size, resource_size_t min_size, - resource_size_t size1, resource_size_t old_size, resource_size_t align) { @@ -1114,7 +1113,7 @@ static resource_size_t calculate_iosize(resource_size_t size, size = min_size; if (old_size == 1) old_size = 0; - size = ALIGN(size + size1, align); + size = ALIGN(size, align); if (size < old_size) size = old_size; return size; @@ -1245,14 +1244,15 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, } size = size_aligned_for_isa(size); - size0 = calculate_iosize(size, min_size, size1, + size += size1; + size0 = calculate_iosize(size, min_size, resource_size(b_res), min_align); sum_add_size = size_aligned_for_isa(sum_add_size); sum_add_size += sum_add_size1; if (sum_add_size < min_sum_size) sum_add_size = min_sum_size; size1 = !realloc_head ? size0 : - calculate_iosize(sum_add_size, min_size, 0, + calculate_iosize(sum_add_size, min_size, resource_size(b_res), min_align); if (!size0 && !size1) { if (b_res->start || b_res->end)