From patchwork Thu Mar 9 18:22:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 737098 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vfJfW2LvGz9s7n for ; Fri, 10 Mar 2017 05:22:59 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XXa66YCj"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oo82ilNbIK7/D06KeW5viC1dqMGJe4oc7n3SIOFZKRc=; b=XXa66YCjTDnduM nbv7oz/dztc1YzQx7W5FoDohz/1xThJTVGtc/3HqlTQwWSRANhVf7xMMMVW7opFhir2q07dCxpDb9 N6jaFuQ5yKw4siYoTorwi6ExWbRRno4udSlot7m7avkg6mzwjSLktKcYDNmR4qp/EtquHenVQ0bk8 R9u7WAKCmiL6E+aX71Q2hwOnRPNB4XLQhIE61WCumvHUd2uoMeint39HqvWFih4QNQvLOrusWWkBJ 6Fe3laIYVejsxRnGp/t+e3R3+YvLWnzv3Vjd0quMWdKItWqd6M4psAn2Pt/pxIkkrwr8MfplUKMkV vmZE193dNXs1nHFK9qlg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cm2iH-0006e8-9z; Thu, 09 Mar 2017 18:22:57 +0000 Received: from mail.kernel.org ([198.145.29.136]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cm2hs-0006Pq-1B for linux-arm-kernel@lists.infradead.org; Thu, 09 Mar 2017 18:22:34 +0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E7EA620490; Thu, 9 Mar 2017 18:22:09 +0000 (UTC) Received: from localhost (unknown [69.55.156.165]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 30F2620465; Thu, 9 Mar 2017 18:22:06 +0000 (UTC) Date: Thu, 9 Mar 2017 12:22:05 -0600 From: Bjorn Helgaas To: =?utf-8?B?UmFmYcWCIE1pxYJlY2tp?= Subject: Re: pcie-iproc: broken 2nd (& 3rd?) controller support by c3245a566400 ("PCI: iproc: Request host bridge window resources") Message-ID: <20170309182205.GB3685@bhelgaas-glaptop.roam.corp.google.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=ham 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170309_102232_123157_57D6BF16 X-CRM114-Status: GOOD ( 21.50 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [198.145.29.136 listed in list.dnswl.org] -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: JD Zheng , Scott Branden , Jon Mason , Ray Jui , Oza Oza , linux-pci@vger.kernel.org, Bjorn Helgaas , bcm-kernel-feedback-list@broadcom.com, Andy Gospodarek , linux-arm-kernel@lists.infradead.org, Felix Fietkau Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org On Thu, Mar 09, 2017 at 08:39:07AM +0100, Rafał Miłecki wrote: > On 03/08/2017 01:56 PM, Rafał Miłecki wrote: > >I just tried upgrading BCM5301X from 4.4 to 4.9 and noticed I don't see card > >connected to the 2nd controller. > > > > pcie_iproc_bcma bcma0:7: PCI host bridge to bus 0000:00 > > pci_bus 0000:00: root bus resource [mem 0x08000000-0x0fffffff] > > pcie_iproc_bcma bcma0:7: link: UP > > PCI: bus0: Fast back to back transfers disabled > > pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring > > PCI: bus1: Fast back to back transfers disabled > > pci 0000:00:00.0: BAR 8: assigned [mem 0x08000000-0x080fffff] > > pci 0000:01:00.0: BAR 0: assigned [mem 0x08000000-0x08007fff 64bit] > > pci 0000:00:00.0: PCI bridge to [bus 01] > > pci 0000:00:00.0: bridge window [mem 0x08000000-0x080fffff] > > > > pcie_iproc_bcma bcma0:8: resource collision: [mem 0x40000000-0x47ffffff] conflicts with PCIe MEM space [mem 0x40000000-0x47ffffff] > > pcie_iproc_bcma bcma0:8: PCIe controller setup failed > > pcie_iproc_bcma: probe of bcma0:8 failed with error -16 > > > > > >This used to work with older kernels because there wasn't any collision check: > > > > pcie_iproc_bcma bcma0:7: PCI host bridge to bus 0000:00 > > pci_bus 0000:00: root bus resource [mem 0x08000000-0x0fffffff] > > pcie_iproc_bcma bcma0:7: link: UP > > PCI: bus0: Fast back to back transfers disabled > > pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring > > PCI: bus1: Fast back to back transfers disabled > > pci 0000:00:00.0: BAR 8: assigned [mem 0x08000000-0x080fffff] > > pci 0000:01:00.0: BAR 0: assigned [mem 0x08000000-0x08007fff 64bit] > > pci 0000:00:00.0: PCI bridge to [bus 01] > > pci 0000:00:00.0: bridge window [mem 0x08000000-0x080fffff] > > > > pcie_iproc_bcma bcma0:8: PCI host bridge to bus 0001:00 > > pci_bus 0001:00: root bus resource [mem 0x40000000-0x47ffffff] > > pcie_iproc_bcma bcma0:8: link: UP > > PCI: bus0: Fast back to back transfers disabled > > pci 0001:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring > > PCI: bus1: Fast back to back transfers disabled > > pci 0001:00:00.0: BAR 8: assigned [mem 0x40000000-0x400fffff] > > pci 0001:01:00.0: BAR 0: assigned [mem 0x40000000-0x40007fff 64bit] > > pci 0001:00:00.0: PCI bridge to [bus 01] > > pci 0001:00:00.0: bridge window [mem 0x40000000-0x400fffff] > > > > > >I guess the check is OK after all and the real problem is iproc driver assigning > >the same resource. > > > >Broadcom team: could you take a look at this, please? > > I found a reason of this conflict (and probably random crashes I started > seeing with 4.9). I believe we have a memory corruption. Yep, we're using a resource structure on the stack when we shouldn't. Can you try the patch below? diff --git a/drivers/pci/host/pcie-iproc-bcma.c b/drivers/pci/host/pcie-iproc-bcma.c index bd4c9ec25edc..8cebbbff1e72 100644 --- a/drivers/pci/host/pcie-iproc-bcma.c +++ b/drivers/pci/host/pcie-iproc-bcma.c @@ -44,8 +44,7 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev) { struct device *dev = &bdev->dev; struct iproc_pcie *pcie; - LIST_HEAD(res); - struct resource res_mem; + LIST_HEAD(resources); int ret; pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); @@ -63,22 +62,23 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev) pcie->base_addr = bdev->addr; - res_mem.start = bdev->addr_s[0]; - res_mem.end = bdev->addr_s[0] + SZ_128M - 1; - res_mem.name = "PCIe MEM space"; - res_mem.flags = IORESOURCE_MEM; - pci_add_resource(&res, &res_mem); + pcie->mem.start = bdev->addr_s[0]; + pcie->mem.end = bdev->addr_s[0] + SZ_128M - 1; + pcie->mem.name = "PCIe MEM space"; + pcie->mem.flags = IORESOURCE_MEM; + pci_add_resource(&resources, &pcie->mem); pcie->map_irq = iproc_pcie_bcma_map_irq; - ret = iproc_pcie_setup(pcie, &res); + ret = iproc_pcie_setup(pcie, &resources); if (ret) dev_err(dev, "PCIe controller setup failed\n"); - - pci_free_resource_list(&res); + pci_free_resource_list(&resources); + return ret; + } bcma_set_drvdata(bdev, pcie); - return ret; + return 0; } static void iproc_pcie_bcma_remove(struct bcma_device *bdev) diff --git a/drivers/pci/host/pcie-iproc-platform.c b/drivers/pci/host/pcie-iproc-platform.c index f4909bb0b2ad..5f6361f27c69 100644 --- a/drivers/pci/host/pcie-iproc-platform.c +++ b/drivers/pci/host/pcie-iproc-platform.c @@ -51,7 +51,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) struct device_node *np = dev->of_node; struct resource reg; resource_size_t iobase = 0; - LIST_HEAD(res); + LIST_HEAD(resources); int ret; pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); @@ -96,10 +96,10 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) pcie->phy = NULL; } - ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &res, &iobase); + ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &resources, + &iobase); if (ret) { - dev_err(dev, - "unable to get PCI host bridge resources\n"); + dev_err(dev, "unable to get PCI host bridge resources\n"); return ret; } @@ -112,14 +112,15 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) pcie->map_irq = of_irq_parse_and_map_pci; } - ret = iproc_pcie_setup(pcie, &res); + ret = iproc_pcie_setup(pcie, &resources); if (ret) dev_err(dev, "PCIe controller setup failed\n"); - - pci_free_resource_list(&res); + pci_free_resource_list(&resources); + return ret; + } platform_set_drvdata(pdev, pcie); - return ret; + return 0; } static int iproc_pcie_pltfm_remove(struct platform_device *pdev) diff --git a/drivers/pci/host/pcie-iproc.h b/drivers/pci/host/pcie-iproc.h index 04fed8e907f1..0bbe2ea44f3e 100644 --- a/drivers/pci/host/pcie-iproc.h +++ b/drivers/pci/host/pcie-iproc.h @@ -90,6 +90,7 @@ struct iproc_pcie { #ifdef CONFIG_ARM struct pci_sys_data sysdata; #endif + struct resource mem; struct pci_bus *root_bus; struct phy *phy; int (*map_irq)(const struct pci_dev *, u8, u8);