linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hongxing Zhu <hongxing.zhu@nxp.com>
To: Fabio Estevam <festevam@gmail.com>
Cc: "l.stach@pengutronix.de" <l.stach@pengutronix.de>,
	"lorenzo.pieralisi@arm.com" <lorenzo.pieralisi@arm.com>,
	"robh@kernel.org" <robh@kernel.org>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>
Subject: RE: [PATCH] PCI: imx6: Allow to probe when dw_pcie_wait_for_link() fails
Date: Thu, 4 Nov 2021 00:58:38 +0000	[thread overview]
Message-ID: <AS8PR04MB8676C527C11B6E0BCB455E1B8C8D9@AS8PR04MB8676.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <20211104000202.4028036-1-festevam@gmail.com>


> -----Original Message-----
> From: Fabio Estevam <festevam@gmail.com>
> Sent: Thursday, November 4, 2021 8:02 AM
> To: Hongxing Zhu <hongxing.zhu@nxp.com>
> Cc: l.stach@pengutronix.de; lorenzo.pieralisi@arm.com;
> robh@kernel.org; bhelgaas@google.com; linux-pci@vger.kernel.org;
> Fabio Estevam <festevam@gmail.com>
> Subject: [PATCH] PCI: imx6: Allow to probe when dw_pcie_wait_for_link()
> fails
> 
> The intention of commit 886a9c134755 ("PCI: dwc: Move link handling
> into common code") was to standardize the behavior of link down as
> explained in its commit log:
> 
> "The behavior for a link down was inconsistent as some drivers would fail
> probe in that case while others succeed. Let's standardize this to succeed
> as there are usecases where devices (and the link) appear later even
> without hotplug. For example, a reconfigured FPGA device."
> 
> The pci-imx6 still fails to probe when the link is not present, which causes
> the following warning:
> 
> [    9.199175] imx6q-pcie 8ffc000.pcie: Phy link never came up
> [    9.208701] imx6q-pcie: probe of 8ffc000.pcie failed with error -110
> [    9.216214] ------------[ cut here ]------------
> [    9.222057] WARNING: CPU: 0 PID: 30 at
> drivers/regulator/core.c:2257 _regulator_put.part.0+0x1b8/0x1dc
> [    9.232411] Modules linked in:
> [    9.236201] CPU: 0 PID: 30 Comm: kworker/u2:2 Not tainted
> 5.15.0-next-20211103 #1
> [    9.244086] Hardware name: Freescale i.MX6 SoloX (Device Tree)
> [    9.250284] Workqueue: events_unbound async_run_entry_fn
> [    9.256067] [<c0111730>] (unwind_backtrace) from [<c010bb74>]
> (show_stack+0x10/0x14)
> [    9.264258] [<c010bb74>] (show_stack) from [<c0f90290>]
> (dump_stack_lvl+0x58/0x70)
> [    9.272245] [<c0f90290>] (dump_stack_lvl) from [<c012631c>]
> (__warn+0xd4/0x154)
> [    9.279969] [<c012631c>] (__warn) from [<c0f87b00>]
> (warn_slowpath_fmt+0x74/0xa8)
> [    9.287882] [<c0f87b00>] (warn_slowpath_fmt) from [<c076b4bc>]
> (_regulator_put.part.0+0x1b8/0x1dc)
> [    9.297273] [<c076b4bc>] (_regulator_put.part.0) from [<c076b574>]
> (regulator_put+0x2c/0x3c)
> [    9.306122] [<c076b574>] (regulator_put) from [<c08c3740>]
> (release_nodes+0x50/0x178)
> 
> Fix this problem by ignoring the dw_pcie_wait_for_link() error like it is
> done on the other dwc drivers.
> 
> Tested on imx6sx-sdb and imx6q-sabresd boards.
> 
> Fixes: 886a9c134755 ("PCI: dwc: Move link handling into common code")
> Signed-off-by: Fabio Estevam <festevam@gmail.com>
[Richard Zhu] Hi Fabio:
First of all, thanks for your help to care this bug.
This dump is planned to be fixed in the #5 patch of
 '[v4,0/6] PCI: imx6: refine codes and add compliance tests mode support'
"https://patchwork.kernel.org/project/linux-arm-kernel/cover/1635747478-25562-1-git-send-email-hongxing.zhu@nxp.com/"

As we know that the hot-plug is not supported by i.MX PCIe. i.MX PCIe would
not have any chances to be functional after one link down.

To save power consumption as much as possible, we should do the error
 handling after link is down.

Ignore the the dw_pcie_wait_for_link() error, PCIe would keep consuming
 the power, this is not friendly for the system power saving.

Best Regards
Richard Zhu
> ---
>  drivers/pci/controller/dwc/pci-imx6.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c
> b/drivers/pci/controller/dwc/pci-imx6.c
> index 26f49f797b0f..bbc3a46549f8 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -779,9 +779,7 @@ static int imx6_pcie_start_link(struct dw_pcie
> *pci)
>  	/* Start LTSSM. */
>  	imx6_pcie_ltssm_enable(dev);
> 
> -	ret = dw_pcie_wait_for_link(pci);
> -	if (ret)
> -		goto err_reset_phy;
> +	dw_pcie_wait_for_link(pci);
> 
>  	if (pci->link_gen == 2) {
>  		/* Allow Gen2 mode after the link is up. */ @@ -817,11 +815,7
> @@ static int imx6_pcie_start_link(struct dw_pcie *pci)
>  		}
> 
>  		/* Make sure link training is finished as well! */
> -		ret = dw_pcie_wait_for_link(pci);
> -		if (ret) {
> -			dev_err(dev, "Failed to bring link up!\n");
> -			goto err_reset_phy;
> -		}
> +		dw_pcie_wait_for_link(pci);
>  	} else {
>  		dev_info(dev, "Link: Gen2 disabled\n");
>  	}
> --
> 2.25.1


  reply	other threads:[~2021-11-04  0:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-04  0:02 [PATCH] PCI: imx6: Allow to probe when dw_pcie_wait_for_link() fails Fabio Estevam
2021-11-04  0:58 ` Hongxing Zhu [this message]
2021-11-04  1:44   ` Fabio Estevam
2021-11-05  8:18     ` Hongxing Zhu
2021-12-04 15:34   ` Fabio Estevam
2021-12-06  2:03     ` Hongxing Zhu

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=AS8PR04MB8676C527C11B6E0BCB455E1B8C8D9@AS8PR04MB8676.eurprd04.prod.outlook.com \
    --to=hongxing.zhu@nxp.com \
    --cc=bhelgaas@google.com \
    --cc=festevam@gmail.com \
    --cc=l.stach@pengutronix.de \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=robh@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).