Skip to contentSkip to conversation

pciehp: Add check for DL_ACTIVE bit in pciehp_check_link_status()

PATCH In review Sanjay R Mehta 2 participants 2 messages Oct 19, 2020 – Oct 20, 2020 PCI

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pciehp: Add check for DL_ACTIVE bit in pciehp_check_link_status()

From: Sanjay R Mehta <[email protected]>

if DL_ACTIVE bit is set it means that there is no need to check PCI_EXP_LNKSTA_LT bit, as DL_ACTIVE would have set only if the link is already trained. Hence adding a check which takes care of this scenario.

---
 drivers/pci/hotplug/pciehp_hpc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/hotplug/pciehp_hpc.c +2 -1
index 53433b37e181..8ab2f6a2f388 100644
@@ -309,7 +309,8 @@ int pciehp_check_link_status(struct controller *ctrl)
 
 	pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status);
 	ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status);
-	if ((lnk_status & PCI_EXP_LNKSTA_LT) ||
+	if (((lnk_status & PCI_EXP_LNKSTA_LT) &&
+	     !(lnk_status & PCI_EXP_LNKSTA_DLLLA)) ||
 	    !(lnk_status & PCI_EXP_LNKSTA_NLW)) {
 		ctrl_err(ctrl, "link training error: status %#06x\n",
 			 lnk_status);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 7 lines · Sanjay R Mehta

From: Sanjay R Mehta <[email protected]>

if DL_ACTIVE bit is set it means that there is no need to check PCI_EXP_LNKSTA_LT bit, as DL_ACTIVE would have set only if the link is already trained. Hence adding a check which takes care of this scenario.

Sorry, I couldn't understand the logic here. if DL_ACTIVE was set, PCI_EXP_LNKSTA_LT is to be cleared, vice versa. why need

(lnk_status & PCI_EXP_LNKSTA_LT) &&
!(lnk_status & PCI_EXP_LNKSTA_DLLLA)

Double safe ?

Thanks,
Ethan

Quoted 23 lines
---
 drivers/pci/hotplug/pciehp_hpc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/hotplug/pciehp_hpc.c +2 -2
index 53433b37e181..8ab2f6a2f388 100644
@@ -309,7 +309,8 @@ int pciehp_check_link_status(struct controller *ctrl)
 
        pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status);
        ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status);
-       if ((lnk_status & PCI_EXP_LNKSTA_LT) ||
+       if (((lnk_status & PCI_EXP_LNKSTA_LT) &&
+            !(lnk_status & PCI_EXP_LNKSTA_DLLLA)) ||
            !(lnk_status & PCI_EXP_LNKSTA_NLW)) {
                ctrl_err(ctrl, "link training error: status %#06x\n",
                         lnk_status);
--

2.25.1