linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] Intel AlderLake-S 2.5Gbps link speed support
@ 2021-08-09 10:22 Wong Vee Khee
  2021-08-09 10:22 ` [PATCH net-next 1/2] net: pcs: xpcs: enable skip xPCS soft reset Wong Vee Khee
  2021-08-09 10:22 ` [PATCH net-next 2/2] stmmac: intel: Enable 2.5Gbps on Intel AlderLake-S Wong Vee Khee
  0 siblings, 2 replies; 10+ messages in thread
From: Wong Vee Khee @ 2021-08-09 10:22 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S . Miller,
	Jakub Kicinski, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Heiner Kallweit, Russell King
  Cc: Voon Weifeng, Wong Vee Khee, Michael Sit Wei Hong,
	Vladimir Oltean, linux-arm-kernel, linux-stm32, netdev,
	linux-kernel

This patch series add 2.5Gbps support for Intel AlderLake-S platform.

Beside register 2.5G callback function in the dwmac_intel driver, an
additional step to not perform xPCS soft reset on driver init is also
required.

Michael Sit Wei Hong (2):
  net: pcs: xpcs: enable skip xPCS soft reset
  stmmac: intel: Enable 2.5Gbps on Intel AlderLake-S

 drivers/net/dsa/sja1105/sja1105_mdio.c           |  2 +-
 .../net/ethernet/stmicro/stmmac/dwmac-intel.c    |  4 ++++
 .../net/ethernet/stmicro/stmmac/stmmac_mdio.c    |  4 +++-
 drivers/net/pcs/pcs-xpcs.c                       | 16 ++++++++++++----
 include/linux/pcs/pcs-xpcs.h                     |  3 ++-
 include/linux/stmmac.h                           |  1 +
 6 files changed, 23 insertions(+), 7 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH net-next 1/2] net: pcs: xpcs: enable skip xPCS soft reset
  2021-08-09 10:22 [PATCH net-next 0/2] Intel AlderLake-S 2.5Gbps link speed support Wong Vee Khee
@ 2021-08-09 10:22 ` Wong Vee Khee
  2021-08-09 11:06   ` Vladimir Oltean
  2021-08-09 13:35   ` Andrew Lunn
  2021-08-09 10:22 ` [PATCH net-next 2/2] stmmac: intel: Enable 2.5Gbps on Intel AlderLake-S Wong Vee Khee
  1 sibling, 2 replies; 10+ messages in thread
From: Wong Vee Khee @ 2021-08-09 10:22 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S . Miller,
	Jakub Kicinski, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Heiner Kallweit, Russell King
  Cc: Voon Weifeng, Wong Vee Khee, Michael Sit Wei Hong,
	Vladimir Oltean, linux-arm-kernel, linux-stm32, netdev,
	linux-kernel

From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>

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 changes the xpcs_create function to take in an additional argument
to check if the platform request to skip xPCS soft reset during device
initialization.

Cc: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>
Signed-off-by: Wong Vee Khee <vee.khee.wong@linux.intel.com>
---
 drivers/net/dsa/sja1105/sja1105_mdio.c           |  2 +-
 .../net/ethernet/stmicro/stmmac/stmmac_mdio.c    |  4 +++-
 drivers/net/pcs/pcs-xpcs.c                       | 16 ++++++++++++----
 include/linux/pcs/pcs-xpcs.h                     |  3 ++-
 include/linux/stmmac.h                           |  1 +
 5 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/net/dsa/sja1105/sja1105_mdio.c b/drivers/net/dsa/sja1105/sja1105_mdio.c
index 19aea8fb76f6..73b43a5da68a 100644
--- a/drivers/net/dsa/sja1105/sja1105_mdio.c
+++ b/drivers/net/dsa/sja1105/sja1105_mdio.c
@@ -437,7 +437,7 @@ 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, priv->phy_mode[port], false);
 		if (IS_ERR(xpcs)) {
 			rc = PTR_ERR(xpcs);
 			goto out_pcs_free;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index a5d150c5f3d8..803a4e61105b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -401,12 +401,14 @@ 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;
 
 	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,7 +416,7 @@ int stmmac_xpcs_setup(struct mii_bus *bus)
 		if (IS_ERR(mdiodev))
 			continue;
 
-		xpcs = xpcs_create(mdiodev, mode);
+		xpcs = xpcs_create(mdiodev, mode, skip_xpcs_soft_reset);
 		if (IS_ERR_OR_NULL(xpcs)) {
 			mdio_device_free(mdiodev);
 			continue;
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 63fda3fc40aa..c7a3aa862079 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -1081,7 +1081,8 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = {
 };
 
 struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev,
-			    phy_interface_t interface)
+			    phy_interface_t interface,
+			    bool skip_reset)
 {
 	struct dw_xpcs *xpcs;
 	u32 xpcs_id;
@@ -1113,9 +1114,16 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev,
 		xpcs->pcs.ops = &xpcs_phylink_ops;
 		xpcs->pcs.poll = true;
 
-		ret = xpcs_soft_reset(xpcs, compat);
-		if (ret)
-			goto out;
+		if (!skip_reset) {
+			dev_info(&xpcs->mdiodev->dev, "%s: xPCS soft reset\n",
+				 __func__);
+			ret = xpcs_soft_reset(xpcs, compat);
+			if (ret)
+				goto out;
+		} else {
+			dev_info(&xpcs->mdiodev->dev,
+				 "%s: skip xpcs soft reset\n", __func__);
+		}
 
 		return xpcs;
 	}
diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h
index add077a81b21..0c05a63f3446 100644
--- a/include/linux/pcs/pcs-xpcs.h
+++ b/include/linux/pcs/pcs-xpcs.h
@@ -36,7 +36,8 @@ void xpcs_validate(struct dw_xpcs *xpcs, unsigned long *supported,
 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);
+			    phy_interface_t interface,
+			    bool xpcs_reset);
 void xpcs_destroy(struct dw_xpcs *xpcs);
 
 #endif /* __LINUX_PCS_XPCS_H */
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index a6f03b36fc4f..0f901773c5e4 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -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
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH net-next 2/2] stmmac: intel: Enable 2.5Gbps on Intel AlderLake-S
  2021-08-09 10:22 [PATCH net-next 0/2] Intel AlderLake-S 2.5Gbps link speed support Wong Vee Khee
  2021-08-09 10:22 ` [PATCH net-next 1/2] net: pcs: xpcs: enable skip xPCS soft reset Wong Vee Khee
@ 2021-08-09 10:22 ` Wong Vee Khee
  1 sibling, 0 replies; 10+ messages in thread
From: Wong Vee Khee @ 2021-08-09 10:22 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S . Miller,
	Jakub Kicinski, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Heiner Kallweit, Russell King
  Cc: Voon Weifeng, Wong Vee Khee, Michael Sit Wei Hong,
	Vladimir Oltean, linux-arm-kernel, linux-stm32, netdev,
	linux-kernel

From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>

Intel 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.

Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>
Signed-off-by: Wong Vee Khee <vee.khee.wong@intel.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
index 8e8778cfbbad..c1db7e53e78f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
@@ -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 */
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 1/2] net: pcs: xpcs: enable skip xPCS soft reset
  2021-08-09 10:22 ` [PATCH net-next 1/2] net: pcs: xpcs: enable skip xPCS soft reset Wong Vee Khee
@ 2021-08-09 11:06   ` Vladimir Oltean
  2021-08-10 23:50     ` Wong Vee Khee
  2021-08-09 13:35   ` Andrew Lunn
  1 sibling, 1 reply; 10+ messages in thread
From: Vladimir Oltean @ 2021-08-09 11:06 UTC (permalink / raw)
  To: Wong Vee Khee
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S . Miller,
	Jakub Kicinski, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Heiner Kallweit, Russell King, Voon Weifeng,
	Michael Sit Wei Hong, linux-arm-kernel, linux-stm32, netdev,
	linux-kernel

Hi VK,

On Mon, Aug 09, 2021 at 06:22:28PM +0800, Wong Vee Khee wrote:
> diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
> index 63fda3fc40aa..c7a3aa862079 100644
> --- a/drivers/net/pcs/pcs-xpcs.c
> +++ b/drivers/net/pcs/pcs-xpcs.c
> @@ -1081,7 +1081,8 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = {
>  };
>  
>  struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev,
> -			    phy_interface_t interface)
> +			    phy_interface_t interface,
> +			    bool skip_reset)
>  {
>  	struct dw_xpcs *xpcs;
>  	u32 xpcs_id;
> @@ -1113,9 +1114,16 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev,
>  		xpcs->pcs.ops = &xpcs_phylink_ops;
>  		xpcs->pcs.poll = true;
>  
> -		ret = xpcs_soft_reset(xpcs, compat);
> -		if (ret)
> -			goto out;
> +		if (!skip_reset) {
> +			dev_info(&xpcs->mdiodev->dev, "%s: xPCS soft reset\n",
> +				 __func__);
> +			ret = xpcs_soft_reset(xpcs, compat);
> +			if (ret)
> +				goto out;
> +		} else {
> +			dev_info(&xpcs->mdiodev->dev,
> +				 "%s: skip xpcs soft reset\n", __func__);
> +		}

I don't feel like the prints are really necessary.

>  
>  		return xpcs;
>  	}
> diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h
> index add077a81b21..0c05a63f3446 100644
> --- a/include/linux/pcs/pcs-xpcs.h
> +++ b/include/linux/pcs/pcs-xpcs.h
> @@ -36,7 +36,8 @@ void xpcs_validate(struct dw_xpcs *xpcs, unsigned long *supported,
>  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);
> +			    phy_interface_t interface,
> +			    bool xpcs_reset);
>  void xpcs_destroy(struct dw_xpcs *xpcs);
>  

How about exporting the reset functionality as a separate function, and
the Intel Alder Lake stmmac shim just won't call it? Like this:

-----------------------------[ cut here ]-----------------------------
diff --git a/drivers/net/dsa/sja1105/sja1105_mdio.c b/drivers/net/dsa/sja1105/sja1105_mdio.c
index 19aea8fb76f6..5acf6742da4d 100644
--- a/drivers/net/dsa/sja1105/sja1105_mdio.c
+++ b/drivers/net/dsa/sja1105/sja1105_mdio.c
@@ -437,13 +437,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;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index a5d150c5f3d8..81a145009488 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -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,21 @@ int stmmac_xpcs_setup(struct mii_bus *bus)
 		if (IS_ERR(mdiodev))
 			continue;
 
-		xpcs = xpcs_create(mdiodev, mode);
+		xpcs = xpcs_create(mdiodev);
 		if (IS_ERR_OR_NULL(xpcs)) {
 			mdio_device_free(mdiodev);
 			continue;
 		}
 
+		if (!skip_xpcs_soft_reset) {
+			err = xpcs_reset(xpcs, mode);
+			if (err) {
+				xpcs_destroy(xpcs);
+				mdio_device_free(mdiodev);
+				continue;
+			}
+		}
+
 		priv->hw->xpcs = xpcs;
 		break;
 	}
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 63fda3fc40aa..2e721e57bee4 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -248,6 +248,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) \
@@ -1080,12 +1092,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)
@@ -1097,35 +1108,18 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev,
 
 	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);
 
diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h
index add077a81b21..d841f55f12cc 100644
--- a/include/linux/pcs/pcs-xpcs.h
+++ b/include/linux/pcs/pcs-xpcs.h
@@ -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 */
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index a6f03b36fc4f..0f901773c5e4 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -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
-----------------------------[ cut here ]-----------------------------

I also gave this patch a run on sja1105 and it still works.

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 1/2] net: pcs: xpcs: enable skip xPCS soft reset
  2021-08-09 10:22 ` [PATCH net-next 1/2] net: pcs: xpcs: enable skip xPCS soft reset Wong Vee Khee
  2021-08-09 11:06   ` Vladimir Oltean
@ 2021-08-09 13:35   ` Andrew Lunn
  2021-08-10 23:55     ` Wong Vee Khee
  1 sibling, 1 reply; 10+ messages in thread
From: Andrew Lunn @ 2021-08-09 13:35 UTC (permalink / raw)
  To: Wong Vee Khee
  Cc: Vivien Didelot, Florian Fainelli, David S . Miller,
	Jakub Kicinski, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Heiner Kallweit, Russell King, Voon Weifeng,
	Michael Sit Wei Hong, Vladimir Oltean, linux-arm-kernel,
	linux-stm32, netdev, linux-kernel

On Mon, Aug 09, 2021 at 06:22:28PM +0800, Wong Vee Khee wrote:
> From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>
> 
> 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 changes the xpcs_create function to take in an additional argument
> to check if the platform request to skip xPCS soft reset during device
> initialization.

Why not just call into the BIOS and ask it to configure the SERDES?
Isn't that what ACPI is all about, hiding the details from the OS? Or
did the BIOS writers not add a control method to do this?

    Andrew

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 1/2] net: pcs: xpcs: enable skip xPCS soft reset
  2021-08-09 11:06   ` Vladimir Oltean
@ 2021-08-10 23:50     ` Wong Vee Khee
  0 siblings, 0 replies; 10+ messages in thread
From: Wong Vee Khee @ 2021-08-10 23:50 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S . Miller,
	Jakub Kicinski, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Heiner Kallweit, Russell King, Voon Weifeng,
	Michael Sit Wei Hong, linux-arm-kernel, linux-stm32, netdev,
	linux-kernel

On Mon, Aug 09, 2021 at 02:06:26PM +0300, Vladimir Oltean wrote:
> Hi VK,
> 
> On Mon, Aug 09, 2021 at 06:22:28PM +0800, Wong Vee Khee wrote:
> > diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
> > index 63fda3fc40aa..c7a3aa862079 100644
> > --- a/drivers/net/pcs/pcs-xpcs.c
> > +++ b/drivers/net/pcs/pcs-xpcs.c
> > @@ -1081,7 +1081,8 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = {
> >  };
> >  
> >  struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev,
> > -			    phy_interface_t interface)
> > +			    phy_interface_t interface,
> > +			    bool skip_reset)
> >  {
> >  	struct dw_xpcs *xpcs;
> >  	u32 xpcs_id;
> > @@ -1113,9 +1114,16 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev,
> >  		xpcs->pcs.ops = &xpcs_phylink_ops;
> >  		xpcs->pcs.poll = true;
> >  
> > -		ret = xpcs_soft_reset(xpcs, compat);
> > -		if (ret)
> > -			goto out;
> > +		if (!skip_reset) {
> > +			dev_info(&xpcs->mdiodev->dev, "%s: xPCS soft reset\n",
> > +				 __func__);
> > +			ret = xpcs_soft_reset(xpcs, compat);
> > +			if (ret)
> > +				goto out;
> > +		} else {
> > +			dev_info(&xpcs->mdiodev->dev,
> > +				 "%s: skip xpcs soft reset\n", __func__);
> > +		}
> 
> I don't feel like the prints are really necessary.

Sounds good to me. I'll remove these.

> 
> >  
> >  		return xpcs;
> >  	}
> > diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h
> > index add077a81b21..0c05a63f3446 100644
> > --- a/include/linux/pcs/pcs-xpcs.h
> > +++ b/include/linux/pcs/pcs-xpcs.h
> > @@ -36,7 +36,8 @@ void xpcs_validate(struct dw_xpcs *xpcs, unsigned long *supported,
> >  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);
> > +			    phy_interface_t interface,
> > +			    bool xpcs_reset);
> >  void xpcs_destroy(struct dw_xpcs *xpcs);
> >  
> 
> How about exporting the reset functionality as a separate function, and
> the Intel Alder Lake stmmac shim just won't call it? Like this:
> 
> -----------------------------[ cut here ]-----------------------------
> diff --git a/drivers/net/dsa/sja1105/sja1105_mdio.c b/drivers/net/dsa/sja1105/sja1105_mdio.c
> index 19aea8fb76f6..5acf6742da4d 100644
> --- a/drivers/net/dsa/sja1105/sja1105_mdio.c
> +++ b/drivers/net/dsa/sja1105/sja1105_mdio.c
> @@ -437,13 +437,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;
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> index a5d150c5f3d8..81a145009488 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> @@ -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,21 @@ int stmmac_xpcs_setup(struct mii_bus *bus)
>  		if (IS_ERR(mdiodev))
>  			continue;
>  
> -		xpcs = xpcs_create(mdiodev, mode);
> +		xpcs = xpcs_create(mdiodev);
>  		if (IS_ERR_OR_NULL(xpcs)) {
>  			mdio_device_free(mdiodev);
>  			continue;
>  		}
>  
> +		if (!skip_xpcs_soft_reset) {
> +			err = xpcs_reset(xpcs, mode);
> +			if (err) {
> +				xpcs_destroy(xpcs);
> +				mdio_device_free(mdiodev);
> +				continue;
> +			}
> +		}
> +
>  		priv->hw->xpcs = xpcs;
>  		break;
>  	}
> diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
> index 63fda3fc40aa..2e721e57bee4 100644
> --- a/drivers/net/pcs/pcs-xpcs.c
> +++ b/drivers/net/pcs/pcs-xpcs.c
> @@ -248,6 +248,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) \
> @@ -1080,12 +1092,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)
> @@ -1097,35 +1108,18 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev,
>  
>  	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);
>  
> diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h
> index add077a81b21..d841f55f12cc 100644
> --- a/include/linux/pcs/pcs-xpcs.h
> +++ b/include/linux/pcs/pcs-xpcs.h
> @@ -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 */
> diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
> index a6f03b36fc4f..0f901773c5e4 100644
> --- a/include/linux/stmmac.h
> +++ b/include/linux/stmmac.h
> @@ -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
> -----------------------------[ cut here ]-----------------------------
> 
> I also gave this patch a run on sja1105 and it still works.

Thanks for the suggestion. I tested it out on stmmac and it works.
I will use this as it looks neater. :)

Regards,
 VK


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 1/2] net: pcs: xpcs: enable skip xPCS soft reset
  2021-08-09 13:35   ` Andrew Lunn
@ 2021-08-10 23:55     ` Wong Vee Khee
  2021-08-11  8:36       ` Florian Fainelli
  0 siblings, 1 reply; 10+ messages in thread
From: Wong Vee Khee @ 2021-08-10 23:55 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Vivien Didelot, Florian Fainelli, David S . Miller,
	Jakub Kicinski, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Heiner Kallweit, Russell King, Voon Weifeng,
	Michael Sit Wei Hong, Vladimir Oltean, linux-arm-kernel,
	linux-stm32, netdev, linux-kernel

Hi Andrew,
On Mon, Aug 09, 2021 at 03:35:09PM +0200, Andrew Lunn wrote:
> On Mon, Aug 09, 2021 at 06:22:28PM +0800, Wong Vee Khee wrote:
> > From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>
> > 
> > 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 changes the xpcs_create function to take in an additional argument
> > to check if the platform request to skip xPCS soft reset during device
> > initialization.
> 
> Why not just call into the BIOS and ask it to configure the SERDES?
> Isn't that what ACPI is all about, hiding the details from the OS? Or
> did the BIOS writers not add a control method to do this?
> 
>     Andrew

BIOS does configured the SerDes. The problem here is that all the
configurations done by BIOS are being reset at xpcs_create().

We would want user of the pcs-xpcs module (stmmac, sja1105) to have
control whether or not we need to perform to the soft reset in the
xpcs_create() call.

Hope that explained.

Regards,
 VK

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 1/2] net: pcs: xpcs: enable skip xPCS soft reset
  2021-08-10 23:55     ` Wong Vee Khee
@ 2021-08-11  8:36       ` Florian Fainelli
  2021-08-11 14:20         ` Andrew Lunn
  0 siblings, 1 reply; 10+ messages in thread
From: Florian Fainelli @ 2021-08-11  8:36 UTC (permalink / raw)
  To: Wong Vee Khee, Andrew Lunn
  Cc: Vivien Didelot, David S . Miller, Jakub Kicinski,
	Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Heiner Kallweit, Russell King, Voon Weifeng,
	Michael Sit Wei Hong, Vladimir Oltean, linux-arm-kernel,
	linux-stm32, netdev, linux-kernel



On 8/10/2021 4:55 PM, Wong Vee Khee wrote:
> Hi Andrew,
> On Mon, Aug 09, 2021 at 03:35:09PM +0200, Andrew Lunn wrote:
>> On Mon, Aug 09, 2021 at 06:22:28PM +0800, Wong Vee Khee wrote:
>>> From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com>
>>>
>>> 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 changes the xpcs_create function to take in an additional argument
>>> to check if the platform request to skip xPCS soft reset during device
>>> initialization.
>>
>> Why not just call into the BIOS and ask it to configure the SERDES?
>> Isn't that what ACPI is all about, hiding the details from the OS? Or
>> did the BIOS writers not add a control method to do this?
>>
>>      Andrew
> 
> BIOS does configured the SerDes. The problem here is that all the
> configurations done by BIOS are being reset at xpcs_create().
> 
> We would want user of the pcs-xpcs module (stmmac, sja1105) to have
> control whether or not we need to perform to the soft reset in the
> xpcs_create() call.

I understood Andrew's response as suggesting to introduce the ability 
for xpcs_create() to make a BIOS call which would configure the SerDes 
after xpcs_soft_reset(). That way the current xpcs_create() signature 
would remain the same, but you could easily hook any post-reset 
initialization by making an appropriate BIOS call.
-- 
Florian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 1/2] net: pcs: xpcs: enable skip xPCS soft reset
  2021-08-11  8:36       ` Florian Fainelli
@ 2021-08-11 14:20         ` Andrew Lunn
  2021-08-26 11:50           ` Wong Vee Khee
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Lunn @ 2021-08-11 14:20 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Wong Vee Khee, Vivien Didelot, David S . Miller, Jakub Kicinski,
	Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Heiner Kallweit, Russell King, Voon Weifeng,
	Michael Sit Wei Hong, Vladimir Oltean, linux-arm-kernel,
	linux-stm32, netdev, linux-kernel

> > BIOS does configured the SerDes. The problem here is that all the
> > configurations done by BIOS are being reset at xpcs_create().
> > 
> > We would want user of the pcs-xpcs module (stmmac, sja1105) to have
> > control whether or not we need to perform to the soft reset in the
> > xpcs_create() call.
> 
> I understood Andrew's response as suggesting to introduce the ability for
> xpcs_create() to make a BIOS call which would configure the SerDes after
> xpcs_soft_reset().

Yes. Exactly. That is what ACPI is for, so we should use it for this.

     Andrew

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH net-next 1/2] net: pcs: xpcs: enable skip xPCS soft reset
  2021-08-11 14:20         ` Andrew Lunn
@ 2021-08-26 11:50           ` Wong Vee Khee
  0 siblings, 0 replies; 10+ messages in thread
From: Wong Vee Khee @ 2021-08-26 11:50 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Florian Fainelli, Vivien Didelot, David S . Miller,
	Jakub Kicinski, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	Maxime Coquelin, Heiner Kallweit, Russell King, Voon Weifeng,
	Michael Sit Wei Hong, Vladimir Oltean, linux-arm-kernel,
	linux-stm32, netdev, linux-kernel

On Wed, Aug 11, 2021 at 04:20:56PM +0200, Andrew Lunn wrote:
> > > BIOS does configured the SerDes. The problem here is that all the
> > > configurations done by BIOS are being reset at xpcs_create().
> > > 
> > > We would want user of the pcs-xpcs module (stmmac, sja1105) to have
> > > control whether or not we need to perform to the soft reset in the
> > > xpcs_create() call.
> > 
> > I understood Andrew's response as suggesting to introduce the ability for
> > xpcs_create() to make a BIOS call which would configure the SerDes after
> > xpcs_soft_reset().
> 
> Yes. Exactly. That is what ACPI is for, so we should use it for this.
> 
>      Andrew

Thanks Florian for the explaination.

I have checked with the BIOS developers and they did not implmenet a
method to this at the kernel level.

Also, Intel AlderLake has both UEFI BIOS and Slim Bootloader which
make it least feasible to go for the ACPI method as per suggested.


Regards,
  VK

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-08-26 11:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09 10:22 [PATCH net-next 0/2] Intel AlderLake-S 2.5Gbps link speed support Wong Vee Khee
2021-08-09 10:22 ` [PATCH net-next 1/2] net: pcs: xpcs: enable skip xPCS soft reset Wong Vee Khee
2021-08-09 11:06   ` Vladimir Oltean
2021-08-10 23:50     ` Wong Vee Khee
2021-08-09 13:35   ` Andrew Lunn
2021-08-10 23:55     ` Wong Vee Khee
2021-08-11  8:36       ` Florian Fainelli
2021-08-11 14:20         ` Andrew Lunn
2021-08-26 11:50           ` Wong Vee Khee
2021-08-09 10:22 ` [PATCH net-next 2/2] stmmac: intel: Enable 2.5Gbps on Intel AlderLake-S Wong Vee Khee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).