From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from acsinet15.oracle.com ([141.146.126.227]:22298 "EHLO acsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755235Ab2AUKJS (ORCPT ); Sat, 21 Jan 2012 05:09:18 -0500 From: Yinghai Lu To: Jesse Barnes Cc: Ram Pai , Linus Torvalds , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH 21/21] PCI: only enable pci realloc when SRIOV bar is not assigned Date: Sat, 21 Jan 2012 02:08:37 -0800 Message-Id: <1327140517-14811-22-git-send-email-yinghai@kernel.org> In-Reply-To: <1327140517-14811-1-git-send-email-yinghai@kernel.org> References: <1327140517-14811-1-git-send-email-yinghai@kernel.org> Sender: linux-pci-owner@vger.kernel.org List-ID: If bios does not assign those BAR or wrong address, then kernel will try to do pci realloc. in that case, user still can use pci=realloc=off to override it. Signed-off-by: Yinghai Lu --- drivers/pci/setup-bus.c | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 1c97e14..3070e1b 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1271,6 +1271,31 @@ static bool __init pci_realloc_enabled(void) return pci_realloc_enable > 0; } +static void __init pci_realloc_detect(void) +{ + struct pci_dev *dev = NULL; + + if (pci_realloc_enable != -1) + return; + +#ifdef CONFIG_PCI_IOV + for_each_pci_dev(dev) { + int i; + + for (i = PCI_IOV_RESOURCES; i <= PCI_IOV_RESOURCE_END; i++) { + struct resource *r = &dev->resource[i]; + + /* Not assigned, or rejected by kernel */ + if (r->flags && !r->start) { + pci_realloc_enable = 2; + + return; + } + } + } +#endif +} + /* * first try will not touch pci bridge res * second and later try will clear small leaf bridge res @@ -1292,6 +1317,7 @@ pci_assign_unassigned_resources(void) int pci_try_num = 1; /* don't realloc if asked to do so */ + pci_realloc_detect(); if (pci_realloc_enabled()) { int max_depth = pci_get_max_depth(); -- 1.7.7