From patchwork Sun Feb 5 15:48:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 52909 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1826010wrn; Sun, 5 Feb 2023 07:53:14 -0800 (PST) X-Google-Smtp-Source: AK7set+HIISw+IbT80vc5ESuD70yXp6JPLArZJsddcirBffaxAzcOERYBqca5vdE2RXoIJtiV6zf X-Received: by 2002:a17:906:948c:b0:84d:4325:7f7a with SMTP id t12-20020a170906948c00b0084d43257f7amr15585142ejx.65.1675612394274; Sun, 05 Feb 2023 07:53:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675612394; cv=none; d=google.com; s=arc-20160816; b=EomwdrPlpblCiqUhjMpzWiZB0rK2qgkK3qiIJ9k2zLP6LOtXQk9dbvm/Zs2LzX/7Mb Wup9+82E34H+KUlXFYD/ZSavB2ZEVwkDFFwygHYvrO4KFhnF4EHXs5bviwQCDUbzE3yM ChoBDPqxnv1s/ZVu2dHM4NLGZaZ1WGacdoaAy32XI0J24tHd+R2aQBrcC2uf3UHyCq+T qjVocthax8XgSr4Hy0CLQJbxhj+p+66aSB6XiTmBHXYYSRKQsFJ0vagFP2SaNkT3MF0E R+q9CD3aHTtXKw2fI2v83VAOKXYtSrzd0NSY/6qnxhmLfIrZUJfHUoY15mOV4uxXh7xL pdKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=P4ZWX4i1+t440lWZRtQ1BMgNbiL9yFdhnyG8Yy4WwyU=; b=u1MvPip0kn3FF6rz5oLHhG/Kd9thZGfK10SBoDkDTwih7Z3vMK1wWIvgAbyMh2tlZ/ 5UuhfinQz/pITqVxBP7bPENKECHcxUV9td66/3G28rM342mojs8BWtLEekrErCjHJTaL hqIBtiOd9nlyPCMW55EEfeCErsMGRA7TXaC0Kh5ndRenbSj0R6fPGrabSOzKB7oW6GPU bvjIUPd4CXAQZYO07nD/9Lj8Uih7FMFKBDj2ikrOkW10VVp2dQzMMCltMcU/aUn/52ko ZSB0yhWBy2sUcRbGUZVIzZVH/Gc+yVzEiZM6o4zBI3cpOxt4gLZGt99XgYPN3XwX7Xgc kwqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iy19-20020a170907819300b0087bd6ca5a89si9332303ejc.62.2023.02.05.07.52.51; Sun, 05 Feb 2023 07:53:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229784AbjBEPtD (ORCPT + 99 others); Sun, 5 Feb 2023 10:49:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjBEPtC (ORCPT ); Sun, 5 Feb 2023 10:49:02 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 630A3EC69; Sun, 5 Feb 2023 07:49:01 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id A6BC192009E; Sun, 5 Feb 2023 16:48:59 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id A23BE92009D; Sun, 5 Feb 2023 15:48:59 +0000 (GMT) Date: Sun, 5 Feb 2023 15:48:59 +0000 (GMT) From: "Maciej W. Rozycki" To: Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni cc: Alex Williamson , Lukas Wunner , Mika Westerberg , Stefan Roese , Jim Wilson , David Abdurachmanov , =?utf-8?q?Pali_Roh?= =?utf-8?q?=C3=A1r?= , linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/7] PCI: Export PCI link retrain timeout In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757006941746623252?= X-GMAIL-MSGID: =?utf-8?q?1757006941746623252?= Rename LINK_RETRAIN_TIMEOUT to PCIE_LINK_RETRAIN_TIMEOUT and make it available via "pci.h" for PCI drivers to use. Signed-off-by: Maciej W. Rozycki --- No change from v5. New change in v5. --- drivers/pci/pci.h | 2 ++ drivers/pci/pcie/aspm.c | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) linux-pcie-link-retrain-timeout.diff Index: linux-macro/drivers/pci/pci.h =================================================================== --- linux-macro.orig/drivers/pci/pci.h +++ linux-macro/drivers/pci/pci.h @@ -11,6 +11,8 @@ #define PCI_VSEC_ID_INTEL_TBT 0x1234 /* Thunderbolt */ +#define PCIE_LINK_RETRAIN_TIMEOUT HZ + extern const unsigned char pcie_link_speed[]; extern bool pci_early_dump; Index: linux-macro/drivers/pci/pcie/aspm.c =================================================================== --- linux-macro.orig/drivers/pci/pcie/aspm.c +++ linux-macro/drivers/pci/pcie/aspm.c @@ -90,8 +90,6 @@ static const char *policy_str[] = { [POLICY_POWER_SUPERSAVE] = "powersupersave" }; -#define LINK_RETRAIN_TIMEOUT HZ - /* * The L1 PM substate capability is only implemented in function 0 in a * multi function device. @@ -213,7 +211,7 @@ static bool pcie_retrain_link(struct pci } /* Wait for link training end. Break out after waiting for timeout */ - end_jiffies = jiffies + LINK_RETRAIN_TIMEOUT; + end_jiffies = jiffies + PCIE_LINK_RETRAIN_TIMEOUT; do { pcie_capability_read_word(parent, PCI_EXP_LNKSTA, ®16); if (!(reg16 & PCI_EXP_LNKSTA_LT)) From patchwork Sun Feb 5 15:49:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 52910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1826200wrn; Sun, 5 Feb 2023 07:53:52 -0800 (PST) X-Google-Smtp-Source: AK7set8rbYOvYYA+iYbfUgqRQ15LFsNpQs70tkTGBFIw3aQjV9I9/0P1oveFYl8BVzENO9gUCZ2+ X-Received: by 2002:a17:907:16a8:b0:89c:7298:2df0 with SMTP id hc40-20020a17090716a800b0089c72982df0mr2780053ejc.23.1675612431858; Sun, 05 Feb 2023 07:53:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675612431; cv=none; d=google.com; s=arc-20160816; b=lzGTbtW3et2hrgtU2bWHZHaOeLdVb3fXmhuqeYnkr/u8e0H4GOpRHBbywFqKwVtAjK ASAjmyr14mXLNbSgiIjF4LFyObMPIZr+gS0OovQuZ+XrO3OkavX6Osb0RaQS3owGb3ed m99itoATcAZlMHAIW9dZnkboAtcf5zN6R1uaNWB34xr+iO8fNmvE7FOLVF7+S+Yg6l1P LuTzBLhwDyDxkUuKDpLZuUjD7awFC+tVrQsQ6e9kkrqZBjtpx+F5id6Aa0j+tEhQUU8v isadriCHA7caZEiXuvhLGN/2QIJA/cPOg943+zqLfRS+O0mk2aKaaXje3627wLh0qrFK 7d8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=9UAHDQR4WiuaoJFFfsgLUZHs44/ilE70iQy/tgrjzJ8=; b=YE1qSbWwAQSuRmVWztx8xPXgKebaZXeway99uatbp7yvp+ObLkya7SQzaekms9P3La b569k+rkg2SDy1W+QiAn+jQ+EM9c0Invd9kkLatJlXaOkxCPmaKx5th57D2xjWb2+sAX Io4/bF85nqzgqzXUq0SgBdyJboTMnYNeConNnCSlpTLbU1Su1Qkn/mgJp07udYKlfkME uvX1jJTvxdNp64pZkoM3KfjQP3WIToFzS0t9Rb5xZiAksmp9Wn4eHDZcgRzG7QjR+h8e 6SI4J9HakcJe0I/CnIRWr2L9OazanM5xOOKAxO4UR4+qN1QO8axhdZJT/e972tD2c9ee epBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p20-20020a1709060dd400b00890d77750a5si5881369eji.864.2023.02.05.07.53.29; Sun, 05 Feb 2023 07:53:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229808AbjBEPtL (ORCPT + 99 others); Sun, 5 Feb 2023 10:49:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbjBEPtF (ORCPT ); Sun, 5 Feb 2023 10:49:05 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DA5441A969 for ; Sun, 5 Feb 2023 07:49:04 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 2C0899200B4; Sun, 5 Feb 2023 16:49:04 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 2908F9200B3; Sun, 5 Feb 2023 15:49:04 +0000 (GMT) Date: Sun, 5 Feb 2023 15:49:04 +0000 (GMT) From: "Maciej W. Rozycki" To: Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni cc: Alex Williamson , Lukas Wunner , Mika Westerberg , Stefan Roese , Jim Wilson , David Abdurachmanov , =?utf-8?q?Pali_Roh?= =?utf-8?q?=C3=A1r?= , linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 2/7] PCI: Execute `quirk_enable_clear_retrain_link' earlier In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757006981334666177?= X-GMAIL-MSGID: =?utf-8?q?1757006981334666177?= Make `quirk_enable_clear_retrain_link' `pci_fixup_early' so that any later fixups can rely on `clear_retrain_link' to have been already initialised. Signed-off-by: Maciej W. Rozycki --- No change from v5. New change in v5. --- drivers/pci/quirks.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) linux-pcie-clear-retrain-link-early.diff Index: linux-macro/drivers/pci/quirks.c =================================================================== --- linux-macro.orig/drivers/pci/quirks.c +++ linux-macro/drivers/pci/quirks.c @@ -2407,9 +2407,9 @@ static void quirk_enable_clear_retrain_l dev->clear_retrain_link = 1; pci_info(dev, "Enable PCIe Retrain Link quirk\n"); } -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PERICOM, 0xe110, quirk_enable_clear_retrain_link); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PERICOM, 0xe111, quirk_enable_clear_retrain_link); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PERICOM, 0xe130, quirk_enable_clear_retrain_link); +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_PERICOM, 0xe110, quirk_enable_clear_retrain_link); +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_PERICOM, 0xe111, quirk_enable_clear_retrain_link); +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_PERICOM, 0xe130, quirk_enable_clear_retrain_link); static void fixup_rev1_53c810(struct pci_dev *dev) { From patchwork Sun Feb 5 15:49:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 52911 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1826291wrn; Sun, 5 Feb 2023 07:54:06 -0800 (PST) X-Google-Smtp-Source: AK7set8xgdsnewF+drJ8ixagaK/Uo48bKIMjLP0l2dWEyaIgmBneQrHaDkXBIc9GTnv4l+ah/OWN X-Received: by 2002:a50:cd83:0:b0:4aa:a51a:24b2 with SMTP id p3-20020a50cd83000000b004aaa51a24b2mr3656093edi.13.1675612445856; Sun, 05 Feb 2023 07:54:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675612445; cv=none; d=google.com; s=arc-20160816; b=TmAsFiCL3jqZZ/b4WCI7HVOrerZxqdwfjPRXD5GmcUd3cSbf2AIFOGaQKpeb+UN38S y/3mBgi4JOq1k1kXhprQOrFqOWAorgjjuO4VzI50S4IriotqnDat7ruF2sdZAbmlQx9s ui2m2CLkexvqgE+X/t9zeKK2Or9hHfwQslLZquWBdwFyVdlKg2ttwWVy+tUP5K4HPDFZ zbP1zGhCusNi4fFH5QzUo8nndqbAv+QBNVptUkVFUHt3jT41UTSP9vHAlP0NXFc/Ile5 DfW/V6/egu63zvh7rLrppKApu+3B572S3ydjn84mQsikQGKfLAkgA2Z/NwiYkJKDi/06 TisQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=9ugHv/TrRDGFKNptkjpoKAqUps6DiYa6ysABuJDXw3Q=; b=Gt7d27TW+41O1061Cshl4+Wzp5tnjBN2urz9ljLz1qrZyIlno5VMA2fiEG2plJmjgs LftxRgWszSnVI3A4++pQluyxDB05yAq2TmGYOOVqtmcEnhsbJLIZ4mskZRAMhlygD5iB 1KfVKLwjYni2O8gpiC5CcvKpJ3ddnP4sBPX4MMs6zEQt8HLkhEzFvk3FZ/dRGAidkbsk B2MR/0ZS3/w8bT602ZLdkB3hPcqkTGkxDuc6ZSK9lsj9hEmu2HAZg6liMlf3ZcFdNQig W3VcIO2/LxWMqKJmGaVMYUrvJ2lWGowv0m0PM6qC3dEXIZ+EHoV+Oxs+zVootbtYxlqa nFDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d3-20020aa7d5c3000000b004a2560e4822si8732418eds.146.2023.02.05.07.53.43; Sun, 05 Feb 2023 07:54:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229809AbjBEPtU (ORCPT + 99 others); Sun, 5 Feb 2023 10:49:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229803AbjBEPtK (ORCPT ); Sun, 5 Feb 2023 10:49:10 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5366C1A4BE for ; Sun, 5 Feb 2023 07:49:09 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 755979200BC; Sun, 5 Feb 2023 16:49:08 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 716119200BB; Sun, 5 Feb 2023 15:49:08 +0000 (GMT) Date: Sun, 5 Feb 2023 15:49:08 +0000 (GMT) From: "Maciej W. Rozycki" To: Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni cc: Alex Williamson , Lukas Wunner , Mika Westerberg , Stefan Roese , Jim Wilson , David Abdurachmanov , =?utf-8?q?Pali_Roh?= =?utf-8?q?=C3=A1r?= , linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 3/7] PCI: Initialize `link_active_reporting' earlier In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757006995949018453?= X-GMAIL-MSGID: =?utf-8?q?1757006995949018453?= Determine whether Data Link Layer Link Active Reporting is available ahead of calling any fixups so that the cached value can be used there and later on. Signed-off-by: Maciej W. Rozycki --- New change in v6. --- drivers/pci/probe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) linux-pcie-link-active-reporting-early.diff Index: linux-macro/drivers/pci/probe.c =================================================================== --- linux-macro.orig/drivers/pci/probe.c +++ linux-macro/drivers/pci/probe.c @@ -819,7 +819,6 @@ static void pci_set_bus_speed(struct pci pcie_capability_read_dword(bridge, PCI_EXP_LNKCAP, &linkcap); bus->max_bus_speed = pcie_link_speed[linkcap & PCI_EXP_LNKCAP_SLS]; - bridge->link_active_reporting = !!(linkcap & PCI_EXP_LNKCAP_DLLLARC); pcie_capability_read_word(bridge, PCI_EXP_LNKSTA, &linksta); pcie_update_link_speed(bus, linksta); @@ -1828,6 +1827,7 @@ int pci_setup_device(struct pci_dev *dev int pos = 0; struct pci_bus_region region; struct resource *res; + u32 linkcap; hdr_type = pci_hdr_type(dev); @@ -1873,6 +1873,10 @@ int pci_setup_device(struct pci_dev *dev /* "Unknown power state" */ dev->current_state = PCI_UNKNOWN; + /* Set it early to make it available to fixups, etc. */ + pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, &linkcap); + dev->link_active_reporting = !!(linkcap & PCI_EXP_LNKCAP_DLLLARC); + /* Early fixups, before probing the BARs */ pci_fixup_device(pci_fixup_early, dev); From patchwork Sun Feb 5 15:49:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 52912 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1826632wrn; Sun, 5 Feb 2023 07:55:14 -0800 (PST) X-Google-Smtp-Source: AK7set+iuk+Dxq+FsyvRvvd3CftPCj0TziyNpwSIDLtNMdgGqx3R+plNuNY1har9hV+deCFJSyD/ X-Received: by 2002:a05:6402:1505:b0:4a2:254f:6b1a with SMTP id f5-20020a056402150500b004a2254f6b1amr15778757edw.11.1675612514644; Sun, 05 Feb 2023 07:55:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675612514; cv=none; d=google.com; s=arc-20160816; b=FVlwrwVpqj5TmPuQwX6OaV6izR2Zn6RIXPFM7Y4wPRNB5Sj5zg8dir/6Cy3eRr9p7Y 3+CaMMtKLOMI3jjBiu4SDcW/5AODpV7JStliPl0lJpH35HXrkJf49KNVIc3zcq5Pqei+ bYXqU2fNMlLupsFknSacCFxHgf7bVHlJWGaYyBCrgzAG/sRWXWaaL1jqYRR5rzUIEpNs vs1GQFKHWsVByLqFaClK+dT/dTNJSHYbxoSEHhSVMh5NwM7EGqXGwvptHc9Rzo95Ur9I iY0vkMbP9POYCSYdbibiADLyCjOIn8ERWAppERc8o4M2fYf5dwpHHFrIhAsvDUEr47Wm Yetg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=G047IZ3Y2vbITp3CDWT/84PczBqe6Kmw1wuHzwXyjWw=; b=d0m7glINBbhSFUOoWGfU6wsMF9xaDwp3JP9EFkT5UfGbSb9SPZecn4W6HDaa12e73k du0ZT4zLVIpD60WsrEBXq2HXk+XfdFMuktWQchUfiU/B+QDdY/F0yitqfiFpUBbSOcAJ S6+tgDfAYgubeB2OnJqxOhHTpsOyqOwjYMmyfFmCWGNZ+c3WYAUd54MuG4/7XztBThfx KJUoLN/NgO3+v1uX4X9BBZn3vs7azs0KNTtxzR1fT8aC2H3+O9kTrNij6PEJ2AgC4fbN EQxaFuq+4mnhnYAUeiSUHscalI+CdR7w3Ipgsgkv59NMOJaCU0/tfXFqqR9jZSE6Z3QW AqiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u17-20020aa7d0d1000000b0046b05ca8929si9047413edo.592.2023.02.05.07.54.51; Sun, 05 Feb 2023 07:55:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbjBEPtm (ORCPT + 99 others); Sun, 5 Feb 2023 10:49:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbjBEPtY (ORCPT ); Sun, 5 Feb 2023 10:49:24 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0C2961F4B0; Sun, 5 Feb 2023 07:49:13 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 97BD39200C0; Sun, 5 Feb 2023 16:49:12 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 910D59200BF; Sun, 5 Feb 2023 15:49:12 +0000 (GMT) Date: Sun, 5 Feb 2023 15:49:12 +0000 (GMT) From: "Maciej W. Rozycki" To: Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni cc: Alex Williamson , Lukas Wunner , Mika Westerberg , Stefan Roese , Jim Wilson , David Abdurachmanov , =?utf-8?q?Pali_Roh?= =?utf-8?q?=C3=A1r?= , linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 4/7] powerpc/eeh: Rely on `link_active_reporting' In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757007068076689448?= X-GMAIL-MSGID: =?utf-8?q?1757007068076689448?= Use `link_active_reporting' to determine whether Data Link Layer Link Active Reporting is available rather than re-retrieving the capability. Signed-off-by: Maciej W. Rozycki --- NB this has been compile-tested only with a PPC64LE configuration. New change in v6. --- arch/powerpc/kernel/eeh_pe.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) linux-pcie-link-active-reporting-eeh.diff Index: linux-macro/arch/powerpc/kernel/eeh_pe.c =================================================================== --- linux-macro.orig/arch/powerpc/kernel/eeh_pe.c +++ linux-macro/arch/powerpc/kernel/eeh_pe.c @@ -671,9 +671,8 @@ static void eeh_bridge_check_link(struct eeh_ops->write_config(edev, cap + PCI_EXP_LNKCTL, 2, val); /* Check link */ - eeh_ops->read_config(edev, cap + PCI_EXP_LNKCAP, 4, &val); - if (!(val & PCI_EXP_LNKCAP_DLLLARC)) { - eeh_edev_dbg(edev, "No link reporting capability (0x%08x) \n", val); + if (!edev->pdev->link_active_reporting) { + eeh_edev_dbg(edev, "No link reporting capability\n"); msleep(1000); return; } From patchwork Sun Feb 5 15:49:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 52913 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1826645wrn; Sun, 5 Feb 2023 07:55:16 -0800 (PST) X-Google-Smtp-Source: AK7set/SwmYzlwMaXKAv7DhU6KHWbwXIfgXP8g1Wwa7A0Rsqdt8hFiu1WbvxI+yzQMThXayGurbm X-Received: by 2002:a05:6402:1ca3:b0:4a2:1033:4e29 with SMTP id cz3-20020a0564021ca300b004a210334e29mr16775918edb.3.1675612516364; Sun, 05 Feb 2023 07:55:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675612516; cv=none; d=google.com; s=arc-20160816; b=mgE7VKTw1T0mtKPc7zyHyFD6PBFlS/+2DCID3kAlhydoyczG7zcpW8RP1rrwBHiNCH jdlJWEXMpVxQaNfT/8RaUa0BPek9rVr92oTcZ85y5GeteZJ+lzQSeRTn1yH4yK+eOkQG 2daxsJanNqwey1bwgX5nJUXiCBuFHP3UDS7BekffYpneAh4LDYzqVbZKqNNIA3+8Z5Or d2ebzkD+9c4oWmer9eP3Adw9eK3QsoYEuxGHCHjFlFqBEJkD+QCmoWv4TLNRwPIKszM1 5IK/cRnFpvql20euYHx2X5I1bnrFun397OnbPxy8qxdKJgXR2GRbW5jEb9+TptUgvI72 jhSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=Gl5f1qnzoTV3AYMFrXRN6E1s3Z1hGJoSC9LO4SIN8Fk=; b=lBlsgRenOHZ+wZjSlHx8sfrbuinIzcy79MRE2dwf9Qjh0vRLVGwqoAZHTxk9Ap1Gbf d9kDvewD4CutWTlExS5FarYlUHvG7LTJhqoBQAOhe4i7rJw5nUK0K4uZrGJjbx+Ej6Vr XbHz2uZfCl4PmoDc4tg8818LaqQx/mWlDmXqb40sdEYiFCR87WxUN9rF72PiGLYeiUL9 pEU8+cnDCZJeV5YcH/koIb/zqqledI8zjCo1J6x/+oLBjP5DQx+TWra4Ue++IVHaXYJd rlfEeYOUP20eGmISSZYL7D98j2tvvhYZG86ZiB2wYRvi0Ps1v4RDI0pYU3FdfLF4sYlU NazA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m24-20020a056402051800b004a08fd958aesi8636231edv.430.2023.02.05.07.54.53; Sun, 05 Feb 2023 07:55:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229868AbjBEPtx (ORCPT + 99 others); Sun, 5 Feb 2023 10:49:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbjBEPth (ORCPT ); Sun, 5 Feb 2023 10:49:37 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 347A71ADDB for ; Sun, 5 Feb 2023 07:49:17 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 6D2B29200C4; Sun, 5 Feb 2023 16:49:16 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 6A1A89200C3; Sun, 5 Feb 2023 15:49:16 +0000 (GMT) Date: Sun, 5 Feb 2023 15:49:16 +0000 (GMT) From: "Maciej W. Rozycki" To: Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni cc: Alex Williamson , Lukas Wunner , Mika Westerberg , Stefan Roese , Jim Wilson , David Abdurachmanov , =?utf-8?q?Pali_Roh?= =?utf-8?q?=C3=A1r?= , linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 5/7] net/mlx5: Rely on `link_active_reporting' In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757007069552033479?= X-GMAIL-MSGID: =?utf-8?q?1757007069552033479?= Use `link_active_reporting' to determine whether Data Link Layer Link Active Reporting is available rather than re-retrieving the capability. Signed-off-by: Maciej W. Rozycki --- NB this has been compile-tested only with PPC64LE and x86-64 configurations. New change in v6. --- drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) linux-pcie-link-active-reporting-mlx5.diff Index: linux-macro/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c =================================================================== --- linux-macro.orig/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +++ linux-macro/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c @@ -294,7 +294,6 @@ static int mlx5_pci_link_toggle(struct m unsigned long timeout; struct pci_dev *sdev; int cap, err; - u32 reg32; /* Check that all functions under the pci bridge are PFs of * this device otherwise fail this function. @@ -333,11 +332,8 @@ static int mlx5_pci_link_toggle(struct m return err; /* Check link */ - err = pci_read_config_dword(bridge, cap + PCI_EXP_LNKCAP, ®32); - if (err) - return err; - if (!(reg32 & PCI_EXP_LNKCAP_DLLLARC)) { - mlx5_core_warn(dev, "No PCI link reporting capability (0x%08x)\n", reg32); + if (!bridge->link_active_reporting) { + mlx5_core_warn(dev, "No PCI link reporting capability\n"); msleep(1000); goto restore; } From patchwork Sun Feb 5 15:49:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 52914 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1827324wrn; Sun, 5 Feb 2023 07:57:25 -0800 (PST) X-Google-Smtp-Source: AK7set8LwnkyT4MKYRHH0lLU6DKXr/iefF3hNQ2Qcye2MWVfWbhPtQUMwrcSuAvZmOzBTgjI32ZG X-Received: by 2002:a50:9b55:0:b0:4aa:b247:6140 with SMTP id a21-20020a509b55000000b004aab2476140mr1537965edj.23.1675612645399; Sun, 05 Feb 2023 07:57:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675612645; cv=none; d=google.com; s=arc-20160816; b=S3qBATyTDzITPIrkgH63bCx26QMleEqdRfJAp5uf1LN1CI3FwWgq7Igli4tByMEeFi 4Ncc60NSLONmM1RQHNFUBGKEUMokajRbsiI1CCwfr/XoypZY62jsBtTRl5cwPsETh/rV St/Hg1QunSa6A6rakI5A4NuStFYrNUK+waEPjh66n8j2/EjEoLwE1U0TWbhBcyVVD9rm nT3DllVnGXpSzCnaSa9jfK5d5yZXvhYAqrU+lYEuoOpsRydeuz5Ni7MRUQk61ROa1PEG WZLxLxYN2Qs1Wxo+iKVHHSgyamr0lXMejYcYKqZ+2kvuYpVCcqB8XMROI5Age8Unt6fj V9Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=PzXqNjyl5BdLNs9/pZ6GblrM7kV5nO+cVOzum2WsFzo=; b=FkzZgk9uzi/SJ9TGZwMCWYQ9TVO8yBs6IsiVatD3IoRRlCT0zwXiwSrqEPIDCPmEYL 37qdkzVCBPtOtLDyEdlekuDlJFJHfGE9RlL8HZxhVnBI8AsEOnU/yw6mDMMoVknoL5FW //0gOTcbGys/sl5+IW/lwAmSJM0Q76IWbH0Mv0dJiu8fOKcEtRhog31S5/ugjJEUDgmO 7P5c1IURO3QvpxKOxcyJBmVpz0HLpSQF4/6zTIUp0N2/7bqlCJ/a6tmCRjLXFeF8KUAi UvcE6PBAzfsjQh5Ll+UIreLyUB0SAqTUHSKTyFiARb76VVGuawh8hYf/c9epnpi7kjDW H3nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fd13-20020a056402388d00b004a90bb88100si9769287edb.260.2023.02.05.07.57.01; Sun, 05 Feb 2023 07:57:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbjBEPt7 (ORCPT + 99 others); Sun, 5 Feb 2023 10:49:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbjBEPtu (ORCPT ); Sun, 5 Feb 2023 10:49:50 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0C7511ADE9; Sun, 5 Feb 2023 07:49:23 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 60B849200CC; Sun, 5 Feb 2023 16:49:21 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 5A74C9200CB; Sun, 5 Feb 2023 15:49:21 +0000 (GMT) Date: Sun, 5 Feb 2023 15:49:21 +0000 (GMT) From: "Maciej W. Rozycki" To: Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni cc: Alex Williamson , Lukas Wunner , Mika Westerberg , Stefan Roese , Jim Wilson , David Abdurachmanov , =?utf-8?q?Pali_Roh?= =?utf-8?q?=C3=A1r?= , linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 6/7] PCI: pciehp: Rely on `link_active_reporting' In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757007205517216355?= X-GMAIL-MSGID: =?utf-8?q?1757007205517216355?= Use `link_active_reporting' to determine whether Data Link Layer Link Active Reporting is available rather than re-retrieving the capability. Signed-off-by: Maciej W. Rozycki Reviewed-by: Lukas Wunner --- NB this has been compile-tested only with PPC64LE and x86-64 configurations. New change in v6. --- drivers/pci/hotplug/pciehp_hpc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) linux-pcie-link-active-reporting-hpc.diff Index: linux-macro/drivers/pci/hotplug/pciehp_hpc.c =================================================================== --- linux-macro.orig/drivers/pci/hotplug/pciehp_hpc.c +++ linux-macro/drivers/pci/hotplug/pciehp_hpc.c @@ -984,7 +984,7 @@ static inline int pcie_hotplug_depth(str struct controller *pcie_init(struct pcie_device *dev) { struct controller *ctrl; - u32 slot_cap, slot_cap2, link_cap; + u32 slot_cap, slot_cap2; u8 poweron; struct pci_dev *pdev = dev->port; struct pci_bus *subordinate = pdev->subordinate; @@ -1030,9 +1030,6 @@ struct controller *pcie_init(struct pcie if (dmi_first_match(inband_presence_disabled_dmi_table)) ctrl->inband_presence_disabled = 1; - /* Check if Data Link Layer Link Active Reporting is implemented */ - pcie_capability_read_dword(pdev, PCI_EXP_LNKCAP, &link_cap); - /* Clear all remaining event bits in Slot Status register. */ pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD | @@ -1051,7 +1048,7 @@ struct controller *pcie_init(struct pcie FLAG(slot_cap, PCI_EXP_SLTCAP_EIP), FLAG(slot_cap, PCI_EXP_SLTCAP_NCCS), FLAG(slot_cap2, PCI_EXP_SLTCAP2_IBPD), - FLAG(link_cap, PCI_EXP_LNKCAP_DLLLARC), + FLAG(pdev->link_active_reporting, true), pdev->broken_cmd_compl ? " (with Cmd Compl erratum)" : ""); /* From patchwork Sun Feb 5 15:49:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 52915 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1827560wrn; Sun, 5 Feb 2023 07:58:05 -0800 (PST) X-Google-Smtp-Source: AK7set92rrp+8cOcmXRkFBrL7empyqDHPedgNbPSYLguOPcc30L+6i1GROYXstZtlpQBUQ2XuiJu X-Received: by 2002:a17:906:b5a:b0:878:72f7:bd99 with SMTP id v26-20020a1709060b5a00b0087872f7bd99mr16548639ejg.6.1675612685181; Sun, 05 Feb 2023 07:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675612685; cv=none; d=google.com; s=arc-20160816; b=sTHPzd0xUUCn+cDHb47asm7xeQsOCZbjIDDIH5wIf5pBSEZSP5q80NC9iv9be4PZrF 5uZRaOjVcsQmJ1cfnRY86mMd8u+OB3KunTwW9rJTpnvYPOLwEfiwauvzEKG24zIYJ2MP rUEW3lya65+Y1O0KHdxqYBlyLwe6dxs3iZkfO4tKE7lBmTB2rwF3fDWwKT/IrNDuD2ut Gku7JHCTULlGtDuZ5bj+t1wr0B2BQkUjrJSzj+Dh3SLUl+Fr56k2fTYTp6iTARu5UxXb 3zzUGxlukZyIeij5CwbYxUCHApBZv3pmWNUGsPD+/Kb6LT8kVHNmuAM2OlpumBgaMQsp xELQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=/lV38wdDw2tcKLrml8j54lhG+Vgr99lIh5A5fUG77MI=; b=SpL5++aaF8vjIXqXLCDKHESUmcTQSyS+z2jJ7R87EpMhA4ikvLeA5pBwxggWQKTSsN Su58EHekV+Pj5LB7w9sxxRfzjQbwbtZJWll8EOq6LcAVemMrokbtFxWOYaBSQDOxNAvR FWaNbdHh2qbwUUWOn9UZnSDLWyj0kcgyl9YmMEASw7zSmBbm1PkyzHe0r6dgxzQTju3g wkV+SAF5DKMvqtsF26hdLPAXuZY9Zc95QFNvpk4UPgcgToj6pS+0D6iHA153UcvS8EoA +Pmm+mhL4iK6oEfXAOFnwxb5+QxUBgZtEuS04DZUa0aVjvVvczX0GSndUwMofaPeUFwP E8GQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t5-20020a056402524500b0046bb35e06e6si8842142edd.149.2023.02.05.07.57.41; Sun, 05 Feb 2023 07:58:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229632AbjBEPyv (ORCPT + 99 others); Sun, 5 Feb 2023 10:54:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbjBEPyp (ORCPT ); Sun, 5 Feb 2023 10:54:45 -0500 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CC1AC171D; Sun, 5 Feb 2023 07:54:43 -0800 (PST) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 90ECE9200C3; Sun, 5 Feb 2023 16:49:27 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 8A5369200BF; Sun, 5 Feb 2023 15:49:27 +0000 (GMT) Date: Sun, 5 Feb 2023 15:49:27 +0000 (GMT) From: "Maciej W. Rozycki" To: Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni cc: Alex Williamson , Lukas Wunner , Mika Westerberg , Stefan Roese , Jim Wilson , David Abdurachmanov , =?utf-8?q?Pali_Roh?= =?utf-8?q?=C3=A1r?= , linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 7/7] PCI: Work around PCIe link training failures In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757007246888610928?= X-GMAIL-MSGID: =?utf-8?q?1757007246888610928?= Attempt to handle cases such as with a downstream port of the ASMedia ASM2824 PCIe switch where link training never completes and the link continues switching between speeds indefinitely with the data link layer never reaching the active state. It has been observed with a downstream port of the ASMedia ASM2824 Gen 3 switch wired to the upstream port of the Pericom PI7C9X2G304 Gen 2 switch, using a Delock Riser Card PCI Express x1 > 2 x PCIe x1 device, P/N 41433, wired to a SiFive HiFive Unmatched board. In this setup the switches are supposed to negotiate the link speed of preferably 5.0GT/s, falling back to 2.5GT/s. Instead the link continues oscillating between the two speeds, at the rate of 34-35 times per second, with link training reported repeatedly active ~84% of the time. Forcibly limiting the target link speed to 2.5GT/s with the upstream ASM2824 device however makes the two switches communicate correctly. Removing the speed restriction afterwards makes the two devices switch to 5.0GT/s then. Make use of these observations then and detect the inability to train the link, by checking for the Data Link Layer Link Active status bit being off while the Link Bandwidth Management Status indicating that hardware has changed the link speed or width in an attempt to correct unreliable link operation. Restrict the speed to 2.5GT/s then with the Target Link Speed field, request a retrain and wait 200ms for the data link to go up. If this turns out successful, then lift the restriction, letting the devices negotiate a higher speed. Also check for a 2.5GT/s speed restriction the firmware may have already arranged and lift it too with ports of devices known to continue working afterwards, currently the ASM2824 only, that already report their data link being up. Signed-off-by: Maciej W. Rozycki Link: https://lore.kernel.org/lkml/alpine.DEB.2.21.2203022037020.56670@angie.orcam.me.uk/ Link: https://source.denx.de/u-boot/u-boot/-/commit/a398a51ccc68 --- Changes from v5: - Move from a quirk into PCI core and call at device probing, hot-plug, reset and resume. Keep the ASMedia part under CONFIG_PCI_QUIRKS. - Rely on `dev->link_active_reporting' rather than re-retrieving the capability. Changes from v4: - Remove inclusion no longer needed. - Make the quirk generic based on probing device features rather than specific to the ASM2824 part only; take the Retrain Link bit erratum into account. - Still lift the 2.5GT/s speed restriction with the ASM2824 only. - Increase retrain timeout from 200ms to 1s (PCIE_LINK_RETRAIN_TIMEOUT). - Remove retrain success notification. - Use PCIe helpers rather than generic PCI functions throughout. - Trim down and update the wording of the change description for the switch from an ASM2824-specific to a generic fixup. Changes from v3: - Remove the entry for the ASM2824. Changes from v2: - Regenerate for 5.17-rc2 for a merge conflict. - Replace BUG_ON for a missing PCI Express capability with WARN_ON and an early return. Changes from v1: - Regenerate for a merge conflict. --- drivers/pci/pci.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++-- drivers/pci/pci.h | 1 drivers/pci/probe.c | 2 3 files changed, 152 insertions(+), 5 deletions(-) linux-pcie-asm2824-manual-retrain.diff Index: linux-macro/drivers/pci/pci.c =================================================================== --- linux-macro.orig/drivers/pci/pci.c +++ linux-macro/drivers/pci/pci.c @@ -859,6 +859,132 @@ int pci_wait_for_pending(struct pci_dev return 0; } +/* + * Retrain the link of a downstream PCIe port by hand if necessary. + * + * This is needed at least where a downstream port of the ASMedia ASM2824 + * Gen 3 switch is wired to the upstream port of the Pericom PI7C9X2G304 + * Gen 2 switch, and observed with the Delock Riser Card PCI Express x1 > + * 2 x PCIe x1 device, P/N 41433, plugged into the SiFive HiFive Unmatched + * board. + * + * In such a configuration the switches are supposed to negotiate the link + * speed of preferably 5.0GT/s, falling back to 2.5GT/s. However the link + * continues switching between the two speeds indefinitely and the data + * link layer never reaches the active state, with link training reported + * repeatedly active ~84% of the time. Forcing the target link speed to + * 2.5GT/s with the upstream ASM2824 device makes the two switches talk to + * each other correctly however. And more interestingly retraining with a + * higher target link speed afterwards lets the two successfully negotiate + * 5.0GT/s. + * + * With the ASM2824 we can rely on the otherwise optional Data Link Layer + * Link Active status bit and in the failed link training scenario it will + * be off along with the Link Bandwidth Management Status indicating that + * hardware has changed the link speed or width in an attempt to correct + * unreliable link operation. For a port that has been left unconnected + * both bits will be clear. So use this information to detect the problem + * rather than polling the Link Training bit and watching out for flips or + * at least the active status. + * + * Since the exact nature of the problem isn't known and in principle this + * could trigger where an ASM2824 device is downstream rather upstream, + * apply this erratum workaround to any downstream ports as long as they + * support Link Active reporting and have the Link Control 2 register. + * Restrict the speed to 2.5GT/s then with the Target Link Speed field, + * request a retrain and wait 200ms for the data link to go up. + * + * If this turns out successful and we know by the Vendor:Device ID it is + * safe to do so, then lift the restriction, letting the devices negotiate + * a higher speed. Also check for a similar 2.5GT/s speed restriction the + * firmware may have already arranged and lift it with ports that already + * report their data link being up. + * + * Return 0 if the link has been successfully retrained, otherwise -1. + */ +int pcie_downstream_link_retrain(struct pci_dev *dev) +{ + static const struct pci_device_id ids[] = { + { PCI_VDEVICE(ASMEDIA, 0x2824) }, /* ASMedia ASM2824 */ + {} + }; + u16 lnksta, lnkctl2; + + if (!pci_is_pcie(dev) || !pcie_downstream_port(dev) || + !pcie_cap_has_lnkctl2(dev) || !dev->link_active_reporting) + return -1; + + pcie_capability_read_word(dev, PCI_EXP_LNKCTL2, &lnkctl2); + pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnksta); + if ((lnksta & (PCI_EXP_LNKSTA_LBMS | PCI_EXP_LNKSTA_DLLLA)) == + PCI_EXP_LNKSTA_LBMS) { + unsigned long timeout; + u16 lnkctl; + + pci_info(dev, "broken device, retraining non-functional downstream link at 2.5GT/s\n"); + + pcie_capability_read_word(dev, PCI_EXP_LNKCTL, &lnkctl); + lnkctl |= PCI_EXP_LNKCTL_RL; + lnkctl2 &= ~PCI_EXP_LNKCTL2_TLS; + lnkctl2 |= PCI_EXP_LNKCTL2_TLS_2_5GT; + pcie_capability_write_word(dev, PCI_EXP_LNKCTL2, lnkctl2); + pcie_capability_write_word(dev, PCI_EXP_LNKCTL, lnkctl); + /* + * Due to an erratum in some devices the Retrain Link bit + * needs to be cleared again manually to allow the link + * training to succeed. + */ + lnkctl &= ~PCI_EXP_LNKCTL_RL; + if (dev->clear_retrain_link) + pcie_capability_write_word(dev, PCI_EXP_LNKCTL, + lnkctl); + + timeout = jiffies + PCIE_LINK_RETRAIN_TIMEOUT; + do { + pcie_capability_read_word(dev, PCI_EXP_LNKSTA, + &lnksta); + if (lnksta & PCI_EXP_LNKSTA_DLLLA) + break; + usleep_range(10000, 20000); + } while (time_before(jiffies, timeout)); + + if (!(lnksta & PCI_EXP_LNKSTA_DLLLA)) { + pci_info(dev, "retraining failed\n"); + return -1; + } + } + + if (IS_ENABLED(CONFIG_PCI_QUIRKS) && (lnksta & PCI_EXP_LNKSTA_DLLLA) && + (lnkctl2 & PCI_EXP_LNKCTL2_TLS) == PCI_EXP_LNKCTL2_TLS_2_5GT && + pci_match_id(ids, dev)) { + u32 lnkcap; + u16 lnkctl; + + pci_info(dev, "removing 2.5GT/s downstream link speed restriction\n"); + pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, &lnkcap); + pcie_capability_read_word(dev, PCI_EXP_LNKCTL, &lnkctl); + lnkctl |= PCI_EXP_LNKCTL_RL; + lnkctl2 &= ~PCI_EXP_LNKCTL2_TLS; + lnkctl2 |= lnkcap & PCI_EXP_LNKCAP_SLS; + pcie_capability_write_word(dev, PCI_EXP_LNKCTL2, lnkctl2); + pcie_capability_write_word(dev, PCI_EXP_LNKCTL, lnkctl); + } + + return 0; +} + +/* Same as above, but called for a downstream device. */ +static int pcie_upstream_link_retrain(struct pci_dev *dev) +{ + struct pci_dev *bridge; + + bridge = pci_upstream_bridge(dev); + if (bridge) + return pcie_downstream_link_retrain(bridge); + else + return -1; +} + static int pci_acs_enable; /** @@ -1148,8 +1274,8 @@ void pci_resume_bus(struct pci_bus *bus) static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) { + int retrain = 0; int delay = 1; - u32 id; /* * After reset, the device should not silently discard config @@ -1163,21 +1289,37 @@ static int pci_dev_wait(struct pci_dev * * Command register instead of Vendor ID so we don't have to * contend with the CRS SV value. */ - pci_read_config_dword(dev, PCI_COMMAND, &id); - while (PCI_POSSIBLE_ERROR(id)) { + for (;;) { + u32 id; + + pci_read_config_dword(dev, PCI_COMMAND, &id); + if (!PCI_POSSIBLE_ERROR(id)) { + if (delay > PCI_RESET_WAIT) + pci_info(dev, "ready %dms after %s\n", + delay - 1, reset_type); + break; + } + if (delay > timeout) { pci_warn(dev, "not ready %dms after %s; giving up\n", delay - 1, reset_type); return -ENOTTY; } - if (delay > PCI_RESET_WAIT) + if (delay > PCI_RESET_WAIT) { + if (!retrain) { + retrain = 1; + if (pcie_upstream_link_retrain(dev) == 0) { + delay = 1; + continue; + } + } pci_info(dev, "not ready %dms after %s; waiting\n", delay - 1, reset_type); + } msleep(delay); delay *= 2; - pci_read_config_dword(dev, PCI_COMMAND, &id); } if (delay > PCI_RESET_WAIT) @@ -4901,6 +5043,8 @@ static bool pcie_wait_for_link_delay(str msleep(10); timeout -= 10; } + if (active && !ret) + ret = pcie_downstream_link_retrain(pdev) == 0; if (active && ret) msleep(delay); Index: linux-macro/drivers/pci/pci.h =================================================================== --- linux-macro.orig/drivers/pci/pci.h +++ linux-macro/drivers/pci/pci.h @@ -37,6 +37,7 @@ int pci_mmap_fits(struct pci_dev *pdev, enum pci_mmap_api mmap_api); bool pci_reset_supported(struct pci_dev *dev); +int pcie_downstream_link_retrain(struct pci_dev *dev); void pci_init_reset_methods(struct pci_dev *dev); int pci_bridge_secondary_bus_reset(struct pci_dev *dev); int pci_bus_error_reset(struct pci_dev *dev); Index: linux-macro/drivers/pci/probe.c =================================================================== --- linux-macro.orig/drivers/pci/probe.c +++ linux-macro/drivers/pci/probe.c @@ -2546,6 +2546,8 @@ void pci_device_add(struct pci_dev *dev, dma_set_max_seg_size(&dev->dev, 65536); dma_set_seg_boundary(&dev->dev, 0xffffffff); + pcie_downstream_link_retrain(dev); + /* Fix up broken headers */ pci_fixup_device(pci_fixup_header, dev);