This is a note to let you know that I've just added the patch titled PCI: aardvark: Wait for endpoint to be ready before training link to the 4.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: pci-aardvark-wait-for-endpoint-to-be-ready-before-training-link.patch and it can be found in the queue-4.14 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Mon Nov 29 01:32:04 PM CET 2021 From: "Marek Behún" <kabel@xxxxxxxxxx> Date: Wed, 24 Nov 2021 23:49:12 +0100 Subject: PCI: aardvark: Wait for endpoint to be ready before training link To: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Sasha Levin <sashal@xxxxxxxxxx> Cc: pali@xxxxxxxxxx, stable@xxxxxxxxxxxxxxx, "Remi Pommarel" <repk@xxxxxxxxxxxx>, "Lorenzo Pieralisi" <lorenzo.pieralisi@xxxxxxx>, "Thomas Petazzoni" <thomas.petazzoni@xxxxxxxxxxx>, "Marek Behún" <kabel@xxxxxxxxxx> Message-ID: <20211124224933.24275-4-kabel@xxxxxxxxxx> From: Remi Pommarel <repk@xxxxxxxxxxxx> commit f4c7d053d7f77cd5c1a1ba7c7ce085ddba13d1d7 upstream. 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 <repk@xxxxxxxxxxxx> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@xxxxxxx> Acked-by: Thomas Petazzoni <thomas.petazzoni@xxxxxxxxxxx> Signed-off-by: Marek Behún <kabel@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/pci/host/pci-aardvark.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/pci/host/pci-aardvark.c +++ b/drivers/pci/host/pci-aardvark.c @@ -362,6 +362,14 @@ static void advk_pcie_setup_hw(struct ad 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; Patches currently in stable-queue which might be from kabel@xxxxxxxxxx are queue-4.14/pci-aardvark-move-pcie-reset-card-code-to-advk_pcie_train_link.patch queue-4.14/pci-aardvark-introduce-an-advk_pcie_valid_device-helper.patch queue-4.14/pci-aardvark-update-comment-about-disabling-link-training.patch queue-4.14/pci-aardvark-train-link-immediately-after-enabling-training.patch queue-4.14/arm64-dts-marvell-armada-37xx-declare-pcie-reset-pin.patch queue-4.14/pci-aardvark-replace-custom-macros-by-standard-linux-pci_regs.h-macros.patch queue-4.14/pci-aardvark-fix-a-leaked-reference-by-adding-missing-of_node_put.patch queue-4.14/pci-aardvark-fix-pcie-max-payload-size-setting.patch queue-4.14/pinctrl-armada-37xx-correct-pwm-pins-definitions.patch queue-4.14/arm64-dts-marvell-armada-37xx-set-pcie_reset_pin-to-gpio-function.patch queue-4.14/pci-aardvark-configure-pcie-resources-from-ranges-dt-property.patch queue-4.14/pci-aardvark-improve-link-training.patch queue-4.14/pci-aardvark-fix-link-training.patch queue-4.14/pci-aardvark-fix-checking-for-link-up-via-ltssm-state.patch queue-4.14/pci-aardvark-issue-perst-via-gpio.patch queue-4.14/pinctrl-armada-37xx-correct-mpp-definitions.patch queue-4.14/pci-add-pci_exp_lnkctl2_tls-macros.patch queue-4.14/pci-aardvark-wait-for-endpoint-to-be-ready-before-training-link.patch queue-4.14/pinctrl-armada-37xx-add-missing-pin-pcie1-wakeup.patch queue-4.14/pci-aardvark-fix-compilation-on-s390.patch queue-4.14/pci-aardvark-fix-i-o-space-page-leak.patch queue-4.14/pci-aardvark-don-t-touch-pcie-registers-if-no-card-connected.patch queue-4.14/pci-aardvark-remove-pcie-outbound-window-configuration.patch queue-4.14/pci-aardvark-indicate-error-in-val-when-config-read-fails.patch