From patchwork Thu Nov 28 07:17:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 294779 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 51A012C00A3 for ; Thu, 28 Nov 2013 18:17:28 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758533Ab3K1HR0 (ORCPT ); Thu, 28 Nov 2013 02:17:26 -0500 Received: from mail-ie0-f171.google.com ([209.85.223.171]:40546 "EHLO mail-ie0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758468Ab3K1HRZ (ORCPT ); Thu, 28 Nov 2013 02:17:25 -0500 Received: by mail-ie0-f171.google.com with SMTP id ar20so13740467iec.16 for ; Wed, 27 Nov 2013 23:17:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=pUS/IafPk5heZgE7aHAWLeimAgz5GldN+UXQbnKXWec=; b=DFTco0mlB+fUDLY4/p1p6VG6PSVSebB9jKzrObPJ512Xnqnnh0rQZT1ar8IFF/qPZr tJ2mB3heDQa4ei7mrsjgBCEAaulkM3ktBMKvYj16F6hYSwROtCsTiLFMLLCkGwcgKN0F jHUpUXUydF8kOLL4a+oKYCjwhyBd0st/9OaLe/xj/3AyCYhXOxKeC9cEDAHGtilXYtxC H81qzTP2bOgGIkYbH+I6S2mBKP7pUshoC2hnPpM36VrTQx4z2HbAsnkuEE1PjIDkQsEb JIAAJ8VfmSZMXrjOkCNl7H9TW2h6nDGD87rUNpmE/bVwaot4iYdkPAn86NnwIwpDj/ln 1CZw== MIME-Version: 1.0 X-Received: by 10.42.196.201 with SMTP id eh9mr9199450icb.39.1385623045025; Wed, 27 Nov 2013 23:17:25 -0800 (PST) Received: by 10.64.235.70 with HTTP; Wed, 27 Nov 2013 23:17:24 -0800 (PST) In-Reply-To: <52965493.8060208@canonical.com> References: <52965493.8060208@canonical.com> Date: Wed, 27 Nov 2013 23:17:24 -0800 X-Google-Sender-Auth: gB43PVxPeWR39GefMD7cDIHXe8Y Message-ID: Subject: Re: [REGRESSION][v3.4-rc1] PCI: add a PCI resource reallocation config option From: Yinghai Lu To: Joseph Salisbury Cc: Jesse Barnes , Bjorn Helgaas , "linux-pci@vger.kernel.org" , LKML , Tim Gardner Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Wed, Nov 27, 2013 at 12:22 PM, Joseph Salisbury wrote: > Hi Yinghai, > > A kernel bug was opened against Ubuntu [0]. After a kernel bisect, it > was found that the following commit introduced the bug: > > commit b07f2ebc109b607789f648dedcff4b125f9afec6 > Author: Yinghai Lu > Date: Thu Feb 23 19:23:32 2012 -0800 > > PCI: add a PCI resource reallocation config option > > > > The regression was introduced as of v3.4-rc1 and also exists in current > mainline. > > The bug seems platform specific since we have not had allot of other > reports. The bug is preventing ixgbe to probe Intel x520 NIC's. > > It would be easy enough to disable the PCI_REALLOC_ENABLE_AUTO config > option, but I wanted to get your feedback since you are the author. It > looks like the bug reporter may also be able to work around the problem > with the pci=realloc=. The bios has problem to have two functions rom bar to same place, and root bus does not enough mmio range and confuse realloc logic. Please try attached patches to top of linus's tree, or your internal tree. Thanks Yinghai Subject: [PATCH] PCI: Only enable realloc auto when root bus has 64bit mmio Joseph found | commit b07f2ebc109b607789f648dedcff4b125f9afec6 | Date: Thu Feb 23 19:23:32 2012 -0800 | | PCI: add a PCI resource reallocation config option cause one system can not load driver for Intel x520 NIC's. The root resource: [ 1.212470] PCI host bridge to bus 0000:20 [ 1.212475] pci_bus 0000:20: root bus resource [bus 20-3e] [ 1.212479] pci_bus 0000:20: root bus resource [io 0xc000-0xdfff] [ 1.212483] pci_bus 0000:20: root bus resource [mem 0xfecc0000-0xfecfffff] [ 1.212487] pci_bus 0000:20: root bus resource [mem 0xe9400000-0xe97fffff] and bios does not assign sriov, also have two function ROM bar point to same position. [ 1.213197] pci 0000:22:00.0: [8086:10fb] type 00 class 0x020000 ... [ 1.213240] pci 0000:22:00.0: reg 0x30: [mem 0xe9500000-0xe957ffff pref] [ 1.213303] pci 0000:22:00.0: reg 0x184: [mem 0x00000000-0x00003fff 64bit] [ 1.213317] pci 0000:22:00.0: reg 0x190: [mem 0x00000000-0x00003fff 64bit] [ 1.213366] pci 0000:22:00.1: [8086:10fb] type 00 class 0x020000 ... [ 1.213408] pci 0000:22:00.1: reg 0x30: [mem 0xe9500000-0xe957ffff pref] [ 1.213468] pci 0000:22:00.1: reg 0x184: [mem 0x00000000-0x00003fff 64bit] [ 1.213481] pci 0000:22:00.1: reg 0x190: [mem 0x00000000-0x00003fff 64bit] [ 1.218527] pci 0000:20:03.0: PCI bridge to [bus 22] [ 1.218534] pci 0000:20:03.0: bridge window [io 0xd000-0xdfff] [ 1.218537] pci 0000:20:03.0: bridge window [mem 0xe9400000-0xe95fffff] ... [ 1.254103] pci 0000:22:00.1: address space collision: [mem 0xe9500000-0xe957ffff pref] conflicts with 0000:22:00.0 [mem 0xe9500000-0xe957ffff pref] [ 1.254111] pci 0000:23:00.1: address space collision: [mem 0xe9700000-0xe977ffff pref] conflicts with 0000:23:00.0 [mem 0xe9700000-0xe977ffff pref] We don't need to enable realloc for this case, as we can not alter root bus mmio range to get big one to hold two rom bar, and sriov under 4G. Add checking if pci root bus have 4G above mmio res, and don't enable realloc auto accordingly. bug report at: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1245938 Reported-by: Joseph Salisbury Signed-off-by: Yinghai Lu --- drivers/pci/setup-bus.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) 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 @@ -1432,17 +1432,39 @@ static int iov_resources_unassigned(stru return 0; } +static bool pci_bus_mem_above_4g(struct pci_bus *bus) +{ + int i; + struct resource *res; + + pci_bus_for_each_resource(bus, res, i) { + struct pci_bus_region region; + + if (!res || !(res->flags & IORESOURCE_MEM)) + continue; + + __pcibios_resource_to_bus(bus, ®ion, res); + if (region.end > 0xffffffff) + return true; + } + + return false; +} + static enum enable_type pci_realloc_detect(struct pci_bus *bus, enum enable_type enable_local) { - bool unassigned = false; - if (enable_local != undefined) return enable_local; - pci_walk_bus(bus, iov_resources_unassigned, &unassigned); - if (unassigned) - return auto_enabled; + /* only enable auto when root bus does support 64bit mmio */ + if (pci_bus_mem_above_4g(bus)) { + bool unassigned = false; + + pci_walk_bus(bus, iov_resources_unassigned, &unassigned); + if (unassigned) + return auto_enabled; + } return enable_local; }