From patchwork Tue Mar 28 15:42:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 9650019 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 F422D60349 for ; Tue, 28 Mar 2017 15:44:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E720B2839B for ; Tue, 28 Mar 2017 15:44:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAC5E283E8; Tue, 28 Mar 2017 15:44:15 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5900A283C9 for ; Tue, 28 Mar 2017 15:44:15 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=pEf8aRz8Remy+h96N7n9bl6bj7mEmbzfzemLEyr/Bm0=; b=tw4q4OBI8Y5GE+U+69V1ieqM8e 3rX2ZRwTGTbvGL8GBQSIRqU3wu1B2Y0lh6bpQooLIrnMWzHvsLPv1NzM8T2Jawj5SBVW8rJqtivxI mzOwogeiWSVOANFw8UnGGvQhvYgRWniFkvl03gPTwzXksLR70k9OYhVt0E6/a7ezmuKYzguItl6UA r5r0iAKZe8EqOd+Gob3wq63hU77Zgni0PpADyHKamIU+2FnxrZEM7fX2XcV3D6jZA3Os5RGgzExsz b7QZlqEUTj+fynDa68cdMuHTdxZi9qmycnKehw14ASHn4hlNnISi6t5FBRMvPhV5LO9LKlAO4+h2V xnBcSnnA==; 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 1cstI5-0005ax-C7; Tue, 28 Mar 2017 15:44:13 +0000 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cstHM-0004au-Qr for linux-arm-kernel@lists.infradead.org; Tue, 28 Mar 2017 15:43:35 +0000 Received: by mail-pg0-x241.google.com with SMTP id g2so22203343pge.2 for ; Tue, 28 Mar 2017 08:43:08 -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=fqxgbPG0LQZJw1V5wBs9+l3DMwlaMg76B2Wq/GldCug=; b=L/6v26jod80+3dY2eQg7ifAUeYPcFVcd2TmP+rW/p04C5iE3habYlH+1IOdJp6Ehd3 A3Df4SNTD76TDZLQDHTlEC89BCFhLFp+tzRYF5EohAxD7GO0gWguxFTEZ2+5bRgnBruP noPsaMUwWAqK7RtBEP2cp61ZoBX2rMUlj9C0DBzSlA8Pwd0GHdrKfzKw3XDwioFP0H0s aAgK4dtFH2JS5bkSmW/MuZ94EsRcNSyjcwCX2IYMs2JoYeKU1966se3X3mXRjh6mkBYj X5XwPkKuKX5VUVYfVMc2bGnvKj3h8sUCUNS+9AfqLjMeGx+uEn1rFRjj9CU6kcKoFNn8 xDiw== 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=fqxgbPG0LQZJw1V5wBs9+l3DMwlaMg76B2Wq/GldCug=; b=fEBPLm+tIoexspd5I4l6xLL9VNCRsE161gPAorAhFePI5x1bgA3hUpXD8TSUMv12Fo +zziukI6V7TIXTtfyHsUkHin0D8bZk+QBae619AEPdvVs1vk92bU1ESdQcakNmGlqS+L Mh4qgYaMhz+yH8KcPcYHPRKmHMrc9nb9DGCFvgMc6MdDErjFmcT118Sr5Q/kkHe8kSTC i5b/26GujuvGHseHdZVHTMa6ZcAiiRfb8AnGeME8nLMuadZCzZVgRpjMZcVe+pDTOChE bpw9AnKI1XDzwnSsuHxJkNoG/U84c8TgjaEVCcNBERoNDiWkVrPVP+1GpHPTs5tWbADt /XXg== X-Gm-Message-State: AFeK/H0yGCWwwZ0riU09O6WZlsNHuSXZ5Apx8s9yWitY5X5aOMQra2GA725wzWBChwzceA== X-Received: by 10.84.179.193 with SMTP id b59mr37914298plc.56.1490715788295; Tue, 28 Mar 2017 08:43:08 -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 e16sm8238865pfb.102.2017.03.28.08.43.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 08:43:07 -0700 (PDT) From: Andrey Smirnov To: Bjorn Helgaas Subject: [PATCH v8 4/4] PCI: imx6: Do not switch speed if Gen2 is disabled Date: Tue, 28 Mar 2017 08:42:52 -0700 Message-Id: <20170328154252.6902-5-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170328154252.6902-1-andrew.smirnov@gmail.com> References: <20170328154252.6902-1-andrew.smirnov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170328_084329_344122_838386E4 X-CRM114-Status: GOOD ( 14.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Aisheng , Andrey Smirnov , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Fabio Estevam , yurovsky@gmail.com, linux-arm-kernel@lists.infradead.org, Lucas Stach MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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: Fabio Estevam Cc: Dong Aisheng Cc: linux-pci@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Lucas Stach Signed-off-by: Andrey Smirnov --- 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);