From patchwork Tue Oct 27 20:55:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 7502171 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 06B4EBEEA4 for ; Tue, 27 Oct 2015 21:00:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2D14D205E1 for ; Tue, 27 Oct 2015 21:00:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 403D820165 for ; Tue, 27 Oct 2015 21:00:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965655AbbJ0U5E (ORCPT ); Tue, 27 Oct 2015 16:57:04 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:37169 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965635AbbJ0U5B (ORCPT ); Tue, 27 Oct 2015 16:57:01 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t9RKugkV002558 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 27 Oct 2015 20:56:43 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t9RKug5f010444 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 27 Oct 2015 20:56:42 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t9RKufIs000631; Tue, 27 Oct 2015 20:56:41 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:41 -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 22/61] PCI: Get new realloc size for bridge for last try Date: Tue, 27 Oct 2015 13:55:14 -0700 Message-Id: <1445979353-1728-23-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: userv0022.oracle.com [156.151.31.74] 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 Current realloc path would not shrink bridge resource through pbus_size_mem() checking with the old size. That cause problem: when "required+optional" resource allocation fails, the cached bridge resource size will prevent "required" resource to get allocated smaller resource. Clear the old resource size for last try or third and later try. Link: https://bugzilla.kernel.org/show_bug.cgi?id=81431 Tested-by: TJ Signed-off-by: Yinghai Lu --- drivers/pci/setup-bus.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 5505942..278cb6d 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1695,6 +1695,17 @@ static enum enable_type pci_realloc_detect(struct pci_bus *bus, } #endif +static void reset_bridge_resource_size(struct pci_dev *dev, + struct resource *res) +{ + int idx = res - &dev->resource[0]; + + if (idx >= PCI_BRIDGE_RESOURCES && idx <= PCI_BRIDGE_RESOURCE_END) { + res->start = 0; + res->end = res->start - 1; + } +} + /* * first try will not touch pci bridge res * second and later try will clear small leaf bridge res @@ -1779,8 +1790,13 @@ again: res->start = fail_res->start; res->end = fail_res->end; res->flags = fail_res->flags; - if (fail_res->dev->subordinate) + if (fail_res->dev->subordinate) { res->flags = 0; + /* last or third times and later */ + if (tried_times + 1 == pci_try_num || + tried_times + 1 > 2) + reset_bridge_resource_size(fail_res->dev, res); + } } free_list(&fail_head); @@ -1854,8 +1870,11 @@ again: res->start = fail_res->start; res->end = fail_res->end; res->flags = fail_res->flags; - if (fail_res->dev->subordinate) + if (fail_res->dev->subordinate) { res->flags = 0; + /* last time */ + reset_bridge_resource_size(fail_res->dev, res); + } } free_list(&fail_head);