net: pcs: xpcs: enable skip xPCS soft reset
Subsystems (8)
PATCH v2 1/2 net: pcs: xpcs: enable skip xPCS soft reset
Unlike any other platforms, Intel AlderLake-S uses Synopsys SerDes where all the SerDes PLL configurations are controlled by the xPCS at the BIOS level. If the driver perform a xPCS soft reset on initialization, these settings will be switched back to the power on reset values.
This patch introduced a new xpcs_reset() function for drivers such as sja1105 and stmmac to decide whether or not to perform a xPCS soft reset.
--- drivers/net/dsa/sja1105/sja1105_mdio.c | 6 ++- .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 15 +++++++- drivers/net/pcs/pcs-xpcs.c | 37 ++++++++++--------- include/linux/pcs/pcs-xpcs.h | 4 +- include/linux/stmmac.h | 1 + 5 files changed, 40 insertions(+), 23 deletions(-)
drivers/net/dsa/sja1105/sja1105_mdio.c +5 -1
@@ -435,13 +435,17 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv) goto out_pcs_free; } - xpcs =xpcs_create (mdiodev, priv->phy_mode[port]); + xpcs =xpcs_create (mdiodev);if (IS_ERR (xpcs)) { rc =PTR_ERR (xpcs); goto out_pcs_free; } priv->xpcs[port] = xpcs; + + rc =xpcs_reset (xpcs, priv->phy_mode[port]); +if (rc) + goto out_pcs_free; } priv->mdio_pcs = bus;
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +13 -2
@@ -401,12 +401,15 @@ int stmmac_xpcs_setup(struct mii_bus *bus) {struct net_device *ndev = bus->priv;struct mdio_device *mdiodev; +bool skip_xpcs_soft_reset;struct stmmac_priv *priv;struct dw_xpcs *xpcs;int mode, addr; +int err; priv =netdev_priv (ndev); mode = priv->plat->phy_interface; + skip_xpcs_soft_reset = priv->plat->skip_xpcs_soft_reset;/* Try to probe the XPCS by scanning all addresses. */ for (addr =0 ; addr <PHY_MAX_ADDR ; addr++) {
@@ -414,12 +417,20 @@ int stmmac_xpcs_setup(struct mii_bus *bus)if (IS_ERR (mdiodev))continue ; - xpcs =xpcs_create (mdiodev, mode); -if (IS_ERR_OR_NULL (xpcs)) { + xpcs =xpcs_create (mdiodev); +if (IS_ERR (xpcs)) {mdio_device_free (mdiodev);continue ; } +if (!skip_xpcs_soft_reset) { + err =xpcs_reset (xpcs, mode); +if (err) { +mdio_device_free (mdiodev); +continue ; + } + } + priv->hw->xpcs = xpcs;break ; }
drivers/net/pcs/pcs-xpcs.c +19 -18
@@ -252,6 +252,18 @@ static int xpcs_soft_reset(struct dw_xpcs *xpcs,return xpcs_poll_reset (xpcs, dev); } +int xpcs_reset (struct dw_xpcs *xpcs,phy_interface_t interface) +{ +const struct xpcs_compat *compat; + + compat =xpcs_find_compat (xpcs->id, interface); +if (!compat) +return -ENODEV ; + +return xpcs_soft_reset (xpcs, compat); +} +EXPORT_SYMBOL_GPL (xpcs_reset); + #define xpcs_warn(__xpcs, __state, __args...) \ ({ \ if ((__state)->link) \
@@ -1084,12 +1096,11 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = { .pcs_link_up = xpcs_link_up, }; -struct dw_xpcs *xpcs_create (struct mdio_device *mdiodev, -phy_interface_t interface) +struct dw_xpcs *xpcs_create (struct mdio_device *mdiodev) {struct dw_xpcs *xpcs;u32 xpcs_id; -int i, ret; +int i; xpcs =kzalloc (sizeof (*xpcs),GFP_KERNEL );if (!xpcs)
@@ -1099,37 +1110,27 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, xpcs_id =xpcs_get_id (xpcs); +/* If Device ID are all ones, there is no device found */ +if (xpcs_id ==0xffffffff ) + goto out; +for (i =0 ; i <ARRAY_SIZE (xpcs_id_list); i++) {const struct xpcs_id *entry = &xpcs_id_list[i]; -const struct xpcs_compat *compat;if ((xpcs_id & entry->mask) != entry->id)continue ; xpcs->id = entry; - - compat =xpcs_find_compat (entry, interface); -if (!compat) { - ret = -ENODEV ; - goto out; - } - xpcs->pcs.ops = &xpcs_phylink_ops; xpcs->pcs.poll = true; - ret =xpcs_soft_reset (xpcs, compat); -if (ret) - goto out; -return xpcs; } - ret = -ENODEV ; - out:kfree (xpcs); -return ERR_PTR (ret); +return ERR_PTR (-ENODEV ); }EXPORT_SYMBOL_GPL (xpcs_create);
include/linux/pcs/pcs-xpcs.h +2 -2
@@ -35,8 +35,8 @@ void xpcs_validate(struct dw_xpcs *xpcs, unsigned long *supported, struct phylink_link_state *state);int xpcs_config_eee (struct dw_xpcs *xpcs,int mult_fact_100ns,int enable); -struct dw_xpcs *xpcs_create (struct mdio_device *mdiodev, -phy_interface_t interface); +int xpcs_reset (struct dw_xpcs *xpcs,phy_interface_t interface); +struct dw_xpcs *xpcs_create (struct mdio_device *mdiodev);void xpcs_destroy (struct dw_xpcs *xpcs);#endif /* __LINUX_PCS_XPCS_H */
include/linux/stmmac.h +1 -0
@@ -268,5 +268,6 @@ struct plat_stmmacenet_data {int msi_rx_base_vec;int msi_tx_base_vec;bool use_phy_wol; + bool skip_xpcs_soft_reset; };#endif
Signature · 1 line
2.25.1
PATCH v2 1/2 net: pcs: xpcs: enable skip xPCS soft reset
Unlike any other platforms, Intel AlderLake-S uses Synopsys SerDes where all the SerDes PLL configurations are controlled by the xPCS at the BIOS level. If the driver perform a xPCS soft reset on initialization, these settings will be switched back to the power on reset values.
This patch introduced a new xpcs_reset() function for drivers such as sja1105 and stmmac to decide whether or not to perform a xPCS soft reset.
--- drivers/net/dsa/sja1105/sja1105_mdio.c | 6 ++- .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 15 +++++++- drivers/net/pcs/pcs-xpcs.c | 37 ++++++++++--------- include/linux/pcs/pcs-xpcs.h | 4 +- include/linux/stmmac.h | 1 + 5 files changed, 40 insertions(+), 23 deletions(-)
drivers/net/dsa/sja1105/sja1105_mdio.c +5 -1
@@ -435,13 +435,17 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv) goto out_pcs_free; } - xpcs =xpcs_create (mdiodev, priv->phy_mode[port]); + xpcs =xpcs_create (mdiodev);if (IS_ERR (xpcs)) { rc =PTR_ERR (xpcs); goto out_pcs_free; } priv->xpcs[port] = xpcs; + + rc =xpcs_reset (xpcs, priv->phy_mode[port]); +if (rc) + goto out_pcs_free; } priv->mdio_pcs = bus;
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +13 -2
@@ -401,12 +401,15 @@ int stmmac_xpcs_setup(struct mii_bus *bus) {struct net_device *ndev = bus->priv;struct mdio_device *mdiodev; +bool skip_xpcs_soft_reset;struct stmmac_priv *priv;struct dw_xpcs *xpcs;int mode, addr; +int err; priv =netdev_priv (ndev); mode = priv->plat->phy_interface; + skip_xpcs_soft_reset = priv->plat->skip_xpcs_soft_reset;/* Try to probe the XPCS by scanning all addresses. */ for (addr =0 ; addr <PHY_MAX_ADDR ; addr++) {
@@ -414,12 +417,20 @@ int stmmac_xpcs_setup(struct mii_bus *bus)if (IS_ERR (mdiodev))continue ; - xpcs =xpcs_create (mdiodev, mode); -if (IS_ERR_OR_NULL (xpcs)) { + xpcs =xpcs_create (mdiodev); +if (IS_ERR (xpcs)) {mdio_device_free (mdiodev);continue ; } +if (!skip_xpcs_soft_reset) { + err =xpcs_reset (xpcs, mode); +if (err) { +mdio_device_free (mdiodev); +continue ; + } + } + priv->hw->xpcs = xpcs;break ; }
drivers/net/pcs/pcs-xpcs.c +19 -18
@@ -252,6 +252,18 @@ static int xpcs_soft_reset(struct dw_xpcs *xpcs,return xpcs_poll_reset (xpcs, dev); } +int xpcs_reset (struct dw_xpcs *xpcs,phy_interface_t interface) +{ +const struct xpcs_compat *compat; + + compat =xpcs_find_compat (xpcs->id, interface); +if (!compat) +return -ENODEV ; + +return xpcs_soft_reset (xpcs, compat); +} +EXPORT_SYMBOL_GPL (xpcs_reset); + #define xpcs_warn(__xpcs, __state, __args...) \ ({ \ if ((__state)->link) \
@@ -1084,12 +1096,11 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = { .pcs_link_up = xpcs_link_up, }; -struct dw_xpcs *xpcs_create (struct mdio_device *mdiodev, -phy_interface_t interface) +struct dw_xpcs *xpcs_create (struct mdio_device *mdiodev) {struct dw_xpcs *xpcs;u32 xpcs_id; -int i, ret; +int i; xpcs =kzalloc (sizeof (*xpcs),GFP_KERNEL );if (!xpcs)
@@ -1099,37 +1110,27 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, xpcs_id =xpcs_get_id (xpcs); +/* If Device ID are all ones, there is no device found */ +if (xpcs_id ==0xffffffff ) + goto out; +for (i =0 ; i <ARRAY_SIZE (xpcs_id_list); i++) {const struct xpcs_id *entry = &xpcs_id_list[i]; -const struct xpcs_compat *compat;if ((xpcs_id & entry->mask) != entry->id)continue ; xpcs->id = entry; - - compat =xpcs_find_compat (entry, interface); -if (!compat) { - ret = -ENODEV ; - goto out; - } - xpcs->pcs.ops = &xpcs_phylink_ops; xpcs->pcs.poll = true; - ret =xpcs_soft_reset (xpcs, compat); -if (ret) - goto out; -return xpcs; } - ret = -ENODEV ; - out:kfree (xpcs); -return ERR_PTR (ret); +return ERR_PTR (-ENODEV ); }EXPORT_SYMBOL_GPL (xpcs_create);
include/linux/pcs/pcs-xpcs.h +2 -2
@@ -35,8 +35,8 @@ void xpcs_validate(struct dw_xpcs *xpcs, unsigned long *supported, struct phylink_link_state *state);int xpcs_config_eee (struct dw_xpcs *xpcs,int mult_fact_100ns,int enable); -struct dw_xpcs *xpcs_create (struct mdio_device *mdiodev, -phy_interface_t interface); +int xpcs_reset (struct dw_xpcs *xpcs,phy_interface_t interface); +struct dw_xpcs *xpcs_create (struct mdio_device *mdiodev);void xpcs_destroy (struct dw_xpcs *xpcs);#endif /* __LINUX_PCS_XPCS_H */
include/linux/stmmac.h +1 -0
@@ -268,5 +268,6 @@ struct plat_stmmacenet_data {int msi_rx_base_vec;int msi_tx_base_vec;bool use_phy_wol; + bool skip_xpcs_soft_reset; };#endif
Signature · 1 line
2.25.1
Andrew Lunn
maintainerdrivers/net/pcs/pcs-xpcs.c struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, · line 1116
Quoted 13 lines · Wong Vee Khee
Unlike any other platforms, Intel AlderLake-S uses Synopsys SerDes where all the SerDes PLL configurations are controlled by the xPCS at the BIOS level. If the driver perform a xPCS soft reset on initialization, these settings will be switched back to the power on reset values.
This patch introduced a new
xpcs_reset()function for drivers such as sja1105 and stmmac to decide whether or not to perform a xPCS soft reset.drivers/net/pcs/pcs-xpcs.c +4
-0+/* If Device ID are all ones, there is no device found */ +if (xpcs_id ==0xffffffff ) + goto out; +
This does not look like plain refactoring. It is not code moved from somewhere else. At minimum, it needs explaining in the commit message, but it probably should be a commit of its own.
Andrew
PATCH v2 2/2 stmmac: intel: Enable 2.5Gbps on Intel AlderLake-S
In reply to Wong Vee KheeIntel AlderLake-S platform is capable of 2.5Gbps link speed.
This patch enables the 2.5Gbps link speed by adding the callback function in the AlderLake-S PCI info struct.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +4 -0
@@ -770,6 +770,8 @@ static int adls_sgmii_phy0_data(struct pci_dev *pdev, { plat->bus_id =1 ; plat->phy_interface =PHY_INTERFACE_MODE_SGMII ; + plat->speed_mode_2500 = intel_speed_mode_2500; + plat->skip_xpcs_soft_reset =1 ;/* SerDes power up and power down are done in BIOS for ADL */
@@ -785,6 +787,8 @@ static int adls_sgmii_phy1_data(struct pci_dev *pdev, { plat->bus_id =2 ; plat->phy_interface =PHY_INTERFACE_MODE_SGMII ; + plat->speed_mode_2500 = intel_speed_mode_2500; + plat->skip_xpcs_soft_reset =1 ;/* SerDes power up and power down are done in BIOS for ADL */
Signature · 1 line
2.25.1
Andrew Lunn
maintainerQuoted 4 lines · Wong Vee Khee
Unlike any other platforms, Intel AlderLake-S uses Synopsys SerDes where all the SerDes PLL configurations are controlled by the xPCS at the BIOS level. If the driver perform a xPCS soft reset on initialization, these settings will be switched back to the power on reset values.
So you have given up on the idea of calling into the BIOS to do this? ACPI is too difficult to use? Can you at least copy the code from the BIOS into the driver? It might then also be possible to fix your inability to swap link speeds?
Andrew