Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1553162ybz; Thu, 30 Apr 2020 01:10:49 -0700 (PDT) X-Google-Smtp-Source: APiQypIGC4oYlL8JVOFoqhUIouPue9bAaQuzXDtkDIr24zEBugZzX+4IFrH27sPU9oy+35rmU7VO X-Received: by 2002:a17:906:dc02:: with SMTP id yy2mr1523096ejb.11.1588234249813; Thu, 30 Apr 2020 01:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588234249; cv=none; d=google.com; s=arc-20160816; b=fbfCOrb/kG0ncvlMUGki/XHlYNY+XuaqEscMCeEtp7aTZyMrU4zItC+p6u7P1GRIkL 9KWS+7ye4PUAtGZ9CAQFnKz3uW1NZWKJrc+xwISt66ypiL99gLC6nY3aPmGwr7REnYZA PGQjVXxpndE6SR1SATOQf0IxnIbSWVWDAF6aRmPpO+2tsAdm3/PT4xovIlcTL4j1158L lo/2VI2410xpUtwK1LsBlkNOY7MWXCdVr9rZnTzb6yzGq4TquBjEHujl3wm2841jNynq EHWPgwjwhGpW27Ff7eumoFZXODMSJpR2P35o0H/+7KDqTt/OXH3RVRFRsS88auQbXmmK LyFw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iWcZtrJwqWswzvacxqXWcS/oG/tMGB4NXX0717tiUkc=; b=am4LFi/zhm3WQHJbiT0nVRWULH89xXZRm9UKF/SHm5rheyHYkQfpXjdrX+IKHVTWL1 /hYsliQbKWKYlR9c7HPhXR+fhJAjoGgrxc6xWbRUg9rtC/E5cPTSg7YRj8tvkoUW4FGT cFJERmrhgj1s/cvyeV5/dPXYQMz8tjCsvgz31QToPTC6nbhfc45dzqFD6iNraXMTf+PY 1ec8iyi1WtzQ5PuVLle7hyL8tcqXX+19/TSZqSx+73y+Mh8fYHj7K4xWZnPeYhszXswc 129Uwn6b8hsbk94cqgQZDdvb11JxLhNy2wvkzhlj2fPq2l2M1WQi2v5bc/CYPaQc8Cdg XdEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sfn8ddWu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si5609186eju.300.2020.04.30.01.10.25; Thu, 30 Apr 2020 01:10:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sfn8ddWu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726884AbgD3IGn (ORCPT + 99 others); Thu, 30 Apr 2020 04:06:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:50796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726428AbgD3IGm (ORCPT ); Thu, 30 Apr 2020 04:06:42 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BD4742186A; Thu, 30 Apr 2020 08:06:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588234001; bh=HhAmAT2/A+qPYpQdZvTmptCNczQiph9isL1WeEaN0bM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sfn8ddWur8OqKt9lcbP1xwQF3fyJR3FHROypX+VYebaQIGcnud648tmINsPhZqe4B OYvNYwX2aprawfc7L2zOh4eN7vIakof39COZ8WRSgFGbp3JoBvrhd18J70P75jMp+Q p7DZpkIkqCz2Lc/HhkKD3fwtoVWEn6NlnxVQdyOI= Received: by pali.im (Postfix) id D38FCA19; Thu, 30 Apr 2020 10:06:39 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Jason Cooper , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Rob Herring , Thomas Petazzoni , Lorenzo Pieralisi , Andrew Murray , Bjorn Helgaas , Remi Pommarel , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Tomasz Maciej Nowak , Xogium Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v4 01/12] PCI: aardvark: Train link immediately after enabling training Date: Thu, 30 Apr 2020 10:06:14 +0200 Message-Id: <20200430080625.26070-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200430080625.26070-1-pali@kernel.org> References: <20200430080625.26070-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding even 100ms (PCI_PM_D3COLD_WAIT) delay between enabling link training and starting link training causes detection issues with some buggy cards (such as Compex WLE900VX). Move the code which enables link training immediately before the one which starts link traning. This fixes detection issues of Compex WLE900VX card on Turris MOX after cold boot. Fixes: f4c7d053d7f7 ("PCI: aardvark: Wait for endpoint to be ready...") Signed-off-by: Pali Rohár --- drivers/pci/controller/pci-aardvark.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 2a20b649f40c..f9955b494267 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -300,11 +300,6 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) reg |= LANE_COUNT_1; advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG); - /* Enable link training */ - reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG); - reg |= LINK_TRAINING_EN; - advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG); - /* Enable MSI */ reg = advk_readl(pcie, PCIE_CORE_CTRL2_REG); reg |= PCIE_CORE_CTRL2_MSI_ENABLE; @@ -346,7 +341,15 @@ static void advk_pcie_setup_hw(struct advk_pcie *pcie) */ msleep(PCI_PM_D3COLD_WAIT); - /* Start link training */ + /* Enable link training */ + reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG); + reg |= LINK_TRAINING_EN; + advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG); + + /* + * Start link training immediately after enabling it. + * This solves problems for some buggy cards. + */ reg = advk_readl(pcie, PCIE_CORE_LINK_CTRL_STAT_REG); reg |= PCIE_CORE_LINK_TRAINING; advk_writel(pcie, reg, PCIE_CORE_LINK_CTRL_STAT_REG); -- 2.20.1