Skip to content

Commit 19a69cb

Browse files
Mani-Sadhasivamkwilczynski
authored andcommitted
PCI: dwc: Always cache the maximum link speed value in dw_pcie::max_link_speed
Currently, the dw_pcie::max_link_speed has a valid value only if the controller driver restricts the maximum link speed in the driver or if the platform does so in the devicetree using the 'max-link-speed' property. But having the maximum supported link speed of the platform would be helpful for the vendor drivers to configure any link specific settings. So in the case of non-valid value in dw_pcie::max_link_speed, just cache the hardware default value from Link Capability register. While at it, remove the 'max_link_speed' argument to the dw_pcie_link_set_max_speed() function since the value can be retrieved within the function. Link: https://lore.kernel.org/linux-pci/[email protected] Tested-by: Johan Hovold <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> [kwilczynski: commit log] Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Frank Li <[email protected]> Reviewed-by: Johan Hovold <[email protected]>
1 parent 2cebf68 commit 19a69cb

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -689,16 +689,27 @@ void dw_pcie_upconfig_setup(struct dw_pcie *pci)
689689
}
690690
EXPORT_SYMBOL_GPL(dw_pcie_upconfig_setup);
691691

692-
static void dw_pcie_link_set_max_speed(struct dw_pcie *pci, u32 max_link_speed)
692+
static void dw_pcie_link_set_max_speed(struct dw_pcie *pci)
693693
{
694694
u32 cap, ctrl2, link_speed;
695695
u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
696696

697697
cap = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCAP);
698+
699+
/*
700+
* Even if the platform doesn't want to limit the maximum link speed,
701+
* just cache the hardware default value so that the vendor drivers can
702+
* use it to do any link specific configuration.
703+
*/
704+
if (pci->max_link_speed < 1) {
705+
pci->max_link_speed = FIELD_GET(PCI_EXP_LNKCAP_SLS, cap);
706+
return;
707+
}
708+
698709
ctrl2 = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCTL2);
699710
ctrl2 &= ~PCI_EXP_LNKCTL2_TLS;
700711

701-
switch (pcie_link_speed[max_link_speed]) {
712+
switch (pcie_link_speed[pci->max_link_speed]) {
702713
case PCIE_SPEED_2_5GT:
703714
link_speed = PCI_EXP_LNKCTL2_TLS_2_5GT;
704715
break;
@@ -1060,8 +1071,7 @@ void dw_pcie_setup(struct dw_pcie *pci)
10601071
{
10611072
u32 val;
10621073

1063-
if (pci->max_link_speed > 0)
1064-
dw_pcie_link_set_max_speed(pci, pci->max_link_speed);
1074+
dw_pcie_link_set_max_speed(pci);
10651075

10661076
/* Configure Gen1 N_FTS */
10671077
if (pci->n_fts[0]) {

0 commit comments

Comments
 (0)