From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Tue, 26 Mar 2024 11:09:01 +0100 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rp3jp-0051oN-1c for lore@lore.pengutronix.de; Tue, 26 Mar 2024 11:09:01 +0100 Received: from bombadil.infradead.org ([2607:7c80:54:3::133]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rp3jo-0002zN-7y for lore@pengutronix.de; Tue, 26 Mar 2024 11:09:01 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To: Cc:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XOq35+pKzzJGh2dYNlQu2A633ZKXnW5WQHu2E/0Hmvw=; b=K9tcgng9ykMMe6QNNE3FOUpguH HWKttn5YxcybC8Yam6E/acLpYoLQCqDf8qbG4DmVu2g2FcLYI2Ynr7A3bcaxhjbW7RixzwmX/wzEk 4q7VhVDbOzq4dl+UNXOnH8o53eU5SXVEJIqX1O7P149B70dEVhcVNyQo2HZgn4H6tC135O5sVo1K0 2nePtB8Zr+V1YSlhdYn85LBRdWkullRkiSrKBUIvv36nnDiq2Iy8woDHKEoKjgPp9UORXoresv/W+ WK7Rt7BPHoIhFZpM1BR8H+AqoaBX1ukZuWqpzh57TnuKrStxQ+bdaakOLJeoSD+MI4giTkHOl67L+ yMMKSCpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rp3j7-00000003xj0-30IL; Tue, 26 Mar 2024 10:08:17 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rp3ii-00000003xS2-0peD for barebox@lists.infradead.org; Tue, 26 Mar 2024 10:07:57 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rp3id-0002HM-Sl; Tue, 26 Mar 2024 11:07:47 +0100 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rp3id-008b0q-Fc; Tue, 26 Mar 2024 11:07:47 +0100 Received: from localhost ([::1] helo=dude02.red.stw.pengutronix.de) by dude02.red.stw.pengutronix.de with esmtp (Exim 4.96) (envelope-from ) id 1rp3id-00202A-1D; Tue, 26 Mar 2024 11:07:47 +0100 From: Sascha Hauer To: Barebox List Date: Tue, 26 Mar 2024 11:07:39 +0100 Message-Id: <20240326100746.471532-10-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240326100746.471532-1-s.hauer@pengutronix.de> References: <20240326100746.471532-1-s.hauer@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240326_030752_534881_42940356 X-CRM114-Status: GOOD ( 13.96 ) X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" X-SA-Exim-Connect-IP: 2607:7c80:54:3::133 X-SA-Exim-Mail-From: barebox-bounces+lore=pengutronix.de@lists.infradead.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-5.1 required=4.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Subject: [PATCH 09/16] pci: pcie-designware: Speed up waiting for link X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.whiteo.stw.pengutronix.de) When the link is not up the first time we test for it, then we wait for 100ms before trying again. This adds unnecessary delays when the link is up considerably faster than 100ms. As we do not have anything useful to do with our CPU time during polling for link we can equally well poll as fast as we can. Signed-off-by: Sascha Hauer --- drivers/pci/pcie-designware.c | 8 +++++--- drivers/pci/pcie-designware.h | 4 ---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/pci/pcie-designware.c b/drivers/pci/pcie-designware.c index 9c8bc772f9..72820de282 100644 --- a/drivers/pci/pcie-designware.c +++ b/drivers/pci/pcie-designware.c @@ -237,15 +237,17 @@ void dw_pcie_disable_atu(struct dw_pcie *pci, int index, int dw_pcie_wait_for_link(struct dw_pcie *pci) { - int retries; + u64 start = get_time_ns(); /* Check if the link is up or not */ - for (retries = 0; retries < LINK_WAIT_MAX_RETRIES; retries++) { + while (1) { if (dw_pcie_link_up(pci)) { dev_dbg(pci->dev, "Link up\n"); return 0; } - udelay(LINK_WAIT_USLEEP_MAX); + + if (is_timeout(start, SECOND)) + break; } dev_err(pci->dev, "Phy link never came up\n"); diff --git a/drivers/pci/pcie-designware.h b/drivers/pci/pcie-designware.h index 9840dde266..96a269dc59 100644 --- a/drivers/pci/pcie-designware.h +++ b/drivers/pci/pcie-designware.h @@ -13,10 +13,6 @@ #include -/* Parameters for the waiting for link up routine */ -#define LINK_WAIT_MAX_RETRIES 10 -#define LINK_WAIT_USLEEP_MAX 100000 - /* Parameters for the waiting for iATU enabled routine */ #define LINK_WAIT_MAX_IATU_RETRIES 5 #define LINK_WAIT_IATU_MAX 10000 -- 2.39.2