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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3EC1C433F5 for ; Thu, 18 Nov 2021 18:06:14 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D81A96126A for ; Thu, 18 Nov 2021 18:06:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D81A96126A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 755D082F8D; Thu, 18 Nov 2021 19:06:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="vMztU1Qb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B29B682F91; Thu, 18 Nov 2021 19:06:09 +0100 (CET) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D92D780636 for ; Thu, 18 Nov 2021 19:06:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 863736126A; Thu, 18 Nov 2021 18:06:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1637258762; bh=mPgIWVNNEKKep8Yz9ryM9GdPz97oCJd/DYf+cs3KFg4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vMztU1QbC1dw9JDcI6j0qtOa4DpZQxCpTh9cVUVT0SYDIFglOpO61L39RRBlVTSw4 4R7v5fYobiAngb+6UKV4c1vnzcnhUdVV5SVoQ9Etv18jL0XWI6creA5CbiWZP3hgwz EETHMLjTiuea6zecVYu0tj6VsEfHvoZP+UxPQkgUouvXxOX63Gu2PXwBX+ADdiTog4 sxqSrQPHMr8wbe8fHfnWsD3hImszg5J3U80mCgdo+cLuR0bYykS0t3tkxCBAGnba8W aOVB42qg+/i2ps49/9DMh6KNxIsBXEFenJ88uzzep5rJEutp+A61yCZHwvPmm5NDLM Lkr1zCScqhKWA== Received: by pali.im (Postfix) id 3C29F799; Thu, 18 Nov 2021 19:06:00 +0100 (CET) Date: Thu, 18 Nov 2021 19:06:00 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: Stefan Roese Cc: Marek =?utf-8?B?QmVow7pu?= , u-boot@lists.denx.de, Marek =?utf-8?B?QmVow7pu?= Subject: Re: [PATCH u-boot-marvell 01/10] pci: pci_mvebu: Wait 100ms for Link Up in mvebu_pcie_probe() Message-ID: <20211118180600.ycljoepok43hbahx@pali> References: <20211111153549.29111-1-kabel@kernel.org> <20211111153549.29111-2-kabel@kernel.org> <2a877aa7-115a-44c8-c940-a24578f7682c@denx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2a877aa7-115a-44c8-c940-a24578f7682c@denx.de> User-Agent: NeoMutt/20180716 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.35 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Friday 12 November 2021 14:59:31 Stefan Roese wrote: > > diff --git a/drivers/pci/pci_mvebu.c b/drivers/pci/pci_mvebu.c > > index 14cd82db6f..a3364d5a59 100644 > > --- a/drivers/pci/pci_mvebu.c > > +++ b/drivers/pci/pci_mvebu.c > > @@ -22,6 +22,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -70,6 +71,9 @@ DECLARE_GLOBAL_DATA_PTR; > > #define PCIE_DEBUG_CTRL 0x1a60 > > #define PCIE_DEBUG_SOFT_RESET BIT(20) > > +#define LINK_WAIT_RETRIES 100 > > +#define LINK_WAIT_TIMEOUT 1000 > > Wouldn't it be easier read, if this was defines like this: > > #define LINK_TIMEOUT_MS 100 > #define LINK_WAIT_TIMEOUT_US 1000 > #define LINK_WAIT_RETRIES ((LINK_TIMEOUT_MS * 1000) / LINK_WAIT_TIMEOUT_US) It looks like a good idea! > Other than this: > > Reviewed-by: Stefan Roese > > Thanks, > Stefan > > > + > > struct mvebu_pcie { > > struct pci_controller hose; > > void __iomem *base; > > @@ -106,6 +110,23 @@ static inline bool mvebu_pcie_link_up(struct mvebu_pcie *pcie) > > return !(val & PCIE_STAT_LINK_DOWN); > > } > > +static void mvebu_pcie_wait_for_link(struct mvebu_pcie *pcie) > > +{ > > + int retries; > > + > > + /* check if the link is up or not */ > > + for (retries = 0; retries < LINK_WAIT_RETRIES; retries++) { > > + if (mvebu_pcie_link_up(pcie)) { > > + printf("%s: Link up\n", pcie->name); > > + return; > > + } > > + > > + udelay(LINK_WAIT_TIMEOUT); > > + } > > + > > + printf("%s: Link down\n", pcie->name); > > +} > > + > > static void mvebu_pcie_set_local_bus_nr(struct mvebu_pcie *pcie, int busno) > > { > > u32 stat;