From patchwork Sat Jun 13 22:39:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 483911 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 B47041401DE for ; Sun, 14 Jun 2015 08:39:35 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751092AbbFMWj2 (ORCPT ); Sat, 13 Jun 2015 18:39:28 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:39301 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750931AbbFMWj1 (ORCPT ); Sat, 13 Jun 2015 18:39:27 -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 t5DMdOcF029838 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 13 Jun 2015 22:39:24 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t5DMdOPx000507 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sat, 13 Jun 2015 22:39:24 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t5DMdNS5020962; Sat, 13 Jun 2015 22:39:23 GMT Received: from linux-siqj.site (/107.215.0.145) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Jun 2015 15:39:23 -0700 From: Yinghai Lu To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Yinghai Lu Subject: [PATCH] PCI: get correct bridge mmio size with old size checking Date: Sat, 13 Jun 2015 15:39:02 -0700 Message-Id: <1434235142-2751-1-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.4.5 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 Found allocation request too big size for must+optional during pci bus rescan via /sys/bus/pci/rescan, and fail with that size. [ 1217.699800] pci 0000:85:02.0: bridge window [mem 0x00100000-0x001fffff] to [bus 86] add_size 100000 add_align 100000 [ 1217.699821] pci 0000:85:03.0: bridge window [mem 0x00100000-0x001fffff] to [bus 87] add_size 100000 add_align 100000 [ 1217.699907] pci 0000:85:02.0: res[14]=[mem 0x00100000-0x001fffff] res_to_dev_res add_size 100000 min_align 100000 [ 1217.699909] pci 0000:85:03.0: res[14]=[mem 0x00100000-0x001fffff] res_to_dev_res add_size 100000 min_align 100000 [ 1217.699933] pci 0000:85:02.0: BAR 14: assigned [mem 0xedf00000-0xee0fffff] [ 1217.699936] pci 0000:85:03.0: BAR 14: no space for [mem size 0x00200000] [ 1217.699939] pci 0000:85:03.0: BAR 14: failed to assign [mem size 0x00200000] After close look, for 85:02.0 only need 1M for must+optional. It turns out that there is bug in calculate_memsize() with checking. We should compare size sum with old size at last instead of partial size. Actually we have that correct in calculate_iosize(), with this patch we have mmio and io port size calculation consistent. Signed-off-by: Yinghai Lu --- drivers/pci/setup-bus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/drivers/pci/setup-bus.c =================================================================== --- linux-2.6.orig/drivers/pci/setup-bus.c +++ linux-2.6/drivers/pci/setup-bus.c @@ -857,9 +857,10 @@ static resource_size_t calculate_memsize size = min_size; if (old_size == 1) old_size = 0; + size = ALIGN(size + size1, align); if (size < old_size) size = old_size; - size = ALIGN(size + size1, align); + return size; }