From patchwork Tue Mar 14 15:18:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 9623753 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 4979160244 for ; Tue, 14 Mar 2017 15:31:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31C95285A3 for ; Tue, 14 Mar 2017 15:31:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24F0B285AB; Tue, 14 Mar 2017 15:31:01 +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 B917C285A3 for ; Tue, 14 Mar 2017 15:31:00 +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=I3PzD+Vaexum1vsKnutpb+ajf8HOqtBMkOG6Sg20+fo=; b=WSuZI0ldE6PoYGN335usKa4Y2A i9qg1Z6WZNZD6aENXYQTXSemhFJ/KLiy+RMfT8JQEVn8IisFx/jM3R48QSl8zsKX9ESZyaW9ZWJAY jGMXXrLBEzG0ubzbBjpctOzkNqxzr0nZ8OeBjJMt2pzn9YG3MIgVKXopO0Uu7hYTbSimO/UwfwStk RRr8kCvAHTUqzd3/xYGPbvWm6fQaLxvp3NX11RywZ1VqcXKNttQIZWX/pFdkgJKvNqThPBaPmRBTn TxX422utIxBXP/sYhmTz1MRkmjoZ/UqqRcLq1EFkzb1iDH9prdDV/Blp0nBZLKD45uGLGjUk8pz7R MOB/YoGA==; 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 1cnoPb-0001Je-3j; Tue, 14 Mar 2017 15:30:59 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cnoDz-0003BF-Ah for linux-arm-kernel@bombadil.infradead.org; Tue, 14 Mar 2017 15:18:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/Dpu4/wG1PGiitFKjh88ifL2ql29jZCTvND+RN8CngU=; b=APN24siNikbejq072yAmCm9PC 6zO+YV0Qn0VZ07RRpObfgdYdsh+zocWyX1EyLZCQugkPjFaqkZf/UrA7Fm7Bmw0pETjkHweSlCCqI ixRLaiHLv7YswtaRDh/mUEaPhMgKFI+N2h3eSoEtmCIwtHKcLyRfZziQFnVAcHGb2JVGm74xajM8t 3lC52Ii3yDN8kqHV6ANnPbb7Acbir3H8tA4VIv9UtzTDfBjcuOIEoG6AmrGnBgPZB6fKKdpcSIcbW gERY25EjrItJH7Ak+1Gppzm8S3OIIfF2DJ/5afooyDuclg/+tElYGEbA/gufCWmlxhaf7yvXnR9oP Mcp+uDqKQ==; Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cnoDx-00072m-Kj for linux-arm-kernel@lists.infradead.org; Tue, 14 Mar 2017 15:18:58 +0000 Received: by mail-pg0-x244.google.com with SMTP id 77so25047978pgc.0 for ; Tue, 14 Mar 2017 08:18:36 -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=/Dpu4/wG1PGiitFKjh88ifL2ql29jZCTvND+RN8CngU=; b=R8mmTPCSK6Zoqs79b91Q6Zmapdq51NxzK6bk2x7fyOzFRvFfabzOY5FYwmOKF3AJIQ Xoyi3lm2VRmJVhEEGQM1XRkthjeSUe81TC/ubNTKhVrUPGQvOVqdm2G3j30M1ENtq8Ev rG7hY3+3FgKjn4PElGXWpipPSZXpD4d7dZEeTxpZSwrkqBKoooVUyl51W4kx7ju5uvQg MJXk6CK/UT19pnlGsQ/QhSaCUBzHiom2s5y3jtwevaBv9GbyKINc0vLuSU5gJQFpgQmK 9kzBdGa3e4AKLTaJcsForCFJjJ1oTE+m6s8yjIqEnX1ZiJ4u1lMUJnAB8Zh00fVzsoEt X3Wg== 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=jhfTzSuzLLh2MrH5DTl4kHlI6ocFeBkcjOw1cWQiEbSxhEEAzy3dt1UNJUHlUgZK4I fKPRozEcbLqf/eq1AY2bSbkHZ1sLRbi8sEv7FJwrBQpYzaNvfgZ6HdIdIgW1yE78EESE ZB5u3TRU3cD1JGJ63x5vAaYXWb7BM7rFJmGaJjf9WKCJUraDcIrdeB2nSpBoEkfEvYPt bM3IDzky24rql3FX8VXy5pg521PvWgpfxAU/M6/8NGyQE9TldwqS8IMWPpgZaN76x2K8 MFPnczj9eQw3/zJYB2eZUoXYHuRSYRYS2GhL/cUsJqI8UCNeXnkI2DWitaoofMyNrwAM 6QcQ== X-Gm-Message-State: AMke39mNJ+M853hhwY5o7C4ZWc5xjB923w+PMGlVxBrRsVKxHQeXt+yfc/CHhP7bihezkA== X-Received: by 10.84.224.131 with SMTP id s3mr56666691plj.162.1489504715769; Tue, 14 Mar 2017 08:18:35 -0700 (PDT) Received: from squirtle.lan ([2601:602:9400:8377:f0f2:a63b:2597:b3d9]) by smtp.gmail.com with ESMTPSA id m6sm39248277pfm.22.2017.03.14.08.18.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Mar 2017 08:18:34 -0700 (PDT) From: Andrey Smirnov To: linux-pci@vger.kernel.org Subject: [PATCH v6 3/4] PCI: imx6: Do not switch speed if Gen2 is disabled Date: Tue, 14 Mar 2017 08:18:26 -0700 Message-Id: <20170314151827.31248-4-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170314151827.31248-1-andrew.smirnov@gmail.com> References: <20170314151827.31248-1-andrew.smirnov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170314_111857_797008_7E2D8E11 X-CRM114-Status: GOOD ( 14.87 ) 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: Andrey Smirnov , linux-kernel@vger.kernel.org, Fabio Estevam , Bjorn Helgaas , 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: 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);