Skip to contentSkip to conversation

pciehp: Retrieve link speed after link is trained

PATCH In review Yinghai Lu 3 participants 6 messages Oct 9, 2011 – Nov 7, 2011 PCI

lore
Share & tools
lore

Yinghai Lu

author
#0 lore raw

PATCH 1/1 pciehp: Retrieve link speed after link is trained

During hot plug, board_added will call pciehp_power_on_slot(). But link speed is updated in pciehp_power_on_slot().

We should not update link speed there, because that is too early.

Move updating to pciehp_check_link_status() after making sure link is trained.

---
 drivers/pci/hotplug/pciehp_hpc.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/pci/hotplug/pciehp_hpc.c +2 -8
Index: linux-2.6/drivers/pci/hotplug/pciehp_hpc.c
===================================================================
@@ -294,6 +294,8 @@ int pciehp_check_link_status(struct cont
 		return retval;
 	}
 
+	pcie_update_link_speed(ctrl->pcie->port->subordinate, lnk_status);
+
 	return retval;
 }
 
@@ -516,14 +518,6 @@ int pciehp_power_on_slot(struct slot * s
 	ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
 		 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_cmd);
 
-	retval = pciehp_readw(ctrl, PCI_EXP_LNKSTA, &lnk_status);
-	if (retval) {
-		ctrl_err(ctrl, "%s: Cannot read LNKSTA register\n",
-				__func__);
-		return retval;
-	}
-	pcie_update_link_speed(ctrl->pcie->port->subordinate, lnk_status);
-
 	return retval;
 }
 
#1 lore raw
Quoted 31 lines · On Sun, 09 Oct 2011 00:06:06 -0700 Yinghai Lu <[email protected]> wrote:

During hot plug, board_added will call pciehp_power_on_slot(). But link speed is updated in pciehp_power_on_slot().

We should not update link speed there, because that is too early.

Move updating to pciehp_check_link_status() after making sure link is trained.

---
 drivers/pci/hotplug/pciehp_hpc.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Index: linux-2.6/drivers/pci/hotplug/pciehp_hpc.c
===================================================================

drivers/pci/hotplug/pciehp_hpc.c +2 -0
@@ -294,6 +294,8 @@ int pciehp_check_link_status(struct cont
 		return retval;
 	}
 
+	pcie_update_link_speed(ctrl->pcie->port->subordinate, lnk_status);
+
 	return retval;
 }
 
@@ -516,14 +518,6 @@ int pciehp_power_on_slot(struct slot * s
 	ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
 		 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_cmd);
 

drivers/pci/hotplug/pciehp_hpc.c int pciehp_power_on_slot(struct slot * s · line 522

Quoted 10 lines
drivers/pci/hotplug/pciehp_hpc.c +0 -8
-	retval = pciehp_readw(ctrl, PCI_EXP_LNKSTA, &lnk_status);
-	if (retval) {
-		ctrl_err(ctrl, "%s: Cannot read LNKSTA register\n",
-				__func__);
-		return retval;
-	}
-	pcie_update_link_speed(ctrl->pcie->port->subordinate, lnk_status);
-
 	return retval;
 }

Kenji-san or Hidetoshi-san, would it be possible to get tested-bys and reviewed-bys from you on this patch?

Thanks,

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Reviewed-by
#2 lore raw
Quoted 48 lines · Jesse Barnes
Quoted 31 lines · On Sun, 09 Oct 2011 00:06:06 -0700 Yinghai Lu<[email protected]> wrote:

During hot plug, board_added will call pciehp_power_on_slot(). But link speed is updated in pciehp_power_on_slot().

We should not update link speed there, because that is too early.

Move updating to pciehp_check_link_status() after making sure link is trained.

---
  drivers/pci/hotplug/pciehp_hpc.c |   10 ++--------
  1 file changed, 2 insertions(+), 8 deletions(-)

Index: linux-2.6/drivers/pci/hotplug/pciehp_hpc.c
===================================================================

drivers/pci/hotplug/pciehp_hpc.c +2 -0
@@ -294,6 +294,8 @@ int pciehp_check_link_status(struct cont
  		return retval;
  	}
 
+	pcie_update_link_speed(ctrl->pcie->port->subordinate, lnk_status);
+
  	return retval;
  }
 
@@ -516,14 +518,6 @@ int pciehp_power_on_slot(struct slot * s
  	ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
  		 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_cmd);
 

drivers/pci/hotplug/pciehp_hpc.c int pciehp_power_on_slot(struct slot * s · line 522

Quoted 10 lines
drivers/pci/hotplug/pciehp_hpc.c +0 -8
-	retval = pciehp_readw(ctrl, PCI_EXP_LNKSTA,&lnk_status);
-	if (retval) {
-		ctrl_err(ctrl, "%s: Cannot read LNKSTA register\n",
-				__func__);
-		return retval;
-	}
-	pcie_update_link_speed(ctrl->pcie->port->subordinate, lnk_status);
-
  	return retval;
  }

Kenji-san or Hidetoshi-san, would it be possible to get tested-bys and reviewed-bys from you on this patch?

Quoted 1 line

Thanks,

Looks good to me.

Unfortunately, I don't have test environment right now. Maybe I will be able to test it early next week.

Regards,
Kenji Kaneshige

Tested-by
#3 lore raw
Quoted 49 lines · Kenji Kaneshige
Quoted 48 lines · Jesse Barnes
Quoted 31 lines · On Sun, 09 Oct 2011 00:06:06 -0700 Yinghai Lu<[email protected]> wrote:

During hot plug, board_added will call pciehp_power_on_slot(). But link speed is updated in pciehp_power_on_slot().

We should not update link speed there, because that is too early.

Move updating to pciehp_check_link_status() after making sure link is trained.

---
drivers/pci/hotplug/pciehp_hpc.c | 10 ++--------

1 file changed, 2 insertions(+), 8 deletions(-)

Index: linux-2.6/drivers/pci/hotplug/pciehp_hpc.c
===================================================================

drivers/pci/hotplug/pciehp_hpc.c +2 -0
@@ -294,6 +294,8 @@ int pciehp_check_link_status(struct cont
 return retval;
 }
 
+ pcie_update_link_speed(ctrl->pcie->port->subordinate, lnk_status);
+
 return retval;
 }
 
@@ -516,14 +518,6 @@ int pciehp_power_on_slot(struct slot * s
 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_cmd);
 

drivers/pci/hotplug/pciehp_hpc.c int pciehp_power_on_slot(struct slot * s · line 522

Quoted 10 lines
drivers/pci/hotplug/pciehp_hpc.c +0 -8
- retval = pciehp_readw(ctrl, PCI_EXP_LNKSTA,&lnk_status);
- if (retval) {
- ctrl_err(ctrl, "%s: Cannot read LNKSTA register\n",
- __func__);
- return retval;
- }
- pcie_update_link_speed(ctrl->pcie->port->subordinate, lnk_status);
-
 return retval;
 }

Kenji-san or Hidetoshi-san, would it be possible to get tested-bys and reviewed-bys from you on this patch?

Quoted 8 lines
Quoted 1 line

Thanks,

Looks good to me.

Unfortunately, I don't have test environment right now. Maybe I will be able to test it early next week.

I got the following warning messages on kernel compile. I'm using 3.1. Yinghai, please fix this.

CC drivers/pci/hotplug/pciehp_hpc.o
drivers/pci/hotplug/pciehp_hpc.c: In function 'pciehp_power_on_slot':
drivers/pci/hotplug/pciehp_hpc.c:489: warning: unused variable 'lnk_status'

Looks good to me, other than this.

Regards,
Kenji Kaneshige

author
#4 lore raw

PATCH 1/1 pciehp: Retrieve link speed after link is trained

During hot plug, board_added will call pciehp_power_on_slot(). But link speed is updated in pciehp_power_on_slot().

We should not update link speed there, because that is too early.

Move updating to pciehp_check_link_status() after making sure link is trained.

-v2: compiling warning that Kenji found.

---
 drivers/pci/hotplug/pciehp_hpc.c |   11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/pci/hotplug/pciehp_hpc.c +2 -9
Index: linux-2.6/drivers/pci/hotplug/pciehp_hpc.c
===================================================================
@@ -294,6 +294,8 @@ int pciehp_check_link_status(struct cont
 		return retval;
 	}
 
+	pcie_update_link_speed(ctrl->pcie->port->subordinate, lnk_status);
+
 	return retval;
 }
 
@@ -484,7 +486,6 @@ int pciehp_power_on_slot(struct slot * s
 	u16 slot_cmd;
 	u16 cmd_mask;
 	u16 slot_status;
-	u16 lnk_status;
 	int retval = 0;
 
 	/* Clear sticky power-fault bit from previous power failures */
@@ -516,14 +517,6 @@ int pciehp_power_on_slot(struct slot * s
 	ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
 		 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, slot_cmd);
 
-	retval = pciehp_readw(ctrl, PCI_EXP_LNKSTA, &lnk_status);
-	if (retval) {
-		ctrl_err(ctrl, "%s: Cannot read LNKSTA register\n",
-				__func__);
-		return retval;
-	}
-	pcie_update_link_speed(ctrl->pcie->port->subordinate, lnk_status);
-
 	return retval;
 }
 
Applied
#5 lore raw
Quoted 9 lines · On Mon, 07 Nov 2011 07:53:23 -0800 Yinghai Lu <[email protected]> wrote:

During hot plug, board_added will call pciehp_power_on_slot(). But link speed is updated in pciehp_power_on_slot().

We should not update link speed there, because that is too early.

Move updating to pciehp_check_link_status() after making sure link is trained.

-v2: compiling warning that Kenji found.

Applied, thanks guys.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center