[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<AS8PR04MB8676C98C4001DDC4851035B18C5C2@AS8PR04MB8676.eurprd04.prod.outlook.com>
Date: Thu, 7 Nov 2024 06:16:23 +0000
From: Hongxing Zhu <hongxing.zhu@....com>
To: Bjorn Helgaas <helgaas@...nel.org>
CC: "kwilczynski@...nel.org" <kwilczynski@...nel.org>, "bhelgaas@...gle.com"
<bhelgaas@...gle.com>, "lorenzo.pieralisi@....com"
<lorenzo.pieralisi@....com>, Frank Li <frank.li@....com>, "mani@...nel.org"
<mani@...nel.org>, "linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "kernel@...gutronix.de"
<kernel@...gutronix.de>, "imx@...ts.linux.dev" <imx@...ts.linux.dev>
Subject: RE: [PATCH v2] PCI: dwc: Fix resume failure if no EP is connected at
some platforms
> -----Original Message-----
> From: Bjorn Helgaas <helgaas@...nel.org>
> Sent: 2024年11月7日 6:30
> To: Hongxing Zhu <hongxing.zhu@....com>
> Cc: kwilczynski@...nel.org; bhelgaas@...gle.com;
> lorenzo.pieralisi@....com; Frank Li <frank.li@....com>; mani@...nel.org;
> linux-pci@...r.kernel.org; linux-arm-kernel@...ts.infradead.org;
> linux-kernel@...r.kernel.org; kernel@...gutronix.de; imx@...ts.linux.dev
> Subject: Re: [PATCH v2] PCI: dwc: Fix resume failure if no EP is connected at
> some platforms
>
> On Wed, Nov 06, 2024 at 01:59:41AM +0000, Hongxing Zhu wrote:
> > > -----Original Message-----
> > > From: Bjorn Helgaas <helgaas@...nel.org>
> > > Sent: 2024年11月6日 7:27
> > > To: Hongxing Zhu <hongxing.zhu@....com>
> > > Cc: kwilczynski@...nel.org; bhelgaas@...gle.com;
> > > lorenzo.pieralisi@....com; Frank Li <frank.li@....com>;
> > > mani@...nel.org; linux-pci@...r.kernel.org;
> > > linux-arm-kernel@...ts.infradead.org;
> > > linux-kernel@...r.kernel.org; kernel@...gutronix.de;
> > > imx@...ts.linux.dev
> > > Subject: Re: [PATCH v2] PCI: dwc: Fix resume failure if no EP is
> > > connected at some platforms
> > >
> > > On Mon, Jul 22, 2024 at 02:15:13PM +0800, Richard Zhu wrote:
> > > > The dw_pcie_suspend_noirq() function currently returns success
> > > > directly if no endpoint (EP) device is connected. However, on some
> > > > platforms, power loss occurs during suspend, causing dw_resume()
> > > > to do nothing in this case.
> > > > This results in a system halt because the DWC controller is not
> > > > initialized after power-on during resume.
>
> > > > @@ -933,23 +933,23 @@ 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;
> > > >
> > > > - if (dw_pcie_get_ltssm(pci) <= DW_PCIE_LTSSM_DETECT_ACT)
> > > > - return 0;
> > > > -
> > > > - if (pci->pp.ops->pme_turn_off)
> > > > - pci->pp.ops->pme_turn_off(&pci->pp);
> > > > - else
> > > > - ret = dw_pcie_pme_turn_off(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)
> > > > + pci->pp.ops->pme_turn_off(&pci->pp);
> > > > + else
> > > > + ret = dw_pcie_pme_turn_off(pci);
> > >
> > > This looks possibly racy since the link can go down at any point.
> >
> > When link is down and without this commit changes,
> > dw_pcie_suspend_noirq() return directly, and the PME_TURN_OFF wouldn't
> > be kicked off.
>
> Right, that's the code change.
>
> > I change the behavior to issue the PME_TURN_OFF when link is up here.
>
> But I don't think you responded to the race question. What happens here?
>
> if (dw_pcie_get_ltssm(pci) > DW_PCIE_LTSSM_DETECT_ACT) {
> --> link goes down here <--
> pci->pp.ops->pme_turn_off(&pci->pp);
>
> You decide the LTSSM is active and the link is up. Then the link goes down.
> Then you send PME_Turn_off. Now what?
>
> If it's safe to try to send PME_Turn_off regardless of whether the link is up or
> down, there would be no need to test the LTSSM state.
I made a local tests on i.MX95/i.MX8QM/i.MX8MP/i.MX8MM/i.MX8MQ, and
confirm that it's safe to send PME_TURN_OFF although the link is down.
You're right. It's no need to test LTSSM state here.
So do the L2 poll listed above after PME_TURN_OFF is sent.
Since the 6.13 merge window is almost closed.
How about I prepare another Fix patch to do the following items for incoming
6.14?
- Before sending PME_TURN_OFF, don't test the LTSSM stat.
- Remove the L2 stat poll, after sending PME_TURN_OFF.
Best Regards
Richard Zhu
>
> Bjorn
Powered by blists - more mailing lists