Pcie: Phy link never came up

[email protected] Thu, 06 Jul 2023 21:33:45 -0700
Newsgroups org.yoctoproject.lists.meta-freescale
Message-ID <[email protected]>
--cdbkza0LyNgte8XhpCXb
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

I am getting the following error message in the bootup sequence:

[ 6.494407] imx6q-pcie 1ffc000.pcie: Phy link never came up
[ 6.500013] imx6q-pcie 1ffc000.pcie: PHY DEBUG_R0=3D0x004abc43 DEBUG_R1=3D0=
x08000000

This issue happens intermittently

I am currently using the 5.10.y kernel source.=C2=A0 Prior to this I was us=
ing 3.10.17 kernel and I faced the same issue, and the issue was solved by =
adding a retry logic in the imx6_pcie_host_init function. Each time the ini=
t failed, the logic was to assert/deassert the Reset signal and try the=C2=
=A0=C2=A0imx6_pcie_host_init again.=C2=A0 In this way we were able to solve=
 the problem.

But when a similar kind of patch is done in kernel v5.10.y I face the same =
issue.

@@ -829,13 +829,48 @@ static int imx6_pcie_host_init(struct pcie_port *pp)
{
struct dw_pcie *pci =3D to_dw_pcie_from_pp(pp);
struct imx6_pcie *imx6_pcie =3D to_imx6_pcie(pci);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0int retry =3D 0;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0int ret =3D 0;
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0do {
imx6_pcie_assert_core_reset(imx6_pcie);
imx6_pcie_init_phy(imx6_pcie);
imx6_pcie_deassert_core_reset(imx6_pcie);
imx6_setup_phy_mpll(imx6_pcie);
dw_pcie_setup_rc(pp);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 imx6_pcie_establish_link(imx6_pcie);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret =3D imx6_pcie_establish_link(imx6_pcie);
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (ret =3D=3D 0) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 dev_info(imx6_pcie->pci->dev, "Pci reset retry=
: %d\n", retry);
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (gpio_is_valid(imx6_pcie->reset_gpio)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dev_info(imx6_pcie=
->pci->dev, "gpio reset: %d\n", imx6_pcie->reset_gpio);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 gpio_set_value(imx=
6_pcie->reset_gpio, 0);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 msleep (200);
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0} while (retry++ < 3);
+
dw_pcie_msi_init(pp);

return 0;

*The main problem is that there are boards in the field which use the curre=
nt hardware design and in the 3.10.17 kernel the retry logic seems to solve=
 the problem.=C2=A0 But the same retry logic is not working in the 5.10.y k=
ernel with the same hardware*

Can anyone suggest me some workaround for this problem?

--cdbkza0LyNgte8XhpCXb
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<p style=3D"margin-bottom: 15px; color: #333f48; font-family: Arial, sans-s=
erif; font-size: 16px;">I am getting the following error message in the boo=
tup sequence:</p>
<p style=3D"margin-bottom: 15px; color: #333f48; font-family: Arial, sans-s=
erif; font-size: 16px;">[ 6.494407] imx6q-pcie 1ffc000.pcie: Phy link never=
 came up<br />[ 6.500013] imx6q-pcie 1ffc000.pcie: PHY DEBUG_R0=3D0x004abc4=
3 DEBUG_R1=3D0x08000000<br /><br /></p>
<p style=3D"margin-bottom: 15px; color: #333f48; font-family: Arial, sans-s=
erif; font-size: 16px;">This issue happens intermittently&nbsp;</p>
<p style=3D"margin-bottom: 15px; color: #333f48; font-family: Arial, sans-s=
erif; font-size: 16px;">I am currently using the 5.10.y kernel source.&nbsp=
; Prior to this I was using 3.10.17 kernel and I faced the same issue, and =
the issue was solved by adding a retry logic in the imx6_pcie_host_init fun=
ction. Each time the init failed, the logic was to assert/deassert the Rese=
t signal and try the&nbsp;&nbsp;imx6_pcie_host_init again.&nbsp; In this wa=
y we were able to solve the problem.</p>
<p style=3D"margin-bottom: 15px; color: #333f48; font-family: Arial, sans-s=
erif; font-size: 16px;">But when a similar kind of patch is done in kernel =
v5.10.y I face the same issue.</p>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">@@ -829,13 +829,48 @@ static int imx6_pcie_host_init(struct pcie_port =
*pp)</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">&nbsp;{</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">&nbsp; &nbsp; &nbsp; &nbsp; struct dw_pcie *pci =3D to_dw_pcie_from_pp=
(pp);</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">&nbsp; &nbsp; &nbsp; &nbsp; struct imx6_pcie *imx6_pcie =3D to_imx6_pc=
ie(pci);</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+&nbsp; &nbsp; &nbsp; &nbsp;int retry =3D 0;</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+&nbsp; &nbsp; &nbsp; &nbsp;int ret =3D 0;</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+&nbsp; &nbsp; &nbsp; &nbsp;do {</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">imx6_pcie_assert_core_reset(imx6_pcie);</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">imx6_pcie_init_phy(imx6_pcie);</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">imx6_pcie_deassert_core_reset(imx6_pcie);</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">imx6_setup_phy_mpll(imx6_pcie);</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">dw_pcie_setup_rc(pp);</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">-&nbsp; &nbsp; &nbsp; &nbsp; imx6_pcie_establish_link(imx6_pcie);</div=
>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+&nbsp; &nbsp; &nbsp; &nbsp; ret =3D imx6_pcie_establish_link(imx6_pci=
e);</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+&nbsp; &nbsp; &nbsp; &nbsp; if (ret =3D=3D 0) {</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp;</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+&nbsp; &nbsp; &nbsp; &nbsp; dev_info(imx6_pcie-&gt;pci-&gt;dev, "Pci =
reset retry: %d\n", retry);</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+&nbsp; &nbsp; &nbsp; &nbsp; if (gpio_is_valid(imx6_pcie-&gt;reset_gpi=
o)) {</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dev_info(imx6=
_pcie-&gt;pci-&gt;dev, "gpio reset: %d\n", imx6_pcie-&gt;reset_gpio);</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gpio_set_valu=
e(imx6_pcie-&gt;reset_gpio, 0);</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+&nbsp; &nbsp; &nbsp; &nbsp; msleep (200);</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+&nbsp; &nbsp; &nbsp; &nbsp;} while (retry++ &lt; 3);</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">+</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">&nbsp; &nbsp; &nbsp; &nbsp; dw_pcie_msi_init(pp);</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">&nbsp;</div>
<div style=3D"color: #333f48; font-family: Arial, sans-serif; font-size: 16=
px;">&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br /><br /></div>
<p style=3D"margin-bottom: 15px; color: #333f48; font-family: Arial, sans-s=
erif; font-size: 16px;"><strong>The main problem is that there are boards i=
n the field which use the current hardware design and in the 3.10.17 kernel=
 the retry logic seems to solve the problem.&nbsp; But the same retry logic=
 is not working in the 5.10.y kernel with the same hardware</strong></p>
<p style=3D"margin-bottom: 15px; color: #333f48; font-family: Arial, sans-s=
erif; font-size: 16px;">Can anyone suggest me some workaround for this prob=
lem?</p>

--cdbkza0LyNgte8XhpCXb--