linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: mediatek-gen3: Assert resets to ensure expected init state
@ 2022-04-04 14:48 AngeloGioacchino Del Regno
  2022-05-09 12:18 ` AngeloGioacchino Del Regno
  2022-05-11 14:26 ` Lorenzo Pieralisi
  0 siblings, 2 replies; 5+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-04-04 14:48 UTC (permalink / raw)
  To: ryder.lee
  Cc: jianjun.wang, lorenzo.pieralisi, robh, kw, bhelgaas, p.zabel,
	matthias.bgg, linux-pci, linux-mediatek, linux-kernel,
	linux-arm-kernel, kernel, nfraprado, AngeloGioacchino Del Regno

The controller may have been left out of reset by the bootloader,
in which case, before the powerup sequence, the controller will be
found preconfigured with values that were set before booting the
kernel: this produces a controller failure, with the result of
a failure during the mtk_pcie_startup_port() sequence as the PCIe
link never gets up.

To ensure that we get a clean start in an expected state, assert
both the PHY and MAC resets before executing the controller
power-up sequence.

Fixes: d3bf75b579b9 ("PCI: mediatek-gen3: Add MediaTek Gen3 driver for MT8192")
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/pci/controller/pcie-mediatek-gen3.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
index f7048ea4c020..dccdfce12b1c 100644
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
@@ -838,6 +838,14 @@ static int mtk_pcie_setup(struct mtk_gen3_pcie *pcie)
 	if (err)
 		return err;
 
+	/*
+	 * The controller may have been left out of reset by the bootloader
+	 * so make sure that we get a clean start by asserting resets here.
+	 */
+	reset_control_assert(pcie->phy_reset);
+	reset_control_assert(pcie->mac_reset);
+	usleep_range(10, 20);
+
 	/* Don't touch the hardware registers before power up */
 	err = mtk_pcie_power_up(pcie);
 	if (err)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] PCI: mediatek-gen3: Assert resets to ensure expected init state
  2022-04-04 14:48 [PATCH] PCI: mediatek-gen3: Assert resets to ensure expected init state AngeloGioacchino Del Regno
@ 2022-05-09 12:18 ` AngeloGioacchino Del Regno
  2022-05-09 17:16   ` Bjorn Helgaas
  2022-05-11 14:26 ` Lorenzo Pieralisi
  1 sibling, 1 reply; 5+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-05-09 12:18 UTC (permalink / raw)
  To: ryder.lee
  Cc: jianjun.wang, lorenzo.pieralisi, robh, kw, bhelgaas, p.zabel,
	matthias.bgg, linux-pci, linux-mediatek, linux-kernel,
	linux-arm-kernel, kernel, nfraprado

Il 04/04/22 16:48, AngeloGioacchino Del Regno ha scritto:
> The controller may have been left out of reset by the bootloader,
> in which case, before the powerup sequence, the controller will be
> found preconfigured with values that were set before booting the
> kernel: this produces a controller failure, with the result of
> a failure during the mtk_pcie_startup_port() sequence as the PCIe
> link never gets up.
> 
> To ensure that we get a clean start in an expected state, assert
> both the PHY and MAC resets before executing the controller
> power-up sequence.
> 
> Fixes: d3bf75b579b9 ("PCI: mediatek-gen3: Add MediaTek Gen3 driver for MT8192")
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

Friendly ping for an important fix :-)

Regards,
Angelo

> ---
>   drivers/pci/controller/pcie-mediatek-gen3.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> index f7048ea4c020..dccdfce12b1c 100644
> --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> @@ -838,6 +838,14 @@ static int mtk_pcie_setup(struct mtk_gen3_pcie *pcie)
>   	if (err)
>   		return err;
>   
> +	/*
> +	 * The controller may have been left out of reset by the bootloader
> +	 * so make sure that we get a clean start by asserting resets here.
> +	 */
> +	reset_control_assert(pcie->phy_reset);
> +	reset_control_assert(pcie->mac_reset);
> +	usleep_range(10, 20);
> +
>   	/* Don't touch the hardware registers before power up */
>   	err = mtk_pcie_power_up(pcie);
>   	if (err)



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PCI: mediatek-gen3: Assert resets to ensure expected init state
  2022-05-09 12:18 ` AngeloGioacchino Del Regno
@ 2022-05-09 17:16   ` Bjorn Helgaas
  2022-05-10  7:59     ` AngeloGioacchino Del Regno
  0 siblings, 1 reply; 5+ messages in thread
From: Bjorn Helgaas @ 2022-05-09 17:16 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno
  Cc: ryder.lee, jianjun.wang, lorenzo.pieralisi, robh, kw, bhelgaas,
	p.zabel, matthias.bgg, linux-pci, linux-mediatek, linux-kernel,
	linux-arm-kernel, kernel, nfraprado

On Mon, May 09, 2022 at 02:18:34PM +0200, AngeloGioacchino Del Regno wrote:
> Il 04/04/22 16:48, AngeloGioacchino Del Regno ha scritto:
> > The controller may have been left out of reset by the bootloader,
> > in which case, before the powerup sequence, the controller will be
> > found preconfigured with values that were set before booting the
> > kernel: this produces a controller failure, with the result of
> > a failure during the mtk_pcie_startup_port() sequence as the PCIe
> > link never gets up.
> > 
> > To ensure that we get a clean start in an expected state, assert
> > both the PHY and MAC resets before executing the controller
> > power-up sequence.
> > 
> > Fixes: d3bf75b579b9 ("PCI: mediatek-gen3: Add MediaTek Gen3 driver for MT8192")
> > Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> 
> Friendly ping for an important fix :-)

d3bf75b579b9 appeared in v5.13-rc1 (May 2021, a year ago), so I assume
this is important for v5.19, but not urgent enough to require being in
v5.18.  Right?

> > ---
> >   drivers/pci/controller/pcie-mediatek-gen3.c | 8 ++++++++
> >   1 file changed, 8 insertions(+)
> > 
> > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
> > index f7048ea4c020..dccdfce12b1c 100644
> > --- a/drivers/pci/controller/pcie-mediatek-gen3.c
> > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
> > @@ -838,6 +838,14 @@ static int mtk_pcie_setup(struct mtk_gen3_pcie *pcie)
> >   	if (err)
> >   		return err;
> > +	/*
> > +	 * The controller may have been left out of reset by the bootloader
> > +	 * so make sure that we get a clean start by asserting resets here.
> > +	 */
> > +	reset_control_assert(pcie->phy_reset);
> > +	reset_control_assert(pcie->mac_reset);
> > +	usleep_range(10, 20);
> > +
> >   	/* Don't touch the hardware registers before power up */
> >   	err = mtk_pcie_power_up(pcie);
> >   	if (err)
> 
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PCI: mediatek-gen3: Assert resets to ensure expected init state
  2022-05-09 17:16   ` Bjorn Helgaas
@ 2022-05-10  7:59     ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 5+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-05-10  7:59 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: ryder.lee, jianjun.wang, lorenzo.pieralisi, robh, kw, bhelgaas,
	p.zabel, matthias.bgg, linux-pci, linux-mediatek, linux-kernel,
	linux-arm-kernel, kernel, nfraprado

Il 09/05/22 19:16, Bjorn Helgaas ha scritto:
> On Mon, May 09, 2022 at 02:18:34PM +0200, AngeloGioacchino Del Regno wrote:
>> Il 04/04/22 16:48, AngeloGioacchino Del Regno ha scritto:
>>> The controller may have been left out of reset by the bootloader,
>>> in which case, before the powerup sequence, the controller will be
>>> found preconfigured with values that were set before booting the
>>> kernel: this produces a controller failure, with the result of
>>> a failure during the mtk_pcie_startup_port() sequence as the PCIe
>>> link never gets up.
>>>
>>> To ensure that we get a clean start in an expected state, assert
>>> both the PHY and MAC resets before executing the controller
>>> power-up sequence.
>>>
>>> Fixes: d3bf75b579b9 ("PCI: mediatek-gen3: Add MediaTek Gen3 driver for MT8192")
>>> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>>
>> Friendly ping for an important fix :-)
> 
> d3bf75b579b9 appeared in v5.13-rc1 (May 2021, a year ago), so I assume
> this is important for v5.19, but not urgent enough to require being in
> v5.18.  Right?
> 

Hello Bjorn,
no it's not *very* urgent, as MediaTek devices that do require this will be
in v5.19 anyway...

Thanks,
Angelo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PCI: mediatek-gen3: Assert resets to ensure expected init state
  2022-04-04 14:48 [PATCH] PCI: mediatek-gen3: Assert resets to ensure expected init state AngeloGioacchino Del Regno
  2022-05-09 12:18 ` AngeloGioacchino Del Regno
@ 2022-05-11 14:26 ` Lorenzo Pieralisi
  1 sibling, 0 replies; 5+ messages in thread
From: Lorenzo Pieralisi @ 2022-05-11 14:26 UTC (permalink / raw)
  To: ryder.lee, AngeloGioacchino Del Regno
  Cc: Lorenzo Pieralisi, linux-arm-kernel, linux-pci, linux-mediatek,
	jianjun.wang, linux-kernel, robh, kernel, p.zabel, matthias.bgg,
	bhelgaas, nfraprado, kw

On Mon, 4 Apr 2022 16:48:58 +0200, AngeloGioacchino Del Regno wrote:
> The controller may have been left out of reset by the bootloader,
> in which case, before the powerup sequence, the controller will be
> found preconfigured with values that were set before booting the
> kernel: this produces a controller failure, with the result of
> a failure during the mtk_pcie_startup_port() sequence as the PCIe
> link never gets up.
> 
> [...]

Applied to pci/mediatek, thanks!

[1/1] PCI: mediatek-gen3: Assert resets to ensure expected init state
      https://git.kernel.org/lpieralisi/pci/c/1d565935e3

Thanks,
Lorenzo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-11 14:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-04 14:48 [PATCH] PCI: mediatek-gen3: Assert resets to ensure expected init state AngeloGioacchino Del Regno
2022-05-09 12:18 ` AngeloGioacchino Del Regno
2022-05-09 17:16   ` Bjorn Helgaas
2022-05-10  7:59     ` AngeloGioacchino Del Regno
2022-05-11 14:26 ` Lorenzo Pieralisi

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).