Skip to contentSkip to conversation

PCI: mediatek-gen3: fix PCIe #PERST being de-asserted too early

PATCH In review Daniel Golle 4 participants 4 messages Oct 6, 2023 – Oct 13, 2023 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: mediatek-gen3: fix PCIe #PERST being de-asserted too early

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.

---
 drivers/pci/controller/pcie-mediatek-gen3.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/pci/controller/pcie-mediatek-gen3.c +7 -1
index e0e27645fdf4..ba8cfce03aad 100644
@@ -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 */
Signature · 1 line
2.42.0
#1 lore raw

drivers/pci/controller/pcie-mediatek-gen3.c static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)

Quoted 15 lines · Daniel Golle

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.

---
 drivers/pci/controller/pcie-mediatek-gen3.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/pci/controller/pcie-mediatek-gen3.c +0 -0
index e0e27645fdf4..ba8cfce03aad 100644
@@ -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.

drivers/pci/controller/pcie-mediatek-gen3.c static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) · line 356

Quoted 8 lines
drivers/pci/controller/pcie-mediatek-gen3.c +4 -1
 	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?

Quoted 13 lines
drivers/pci/controller/pcie-mediatek-gen3.c +2 -0
+	/* 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 */
Signature · 7 lines
2.42.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 59 lines · Frank Wunderlich

Am 10. Oktober 2023 18:04:23 MESZ schrieb Bjorn Helgaas <[email protected]>:

Quoted 51 lines · Daniel Golle

drivers/pci/controller/pcie-mediatek-gen3.c static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)

Quoted 15 lines

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.

---
 drivers/pci/controller/pcie-mediatek-gen3.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/pci/controller/pcie-mediatek-gen3.c +0 -0
index e0e27645fdf4..ba8cfce03aad 100644
@@ -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.

drivers/pci/controller/pcie-mediatek-gen3.c static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) · line 356

Quoted 8 lines
drivers/pci/controller/pcie-mediatek-gen3.c +4 -1
 	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?

Quoted 9 lines
drivers/pci/controller/pcie-mediatek-gen3.c +2 -0
+	/* 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 */
Signature · 1 line
2.42.0
Quoted 4 lines
Quoted 4 lines

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Hi

Quoted 6 lines

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/[email protected]/

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.

Signature · 1 line
	Ansuel
#4 lore raw
In reply to a message not in the archive
Quoted 67 lines · Frank Wunderlich

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 < [email protected]>:

Quoted 53 lines · Daniel Golle
Quoted 16 lines

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.

 drivers/pci/controller/pcie-mediatek-gen3.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/pci/controller/pcie-mediatek-gen3.c +0 -0
index e0e27645fdf4..ba8cfce03aad 100644

drivers/pci/controller/pcie-mediatek-gen3.c static int mtk_pcie_startup_port(struct · line 351

Quoted 2 lines
drivers/pci/controller/pcie-mediatek-gen3.c +0 -0
@@ -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.

drivers/pci/controller/pcie-mediatek-gen3.c static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) · line 356

Quoted 10 lines
drivers/pci/controller/pcie-mediatek-gen3.c +4 -1
 	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?

Quoted 4 lines
drivers/pci/controller/pcie-mediatek-gen3.c +2 -0
+	/* De-assert PERST# signals */
+	val &= ~(PCIE_PE_RSTB);
 	writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
Quoted 6 lines
Quoted 6 lines

/* Check if the link is up or not */

Signature · 4 lines
2.42.0
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Hi

Quoted 4 lines

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/[email protected]/

Quoted 3 lines

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.