Skip to content

Commit af3c6ea

Browse files
Wenbin Yaobjorn-helgaas
authored andcommitted
PCI: dwc: Make link training more robust by setting PORT_LOGIC_LINK_WIDTH to one lane
As per DWC PCIe registers description 4.30a, section 1.13.43, NUM_OF_LANES named as PORT_LOGIC_LINK_WIDTH in PCIe DWC driver, is referred to as the "Predetermined Number of Lanes" in PCIe r6.0, sec 4.2.7.2.1, which explains the conditions required to enter Polling.Configuration: Next state is Polling.Configuration after at least 1024 TS1 Ordered Sets were transmitted, and all Lanes that detected a Receiver during Detect receive eight consecutive training sequences ... Otherwise, after a 24 ms timeout the next state is: Polling.Configuration if, (i) Any Lane, which detected a Receiver during Detect, received eight consecutive training sequences ... and a minimum of 1024 TS1 Ordered Sets are transmitted after receiving one TS1 or TS2 Ordered Set. And (ii) At least a predetermined set of Lanes that detected a Receiver during Detect have detected an exit from Electrical Idle at least once since entering Polling.Active. Note: This may prevent one or more bad Receivers or Transmitters from holding up a valid Link from being configured, and allow for additional training in Polling.Configuration. The exact set of predetermined Lanes is implementation specific. Note: Any Lane that receives eight consecutive TS1 or TS2 Ordered Sets should have detected an exit from Electrical Idle at least once since entering Polling.Active. In a PCIe link supporting multiple lanes, if PORT_LOGIC_LINK_WIDTH is set to lane width the hardware supports, all lanes that detect a receiver during the Detect phase must receive eight consecutive training sequences. Otherwise, LTSSM will not enter Polling.Configuration and link training will fail. Therefore, always set PORT_LOGIC_LINK_WIDTH to 1, regardless of the number of lanes the port actually supports, to make link up more robust. This setting will not affect the intended link width if all lanes are functional. Additionally, the link can still be established with at least one lane if other lanes are faulty. Co-developed-by: Qiang Yu <[email protected]> Signed-off-by: Qiang Yu <[email protected]> Signed-off-by: Wenbin Yao <[email protected]> [mani: subject change] Signed-off-by: Manivannan Sadhasivam <[email protected]> [bhelgaas: update PCIe spec citation, format quote] Signed-off-by: Bjorn Helgaas <[email protected]> Tested-by: Niklas Cassel <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 0af2f6b commit af3c6ea

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

drivers/pci/controller/dwc/pcie-designware.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -797,22 +797,19 @@ static void dw_pcie_link_set_max_link_width(struct dw_pcie *pci, u32 num_lanes)
797797
/* Set link width speed control register */
798798
lwsc = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
799799
lwsc &= ~PORT_LOGIC_LINK_WIDTH_MASK;
800+
lwsc |= PORT_LOGIC_LINK_WIDTH_1_LANES;
800801
switch (num_lanes) {
801802
case 1:
802803
plc |= PORT_LINK_MODE_1_LANES;
803-
lwsc |= PORT_LOGIC_LINK_WIDTH_1_LANES;
804804
break;
805805
case 2:
806806
plc |= PORT_LINK_MODE_2_LANES;
807-
lwsc |= PORT_LOGIC_LINK_WIDTH_2_LANES;
808807
break;
809808
case 4:
810809
plc |= PORT_LINK_MODE_4_LANES;
811-
lwsc |= PORT_LOGIC_LINK_WIDTH_4_LANES;
812810
break;
813811
case 8:
814812
plc |= PORT_LINK_MODE_8_LANES;
815-
lwsc |= PORT_LOGIC_LINK_WIDTH_8_LANES;
816813
break;
817814
default:
818815
dev_err(pci->dev, "num-lanes %u: invalid value\n", num_lanes);

0 commit comments

Comments
 (0)