public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>
Cc: pali@kernel.org, stable@vger.kernel.org,
	"Tomasz Maciej Nowak" <tmn505@gmail.com>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Rob Herring" <robh@kernel.org>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Marek Behún" <kabel@kernel.org>
Subject: [PATCH 5.4 03/22] PCI: aardvark: Train link immediately after enabling training
Date: Thu, 25 Nov 2021 01:25:57 +0100	[thread overview]
Message-ID: <20211125002616.31363-4-kabel@kernel.org> (raw)
In-Reply-To: <20211125002616.31363-1-kabel@kernel.org>

From: Pali Rohár <pali@kernel.org>

commit 6964494582f56a3882c2c53b0edbfe99eb32b2e1 upstream.

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.

Link: https://lore.kernel.org/r/20200430080625.26070-2-pali@kernel.org
Fixes: f4c7d053d7f7 ("PCI: aardvark: Wait for endpoint to be ready...")
Tested-by: Tomasz Maciej Nowak <tmn505@gmail.com>
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Marek Behún <kabel@kernel.org>
---
 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 d92644e0206b..a423ea638324 100644
--- a/drivers/pci/controller/pci-aardvark.c
+++ b/drivers/pci/controller/pci-aardvark.c
@@ -394,11 +394,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;
@@ -440,7 +435,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.32.0


  parent reply	other threads:[~2021-11-25  0:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25  0:25 [PATCH 5.4 00/22] Armada 3720 PCIe fixes for 5.4 Marek Behún
2021-11-25  0:25 ` [PATCH 5.4 01/22] PCI: aardvark: Wait for endpoint to be ready before training link Marek Behún
2021-11-25  0:25 ` [PATCH 5.4 02/22] PCI: aardvark: Fix big endian support Marek Behún
2021-11-25  0:25 ` Marek Behún [this message]
2021-11-25  0:25 ` [PATCH 5.4 04/22] PCI: aardvark: Improve link training Marek Behún
2021-11-25  0:25 ` [PATCH 5.4 05/22] PCI: aardvark: Issue PERST via GPIO Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 06/22] PCI: aardvark: Replace custom macros by standard linux/pci_regs.h macros Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 07/22] PCI: aardvark: Don't touch PCIe registers if no card connected Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 08/22] PCI: aardvark: Fix compilation on s390 Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 09/22] PCI: aardvark: Move PCIe reset card code to advk_pcie_train_link() Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 10/22] PCI: aardvark: Update comment about disabling link training Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 11/22] PCI: pci-bridge-emul: Fix array overruns, improve safety Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 12/22] PCI: aardvark: Configure PCIe resources from 'ranges' DT property Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 13/22] PCI: aardvark: Fix PCIe Max Payload Size setting Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 14/22] PCI: aardvark: Deduplicate code in advk_pcie_rd_conf() Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 15/22] PCI: aardvark: Implement re-issuing config requests on CRS response Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 16/22] PCI: aardvark: Simplify initialization of rootcap on virtual bridge Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 17/22] PCI: aardvark: Fix link training Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 18/22] PCI: aardvark: Fix support for bus mastering and PCI_COMMAND on emulated bridge Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 19/22] PCI: aardvark: Set PCI Bridge Class Code to PCI Bridge Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 20/22] PCI: aardvark: Fix support for PCI_BRIDGE_CTL_BUS_RESET on emulated bridge Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 21/22] pinctrl: armada-37xx: Correct PWM pins definitions Marek Behún
2021-11-25  0:26 ` [PATCH 5.4 22/22] arm64: dts: marvell: armada-37xx: Set pcie_reset_pin to gpio function Marek Behún
2021-11-28 13:00 ` [PATCH 5.4 00/22] Armada 3720 PCIe fixes for 5.4 Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211125002616.31363-4-kabel@kernel.org \
    --to=kabel@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=pali@kernel.org \
    --cc=robh@kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tmn505@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox