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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB15DEB64DC for ; Fri, 21 Jul 2023 06:14:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230478AbjGUGOe (ORCPT ); Fri, 21 Jul 2023 02:14:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230522AbjGUGOL (ORCPT ); Fri, 21 Jul 2023 02:14:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 518BA4494 for ; Thu, 20 Jul 2023 23:12:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3CD6461083 for ; Fri, 21 Jul 2023 06:11:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35E30C433C7; Fri, 21 Jul 2023 06:11:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1689919864; bh=tfrPjWWs2ksfAi0ktZEYhpSxiSPVuS2wPrqAZYchcfo=; h=Subject:To:Cc:From:Date:From; b=T7/gBZr4cMq9MU/JXItzMw4FwC1Bzj5hcXRD9TvRi6MVPZKELr6A/31J/FA7A4aOV LU5/0Z221QbyAbAsUMd/PvqjKNnQ0QV4WjFPFRvGquFt0wkU66zdOHqVROhoUV9QbD iALUHrbXZPtHyDeXuNMa5CffPgY9mfVAh+zlUMfE= Subject: FAILED: patch "[PATCH] PCI/ASPM: Avoid link retraining race" failed to apply to 5.10-stable tree To: ilpo.jarvinen@linux.intel.com, bhelgaas@google.com, lukas@wunner.de Cc: From: Date: Fri, 21 Jul 2023 08:10:56 +0200 Message-ID: <2023072156-module-carrot-987b@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x e7e39756363ad5bd83ddeae1063193d0f13870fd # git commit -s git send-email --to '' --in-reply-to '2023072156-module-carrot-987b@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^.. Possible dependencies: e7e39756363a ("PCI/ASPM: Avoid link retraining race") 9c7f136433d2 ("PCI/ASPM: Factor out pcie_wait_for_retrain()") f5297a01ee80 ("PCI/ASPM: Return 0 or -ETIMEDOUT from pcie_retrain_link()") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From e7e39756363ad5bd83ddeae1063193d0f13870fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Tue, 2 May 2023 11:39:23 +0300 Subject: [PATCH] PCI/ASPM: Avoid link retraining race MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PCIe r6.0.1, sec 7.5.3.7, recommends setting the link control parameters, then waiting for the Link Training bit to be clear before setting the Retrain Link bit. This avoids a race where the LTSSM may not use the updated parameters if it is already in the midst of link training because of other normal link activity. Wait for the Link Training bit to be clear before toggling the Retrain Link bit to ensure that the LTSSM uses the updated link control parameters. [bhelgaas: commit log, return 0 (success)/-ETIMEDOUT instead of bool for both pcie_wait_for_retrain() and the existing pcie_retrain_link()] Suggested-by: Lukas Wunner Fixes: 7d715a6c1ae5 ("PCI: add PCI Express ASPM support") Link: https://lore.kernel.org/r/20230502083923.34562-1-ilpo.jarvinen@linux.intel.com Signed-off-by: Ilpo Järvinen Signed-off-by: Bjorn Helgaas Reviewed-by: Lukas Wunner Cc: stable@vger.kernel.org diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 954717d7033f..3aa73ecdf86f 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -213,8 +213,19 @@ static int pcie_wait_for_retrain(struct pci_dev *pdev) static int pcie_retrain_link(struct pcie_link_state *link) { struct pci_dev *parent = link->pdev; + int rc; u16 reg16; + /* + * Ensure the updated LNKCTL parameters are used during link + * training by checking that there is no ongoing link training to + * avoid LTSSM race as recommended in Implementation Note at the + * end of PCIe r6.0.1 sec 7.5.3.7. + */ + rc = pcie_wait_for_retrain(parent); + if (rc) + return rc; + pcie_capability_read_word(parent, PCI_EXP_LNKCTL, ®16); reg16 |= PCI_EXP_LNKCTL_RL; pcie_capability_write_word(parent, PCI_EXP_LNKCTL, reg16);