Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4603919rwd; Sun, 11 Jun 2023 10:49:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5dvMwuJOlCKoGjhPEEVqQfbSBfOyAezsSd0HdDf219a95DNcPzOCLyuevMZML4fcrBXzz/ X-Received: by 2002:a17:907:320c:b0:976:8fdd:9046 with SMTP id xg12-20020a170907320c00b009768fdd9046mr6769574ejb.12.1686505795691; Sun, 11 Jun 2023 10:49:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686505795; cv=none; d=google.com; s=arc-20160816; b=H6wnHrR+AdNeB/20p5mk4ov4Pk781SVknU9M0GkdnGI5ir/YgAElW9Uq6zW3AfK/Sh JWYh69MSETKoy1kNGxfE33GMdp4HA2G0N5Egcl0Yzjz5sn/Cm5GE0O8Zkr7pc5hRgoo7 lQJkahlTn5I6TuK3TXmpxa+cON0Q6IOPlExKep4/xTklwgdMMuLiqxM+D0DdW7MGy172 2u4mF3lNe0V+R7Uj/5YaCL3Qh84ddMNgf1yOdu8heWjwqnThnKMfmYVY844dpVFBmTji Xzh5paQGr69aZyZd/+Abt2fDXQ5heMTVe/z2UzQiTLc6tLzo3xaeasAyb6lsF3vT62kq ym8Q== 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=y+2Iv8iqD/YoX2tQg597P+BNOZ5EFD2yj/px1/Lej4c=; b=hyKAHzVNIm4AHztqBenDyy49j6jmner1DxjUfcbHf7DIpXfN7CMul3AtwHMAsUzhjG udQqVyzwKyPKCva8AJEIiEbfbmOGsNvyusqAcT3Wnz88taEY3mLANUwv8KERp4TQOa8k emEJegjEcimODbhtq0hh47cTwG/JmGz9muvsukNOmKqXA4czPBm1dOHwuwlr862Rb3rm UA002nk646+3FFLKI+UKm0+736rujrwj2UuFFgp+CMA9Xbd5HCuVC98OKzxg1tybpuys Q0aATsaXUXSq1zWFXrTg58AG+IdTuRsRI9a8qVZQbzG+gEg8AvYxN5ukzZL7JVy5Ne3b fk/g== 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 qc15-20020a170906d8af00b00977dcff6f05si360633ejb.232.2023.06.11.10.49.30; Sun, 11 Jun 2023 10:49:55 -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 S229933AbjFKRUu (ORCPT + 99 others); Sun, 11 Jun 2023 13:20:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230233AbjFKRUs (ORCPT ); Sun, 11 Jun 2023 13:20:48 -0400 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9B5ED199E; Sun, 11 Jun 2023 10:20:21 -0700 (PDT) Received: by angie.orcam.me.uk (Postfix, from userid 500) id E73559200C7; Sun, 11 Jun 2023 19:19:57 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id E0F309200C0; Sun, 11 Jun 2023 18:19:57 +0100 (BST) Date: Sun, 11 Jun 2023 18:19:57 +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 11/14] PCI: Use `pcie_wait_for_link_status' in `pcie_wait_for_link_delay' 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 Remove a DLLLA status bit polling loop from `pcie_wait_for_link_delay' and call almost identical code in `pcie_wait_for_link_status' instead. This reduces the lower bound on the polling interval from 10ms to 1ms, possibly increasing the CPU load on the system in favour to reducing the wait time. Signed-off-by: Maciej W. Rozycki --- New change in v9. --- drivers/pci/pci.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) linux-pcie-wait-for-link-delay-status.diff Index: linux-macro/drivers/pci/pci.c =================================================================== --- linux-macro.orig/drivers/pci/pci.c +++ linux-macro/drivers/pci/pci.c @@ -4889,16 +4889,14 @@ static bool pcie_wait_for_link_status(st static bool pcie_wait_for_link_delay(struct pci_dev *pdev, bool active, int delay) { - int timeout = PCIE_LINK_RETRAIN_TIMEOUT_MS; bool ret; - u16 lnk_status; /* * Some controllers might not implement link active reporting. In this * case, we wait for 1000 ms + any delay requested by the caller. */ if (!pdev->link_active_reporting) { - msleep(timeout + delay); + msleep(PCIE_LINK_RETRAIN_TIMEOUT_MS + delay); return true; } @@ -4913,20 +4911,11 @@ static bool pcie_wait_for_link_delay(str */ if (active) msleep(20); - for (;;) { - pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status); - ret = !!(lnk_status & PCI_EXP_LNKSTA_DLLLA); - if (ret == active) - break; - if (timeout <= 0) - break; - msleep(10); - timeout -= 10; - } + ret = pcie_wait_for_link_status(pdev, false, active); if (active && ret) msleep(delay); - return ret == active; + return ret; } /**