* [PATCH] PCI: mediatek-gen3: fix PCIe #PERST being de-asserted too early @ 2023-10-06 7:45 Daniel Golle 2023-10-10 16:04 ` Bjorn Helgaas 0 siblings, 1 reply; 4+ messages in thread From: Daniel Golle @ 2023-10-06 7:45 UTC (permalink / raw) To: linux-pci, linux-mediatek, linux-arm-kernel, linux-kernel, AngeloGioacchino Del Regno, Matthias Brugger, Bjorn Helgaas, Rob Herring, Krzysztof Wilczyński, Lorenzo Pieralisi, Jianjun Wang, Ryder Lee Cc: Christian Marangi, Frank Wunderlich, John Crispin The driver for MediaTek gen3 PCIe hosts de-asserts all reset signals at the same time using a single register write operation. Delay the de-assertion of the #PERST signal by 100ms as required by PCIe CEM clause 2.2, some PCIe devices fail to come up otherwise. Signed-off-by: Daniel Golle <daniel@makrotopia.org> --- drivers/pci/controller/pcie-mediatek-gen3.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c index e0e27645fdf4..ba8cfce03aad 100644 --- a/drivers/pci/controller/pcie-mediatek-gen3.c +++ b/drivers/pci/controller/pcie-mediatek-gen3.c @@ -350,7 +350,13 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) msleep(100); /* De-assert reset signals */ - val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB); + val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB); + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); + + msleep(100); + + /* De-assert PERST# signals */ + val &= ~(PCIE_PE_RSTB); writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); /* Check if the link is up or not */ -- 2.42.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: mediatek-gen3: fix PCIe #PERST being de-asserted too early 2023-10-06 7:45 [PATCH] PCI: mediatek-gen3: fix PCIe #PERST being de-asserted too early Daniel Golle @ 2023-10-10 16:04 ` Bjorn Helgaas [not found] ` <1E611A63-AD66-4E61-90F9-F1DB41BD6466@fw-web.de> 0 siblings, 1 reply; 4+ messages in thread From: Bjorn Helgaas @ 2023-10-10 16:04 UTC (permalink / raw) To: Daniel Golle Cc: linux-pci, linux-mediatek, linux-arm-kernel, linux-kernel, AngeloGioacchino Del Regno, Matthias Brugger, Bjorn Helgaas, Rob Herring, Krzysztof Wilczyński, Lorenzo Pieralisi, Jianjun Wang, Ryder Lee, Christian Marangi, Frank Wunderlich, John Crispin On Fri, Oct 06, 2023 at 09:45:58AM +0200, Daniel Golle wrote: > The driver for MediaTek gen3 PCIe hosts de-asserts all reset > signals at the same time using a single register write operation. > Delay the de-assertion of the #PERST signal by 100ms as required by > PCIe CEM clause 2.2, some PCIe devices fail to come up otherwise. > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > --- > drivers/pci/controller/pcie-mediatek-gen3.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c > index e0e27645fdf4..ba8cfce03aad 100644 > --- a/drivers/pci/controller/pcie-mediatek-gen3.c > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c > @@ -350,7 +350,13 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) I feel like I'm missing something because this patch seems to be adding a delay for T_PVPERL, but the comment before the existing msleep() claims *it* is the T_PVPERL delay: * Described in PCIe CEM specification sections 2.2 (PERST# Signal) * and 2.2.1 (Initial Power-Up (G3 to S0)). * The deassertion of PERST# should be delayed 100ms (TPVPERL) * for the power and clock to become stable. > msleep(100); > > /* De-assert reset signals */ > - val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB); > + val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB); > + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); > + > + msleep(100); So I'm confused about these two sleeps. Are they for different parameters? T_PVPERL is defined from "Power stable to PERST# inactive". Do we have any actual indication of when to start that delay, i.e., do we have a clue about when power became stable? > + /* De-assert PERST# signals */ > + val &= ~(PCIE_PE_RSTB); > writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); > > /* Check if the link is up or not */ > -- > 2.42.0 > > > _______________________________________________ > 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] 4+ messages in thread
[parent not found: <1E611A63-AD66-4E61-90F9-F1DB41BD6466@fw-web.de>]
* Re: [PATCH] PCI: mediatek-gen3: fix PCIe #PERST being de-asserted too early [not found] ` <1E611A63-AD66-4E61-90F9-F1DB41BD6466@fw-web.de> @ 2023-10-10 16:49 ` Christian Marangi 2023-10-13 8:31 ` Jianjun Wang (王建军) 1 sibling, 0 replies; 4+ messages in thread From: Christian Marangi @ 2023-10-10 16:49 UTC (permalink / raw) To: Frank Wunderlich Cc: Bjorn Helgaas, Daniel Golle, linux-pci, linux-mediatek, linux-arm-kernel, linux-kernel, AngeloGioacchino Del Regno, Matthias Brugger, Bjorn Helgaas, Rob Herring, Krzysztof Wilczyński, Lorenzo Pieralisi, Jianjun Wang, Ryder Lee, John Crispin On Tue, Oct 10, 2023 at 06:42:07PM +0200, Frank Wunderlich wrote: > Am 10. Oktober 2023 18:04:23 MESZ schrieb Bjorn Helgaas <helgaas@kernel.org>: > >On Fri, Oct 06, 2023 at 09:45:58AM +0200, Daniel Golle wrote: > >> The driver for MediaTek gen3 PCIe hosts de-asserts all reset > >> signals at the same time using a single register write operation. > >> Delay the de-assertion of the #PERST signal by 100ms as required by > >> PCIe CEM clause 2.2, some PCIe devices fail to come up otherwise. > >> > >> Signed-off-by: Daniel Golle <daniel@makrotopia.org> > >> --- > >> drivers/pci/controller/pcie-mediatek-gen3.c | 8 +++++++- > >> 1 file changed, 7 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c > >> index e0e27645fdf4..ba8cfce03aad 100644 > >> --- a/drivers/pci/controller/pcie-mediatek-gen3.c > >> +++ b/drivers/pci/controller/pcie-mediatek-gen3.c > >> @@ -350,7 +350,13 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) > > > >I feel like I'm missing something because this patch seems to be > >adding a delay for T_PVPERL, but the comment before the existing > >msleep() claims *it* is the T_PVPERL delay: > > > > * Described in PCIe CEM specification sections 2.2 (PERST# Signal) > > * and 2.2.1 (Initial Power-Up (G3 to S0)). > > * The deassertion of PERST# should be delayed 100ms (TPVPERL) > > * for the power and clock to become stable. > > > >> msleep(100); > >> > >> /* De-assert reset signals */ > >> - val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB); > >> + val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB); > >> + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); > >> + > >> + msleep(100); > > > >So I'm confused about these two sleeps. Are they for different > >parameters? > > > >T_PVPERL is defined from "Power stable to PERST# inactive". Do we > >have any actual indication of when to start that delay, i.e., do we > >have a clue about when power became stable? > > > >> + /* De-assert PERST# signals */ > >> + val &= ~(PCIE_PE_RSTB); > >> writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); > >> > >> /* Check if the link is up or not */ > >> -- > >> 2.42.0 > >> > >> > >> _______________________________________________ > >> linux-arm-kernel mailing list > >> linux-arm-kernel@lists.infradead.org > >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > > Hi > > Seems it is same as the patch i've sent some time ago and which was rejected because of the additional delay... > > https://patchwork.kernel.org/project/linux-mediatek/patch/20230402131347.99268-1-linux@fw-web.de/ > > Or am i wrong? > regards Frank Reading the other series, I smell this can only be handled by a quirk... This might be a defect or the board not following PCIE hw specs. Thing is that the bug/limitation is there and we have enough info to find way to fix this and lots of tester. Eventually even a fixup based on a specific compatible. -- Ansuel ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PCI: mediatek-gen3: fix PCIe #PERST being de-asserted too early [not found] ` <1E611A63-AD66-4E61-90F9-F1DB41BD6466@fw-web.de> 2023-10-10 16:49 ` Christian Marangi @ 2023-10-13 8:31 ` Jianjun Wang (王建军) 1 sibling, 0 replies; 4+ messages in thread From: Jianjun Wang (王建军) @ 2023-10-13 8:31 UTC (permalink / raw) To: daniel@makrotopia.org, linux@fw-web.de, helgaas@kernel.org Cc: linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, john@phrozen.org, ansuelsmth@gmail.com, robh@kernel.org, kw@linux.com, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, bhelgaas@google.com, lpieralisi@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, Ryder Lee On Tue, 2023-10-10 at 18:42 +0200, Frank Wunderlich wrote: > > External email : Please do not click links or open attachments until > you have verified the sender or the content. > Am 10. Oktober 2023 18:04:23 MESZ schrieb Bjorn Helgaas < > helgaas@kernel.org>: > > On Fri, Oct 06, 2023 at 09:45:58AM +0200, Daniel Golle wrote: > > > The driver for MediaTek gen3 PCIe hosts de-asserts all reset > > > signals at the same time using a single register write operation. > > > Delay the de-assertion of the #PERST signal by 100ms as required > > > by > > > PCIe CEM clause 2.2, some PCIe devices fail to come up otherwise. > > > > > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > > > drivers/pci/controller/pcie-mediatek-gen3.c | 8 +++++++- > > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c > > > b/drivers/pci/controller/pcie-mediatek-gen3.c > > > index e0e27645fdf4..ba8cfce03aad 100644 > > > --- a/drivers/pci/controller/pcie-mediatek-gen3.c > > > +++ b/drivers/pci/controller/pcie-mediatek-gen3.c > > > @@ -350,7 +350,13 @@ static int mtk_pcie_startup_port(struct > > > mtk_gen3_pcie *pcie) > > > > > > > I feel like I'm missing something because this patch seems to be > > adding a delay for T_PVPERL, but the comment before the existing > > msleep() claims *it* is the T_PVPERL delay: > > > > * Described in PCIe CEM specification sections 2.2 (PERST# > > Signal) > > * and 2.2.1 (Initial Power-Up (G3 to S0)). > > * The deassertion of PERST# should be delayed 100ms > > (TPVPERL) > > * for the power and clock to become stable. > > > > > msleep(100); > > > > > > /* De-assert reset signals */ > > > - val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | > > > PCIE_PE_RSTB); > > > + val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB); > > > + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); > > > + > > > + msleep(100); > > > > > > > So I'm confused about these two sleeps. Are they for different > > parameters? > > > > T_PVPERL is defined from "Power stable to PERST# inactive". Do we > > have any actual indication of when to start that delay, i.e., do we > > have a clue about when power became stable? > > > > > + /* De-assert PERST# signals */ > > > + val &= ~(PCIE_PE_RSTB); > > > writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); > > > > > > /* Check if the link is up or not */ > > > -- > > > 2.42.0 > > > linux-arm-kernel mailing list > > > linux-arm-kernel@lists.infradead.org > > > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > > Hi > > Seems it is same as the patch i've sent some time ago and which was > rejected because of the additional delay... > > https://patchwork.kernel.org/project/linux-mediatek/patch/20230402131347.99268-1-linux@fw-web.de/ > > Or am i wrong? > regards Frank Hi Daniel, Did you found this issue on MT7986(BPI-R3) or other platforms? Can you share the PCIe device model that failed to link up? Thanks. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-13 8:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-06 7:45 [PATCH] PCI: mediatek-gen3: fix PCIe #PERST being de-asserted too early Daniel Golle
2023-10-10 16:04 ` Bjorn Helgaas
[not found] ` <1E611A63-AD66-4E61-90F9-F1DB41BD6466@fw-web.de>
2023-10-10 16:49 ` Christian Marangi
2023-10-13 8:31 ` Jianjun Wang (王建军)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox