Skip to contentSkip to conversation

PCI: altera: fix altera_pcie_link_is_up()

PATCH Applied Ley Foon Tan 2 participants 2 messages Mar 2, 2016 – Mar 11, 2016 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: altera: fix altera_pcie_link_is_up()

The original code return true if RP_LTSSM register return non-zero value. This fix to return true only RP_LTSSM register is in L0 state (link up).

---
 drivers/pci/host/pcie-altera.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/host/pcie-altera.c +2 -1
index 99da549..dbac6fb 100644
@@ -40,6 +40,7 @@
 #define P2A_INT_ENABLE			0x3070
 #define P2A_INT_ENA_ALL			0xf
 #define RP_LTSSM			0x3c64
+#define RP_LTSSM_MASK			0x1f
 #define LTSSM_L0			0xf
 
 /* TLP configuration type 0 and 1 */
@@ -140,7 +141,7 @@ static void tlp_write_tx(struct altera_pcie *pcie,
 
 static bool altera_pcie_link_is_up(struct altera_pcie *pcie)
 {
-	return !!(cra_readl(pcie, RP_LTSSM) & LTSSM_L0);
+	return !!((cra_readl(pcie, RP_LTSSM) & RP_LTSSM_MASK) == LTSSM_L0);
 }
 
 static bool altera_pcie_valid_config(struct altera_pcie *pcie,
Signature · 1 line
2.2.0
#1 lore raw
Quoted 5 lines · Ley Foon Tan

The original code return true if RP_LTSSM register return non-zero value. This fix to return true only RP_LTSSM register is in L0 state (link up).

Applied to pci/host-altera for v4.6 with the following changelog. Thanks!

PCI: altera: Fix altera_pcie_link_is_up()

Originally altera_pcie_link_is_up() decided the link was up if any of the low four bits of the LTSSM register were set. But the link is only up if the LTSSM state is L0, so check for that exact value.

[bhelgaas: changelog]
Quoted 32 lines
---
 drivers/pci/host/pcie-altera.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/host/pcie-altera.c +2 -1
index 99da549..dbac6fb 100644
@@ -40,6 +40,7 @@
 #define P2A_INT_ENABLE			0x3070
 #define P2A_INT_ENA_ALL			0xf
 #define RP_LTSSM			0x3c64
+#define RP_LTSSM_MASK			0x1f
 #define LTSSM_L0			0xf
 
 /* TLP configuration type 0 and 1 */
@@ -140,7 +141,7 @@ static void tlp_write_tx(struct altera_pcie *pcie,
 
 static bool altera_pcie_link_is_up(struct altera_pcie *pcie)
 {
-	return !!(cra_readl(pcie, RP_LTSSM) & LTSSM_L0);
+	return !!((cra_readl(pcie, RP_LTSSM) & RP_LTSSM_MASK) == LTSSM_L0);
 }
 
 static bool altera_pcie_valid_config(struct altera_pcie *pcie,
Signature · 6 lines
2.2.0

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html