Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4102941yba; Tue, 23 Apr 2019 15:21:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXsEk1jZvf3PMWRInIY9rducQ9u2cbmePFaqgemOtZXzEwhyOWnWpTNh+I6KANhDlYFh8c X-Received: by 2002:a17:902:2ec5:: with SMTP id r63mr28894373plb.139.1556058086939; Tue, 23 Apr 2019 15:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556058086; cv=none; d=google.com; s=arc-20160816; b=SvaSaWJFMqujYN4QwjBhIZ1AcEWr91HeAkrKEuXUOcvOUpm+bqpRUXnjxVNGh+H4OH WrkgDxq2dSOkaKmCBIQlUjD68+oluf9UZAeu/XvTLOLFGIWkC4oB0hgJrMiOhoJJFNnL RCKrDkW4ahWThnqHZA/6qKvBOup9ZjyRB3oYngmYVWJHWUMyB7Y0829yPyepo4NjSYDI N7UsVV7cy0Moi+hRUloUfpdHbGSXSXpQr644Y349+GILPq6gOlqjR2mf6Bz5r1XDFnCE 7cy90MxZKLJg12u9aqPlMC90x/5t2P5B82Znxhuq7+faMSkm7LA9WYCMyn7qqFTjL7gv 6DXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=tGjVJDzlilIRARFHi2CwU16/U9rv0AhMTlN9JYNQlUE=; b=ciSmMnz9s4c/ukZRKNdGirWXnuo7qVuu4wd3YY3yEcQfIv0h2aO8wGROFC0zWvEYy0 ZzXnpfZgZYzRQJ8eJrgFyUeBqfOHePGz+Oa6YtUqS/MLWiMWex5r7PxiS3Ng50TI18Ls PjUGSnu9ZELkEK2iXsQIySIUc1lysGkhfD+j3+6Jy3namsaD9eu0Owp2ujY5029uMXJq iWx3n8HKM7v7kwznOcyS43ffCmoCLYz63BK81AR+h6oOTAAv1HtCgt0HjrWAsI6I3TF6 nNALWLdQ2X9ppyFRa4ImTu9aiDoG5qY4Y870ilWRT4D3NSIx/eaXYANpc8ejW1NsrbaD sp3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8si17336253pfd.55.2019.04.23.15.21.11; Tue, 23 Apr 2019 15:21:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727929AbfDWWUW (ORCPT + 99 others); Tue, 23 Apr 2019 18:20:22 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:44379 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbfDWWUV (ORCPT ); Tue, 23 Apr 2019 18:20:21 -0400 Received: from localhost (unknown [88.190.179.123]) (Authenticated sender: repk@triplefau.lt) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 7133724000A; Tue, 23 Apr 2019 22:20:18 +0000 (UTC) Date: Wed, 24 Apr 2019 00:29:18 +0200 From: Remi Pommarel To: Lorenzo Pieralisi Cc: Thomas Petazzoni , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Miquel Raynal Subject: Re: [PATCH] pci: aardvark: Wait for endpoint to be ready before training link Message-ID: <20190423222917.GN2754@voidbox.localdomain> References: <20190313213752.1246-1-repk@triplefau.lt> <20190423163215.GB26523@red-moon> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190423163215.GB26523@red-moon> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Apr 23, 2019 at 05:32:15PM +0100, Lorenzo Pieralisi wrote: > On Wed, Mar 13, 2019 at 10:37:52PM +0100, Remi Pommarel wrote: > > When configuring pcie reset pin from gpio (e.g. initially set by > > u-boot) to pcie function this pin goes low for a brief moment > > asserting the PERST# signal. Thus connected device enters fundamental > > reset process and link configuration can only begin after a minimal > > 100ms delay (see [1]). > > > > This makes sure that link is configured after at least 100ms from > > beginning of probe() callback (shortly after the reset pin function > > configuration switch through pinctrl subsytem). > > > > [1] "PCI Express Base Specification", REV. 2.1 > > PCI Express, March 4 2009, 6.6.1 Conventional Reset > > > > Signed-off-by: Remi Pommarel > > --- > > drivers/pci/controller/pci-aardvark.c | 17 ++++++++++++++--- > > 1 file changed, 14 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c > > index a30ae7cf8e7e..70a1023d0ef1 100644 > > --- a/drivers/pci/controller/pci-aardvark.c > > +++ b/drivers/pci/controller/pci-aardvark.c > > @@ -177,6 +177,9 @@ > > > > #define PIO_TIMEOUT_MS 1 > > > > +/* Endpoint can take up to 100ms to be ready after a reset */ > > +#define ENDPOINT_RST_MS 100 > > + > > #define LINK_WAIT_MAX_RETRIES 10 > > #define LINK_WAIT_USLEEP_MIN 90000 > > #define LINK_WAIT_USLEEP_MAX 100000 > > @@ -242,8 +245,10 @@ static int advk_pcie_wait_for_link(struct advk_pcie *pcie) > > return -ETIMEDOUT; > > } > > > > -static void advk_pcie_setup_hw(struct advk_pcie *pcie) > > +static void > > +advk_pcie_setup_hw(struct advk_pcie *pcie, unsigned long ep_rdy_time) > > Nit: I prefer the prototype to be in one line, I wrap it for you. > > I am wondering why you need to pass in ep_rdy_time parameter when you > can easily compute it in the function itself. > The only reason for that is because the sooner I get the jiffies the lower the delay has to be. I was trying to reduce the impact of this delay to a minimum, but maybe the improvement is not worth it. -- Remi