Skip to contentSkip to conversation

PCI: meson: Remove meson_pcie_link_up() timeout, message, speed check

PATCH Applied Bjorn Helgaas 4 participants 6 messages Nov 3, 2025 – Jan 5

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

PATCH 1/1 PCI: meson: Remove meson_pcie_link_up() timeout, message, speed check

From: Bjorn Helgaas <[email protected]>

Previously meson_pcie_link_up() only returned true if the link was in the L0 state. This was incorrect because hardware autonomously manages transitions between L0, L0s, and L1 while both components on the link stay in D0. Those states should all be treated as "link is active".

Returning false when the device was in L0s or L1 broke config accesses because dw_pcie_other_conf_map_bus() fails if the link is down, which caused errors like this:

meson-pcie fc000000.pcie: error: wait linkup timeout pci 0000:01:00.0: BAR 0: error updating (0xfc700004 != 0xffffffff)

Remove the LTSSM state check, timeout, speed check, and error message from meson_pcie_link_up(), the dw_pcie_ops.link_up() method, so it is a simple boolean check of whether the link is active. Timeouts and and error messages are handled at a higher level, e.g., dw_pcie_wait_for_link().

---
 drivers/pci/controller/dwc/pci-meson.c | 36 +++-----------------------
 1 file changed, 3 insertions(+), 33 deletions(-)
drivers/pci/controller/dwc/pci-meson.c +3 -33
index 787469d1b396..13685d89227a 100644
@@ -338,40 +338,10 @@ static struct pci_ops meson_pci_ops = {
 static bool meson_pcie_link_up(struct dw_pcie *pci)
 {
 	struct meson_pcie *mp = to_meson_pcie(pci);
-	struct device *dev = pci->dev;
-	u32 speed_okay = 0;
-	u32 cnt = 0;
-	u32 state12, state17, smlh_up, ltssm_up, rdlh_up;
+	u32 state12;
 
-	do {
-		state12 = meson_cfg_readl(mp, PCIE_CFG_STATUS12);
-		state17 = meson_cfg_readl(mp, PCIE_CFG_STATUS17);
-		smlh_up = IS_SMLH_LINK_UP(state12);
-		rdlh_up = IS_RDLH_LINK_UP(state12);
-		ltssm_up = IS_LTSSM_UP(state12);
-
-		if (PM_CURRENT_STATE(state17) < PCIE_GEN3)
-			speed_okay = 1;
-
-		if (smlh_up)
-			dev_dbg(dev, "smlh_link_up is on\n");
-		if (rdlh_up)
-			dev_dbg(dev, "rdlh_link_up is on\n");
-		if (ltssm_up)
-			dev_dbg(dev, "ltssm_up is on\n");
-		if (speed_okay)
-			dev_dbg(dev, "speed_okay\n");
-
-		if (smlh_up && rdlh_up && ltssm_up && speed_okay)
-			return true;
-
-		cnt++;
-
-		udelay(10);
-	} while (cnt < WAIT_LINKUP_TIMEOUT);
-
-	dev_err(dev, "error: wait linkup timeout\n");
-	return false;
+	state12 = meson_cfg_readl(mp, PCIE_CFG_STATUS12);
+	return IS_SMLH_LINK_UP(state12) && IS_RDLH_LINK_UP(state12);
 }
 
 static int meson_pcie_host_init(struct dw_pcie_rp *pp)
Signature · 1 line
2.43.0
maintainer Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 67 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

Previously meson_pcie_link_up() only returned true if the link was in the L0 state. This was incorrect because hardware autonomously manages transitions between L0, L0s, and L1 while both components on the link stay in D0. Those states should all be treated as "link is active".

Returning false when the device was in L0s or L1 broke config accesses because dw_pcie_other_conf_map_bus() fails if the link is down, which caused errors like this:

meson-pcie fc000000.pcie: error: wait linkup timeout pci 0000:01:00.0: BAR 0: error updating (0xfc700004 != 0xffffffff)

Remove the LTSSM state check, timeout, speed check, and error message from meson_pcie_link_up(), the dw_pcie_ops.link_up() method, so it is a simple boolean check of whether the link is active. Timeouts and and error messages are handled at a higher level, e.g., dw_pcie_wait_for_link().

---
  drivers/pci/controller/dwc/pci-meson.c | 36 +++-----------------------
  1 file changed, 3 insertions(+), 33 deletions(-)
drivers/pci/controller/dwc/pci-meson.c +1 -28
index 787469d1b396..13685d89227a 100644
@@ -338,40 +338,10 @@ static struct pci_ops meson_pci_ops = {
  static bool meson_pcie_link_up(struct dw_pcie *pci)
  {
  	struct meson_pcie *mp = to_meson_pcie(pci);
-	struct device *dev = pci->dev;
-	u32 speed_okay = 0;
-	u32 cnt = 0;
-	u32 state12, state17, smlh_up, ltssm_up, rdlh_up;
+	u32 state12;
 
-	do {
-		state12 = meson_cfg_readl(mp, PCIE_CFG_STATUS12);
-		state17 = meson_cfg_readl(mp, PCIE_CFG_STATUS17);
-		smlh_up = IS_SMLH_LINK_UP(state12);
-		rdlh_up = IS_RDLH_LINK_UP(state12);
-		ltssm_up = IS_LTSSM_UP(state12);
-
-		if (PM_CURRENT_STATE(state17) < PCIE_GEN3)
-			speed_okay = 1;
-
-		if (smlh_up)
-			dev_dbg(dev, "smlh_link_up is on\n");
-		if (rdlh_up)
-			dev_dbg(dev, "rdlh_link_up is on\n");
-		if (ltssm_up)
-			dev_dbg(dev, "ltssm_up is on\n");
-		if (speed_okay)
-			dev_dbg(dev, "speed_okay\n");
-
-		if (smlh_up && rdlh_up && ltssm_up && speed_okay)
-			return true;
-
-		cnt++;
-

drivers/pci/controller/dwc/pci-meson.c static struct pci_ops meson_pci_ops = { · line 347

Quoted 10 lines
drivers/pci/controller/dwc/pci-meson.c +2 -5
-		udelay(10);
-	} while (cnt < WAIT_LINKUP_TIMEOUT);
-
-	dev_err(dev, "error: wait linkup timeout\n");
-	return false;
+	state12 = meson_cfg_readl(mp, PCIE_CFG_STATUS12);
+	return IS_SMLH_LINK_UP(state12) && IS_RDLH_LINK_UP(state12);
  }
 
  static int meson_pcie_host_init(struct dw_pcie_rp *pp)

Thanks !

Neil

#2 lore raw
In reply to Bjorn Helgaas
Quoted 10 lines · Bjorn Helgaas

Previously meson_pcie_link_up() only returned true if the link was in the L0 state. This was incorrect because hardware autonomously manages transitions between L0, L0s, and L1 while both components on the link stay in D0. Those states should all be treated as "link is active".

Returning false when the device was in L0s or L1 broke config accesses because dw_pcie_other_conf_map_bus() fails if the link is down, which caused errors like this:

[...]

Applied, thanks!

[1/1] PCI: meson: Remove meson_pcie_link_up() timeout, message, speed check

      commit: 11647fc772e977c981259a63c4a2b7e2c312ea22

Best regards,

Signature · 1 line
Manivannan Sadhasivam <[email protected]>
#3 lore raw

Hi Mani,

Quoted 12 lines · Manivannan Sadhasivam
Quoted 9 lines · Bjorn Helgaas

Previously meson_pcie_link_up() only returned true if the link was in the L0 state. This was incorrect because hardware autonomously manages transitions between L0, L0s, and L1 while both components on the link stay in D0. Those states should all be treated as "link is active".

Returning false when the device was in L0s or L1 broke config accesses because dw_pcie_other_conf_map_bus() fails if the link is down, which caused errors like this:

Quoted 6 lines
Quoted 1 line

[...]

Applied, thanks!

[1/1] PCI: meson: Remove meson_pcie_link_up() timeout, message, speed check

      commit: 11647fc772e977c981259a63c4a2b7e2c312ea22

My understanding is that this is queued for -next.
Ricardo (Cc'ed) reported that this patch fixes PCI link up on his Odroid-HC4. Is there a chance to get this patch into -fixes, so it can be pulled by Linus for one of the next -rc?

Best regards,
Martin

#4 lore raw
Quoted 18 lines · Martin Blumenstingl

Hi Mani,

Quoted 14 lines · Manivannan Sadhasivam
Quoted 10 lines · Bjorn Helgaas

Previously meson_pcie_link_up() only returned true if the link was in the L0 state. This was incorrect because hardware autonomously manages transitions between L0, L0s, and L1 while both components on the link stay in D0. Those states should all be treated as "link is active".

Returning false when the device was in L0s or L1 broke config accesses because dw_pcie_other_conf_map_bus() fails if the link is down, which caused errors like this:

[...]

Quoted 9 lines
Quoted 4 lines

Applied, thanks!

[1/1] PCI: meson: Remove meson_pcie_link_up() timeout, message, speed check

      commit: 11647fc772e977c981259a63c4a2b7e2c312ea22

My understanding is that this is queued for -next.
Ricardo (Cc'ed) reported that this patch fixes PCI link up on his Odroid-HC4. Is there a chance to get this patch into -fixes, so it can be pulled by Linus for one of the next -rc?

Hmm, I looked at the Fixes tag and mistakenly assumed that the issue existed from the beginning.

Bjorn, could you please include this patch in the next fixes PR?

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#5 lore raw
In reply to Martin Blumenstingl
Quoted 18 lines · Martin Blumenstingl
Quoted 16 lines · Manivannan Sadhasivam
Quoted 10 lines · Bjorn Helgaas

Previously meson_pcie_link_up() only returned true if the link was in the L0 state. This was incorrect because hardware autonomously manages transitions between L0, L0s, and L1 while both components on the link stay in D0. Those states should all be treated as "link is active".

Returning false when the device was in L0s or L1 broke config accesses because dw_pcie_other_conf_map_bus() fails if the link is down, which caused errors like this:

[...]

Applied, thanks!

Quoted 8 lines
Quoted 2 lines

[1/1] PCI: meson: Remove meson_pcie_link_up() timeout, message, speed check

      commit: 11647fc772e977c981259a63c4a2b7e2c312ea22

My understanding is that this is queued for -next.

Ricardo (Cc'ed) reported that this patch fixes PCI link up on his Odroid-HC4. Is there a chance to get this patch into -fixes, so it can be pulled by Linus for one of the next -rc?

The Fixes tag is for 9c0ef6d34fdb ("PCI: amlogic: Add the Amlogic Meson PCIe controller driver"), which appeared in v5.0 in 2019, so it was a latent issue since then. v5.0 kernels built with CONFIG_PCIEASPM_POWERSAVE=y or CONFIG_PCIEASPM_POWER_SUPERSAVE=y should show the same problem.

But I think that latent issue became obvious when the following two commits essentially made CONFIG_PCIEASPM_POWERSAVE the default for devicetree platforms:

f3ac2ff14834 ("PCI/ASPM: Enable all ClockPM and ASPM states for devicetree platforms") df5192d9bb0e ("PCI/ASPM: Enable only L0s and L1 for devicetree platforms")

Those two commits appeared in v6.18, so I think we can make a case that it fixes a recent problem and is thus material for the current release.

Moved to for-linus for v6.19 and squashed your unused WAIT_LINKUP_TIMEOUT fix. Thanks!

Bjorn