Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4585345rwd; Sun, 11 Jun 2023 10:22:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4FWBG1W+4XqpFlv1SxDWLxC0ciVJFi1uPLMIxISVIufBHMtJhq1romCJiz05c77Oo5qux4 X-Received: by 2002:a05:6402:88e:b0:514:964c:4c42 with SMTP id e14-20020a056402088e00b00514964c4c42mr3656483edy.8.1686504136561; Sun, 11 Jun 2023 10:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686504136; cv=none; d=google.com; s=arc-20160816; b=TQi0eRsvSx7h5Ln5EmwBpWtntHfjfD3xMD54pnn9qmyUyhFRXa/xLZMiJI4vacyLzd U1uyIf+dQchsAEeI4CiGawnJCaiEs/GhGxL3Xm2vA77MLlVjvz+z24tpo/CCnxqbXous o9+XFW8Gtbw4fy6UG2YXg6zkJZswwczSx2H4PD+p+KnZZK2+rKRZpHL5IQp1iL3ZyYZB GOWTOxKAurOPgC77T7rLVAQrDDn5YRw4Ff9JLhmYTkso1yT6Du8j3Psx39mjW6wmiNyK RMZuWKUDZ2if3IQztiIajmbuNRWKZho1hywtuG7ykUS1GHrEJz91Y10orz6Om/qQBBQi xm2Q== 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=jXtpYvkKk9QWqpFGXcqUbxFOs23Zj1fwmi1JYXP7DEM=; b=AmPTj5KhjIjYLAAQm8w+G6OX5xswvLaqwCn4cx69eIBKhFxntdu8Ob/O7H4xMCteoR wgnTUD84wQOyLzA3jqQVFxp4DvxLmZ0sS+T9NpInyYz8YuIKJSfSifai/7dWy51FJisc jUjjJIjYDXUpdhDewT7bZySKszmrCaZfWHmvQQHv6tisSSQFimcsuwgxXNNCADKOmomx +qrsREo0IgCkAmlHshg/mFF3bHAit/YKW6FPe5Ae7vBjiGoT/UOcA3Z8PDSE/ALd1jfQ ClAD978zNYIPkUlqEntZ75K9qPgIPSmFh1DAKquRBvShM0y/D9nvuPx1PazKsK1TB3AS ONVg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020a50eb0a000000b00516acdfe14csi5429647edp.327.2023.06.11.10.21.52; Sun, 11 Jun 2023 10:22:16 -0700 (PDT) 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 S233530AbjFKRTX (ORCPT + 99 others); Sun, 11 Jun 2023 13:19:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233665AbjFKRTV (ORCPT ); Sun, 11 Jun 2023 13:19:21 -0400 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 57FD6E68; Sun, 11 Jun 2023 10:19:20 -0700 (PDT) Received: by angie.orcam.me.uk (Postfix, from userid 500) id B62CE9200BC; Sun, 11 Jun 2023 19:19:19 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id AEEC09200B3; Sun, 11 Jun 2023 18:19:19 +0100 (BST) Date: Sun, 11 Jun 2023 18:19:19 +0100 (BST) 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=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 v9 02/14] PCI: Export PCIe link retrain timeout In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Convert LINK_RETRAIN_TIMEOUT from jiffies to milliseconds, accordingly rename to PCIE_LINK_RETRAIN_TIMEOUT_MS, and make available via "pci.h" for PCI drivers to use. Use in `pcie_wait_for_link_delay'. Signed-off-by: Maciej W. Rozycki --- Changes from v8: - Convert LINK_RETRAIN_TIMEOUT from jiffies to milliseconds, rename it to PCIE_LINK_RETRAIN_TIMEOUT_MS rather than PCIE_LINK_RETRAIN_TIMEOUT, and adjust its use accordingly. - Also replace hardcoded 1000 in `pcie_wait_for_link_delay'. - Correct the change heading, s/PCI/PCIe/ for the link reference. Changes from v7: - Reorder from 1/7. No change from v6. No change from v5. New change in v5. --- drivers/pci/pci.c | 2 +- drivers/pci/pci.h | 2 ++ drivers/pci/pcie/aspm.c | 4 +--- 3 files changed, 4 insertions(+), 4 deletions(-) linux-pcie-link-retrain-timeout.diff Index: linux-macro/drivers/pci/pci.c =================================================================== --- linux-macro.orig/drivers/pci/pci.c +++ linux-macro/drivers/pci/pci.c @@ -4860,7 +4860,7 @@ static int pci_pm_reset(struct pci_dev * static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active, int delay) { - int timeout = 1000; + int timeout = PCIE_LINK_RETRAIN_TIMEOUT_MS; bool ret; u16 lnk_status; 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_MS 1000 + 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 + msecs_to_jiffies(PCIE_LINK_RETRAIN_TIMEOUT_MS); do { pcie_capability_read_word(parent, PCI_EXP_LNKSTA, ®16); if (!(reg16 & PCI_EXP_LNKSTA_LT))