From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8EEFFC4332F for ; Mon, 7 Nov 2022 08:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Subject:Cc:To:From: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=OCsbbT067qWmb8dNgwoOU0tuv6cPlhHOL7+ydRAyhrY=; b=ILC /DrtB2ZbAxsYnK+9vRriEqGhULTAJUCefWGNcDb4uSqPTx8m/uyoOl+kykzY7pLkbLYG9KA2qV0FR dO2gZ0cRBgXhRo4y3yzZbvGF15fUJyIYktqSyj404BeGwFmLdBgZdWxgV4Hvdck7ChprSTEXL9O9p BCJnCBoZOvZLHMWu/WQITtGoB34nFd2qIAn+ApXNXapqtIUrOwHA8b2Fyk3hjGS5YE+ybqkNREc2n Dy61nJCsCcLs8uBlFc26yZs6rN7iRy5inwSF4N2gT496q7Nlo2hWR3b1BPc3Us3rOGLjFpxXt0CDy 0Lbk0oA9p+sxafJbTfGvPYYJfoC2Lsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1orxGP-00CpBY-MV; Mon, 07 Nov 2022 08:13:49 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1orxGM-00Cp9N-5x for linux-arm-kernel@lists.infradead.org; Mon, 07 Nov 2022 08:13:47 +0000 Received: by mail-pg1-x535.google.com with SMTP id s196so9799397pgs.3 for ; Mon, 07 Nov 2022 00:13:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nathanrossi.com; s=google; h=mime-version:content-transfer-encoding:subject:cc:to:from :message-id:date:from:to:cc:subject:date:message-id:reply-to; bh=y71pLMvooIRecOUj8AXrDoMOrUDoDubP/fQuwH79cVQ=; b=W7E7bB/v9cZQW93GKuGYJEJvY7ThtLs55R2ykpJdCI1aALO6M5vSiJd0lvjmxfNMMg wZiIJhDNqe6+tHHHtPW4Ue3sQK55dTfTuAdMeWJ+XEuZnGQMVC80Gly9j5tk+RbDSZdl f1LCtU+1QqqFUsLdQcxRpAOircqMCAGCIjTjPxWAN6LbvM5bP9pJswTbyDACmLYqslaA teX0SHTXTMOzq71cnehss6sz08a8Mtlw8zi9w9zfvE1E2xUvB59DVnNmvOOqsDq3oGFY PVdvNe5EPnKbO1QBUQXEKNX5Rm4kCfp3AUF8jLznBJvhtDrzKN2Hvx8v6iKI2Ih4FEce K0zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:content-transfer-encoding:subject:cc:to:from :message-id:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=y71pLMvooIRecOUj8AXrDoMOrUDoDubP/fQuwH79cVQ=; b=hjzdEeXr3CuaJIE124EFZ8Rn3fbAXpeeOiRtY5asKTpRG8hleWsWvXq1P8w2LIyGyu 2IxczD6It4zYCm4l5SfZWC/5HNvYbCxMQlavfxQGirZzdNHd6HcEXwjDd51O+lclI4pA yePLtJVEbI8VakOrY++lHvQUjE1NOKhxUfp3Zcf+fjrF+uS6fUWOPmN4lwiFci2+5Gh3 KfNUsELvle3MCTKOaluiBZ/XdgyOBkDDw+Oj7f4r4NPNYU/Dz8PBVLDn7uZFqQRfdoQf kcOkqrIKDnEPdCyXpPGKh97MWGDDBe4CDY5PJQ+TrLngcqbzvUbT1D8EzgoQKaokPeag qkpg== X-Gm-Message-State: ACrzQf0zWhWEFV7LsO0yKOsE1M+43YuMes61z09OSJZakzl9oqzSK2WW sNpLEeQ8bZtefuRwmBNc3AjCXY2uM+vKQKKx X-Google-Smtp-Source: AMsMyM4Sl/kXw/jB7JyTksaM0VO42+EshFVOhqAXTLRxKZ77IelcNlGxrwh8AxGDugduoJGX4PAyMA== X-Received: by 2002:a63:dd4f:0:b0:46f:fae3:373d with SMTP id g15-20020a63dd4f000000b0046ffae3373dmr26459600pgj.31.1667808822337; Mon, 07 Nov 2022 00:13:42 -0800 (PST) Received: from [127.0.1.1] (117-20-68-146.751444.bne.nbn.aussiebb.net. [117.20.68.146]) by smtp.gmail.com with UTF8SMTPSA id pc3-20020a17090b3b8300b00212cf2fe8c3sm17579487pjb.1.2022.11.07.00.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 00:13:41 -0800 (PST) Date: Mon, 07 Nov 2022 08:13:27 +0000 Message-Id: <20221107081327.336239-1-nathan@nathanrossi.com> From: Nathan Rossi To: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Nathan Rossi , Nathan Rossi , Thomas Petazzoni , Lorenzo Pieralisi , Bjorn Helgaas , Pali =?utf-8?q?Roh=C3=A1r?= Subject: [PATCH] PCI: mvebu: Set Target Link Speed for 2.5GT downstream devices MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221107_001346_250297_CB67233B X-CRM114-Status: GOOD ( 18.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Nathan Rossi There is a known issue with the mvebu PCIe controller when triggering retraining of the link (via Link Control) where the link is dropped completely causing significant delay in the renegotiation of the link. This occurs only when the downstream device is 2.5GT and the upstream port is configured to support both 2.5GT and 5GT. It is possible to prevent this link dropping by setting the associated link speed in Target Link Speed of the Link Control 2 register. This only needs to be done when the downstream is specifically 2.5GT. This change applies the required Target Link Speed value during mvebu_pcie_setup_hw conditionally depending on the current link speed from the Link Status register, only applying the change when the link is configured to 2.5GT already. Signed-off-by: Nathan Rossi --- drivers/pci/controller/pci-mvebu.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c index 1ced73726a..6a869a33ba 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -248,7 +248,7 @@ static void mvebu_pcie_setup_wins(struct mvebu_pcie_port *port) static void mvebu_pcie_setup_hw(struct mvebu_pcie_port *port) { - u32 ctrl, lnkcap, cmd, dev_rev, unmask, sspl; + u32 ctrl, lnkcap, cmd, dev_rev, unmask, sspl, lnksta, lnkctl2; /* Setup PCIe controller to Root Complex mode. */ ctrl = mvebu_readl(port, PCIE_CTRL_OFF); @@ -339,6 +339,22 @@ static void mvebu_pcie_setup_hw(struct mvebu_pcie_port *port) unmask |= PCIE_INT_INTX(0) | PCIE_INT_INTX(1) | PCIE_INT_INTX(2) | PCIE_INT_INTX(3); mvebu_writel(port, unmask, PCIE_INT_UNMASK_OFF); + + /* + * Set Target Link Speed within the Link Control 2 register when the + * linked downstream device is connected at 2.5GT. This is configured + * in order to avoid issues with the controller when the upstream port + * is configured to support 2.5GT and 5GT and the downstream device is + * linked at 2.5GT, retraining the link in this case causes the link to + * drop taking significant time to retrain. + */ + lnksta = mvebu_readl(port, PCIE_CAP_PCIEXP + PCI_EXP_LNKCTL) >> 16; + if ((lnksta & PCI_EXP_LNKSTA_CLS) == PCI_EXP_LNKSTA_CLS_2_5GB) { + lnkctl2 = mvebu_readl(port, PCIE_CAP_PCIEXP + PCI_EXP_LNKCTL2); + lnkctl2 &= ~PCI_EXP_LNKCTL2_TLS; + lnkctl2 |= PCI_EXP_LNKCTL2_TLS_2_5GT; + mvebu_writel(port, lnkctl2, PCIE_CAP_PCIEXP + PCI_EXP_LNKCTL2); + } } static struct mvebu_pcie_port *mvebu_pcie_find_port(struct mvebu_pcie *pcie, --- 2.37.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel