From: Frank Li <Frank.li@nxp.com>
To: Richard Zhu <hongxing.zhu@nxp.com>
Cc: imx@lists.linux.dev
Subject: Re: [PATCH v2] PCI: dwc: Fix suspend hang when e1000e network card is connected
Date: Tue, 14 May 2024 10:28:42 -0400 [thread overview]
Message-ID: <ZkN1GgczTvzAwYDQ@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <1715666198-9140-1-git-send-email-hongxing.zhu@nxp.com>
On Tue, May 14, 2024 at 01:56:38PM +0800, Richard Zhu wrote:
> In dw_pcie_suspend_noirq() and after the PME_TURN_OFF messgage is sent out,
> one PMC version2.0 endpoint device E1000E network card hangs in LTSSM stat
> polling and L2 stat check.
>
> To avoid this hang issue after the PME_TURN_OFF message is sent out.
> Only poll and check LTSSM L2 stat if the EP's PMC version is 3 or later,
>
> Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
> ---
> - Add a new help function dwc_get_devices_pmc_version() to get devices PMC
> versions.
>
> .../pci/controller/dwc/pcie-designware-host.c | 46 ++++++++++++++++++-
> 1 file changed, 45 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> index cb8c3c2bcc790..0c2794e7bcf0a 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
> @@ -884,6 +884,42 @@ int dw_pcie_setup_rc(struct dw_pcie_rp *pp)
> }
> EXPORT_SYMBOL_GPL(dw_pcie_setup_rc);
>
> +static int dwc_get_devices_pmc_version(struct dw_pcie *pci)
> +{
> + int ret;
> + u16 pmc, ver = 0;
> + struct dw_pcie_rp *pp = &pci->pp;
> + struct pci_bus *child, *root_bus = NULL;
> + struct pci_dev *pdev;
> +
> + /* Check the remote EP's PMC version */
> + list_for_each_entry(child, &pp->bridge->bus->children, node) {
> + if (child->parent == pp->bridge->bus) {
> + root_bus = child;
> + break;
> + }
> + }
> +
> + if (!root_bus) {
> + dev_err(pci->dev, "Failed to find downstream devices\n");
> + return -ENODEV;
> + }
> +
> + list_for_each_entry(pdev, &root_bus->devices, bus_list) {
> + if (PCI_SLOT(pdev->devfn) == 0) {
> + /* find PCI PM capability in list */
> + ret = pci_find_capability(pdev, PCI_CAP_ID_PM);
> + if (!ret)
> + return ret;
> + /* Check device's PM ability version */
> + pci_read_config_word(pdev, ret + PCI_PM_PMC, &pmc);
> + ver &= pmc;
ver is 0. so ver will be always 0 by '&='.
By the ways, in 7.5.2 PCI Power Management Capability Structure
I have not found version info.
Frank
> + }
> + }
> +
> + return ver;
> +}
> +
> static int dw_pcie_pme_turn_off(struct dw_pcie *pci)
> {
> struct dw_pcie_ob_atu_cfg atu = { 0 };
> @@ -924,7 +960,7 @@ int dw_pcie_suspend_noirq(struct dw_pcie *pci)
> {
> u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
> u32 val;
> - int ret = 0;
> + int pmc_ver, ret = 0;
>
> /*
> * If L1SS is supported, then do not put the link into L2 as some
> @@ -933,6 +969,8 @@ int dw_pcie_suspend_noirq(struct dw_pcie *pci)
> if (dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKCTL) & PCI_EXP_LNKCTL_ASPM_L1)
> return 0;
>
> + pmc_ver = dwc_get_devices_pmc_version(pci);
> +
> if (dw_pcie_get_ltssm(pci) > DW_PCIE_LTSSM_DETECT_ACT) {
> /* Only send out PME_TURN_OFF when PCIE link is up */
> if (pci->pp.ops->pme_turn_off)
> @@ -942,7 +980,13 @@ int dw_pcie_suspend_noirq(struct dw_pcie *pci)
>
> if (ret)
> return ret;
> + }
>
> + /*
> + * PMC Ver2.0 device e1000e NIC hangs in LTSSM polling and L2 check.
> + * Only do the L2 check when PMC version is Ver3.0 or later.
> + */
> + if (pmc_ver >= 3) {
> ret = read_poll_timeout(dw_pcie_get_ltssm, val, val == DW_PCIE_LTSSM_L2_IDLE,
> PCIE_PME_TO_L2_TIMEOUT_US/10,
> PCIE_PME_TO_L2_TIMEOUT_US, false, pci);
> --
> 2.37.1
>
next prev parent reply other threads:[~2024-05-14 14:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-14 5:56 [PATCH v2] PCI: dwc: Fix suspend hang when e1000e network card is connected Richard Zhu
2024-05-14 11:03 ` Fabio Estevam
2024-05-15 1:06 ` Hongxing Zhu
2024-05-14 14:28 ` Frank Li [this message]
2024-05-15 1:05 ` 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=ZkN1GgczTvzAwYDQ@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=hongxing.zhu@nxp.com \
--cc=imx@lists.linux.dev \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).