From patchwork Thu Apr 10 21:56:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Greatorex X-Patchwork-Id: 338290 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D308F140088 for ; Fri, 11 Apr 2014 07:57:17 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WYMxn-0002xw-97; Thu, 10 Apr 2014 21:56:51 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WYMxk-0007S8-SS; Thu, 10 Apr 2014 21:56:48 +0000 Received: from bombadil.infradead.org ([2001:1868:205::9]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WYMxa-0007S2-Ai for linux-arm-kernel@merlin.infradead.org; Thu, 10 Apr 2014 21:56:38 +0000 Received: from mail-we0-f170.google.com ([74.125.82.170]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WYMxY-0003MG-AW for linux-arm-kernel@lists.infradead.org; Thu, 10 Apr 2014 21:56:37 +0000 Received: by mail-we0-f170.google.com with SMTP id w61so4634419wes.15 for ; Thu, 10 Apr 2014 14:56:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fatboyfat.co.uk; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version:content-type; bh=UuCdQ0ckQnmyKBUhWyBh6i/CqGa0+P4lKHpWfZT6FVs=; b=QlkeiyBcB3B6CSGAMCUEpc0EYQbxtZqR3Pi6SktSlHU7uPjdqwLug+voRNGLsljm/X CLoKOy62yxBwe7Wp+U0Fwuj7WNZ09ziu3Vv/xmBRk4Sk5Th+Aa0Mcnr5JeMHuv8VA2fs DuAlJUy3LfSIh755vChkmGlX6A8imCRBPO5R4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version:content-type; bh=UuCdQ0ckQnmyKBUhWyBh6i/CqGa0+P4lKHpWfZT6FVs=; b=RBrkOoKZ6XrkBqT9Xd8L1g4UJGEIyZSROB1LSyyFIVBjHK/a8wW5jWYbpWei9LT4VP 7VKmya2s0EFj99eop/+cVeJ2pMWPGAxNN9zo4blRgwOVjVBCiT3OEPK5I5Ii5wxfRmVC ByECEb9vJLP5rqPOSimuSdAFWxNP9QzBgGy/T+kgIrzEjAv/4l+g7hezfaovTNbM3wlv aUn6JYlLt1d8suHl/ZlO9QwBP0gayWzsBbkUoxn8gamGRc3VPygcNOt8wOCMHNrDFqxD 6PTxP/NxgIcaxGkmf/wjRY2W1R/xcHbY3YjMShGAuI6sA+NJ2shGJwtIy5gG9tR3Qy7w gqIg== X-Gm-Message-State: ALoCoQmZctiTWk9ssOcr3iCI/Y3jx4vmlAUNT6rVvlEDYnen9bcPKf7IUAKDEQoYpdT3FxLQv7cc X-Received: by 10.194.161.168 with SMTP id xt8mr17287322wjb.35.1397166966133; Thu, 10 Apr 2014 14:56:06 -0700 (PDT) Received: from [2001:470:1f09:284::1b9d] ([2001:470:1f09:284::1b9d]) by mx.google.com with ESMTPSA id co9sm8335126wjb.22.2014.04.10.14.56.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Apr 2014 14:56:04 -0700 (PDT) Date: Thu, 10 Apr 2014 22:56:00 +0100 (BST) From: Neil Greatorex X-X-Sender: neil@vroombuntu To: Jason Gunthorpe Subject: Re: Fixing PCIe issues on Armada XP In-Reply-To: <20140410201201.GA12661@obsidianresearch.com> Message-ID: References: <20140410181953.50ccfcc3@skate> <20140410165733.GB23104@obsidianresearch.com> <20140410200153.46669e0c@skate> <20140410201201.GA12661@obsidianresearch.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140410_145636_662938_84BB44C3 X-CRM114-Status: GOOD ( 25.14 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.170 listed in list.dnswl.org] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Cc: Thomas Petazzoni , Andrew Lunn , Matthew Minter , Jason Cooper , Tawfik Bayouk , linux-pci@vger.kernel.org, Lior Amsalem , Gerlando Falauto , Ezequiel Garcia , =?ISO-8859-15?Q?Gregory_Cl=E9ment?= , Willy Tarreau , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Jason, On Thu, 10 Apr 2014, Jason Gunthorpe wrote: > Gating the clock without disabling the Phy first does sound like a > bad idea.. > > Neil, does this do anything for you? > > diff --git a/arch/arm/mach-mvebu/mvebu-soc-id.c b/arch/arm/mach-mvebu/mvebu-soc-id.c > index f3b325f..e0a032f 100644 > --- a/arch/arm/mach-mvebu/mvebu-soc-id.c > +++ b/arch/arm/mach-mvebu/mvebu-soc-id.c > @@ -107,7 +107,7 @@ static int __init mvebu_soc_id_init(void) > iounmap(pci_base); > > res_ioremap: > - clk_disable_unprepare(clk); > +// clk_disable_unprepare(clk); > > clk_err: > of_node_put(child); > That patch has fixed it for me. The PCIe card seems to be now be always properly detected. > In any event, turning on the clock should almost certainly be > accompanied by a phy reset sequence to get both link ends on the same > page. > > Attached is a rough, untested patch along those lines. > I took your attached patch and extended it a bit to print out how long it took. The delays also need to be much longer for me. I also fixed a small typo you made where the bit wasn't being set again to bring the link back up. I've attached the diff to your patch, as well as the combined patch (hope that makes sense). With the attached patch I get the following output: mirabox ~ # dmesg | grep PCIe0.0 [ 0.135947] mvebu-pcie pcie-controller.3: PCIe0.0: performing link reset [ 0.161989] mvebu-pcie pcie-controller.3: PCIe0.0: link went down after 26 tries [ 0.173984] mvebu-pcie pcie-controller.3: PCIe0.0: link came back up after 12 tries mirabox ~ # lspci 00:01.0 PCI bridge: Marvell Technology Group Ltd. Device 6710 (rev 01) 00:02.0 PCI bridge: Marvell Technology Group Ltd. Device 6710 (rev 01) 01:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01) 01:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01) 03:00.0 USB controller: Fresco Logic FL1009 USB 3.0 Host Controller (rev 02) So that seems to also work. I will leave it to you and Thomas to decide which approach is better! Cheers, Neil diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index c902ca0..d09a7e5 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c @@ -1054,15 +1054,25 @@ static int mvebu_pcie_probe(struct platform_device *pdev) mvebu_writel(port, reg & ~BIT(30), // Conf_TrainingDisable PCIE_CTRL_OFF); - do { - udelay(100); // Guess? - } while (mvebu_pcie_link_up(port)); + + for (tries = 0; + mvebu_pcie_link_up(port) && tries < 100; tries++) + mdelay(1); + + dev_info(&pdev->dev, + "PCIe%d.%d: link went down after %d tries\n", + port->port, port->lane, tries); + mvebu_pcie_set_local_dev_nr(port, 1); - mvebu_writel(port, reg | ~BIT(30), PCIE_CTRL_OFF); + mvebu_writel(port, reg | BIT(30), PCIE_CTRL_OFF); for (tries = 0; !mvebu_pcie_link_up(port) && tries != 100; tries++) - udelay(100); + mdelay(1); + + dev_info(&pdev->dev, + "PCIe%d.%d: link came back up after %d tries\n", + port->port, port->lane, tries); } else { /* We expect the bootloader has setup the port and * waited for the link to go up