From patchwork Tue Mar 21 13:42:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 9636611 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 79D3160216 for ; Tue, 21 Mar 2017 13:42:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 746CA206E2 for ; Tue, 21 Mar 2017 13:42:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 675D826E4C; Tue, 21 Mar 2017 13:42:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 046EE206E2 for ; Tue, 21 Mar 2017 13:42:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757441AbdCUNmP (ORCPT ); Tue, 21 Mar 2017 09:42:15 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:35255 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757488AbdCUNmO (ORCPT ); Tue, 21 Mar 2017 09:42:14 -0400 Received: by mail-pg0-f66.google.com with SMTP id g2so25237135pge.2; Tue, 21 Mar 2017 06:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PADk511T6UvFEEkC+EgYF4H9lwlmZDln8FBwQxNzJSs=; b=VOweWaZ1CjMQzd7bjrnJcs+7ItBomMSf1pjYjnmrvixAMwyP7qzC9IxWKtca4x9kpJ ZceCQHF4DXooCTW5SNEWlHnZnvZZT9hnNrhTEZIH9M30a+5ckjfM5erPWA3SAIqAODKs LlZYL4gg4EGs0woZ6nb0BeBng+2+jlt2Qvlnq4UKSbDIBSqoYVGAia4z1n8GbQ+yiX45 N+D/OX9dVYA8x1n+Zryix3Amw0LLsRN10kjG2M+L1Po7cmd1xKS7GpKUl1NxBI9rD1F1 mNrkz3c743VMWK+y/BAS/K4ml9EX57IBXRRCDtTOa9xXmD4c7K0xDNt4GaRKgdXc3n3g 012A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PADk511T6UvFEEkC+EgYF4H9lwlmZDln8FBwQxNzJSs=; b=XfjJFG/GQnODT7yQr4AdbSskaaueOWVJZsWKdepDh/zBlzdKWy2jZ+QG9ThbGzaBSf 4Nk/oxG6gFabmqa4XvCR5g2+vibz9ERdiUMh9aZ3Kk9TotvivgHNXHgzHcutl231qzaS W80cPD0ogHpbQevwQERpktH/bpWv4MnRMc7I+M+1zmNZpX7Z0HoAoyJlcMHdWfeGiMib i4A8MkuxL5SkhwG69wNK9EhR3zaymOlpKz4I0e0gMEozG1hH1yP0gLc+CSoFrz2D+mOA YILwgY+9pmR6YyAV/J0+jp8w6NJ2I6prrcI6m2J98ewoo4Ak2xAHmmWJ0qCHGlFdax77 zzLA== X-Gm-Message-State: AFeK/H1CyAHTWF4iIfE0aWC8yBqhuE0+h1QCybUO9dLpgzQtbjElI9srtszTQ8nMOFOyWw== X-Received: by 10.98.104.4 with SMTP id d4mr40477366pfc.2.1490103731078; Tue, 21 Mar 2017 06:42:11 -0700 (PDT) Received: from squirtle.lan (c-73-19-0-61.hsd1.wa.comcast.net. [73.19.0.61]) by smtp.gmail.com with ESMTPSA id x21sm39898761pfa.71.2017.03.21.06.42.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Mar 2017 06:42:10 -0700 (PDT) From: Andrey Smirnov To: linux-pci@vger.kernel.org Cc: Andrey Smirnov , yurovsky@gmail.com, Lucas Stach , Bjorn Helgaas , Fabio Estevam , Dong Aisheng , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 4/4] PCI: imx6: Do not switch speed if Gen2 is disabled Date: Tue, 21 Mar 2017 06:42:03 -0700 Message-Id: <20170321134203.26325-5-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170321134203.26325-1-andrew.smirnov@gmail.com> References: <20170321134203.26325-1-andrew.smirnov@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Save a bit of time and avoid going through link speed change procedure in configuration where link max speed is limited to Gen1 in DT. Cc: yurovsky@gmail.com Cc: Lucas Stach Cc: Bjorn Helgaas Cc: Fabio Estevam Cc: Dong Aisheng Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Andrey Smirnov Reviewed-by: Lucas Stach --- drivers/pci/dwc/pci-imx6.c | 52 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/pci/dwc/pci-imx6.c b/drivers/pci/dwc/pci-imx6.c index c731e41..9407c03 100644 --- a/drivers/pci/dwc/pci-imx6.c +++ b/drivers/pci/dwc/pci-imx6.c @@ -533,40 +533,40 @@ static int imx6_pcie_establish_link(struct imx6_pcie *imx6_pcie) tmp &= ~PCIE_RC_LCR_MAX_LINK_SPEEDS_MASK; tmp |= PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN2; dw_pcie_writel_dbi(pci, PCIE_RC_LCR, tmp); - } else { - dev_info(dev, "Link: Gen2 disabled\n"); - } - - /* - * Start Directed Speed Change so the best possible speed both link - * partners support can be negotiated. - */ - tmp = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL); - tmp |= PORT_LOGIC_SPEED_CHANGE; - dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, tmp); - if (imx6_pcie->variant != IMX7D) { /* - * On i.MX7, DIRECT_SPEED_CHANGE behaves differently - * from i.MX6 family when no link speed transition - * occurs and we go Gen1 -> yep, Gen1. The difference - * is that, in such case, it will not be cleared by HW - * which will cause the following code to report false - * failure. + * Start Directed Speed Change so the best possible + * speed both link partners support can be negotiated. */ + tmp = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL); + tmp |= PORT_LOGIC_SPEED_CHANGE; + dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, tmp); + + if (imx6_pcie->variant != IMX7D) { + /* + * On i.MX7, DIRECT_SPEED_CHANGE behaves differently + * from i.MX6 family when no link speed transition + * occurs and we go Gen1 -> yep, Gen1. The difference + * is that, in such case, it will not be cleared by HW + * which will cause the following code to report false + * failure. + */ + + ret = imx6_pcie_wait_for_speed_change(imx6_pcie); + if (ret) { + dev_err(dev, "Failed to bring link up!\n"); + goto err_reset_phy; + } + } - ret = imx6_pcie_wait_for_speed_change(imx6_pcie); + /* Make sure link training is finished as well! */ + ret = imx6_pcie_wait_for_link(imx6_pcie); if (ret) { dev_err(dev, "Failed to bring link up!\n"); goto err_reset_phy; } - } - - /* Make sure link training is finished as well! */ - ret = imx6_pcie_wait_for_link(imx6_pcie); - if (ret) { - dev_err(dev, "Failed to bring link up!\n"); - goto err_reset_phy; + } else { + dev_info(dev, "Link: Gen2 disabled\n"); } tmp = dw_pcie_readl_dbi(pci, PCIE_RC_LCSR);