From patchwork Mon Feb 20 16:08:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 9583193 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 29AD6604A0 for ; Mon, 20 Feb 2017 16:09:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41098269DA for ; Mon, 20 Feb 2017 16:09:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35C1B28696; Mon, 20 Feb 2017 16:09:57 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham 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 8FE2F269DA for ; Mon, 20 Feb 2017 16:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754030AbdBTQJy (ORCPT ); Mon, 20 Feb 2017 11:09:54 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:34195 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753669AbdBTQJw (ORCPT ); Mon, 20 Feb 2017 11:09:52 -0500 Received: by mail-pg0-f65.google.com with SMTP id s67so2926231pgb.1; Mon, 20 Feb 2017 08:09:52 -0800 (PST) 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=/Dpu4/wG1PGiitFKjh88ifL2ql29jZCTvND+RN8CngU=; b=rIxX9ukCeiCNvm92Mw/VdnCFOrvgUXprBgmvrGYWVoDDZj17J26xe8WuqRgng9ZKmB 1D/Eh0yOgQ/Kj5NSevyZgxIMVFljr0NbgL44/8XjUa2pSApVwMUZufhGRQrBUuS000Tw Bc3ukfrQ9uSy40doG4HAMhxR8dOBAwMSAHnHzIoBscs0dCOrfnJkRO8m+oDhmaMnAPcz y9/PUIG8v37yhBI0PF8jNrCdPk6EZUiCSoxo+pnwb/t7+7wdGfgOJE+MJNRmhuw4pRX8 x1oLuHDyPlyfONOE5J2eucWm3wWnL6sxMn+uTp0PylnAalU5l3a6rIpDwk7uoz6UIXbY 1WCQ== 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=/Dpu4/wG1PGiitFKjh88ifL2ql29jZCTvND+RN8CngU=; b=ryw8uWwsR/r9hiiu8q5lV/roa5Joiu+vq3xltnakN6w5RkGIz9scRAjhx/RvJD9xHV kRzQVROE0bloLXsMJpQUV0R3XXRqJDGDqzerXR2wdb54N+u/ZE/KvG/S+5Y5uxKYpvbc IhhhWkOjBx80suGt7Va0Vq4pbTAyDv7uK+gPIkZ5ro6tiX4hl/4+NggLuaA8zCKKeAUW eAeC/ZG6lT4UXRu1JHYcZrglGJbltofKb6o++meTjFTzqekzIxL/+XKeJRXtBHJOZsy2 e4XzuM6dxLR62HbonDGie9s7QHZ7ngVnKcr0snjBrpe4I6koH7H4hl0DVAFt2IA3s4T2 P06A== X-Gm-Message-State: AMke39k+9QAQBXZRVgzVXVWFHAoM/3s9nzHM1TuxeCisUABxqcKXBDvHGxbUlRUmHwvYfg== X-Received: by 10.98.70.194 with SMTP id o63mr27166301pfi.49.1487606991781; Mon, 20 Feb 2017 08:09:51 -0800 (PST) Received: from localhost.localdomain (c-73-19-0-61.hsd1.wa.comcast.net. [73.19.0.61]) by smtp.gmail.com with ESMTPSA id y184sm36059266pfg.86.2017.02.20.08.09.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Feb 2017 08:09:51 -0800 (PST) From: Andrey Smirnov To: linux-pci@vger.kernel.org Cc: Andrey Smirnov , yurovsky@gmail.com, Lucas Stach , Bjorn Helgaas , Fabio Estevam , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH v5 3/4] PCI: imx6: Do not switch speed if Gen2 is disabled Date: Mon, 20 Feb 2017 08:08:59 -0800 Message-Id: <20170220160900.7014-4-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170220160900.7014-1-andrew.smirnov@gmail.com> References: <20170220160900.7014-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: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Andrey Smirnov --- drivers/pci/host/pci-imx6.c | 52 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c index 473bbdc..071251f3 100644 --- a/drivers/pci/host/pci-imx6.c +++ b/drivers/pci/host/pci-imx6.c @@ -565,40 +565,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_rc(pp, 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_rc(pp, PCIE_LINK_WIDTH_SPEED_CONTROL); - tmp |= PORT_LOGIC_SPEED_CHANGE; - dw_pcie_writel_rc(pp, 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_rc(pp, PCIE_LINK_WIDTH_SPEED_CONTROL); + tmp |= PORT_LOGIC_SPEED_CHANGE; + dw_pcie_writel_rc(pp, 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_rc(pp, PCIE_RC_LCSR);