PCI: meson: Fix PERST# timing by asserting reset before LTSSM enable
Subsystems (4)
PATCH 1/1 PCI: meson: Fix PERST# timing by asserting reset before LTSSM enable
On warm reboot, the PCIe controller's LTSSM starts link training immediately if PERST# is already deasserted from the previous boot. The driver then pulses PERST# for only 500us, which is too short to properly reset the endpoint device that has already started training.
Fix by moving the PERST# assert/deassert pulse BEFORE enabling LTSSM, so the endpoint gets a clean reset cycle before link training begins.
This was found on Amlogic G12B (A311D) with NVMe on an M.2 slot. Cold boot worked because POR held PERST# low; warm reboot did not. The fix was confirmed on a Banana Pi CM4 with Waveshare IO base board.
--- drivers/pci/controller/dwc/pci-meson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pci-meson.c +1 -1
@@ -310,8 +310,8 @@ static int meson_pcie_start_link(struct dw_pcie *pci) {struct meson_pcie *mp =to_meson_pcie (pci); +meson_pcie_assert_reset (mp);meson_pcie_ltssm_enable (mp); -meson_pcie_assert_reset (mp);return 0 ; }
Signature · 1 line
2.49.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines
On warm reboot, the PCIe controller's LTSSM starts link training immediately if PERST# is already deasserted from the previous boot. The driver then pulses PERST# for only 500us, which is too short to properly reset the endpoint device that has already started training.
Quoted 8 lines
Fix by moving the PERST# assert/deassert pulse BEFORE enabling LTSSM, so the endpoint gets a clean reset cycle before link training begins.
This was found on Amlogic G12B (A311D) with NVMe on an M.2 slot. Cold boot worked because POR held PERST# low; warm reboot did not. The fix was confirmed on a Banana Pi CM4 with Waveshare IO base board.
Signed-off-by Gowtham Kudupudi <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 22 lines · Gowtham Kudupudi
On warm reboot, the PCIe controller's LTSSM starts link training immediately if PERST# is already deasserted from the previous boot. The driver then pulses PERST# for only 500us, which is too short to properly reset the endpoint device that has already started training.
Fix by moving the PERST# assert/deassert pulse BEFORE enabling LTSSM, so the endpoint gets a clean reset cycle before link training begins.
This was found on Amlogic G12B (A311D) with NVMe on an M.2 slot. Cold boot worked because POR held PERST# low; warm reboot did not. The fix was confirmed on a Banana Pi CM4 with Waveshare IO base board.
Signed-off-by Gowtham Kudupudi <[email protected]>--- drivers/pci/controller/dwc/pci-meson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/controller/dwc/pci-meson.c +0
-0
drivers/pci/controller/dwc/pci-meson.c static int meson_pcie_start_link(struct dw_pcie *pci) · line 317
Quoted 9 lines
drivers/pci/controller/dwc/pci-meson.c +1
-1@@ -310,8 +310,8 @@ static int meson_pcie_start_link(struct dw_pcie *pci) {struct meson_pcie *mp =to_meson_pcie (pci); +meson_pcie_assert_reset (mp);meson_pcie_ltssm_enable (mp); -meson_pcie_assert_reset (mp);return 0 ; }
Hi Gowtham,
I have a patch [1] that I haven't submitted yet. This might be related to your issue, what do you think ?
[1] https://github.com/rclaveau-tech/linux-khadas/commit/bee0a02d9756
Signature · 7 lines
Best regards, Ronald _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
Quoted 26 lines · Ronald Claveau
Quoted 25 lines · Gowtham Kudupudi
On warm reboot, the PCIe controller's LTSSM starts link training immediately if PERST# is already deasserted from the previous boot. The driver then pulses PERST# for only 500us, which is too short to properly reset the endpoint device that has already started training.
Fix by moving the PERST# assert/deassert pulse BEFORE enabling LTSSM, so the endpoint gets a clean reset cycle before link training begins.
This was found on Amlogic G12B (A311D) with NVMe on an M.2 slot. Cold boot worked because POR held PERST# low; warm reboot did not. The fix was confirmed on a Banana Pi CM4 with Waveshare IO base board.
Signed-off-by Gowtham Kudupudi <[email protected]>--- drivers/pci/controller/dwc/pci-meson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/controller/dwc/pci-meson.c +0
-0@@ -310,8 +310,8 @@ static int meson_pcie_start_link(struct dw_pcie *pci) {struct meson_pcie *mp =to_meson_pcie (pci);
Quoted 3 lines
drivers/pci/controller/dwc/pci-meson.c static int meson_pcie_start_link(struct dw_pcie *pci) · line 314
Quoted 3 lines
drivers/pci/controller/dwc/pci-meson.c +1
-1+meson_pcie_assert_reset (mp);meson_pcie_ltssm_enable (mp); -meson_pcie_assert_reset (mp);
I think this change is valid, other controllers resets PERST in the host init callback, so either this or move to the init callback.
Quoted 8 lines
drivers/pci/controller/dwc/pci-meson.c static int meson_pcie_start_link(struct dw_pcie *pci) · line 317
Quoted 3 lines
drivers/pci/controller/dwc/pci-meson.c +0
-0return 0 ; }Hi Gowtham,
I have a patch [1] that I haven't submitted yet. This might be related to your issue, what do you think ?
Ronald, This fix is valid, it's definitely better to probe the driver with PERST asserted, please send it.
Neil
Quoted 3 lines
[1] https://github.com/rclaveau-tech/linux-khadas/commit/bee0a02d9756
Hi,
As Neil suggested I moved the PCIe reset to init; I've updated the tag at
https://github.com/GowthamKudupudi/linux/tree/meson-pcie-warm-reset-linux-7.0.y
Ronald, yes, I do think its proper to initialize PCIe with RESET Active. Anyway we need the reset *cycle*. Please submit your patch as well.
Thank you!
...Gowtham
Quoted 58 lines · On Tue, 16 Jun 2026 08:06:02 +0200 [email protected] wrote:
Quoted 29 lines · Ronald Claveau
Quoted 28 lines · Gowtham Kudupudi
On warm reboot, the PCIe controller's LTSSM starts link training immediately if PERST# is already deasserted from the previous boot. The driver then pulses PERST# for only 500us, which is too short to properly reset the endpoint device that has already started training.
Fix by moving the PERST# assert/deassert pulse BEFORE enabling LTSSM, so the endpoint gets a clean reset cycle before link training begins.
This was found on Amlogic G12B (A311D) with NVMe on an M.2 slot. Cold boot worked because POR held PERST# low; warm reboot did not. The fix was confirmed on a Banana Pi CM4 with Waveshare IO base board.
Signed-off-by Gowtham Kudupudi <[email protected]>--- drivers/pci/controller/dwc/pci-meson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/pci/controller/dwc/pci-meson.cindex5f8e2f4b3c12..3a7e9f1d5b8c100644 ---a/drivers/pci/controller/dwc/pci-meson.c+++b/drivers/pci/controller/dwc/pci-meson.c@@ -310,8 +310,8 @@ static intmeson_pcie_start_link(struct dw_pcie *pci){
structmeson_pcie*mp =to_meson_pcie(pci);Quoted 3 lines
drivers/pci/controller/dwc/pci-meson.c static int meson_pcie_start_link(struct dw_pcie *pci) · line 314
Quoted 3 lines
drivers/pci/controller/dwc/pci-meson.c +1
-1+meson_pcie_assert_reset (mp);meson_pcie_ltssm_enable (mp); -meson_pcie_assert_reset (mp);I think this change is valid, other controllers resets PERST in the host init callback, so either this or move to the init callback.
Reviewed-by Neil Armstrong <[email protected]>Quoted 8 lines
Quoted 3 lines
return 0; }Hi Gowtham,
I have a patch [1] that I haven't submitted yet. This might be related to your issue, what do you think ?
Ronald, This fix is valid, it's definitely better to probe the driver with PERST asserted, please send it.
Neil
Quoted 3 lines
[1]
https://github.com/rclaveau-tech/linux-khadas/commit/bee0a02d9756
Hi Ronald,
I see you submitted the patch. Last couple of days I've been fixing the etherenet of my BPiCM4+Waveshare-io-base-b due to which I couldn't test your patch any sooner. Now I got my ethernet working but now I couldn't reproduce the issue *without* either of our patches!!!
Anyway it's proper to initialize PCIe with RESET Active but I think meson_pcie_assert_reset(mp) will give sufficient time to PCIe devices to complete the reset cycle.
--- drivers/pci/controller/dwc/pci-meson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0
b/drivers/pci/controller/dwc/pci-meson.c index 0694084f612..c28ab40c9ff 100644 --- a/drivers/pci/controller/dwc/pci-meson.c
+++ b/drivers/pci/controller/dwc/pci-meson.c
@@ -308,8 +308,8 @@ static int meson_pcie_start_link(struct dw_pcie *pci) {
struct meson_pcie *mp = to_meson_pcie(pci);
- meson_pcie_ltssm_enable(mp);
meson_pcie_assert_reset(mp);
+ meson_pcie_ltssm_enable(mp);
return 0;
}
Signature · 3 lines
--- drivers/pci/controller/dwc/pci-meson.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
(quoted diff) +0 -0
b/drivers/pci/controller/dwc/pci-meson.c index c28ab40c9ff..2ef75157530 100644 --- a/drivers/pci/controller/dwc/pci-meson.c
+++ b/drivers/pci/controller/dwc/pci-meson.c
@@ -308,7 +308,6 @@ static int meson_pcie_start_link(struct dw_pcie *pci) {
struct meson_pcie *mp = to_meson_pcie(pci);
- meson_pcie_assert_reset(mp);
meson_pcie_ltssm_enable(mp);
return 0;
@@ -362,6 +361,8 @@ static int meson_pcie_host_init(struct dw_pcie_rp *pp)
pp->bridge->ops = &meson_pci_ops;
+ meson_pcie_assert_reset(mp);
+
meson_set_max_payload(mp, MAX_PAYLOAD_SIZE); meson_set_max_rd_req_size(mp, MAX_READ_REQ_SIZE);
Signature · 4 lines
...Gowtham On Wed, 17 Jun 2026 05:06:27 +0530
Quoted 10 lines · gowtham
Hi,
As Neil suggested I moved the PCIe reset to init; I've updated the tag at
https://github.com/GowthamKudupudi/linux/tree/meson-pcie-warm-reset-linux-7.0.yRonald, yes, I do think its proper to initialize PCIe with RESET Active. Anyway we need the reset *cycle*. Please submit your patch as well.
Quoted 67 lines
Thank you!
...Gowtham
Quoted 59 lines · On Tue, 16 Jun 2026 08:06:02 +0200 [email protected] wrote:
Quoted 29 lines · Ronald Claveau
Quoted 28 lines · Gowtham Kudupudi
On warm reboot, the PCIe controller's LTSSM starts link training immediately if PERST# is already deasserted from the previous boot. The driver then pulses PERST# for only 500us, which is too short to properly reset the endpoint device that has already started training.
Fix by moving the PERST# assert/deassert pulse BEFORE enabling LTSSM, so the endpoint gets a clean reset cycle before link training begins.
This was found on Amlogic G12B (A311D) with NVMe on an M.2 slot. Cold boot worked because POR held PERST# low; warm reboot did not. The fix was confirmed on a Banana Pi CM4 with Waveshare IO base board.
Signed-off-by Gowtham Kudupudi <[email protected]>--- drivers/pci/controller/dwc/pci-meson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/pci/controller/dwc/pci-meson.cindex5f8e2f4b3c12..3a7e9f1d5b8c100644 ---a/drivers/pci/controller/dwc/pci-meson.c+++b/drivers/pci/controller/dwc/pci-meson.c@@ -310,8 +310,8 @@ static intmeson_pcie_start_link(struct dw_pcie *pci){
structmeson_pcie*mp =to_meson_pcie(pci);Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +1
-1+ meson_pcie_assert_reset(mp); meson_pcie_ltssm_enable(mp); - meson_pcie_assert_reset(mp);I think this change is valid, other controllers resets PERST in the host init callback, so either this or move to the init callback.
Reviewed-by Neil Armstrong <[email protected]>Quoted 8 lines
Quoted 3 lines
return 0; }Hi Gowtham,
I have a patch [1] that I haven't submitted yet. This might be related to your issue, what do you think ?
Ronald, This fix is valid, it's definitely better to probe the driver with PERST asserted, please send it.
Neil
Quoted 4 lines
[1]
https://github.com/rclaveau-tech/linux-khadas/commit/bee0a02d9756
From 852811b11795ee389ea6a953ed0db69b76722469 Mon Sep 17 00:00:00 2001
From: Gowtham Kudupudi <[email protected]>
Date: Sun, 14 Jun 2026 09:41:01 +0530
Subject: [PATCH 1/2] PCI: meson: Fix PERST# timing by asserting reset before
LTSSM enable
On warm reboot, the PCIe controller's LTSSM starts link training immediately if PERST# is already deasserted from the previous boot. The driver then pulses PERST# for only 500us, which is too short to properly reset the endpoint device that has already started training.
Fix by moving the PERST# assert/deassert pulse BEFORE enabling LTSSM, so the endpoint gets a clean reset cycle before link training begins.
This was found on Amlogic G12B (A311D) with NVMe on an M.2 slot. Cold boot worked because POR held PERST# low; warm reboot did not. The fix was confirmed on a Banana Pi CM4 with Waveshare IO base board.
--- drivers/pci/controller/dwc/pci-meson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pci-meson.c +1 -1
@@ -308,8 +308,8 @@ static int meson_pcie_start_link(struct dw_pcie *pci) {struct meson_pcie *mp =to_meson_pcie (pci); -meson_pcie_ltssm_enable (mp);meson_pcie_assert_reset (mp); +meson_pcie_ltssm_enable (mp);return 0 ; }
Signature · 1 line
2.54.0
From 1bcf2c787d72b2c25852cc598b1201510b4132b0 Mon Sep 17 00:00:00 2001
From: Gowtham Kudupudi <[email protected]>
Date: Wed, 17 Jun 2026 04:29:45 +0530
Subject: [PATCH 2/2] PCI: meson: pcie reset moved to meson_pcie_host_init
As per the Neil's suggestion, inititial PCIe reset is moved to init to make it proper.
--- drivers/pci/controller/dwc/pci-meson.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pci-meson.c +2 -1
@@ -308,7 +308,6 @@ static int meson_pcie_start_link(struct dw_pcie *pci) {struct meson_pcie *mp =to_meson_pcie (pci); -meson_pcie_assert_reset (mp);meson_pcie_ltssm_enable (mp);return 0 ;
@@ -362,6 +361,8 @@ static int meson_pcie_host_init(struct dw_pcie_rp *pp) pp->bridge->ops = &meson_pci_ops; +meson_pcie_assert_reset (mp); +meson_set_max_payload (mp,MAX_PAYLOAD_SIZE );meson_set_max_rd_req_size (mp,MAX_READ_REQ_SIZE );
Signature · 1 line
2.54.0
Quoted 10 lines · gowtham
Hi Ronald,
I see you submitted the patch. Last couple of days I've been fixing the etherenet of my BPiCM4+Waveshare-io-base-b due to which I couldn't test your patch any sooner. Now I got my ethernet working but now I couldn't reproduce the issue *without* either of our patches!!!Anyway it's proper to initialize PCIe with RESET Active but I think
meson_pcie_assert_reset(mp)will give sufficient time to PCIe devices to complete the reset cycle.
Hi Gowtham,
No worries and no rush to me.
I think it's due to how uboot set the gpio before the linux boot for my issue, and that does not seem to be relevant for yours. Thank you for testing the patch.
Quoted 18 lines
--- drivers/pci/controller/dwc/pci-meson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/pci/controller/dwc/pci-meson.cindex0694084f612..c28ab40c9ff100644 ---a/drivers/pci/controller/dwc/pci-meson.c
+++b/drivers/pci/controller/dwc/pci-meson.cdrivers/pci/controller/dwc/pci-meson.c +1
-1@@ -308,8 +308,8 @@ static int meson_pcie_start_link(struct dw_pcie *pci) {struct meson_pcie *mp =to_meson_pcie (pci); -meson_pcie_ltssm_enable (mp);meson_pcie_assert_reset (mp); +meson_pcie_ltssm_enable (mp);return 0 ; }
Signature · 2 lines
Best regards, Ronald
Manivannan Sadhasivam
maintainerQuoted 26 lines · Ronald Claveau
Quoted 25 lines · Gowtham Kudupudi
On warm reboot, the PCIe controller's LTSSM starts link training immediately if PERST# is already deasserted from the previous boot. The driver then pulses PERST# for only 500us, which is too short to properly reset the endpoint device that has already started training.
Fix by moving the PERST# assert/deassert pulse BEFORE enabling LTSSM, so the endpoint gets a clean reset cycle before link training begins.
This was found on Amlogic G12B (A311D) with NVMe on an M.2 slot. Cold boot worked because POR held PERST# low; warm reboot did not. The fix was confirmed on a Banana Pi CM4 with Waveshare IO base board.
Signed-off-by Gowtham Kudupudi <[email protected]>--- drivers/pci/controller/dwc/pci-meson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/controller/dwc/pci-meson.c +0
-0@@ -310,8 +310,8 @@ static int meson_pcie_start_link(struct dw_pcie *pci) {struct meson_pcie *mp =to_meson_pcie (pci);
Quoted 3 lines
drivers/pci/controller/dwc/pci-meson.c static int meson_pcie_start_link(struct dw_pcie *pci) · line 314
Quoted 3 lines
drivers/pci/controller/dwc/pci-meson.c +1
-1+meson_pcie_assert_reset (mp);meson_pcie_ltssm_enable (mp); -meson_pcie_assert_reset (mp);
meson_pcie_assert_reset() itself is wrong as it toggles PERST#. You'd just need:
msleep(PCIE_T_PERST_CLK_US); gpiod_set_value_cansleep(mp->reset_gpio, GPIOD_OUT_LOW)
but in probe(), after meson_pcie_probe_clocks() as that's when both power and REFCLK becomes stable.
Quoted 11 lines
drivers/pci/controller/dwc/pci-meson.c static int meson_pcie_start_link(struct dw_pcie *pci) · line 317
Quoted 3 lines
drivers/pci/controller/dwc/pci-meson.c +0
-0return 0 ; }Hi Gowtham,
I have a patch [1] that I haven't submitted yet. This might be related to your issue, what do you think ?
[1] https://github.com/rclaveau-tech/linux-khadas/commit/bee0a02d9756
This patch is also needed as it correctly fixes the PERST# polarity when requesting the GPIO. Since the devicetree is defining the PERST# GPIO as ACIVE_LOW, the driver should request it as GPIOD_OUT_HIGH to make sure that PERST# is asserted.
So please submit the referenced patch.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 51 lines · Manivannan Sadhasivam
Quoted 26 lines · Ronald Claveau
Quoted 25 lines · Gowtham Kudupudi
On warm reboot, the PCIe controller's LTSSM starts link training immediately if PERST# is already deasserted from the previous boot. The driver then pulses PERST# for only 500us, which is too short to properly reset the endpoint device that has already started training.
Fix by moving the PERST# assert/deassert pulse BEFORE enabling LTSSM, so the endpoint gets a clean reset cycle before link training begins.
This was found on Amlogic G12B (A311D) with NVMe on an M.2 slot. Cold boot worked because POR held PERST# low; warm reboot did not. The fix was confirmed on a Banana Pi CM4 with Waveshare IO base board.
Signed-off-by Gowtham Kudupudi <[email protected]>--- drivers/pci/controller/dwc/pci-meson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/controller/dwc/pci-meson.c +0
-0@@ -310,8 +310,8 @@ static int meson_pcie_start_link(struct dw_pcie *pci) {struct meson_pcie *mp =to_meson_pcie (pci);Quoted 3 lines
drivers/pci/controller/dwc/pci-meson.c static int meson_pcie_start_link(struct dw_pcie *pci) · line 314
Quoted 3 lines
drivers/pci/controller/dwc/pci-meson.c +1
-1+meson_pcie_assert_reset (mp);meson_pcie_ltssm_enable (mp); -meson_pcie_assert_reset (mp);
meson_pcie_assert_reset()itself is wrong as it toggles PERST#. You'd just need:
msleep(PCIE_T_PERST_CLK_US);gpiod_set_value_cansleep(mp->reset_gpio, GPIOD_OUT_LOW)but in
probe(), aftermeson_pcie_probe_clocks()as that's when both power and REFCLK becomes stable.Quoted 11 lines
drivers/pci/controller/dwc/pci-meson.c static int meson_pcie_start_link(struct dw_pcie *pci) · line 317
Quoted 3 lines
drivers/pci/controller/dwc/pci-meson.c +0
-0return 0 ; }Hi Gowtham,
I have a patch [1] that I haven't submitted yet. This might be related to your issue, what do you think ?
[1] https://github.com/rclaveau-tech/linux-khadas/commit/bee0a02d9756
Quoted 9 lines
This patch is also needed as it correctly fixes the PERST# polarity when requesting the GPIO. Since the devicetree is defining the PERST# GPIO as
ACIVE_LOW, the driver should request it asGPIOD_OUT_HIGHto make sure that PERST# is asserted.So please submit the referenced patch.
- Mani
Hi Mani,
I sent it here:
https://lore.kernel.org/all/[email protected]/
Signature · 2 lines
Best regards, Ronald