Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp947395ybm; Wed, 22 May 2019 14:28:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2NAjrOZLBsoTRIIE/E5qE6Xo6XzJk4ziSeVgN4k1V2U4NMKDK27Os6I5c9sO7ELwbCv5Q X-Received: by 2002:a17:902:3103:: with SMTP id w3mr17822053plb.187.1558560481645; Wed, 22 May 2019 14:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558560481; cv=none; d=google.com; s=arc-20160816; b=qHOtZL4RnPbaA9uqFYYuYk8Tj25sKCTNhP2zdGODSOCg/PYviOT+dMj+H+K9lgBYHP S1vkdAvkOIcbjvUQBJe+4TQ3MfhfxkXV3GUC8JPc7nxXWuDTcbCCl8BnqzzLmKUcnXzi wXISyz8maZqUZhENeTusFwLaL1pJ8xb0SpjhPTRNZfRRY7OZmo2XSaQe52oJMGWOfvNA FeU3KGV+gRQ99WI+NGEQ9273j+wXKunKthmM9HFr1bHzGdtHWRn4zzCA2fbJi0SELj6+ hc8IXVr18GvxZlnNKl3N2OQljst+wfUZ0Aoes1Gg02H4NdEsHuTaB238l8ZvSsHELUQg X1nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=5yCmDNS8w+ErXB5m2p70lWiyIkI1MscjMaZto/zbCOI=; b=D9f7ZgHXfdryHNMmejEfRFhm/+W4O0VY2+iLhOC2fNG5Q8D6mDMsZYR1mlqWqTkq2s AFSqWHuEQ+LeXSSjJDa8WWfyx/v+pumkVvKKFij5WEi4oJoDtft5tyZI1kai9NE4LElv 6LQZil0YGhOPLG3KItM5PGj6mScaBJ24HIzz85hkJN/Otmy+wWZoTV3gNWQWY1RDaWFV 8NO4mvK1Jcb/gCLgx/foIDKLy4IyyBimW1dWN99OAZTlHGC0JfH0iV19yZjsBPkrWWRc XdCsbeOm3CzHGL3bARSrkG8QtEbJ2yxBT/1Xp7lo66sHTxM6YkUDc15sVuZ1zldN5t1a 6geA== 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 d23si27047191pgv.513.2019.05.22.14.27.45; Wed, 22 May 2019 14:28:01 -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 S1729906AbfEVV0c (ORCPT + 99 others); Wed, 22 May 2019 17:26:32 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:59269 "EHLO relay9-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728761AbfEVV0c (ORCPT ); Wed, 22 May 2019 17:26:32 -0400 X-Originating-IP: 88.190.179.123 Received: from localhost (unknown [88.190.179.123]) (Authenticated sender: repk@triplefau.lt) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 5D16DFF805; Wed, 22 May 2019 21:26:25 +0000 (UTC) From: Remi Pommarel To: Thomas Petazzoni , Lorenzo Pieralisi , Bjorn Helgaas Cc: Ellie Reeves , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Remi Pommarel Subject: [PATCH v2] PCI: aardvark: Wait for endpoint to be ready before training link Date: Wed, 22 May 2019 23:33:50 +0200 Message-Id: <20190522213351.21366-2-repk@triplefau.lt> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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]). Because the pin configuration comes from the "default" pinctrl it is implicitly configured before the probe callback is called: driver_probe_device() really_probe() ... pinctrl_bind_pins() /* Here pin goes from gpio to PCIE reset function and PERST# is asserted */ ... drv->probe() [1] "PCI Express Base Specification", REV. 4.0 PCI Express, February 19 2014, 6.6.1 Conventional Reset Signed-off-by: Remi Pommarel --- Changes since v1: - Add a comment about pinctrl implicit pin configuration - Use more legible msleep - Use PCI_PM_D3COLD_WAIT macro Please note that I will unlikely be able to answer any comments from May 24th to June 10th. --- drivers/pci/controller/pci-aardvark.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 134e0306ff00..d998c2b9cd04 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -324,6 +324,14 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) reg |= PIO_CTRL_ADDR_WIN_DISABLE; advk_writel(pcie, reg, PIO_CTRL); + /* + * PERST# signal could have been asserted by pinctrl subsystem before + * probe() callback has been called, making the endpoint going into + * fundamental reset. As required by PCI Express spec a delay for at + * least 100ms after such a reset before link training is needed. + */ + msleep(PCI_PM_D3COLD_WAIT); + /* Start link training */ reg = advk_readl(pcie, PCIE_CORE_LINK_CTRL_STAT_REG); reg |= PCIE_CORE_LINK_TRAINING; -- 2.20.1