Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration
@ 2026-11-16 15:27 Paul Louvel
  2026-11-16 15:27 ` [PATCH net-next v2 1/4] net: phy: marvell: move mode configuration into standalone function Paul Louvel
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Paul Louvel @ 2026-11-16 15:27 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Chevallier
  Cc: netdev, linux-kernel, Thomas Petazzoni, Miquel Raynal,
	Herve Codina, Paul Louvel (Schneider Electric)

Hi,

This series add the configuration of the RGMII-to-Copper MAC interface
for Marvell 88E1510/88E1518/88E1512/88E1514 PHYs.

Patch #1, #2, #3 are cleanup commits.

Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>
---
Changes in v2:
- Reword patches to be more accurate.
- Added a patch to deduplicate the mode setting code in
  m88e1510_config_init(), as suggested by Marek.
- When setting RGMII system interface, avoid erasing existing mode that
  uses RGMII but a different media interface. This issue was raised by
  Sashiko.
- Added a patch to rework the EEE errata code by using
  phy_select_page() and phy_restore_page(), avoiding useless bus lock.
- Link to v1: https://patch.msgid.link/20261109-marvell-phy-rgmii-v1-0-026979ef4f13@bootlin.com

---
Paul Louvel (4):
      net: phy: marvell: move mode configuration into standalone function
      net: phy: marvell: de-duplicate mode initialization code
      net: phy: marvell: factor out EEE errata initialization
      net: phy: marvell: add RGMII-to-Copper mode configuration

 drivers/net/phy/marvell.c | 127 ++++++++++++++++++++++++++--------------------
 1 file changed, 71 insertions(+), 56 deletions(-)
---
base-commit: 7b6ab4dbc156e2f96419715130b3d5738a306c93
change-id: 20261109-marvell-phy-rgmii-60a8bf619582

Best regards,
--  
Paul Louvel, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


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

* [PATCH net-next v2 1/4] net: phy: marvell: move mode configuration into standalone function
  2026-11-16 15:27 [PATCH net-next v2 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
@ 2026-11-16 15:27 ` Paul Louvel
  2026-11-17  2:02   ` Andrew Lunn
  2026-11-16 15:27 ` [PATCH net-next v2 2/4] net: phy: marvell: de-duplicate mode initialization code Paul Louvel
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Paul Louvel @ 2026-11-16 15:27 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Chevallier
  Cc: netdev, linux-kernel, Thomas Petazzoni, Miquel Raynal,
	Herve Codina, Paul Louvel (Schneider Electric)

Move the configuration of the m88e151x out of the
m88e1510_port_configure_serdes() function, so that other parts of the
driver can use it.

Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>
---
 drivers/net/phy/marvell.c | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 2c688d661297..aef5f8279133 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1332,6 +1332,27 @@ static int m88e1318_config_init(struct phy_device *phydev)
 	return marvell_config_init(phydev);
 }
 
+static int m88e1510_config_mode(struct phy_device *phydev, u16 mode)
+{
+	int oldpage;
+	int ret = 0;
+
+	oldpage = phy_select_page(phydev, MII_MARVELL_MODE_PAGE);
+	if (oldpage < 0)
+		goto error;
+
+	ret = __phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1,
+			   MII_88E1510_GEN_CTRL_REG_1_MODE_MASK, mode);
+	if (ret < 0)
+		goto error;
+
+	ret = __phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1,
+			     MII_88E1510_GEN_CTRL_REG_1_RESET);
+
+error:
+	return phy_restore_page(phydev, oldpage, ret);
+}
+
 static int m88e1510_config_init(struct phy_device *phydev)
 {
 	static const struct {
@@ -3656,8 +3677,6 @@ static int m88e1510_port_configure_serdes(struct phy_port *port, bool enable,
 {
 	struct phy_device *phydev = port_phydev(port);
 	struct device *dev;
-	int oldpage;
-	int ret = 0;
 	u16 mode;
 
 	dev = &phydev->mdio.dev;
@@ -3685,20 +3704,7 @@ static int m88e1510_port_configure_serdes(struct phy_port *port, bool enable,
 		mode = MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII;
 	}
 
-	oldpage = phy_select_page(phydev, MII_MARVELL_MODE_PAGE);
-	if (oldpage < 0)
-		goto error;
-
-	ret = __phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1,
-			   MII_88E1510_GEN_CTRL_REG_1_MODE_MASK, mode);
-	if (ret < 0)
-		goto error;
-
-	ret = __phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1,
-			     MII_88E1510_GEN_CTRL_REG_1_RESET);
-
-error:
-	return phy_restore_page(phydev, oldpage, ret);
+	return m88e1510_config_mode(phydev, mode);
 }
 
 static const struct phy_port_ops m88e1510_serdes_port_ops = {

-- 
2.56.1


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

* [PATCH net-next v2 2/4] net: phy: marvell: de-duplicate mode initialization code
  2026-11-16 15:27 [PATCH net-next v2 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
  2026-11-16 15:27 ` [PATCH net-next v2 1/4] net: phy: marvell: move mode configuration into standalone function Paul Louvel
@ 2026-11-16 15:27 ` Paul Louvel
  2026-11-17  2:03   ` Andrew Lunn
  2026-11-16 15:27 ` [PATCH net-next v2 3/4] net: phy: marvell: factor out EEE errata initialization Paul Louvel
  2026-11-16 15:27 ` [PATCH net-next v2 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
  3 siblings, 1 reply; 11+ messages in thread
From: Paul Louvel @ 2026-11-16 15:27 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Chevallier
  Cc: netdev, linux-kernel, Thomas Petazzoni, Miquel Raynal,
	Herve Codina, Paul Louvel (Schneider Electric)

The code that initializes the m88e151x PHYs to use the SGMII-to-Copper
interface is duplicated, and does not restore the old page in case of an
error.

Instead, use m88e1510_config_mode().

Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>
---
 drivers/net/phy/marvell.c | 27 ++++-----------------------
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index aef5f8279133..d2c5d3c5ce7d 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1395,30 +1395,11 @@ static int m88e1510_config_init(struct phy_device *phydev)
 		return err;
 
 	/* SGMII-to-Copper mode initialization */
-	if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
-		/* Select page 18 */
-		err = marvell_set_page(phydev, 18);
-		if (err < 0)
-			return err;
-
-		/* In reg 20, write MODE[2:0] = 0x1 (SGMII to Copper) */
-		err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1,
-				 MII_88E1510_GEN_CTRL_REG_1_MODE_MASK,
-				 MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII);
-		if (err < 0)
-			return err;
-
-		/* PHY reset is necessary after changing MODE[2:0] */
-		err = phy_set_bits(phydev, MII_88E1510_GEN_CTRL_REG_1,
-				   MII_88E1510_GEN_CTRL_REG_1_RESET);
-		if (err < 0)
-			return err;
+	if (phydev->interface == PHY_INTERFACE_MODE_SGMII)
+		err = m88e1510_config_mode(phydev, MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII);
+	if (err < 0)
+		return err;
 
-		/* Reset page selection */
-		err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE);
-		if (err < 0)
-			return err;
-	}
 	err = m88e1011_set_downshift(phydev, 3);
 	if (err < 0)
 		return err;

-- 
2.56.1


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

* [PATCH net-next v2 3/4] net: phy: marvell: factor out EEE errata initialization
  2026-11-16 15:27 [PATCH net-next v2 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
  2026-11-16 15:27 ` [PATCH net-next v2 1/4] net: phy: marvell: move mode configuration into standalone function Paul Louvel
  2026-11-16 15:27 ` [PATCH net-next v2 2/4] net: phy: marvell: de-duplicate mode initialization code Paul Louvel
@ 2026-11-16 15:27 ` Paul Louvel
  2026-11-17  2:04   ` Andrew Lunn
  2026-11-19  6:29   ` netdev-bot+sashiko
  2026-11-16 15:27 ` [PATCH net-next v2 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
  3 siblings, 2 replies; 11+ messages in thread
From: Paul Louvel @ 2026-11-16 15:27 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Chevallier
  Cc: netdev, linux-kernel, Thomas Petazzoni, Miquel Raynal,
	Herve Codina, Paul Louvel (Schneider Electric)

The 88E151x EEE errata sequence writes four register pairs on page 0xFF.
Using phy_write() for each access takes and releases the MDIO bus lock
every time, and returning early on error leaves the PHY on the errata
page.

Move the sequence into m88e1510_eee_errata() and use phy_select_page()
and phy_restore_page().
This reduces the number of bus lock/unlock cycles and restores the
previous page if one of the errata writes fails.

Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>
---
 drivers/net/phy/marvell.c | 41 +++++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index d2c5d3c5ce7d..a72d307eaf12 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1353,7 +1353,7 @@ static int m88e1510_config_mode(struct phy_device *phydev, u16 mode)
 	return phy_restore_page(phydev, oldpage, ret);
 }
 
-static int m88e1510_config_init(struct phy_device *phydev)
+static int m88e1510_eee_errata(struct phy_device *phydev)
 {
 	static const struct {
 		u16 reg17, reg16;
@@ -1363,31 +1363,40 @@ static int m88e1510_config_init(struct phy_device *phydev)
 		{ 0xb233, 0x214d },
 		{ 0xcc0c, 0x2159 },
 	};
-	int err;
-	int i;
+	int i, oldpage, ret = 0;
 
 	/* As per Marvell Release Notes - Alaska 88E1510/88E1518/88E1512/
 	 * 88E1514 Rev A0, Errata Section 5.1:
 	 * If EEE is intended to be used, the following register writes
 	 * must be done once after every hardware reset.
 	 */
-	err = marvell_set_page(phydev, 0x00FF);
-	if (err < 0)
-		return err;
+	oldpage = phy_select_page(phydev, 0x00FF);
+	if (oldpage < 0)
+		goto restore;
 
 	for (i = 0; i < ARRAY_SIZE(errata_vals); ++i) {
-		err = phy_write(phydev, 17, errata_vals[i].reg17);
-		if (err)
-			return err;
-		err = phy_write(phydev, 16, errata_vals[i].reg16);
-		if (err)
-			return err;
+		ret = __phy_write(phydev, 17, errata_vals[i].reg17);
+		if (ret)
+			goto restore;
+
+		ret = __phy_write(phydev, 16, errata_vals[i].reg16);
+		if (ret)
+			goto restore;
 	}
 
-	err = marvell_set_page(phydev, 0x00FB);
-	if (err < 0)
-		return err;
-	err = phy_write(phydev, 07, 0xC00D);
+restore:
+	ret = phy_restore_page(phydev, oldpage, ret);
+	if (ret < 0)
+		return ret;
+
+	return phy_write_paged(phydev, 0x00FB, 07, 0xC00D);
+}
+
+static int m88e1510_config_init(struct phy_device *phydev)
+{
+	int err;
+
+	err = m88e1510_eee_errata(phydev);
 	if (err < 0)
 		return err;
 	err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE);

-- 
2.56.1


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

* [PATCH net-next v2 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration
  2026-11-16 15:27 [PATCH net-next v2 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
                   ` (2 preceding siblings ...)
  2026-11-16 15:27 ` [PATCH net-next v2 3/4] net: phy: marvell: factor out EEE errata initialization Paul Louvel
@ 2026-11-16 15:27 ` Paul Louvel
  2026-11-18  8:20   ` Maxime Chevallier
  2026-11-19  6:29   ` netdev-bot+sashiko
  3 siblings, 2 replies; 11+ messages in thread
From: Paul Louvel @ 2026-11-16 15:27 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Maxime Chevallier
  Cc: netdev, linux-kernel, Thomas Petazzoni, Miquel Raynal,
	Herve Codina, Paul Louvel (Schneider Electric)

The driver currently programs the mode only for SGMII-to-Copper, based
on the PHY interface mode.

Some MACs connect to the PHY via RGMII. Add code in
m88e1510_config_init() to configure the device.

Do not overwrite the media interface mode configured via
m88e1510_port_configure_serdes().

Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>
---
 drivers/net/phy/marvell.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index a72d307eaf12..9748fdd843ff 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1341,6 +1341,23 @@ static int m88e1510_config_mode(struct phy_device *phydev, u16 mode)
 	if (oldpage < 0)
 		goto error;
 
+	ret = __phy_read(phydev, MII_88E1510_GEN_CTRL_REG_1);
+	if (ret < 0)
+		goto error;
+
+	if (mode == MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII) {
+		switch (FIELD_GET(MII_88E1510_GEN_CTRL_REG_1_MODE_MASK, ret)) {
+		case MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII:
+		case MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_1000X:
+		case MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_100FX:
+		case MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_SGMII:
+			ret = 0;
+			goto error;
+		default:
+			break;
+		}
+	}
+
 	ret = __phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1,
 			   MII_88E1510_GEN_CTRL_REG_1_MODE_MASK, mode);
 	if (ret < 0)
@@ -1403,9 +1420,11 @@ static int m88e1510_config_init(struct phy_device *phydev)
 	if (err < 0)
 		return err;
 
-	/* SGMII-to-Copper mode initialization */
+	/* RGMII/SGMII-to-Copper mode initialization */
 	if (phydev->interface == PHY_INTERFACE_MODE_SGMII)
 		err = m88e1510_config_mode(phydev, MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII);
+	else if (phy_interface_is_rgmii(phydev))
+		err = m88e1510_config_mode(phydev, MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII);
 	if (err < 0)
 		return err;
 

-- 
2.56.1


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

* Re: [PATCH net-next v2 1/4] net: phy: marvell: move mode configuration into standalone function
  2026-11-16 15:27 ` [PATCH net-next v2 1/4] net: phy: marvell: move mode configuration into standalone function Paul Louvel
@ 2026-11-17  2:02   ` Andrew Lunn
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2026-11-17  2:02 UTC (permalink / raw)
  To: Paul Louvel
  Cc: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Maxime Chevallier, netdev,
	linux-kernel, Thomas Petazzoni, Miquel Raynal, Herve Codina

On Mon, Nov 16, 2026 at 04:27:01PM +0100, Paul Louvel wrote:
> Move the configuration of the m88e151x out of the
> m88e1510_port_configure_serdes() function, so that other parts of the
> driver can use it.
> 
> Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v2 2/4] net: phy: marvell: de-duplicate mode initialization code
  2026-11-16 15:27 ` [PATCH net-next v2 2/4] net: phy: marvell: de-duplicate mode initialization code Paul Louvel
@ 2026-11-17  2:03   ` Andrew Lunn
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2026-11-17  2:03 UTC (permalink / raw)
  To: Paul Louvel
  Cc: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Maxime Chevallier, netdev,
	linux-kernel, Thomas Petazzoni, Miquel Raynal, Herve Codina

On Mon, Nov 16, 2026 at 04:27:02PM +0100, Paul Louvel wrote:
> The code that initializes the m88e151x PHYs to use the SGMII-to-Copper
> interface is duplicated, and does not restore the old page in case of an
> error.
> 
> Instead, use m88e1510_config_mode().
> 
> Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v2 3/4] net: phy: marvell: factor out EEE errata initialization
  2026-11-16 15:27 ` [PATCH net-next v2 3/4] net: phy: marvell: factor out EEE errata initialization Paul Louvel
@ 2026-11-17  2:04   ` Andrew Lunn
  2026-11-19  6:29   ` netdev-bot+sashiko
  1 sibling, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2026-11-17  2:04 UTC (permalink / raw)
  To: Paul Louvel
  Cc: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Maxime Chevallier, netdev,
	linux-kernel, Thomas Petazzoni, Miquel Raynal, Herve Codina

On Mon, Nov 16, 2026 at 04:27:03PM +0100, Paul Louvel wrote:
> The 88E151x EEE errata sequence writes four register pairs on page 0xFF.
> Using phy_write() for each access takes and releases the MDIO bus lock
> every time, and returning early on error leaves the PHY on the errata
> page.
> 
> Move the sequence into m88e1510_eee_errata() and use phy_select_page()
> and phy_restore_page().
> This reduces the number of bus lock/unlock cycles and restores the
> previous page if one of the errata writes fails.
> 
> Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v2 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration
  2026-11-16 15:27 ` [PATCH net-next v2 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
@ 2026-11-18  8:20   ` Maxime Chevallier
  2026-11-19  6:29   ` netdev-bot+sashiko
  1 sibling, 0 replies; 11+ messages in thread
From: Maxime Chevallier @ 2026-11-18  8:20 UTC (permalink / raw)
  To: Paul Louvel, Andrew Lunn, Heiner Kallweit, Russell King,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel, Thomas Petazzoni, Miquel Raynal,
	Herve Codina

Hi Paul,

On 11/16/26 16:27, Paul Louvel wrote:
> The driver currently programs the mode only for SGMII-to-Copper, based
> on the PHY interface mode.
> 
> Some MACs connect to the PHY via RGMII. Add code in
> m88e1510_config_init() to configure the device.
> 
> Do not overwrite the media interface mode configured via
> m88e1510_port_configure_serdes().
> 
> Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>

FWIW I've tested that on a SGMII-to-Copper 88e1512 PHY, and no regressions
found. I can't test on RGMII though :)

Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>

Maxime


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

* Re: [PATCH net-next v2 3/4] net: phy: marvell: factor out EEE errata initialization
  2026-11-16 15:27 ` [PATCH net-next v2 3/4] net: phy: marvell: factor out EEE errata initialization Paul Louvel
  2026-11-17  2:04   ` Andrew Lunn
@ 2026-11-19  6:29   ` netdev-bot+sashiko
  1 sibling, 0 replies; 11+ messages in thread
From: netdev-bot+sashiko @ 2026-11-19  6:29 UTC (permalink / raw)
  To: paul.louvel
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni,
	maxime.chevallier, netdev, linux-kernel, thomas.petazzoni,
	miquel.raynal, herve.codina

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] In m88e1510_eee_errata() (drivers/net/phy/marvell.c), the patch
  changes the sequence of register writes the PHY receives even when…

--

net: phy: marvell: factor out EEE errata initialization

This patch moves the 88E151x EEE errata register sequence out of
m88e1510_config_init() and into a new helper, m88e1510_eee_errata(). The
page 0xFF writes now go through phy_select_page(), __phy_write() and
phy_restore_page(). The final page 0xFB write now uses phy_write_paged().

> diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> index d2c5d3c5ce7d1..a72d307eaf12c 100644
> --- a/drivers/net/phy/marvell.c
> +++ b/drivers/net/phy/marvell.c

[ ... ]

> @@ -1363,31 +1363,40 @@ static int m88e1510_config_init(struct phy_device *phydev)
>  		{ 0xb233, 0x214d },
>  		{ 0xcc0c, 0x2159 },
>  	};
> -	int err;
> -	int i;
> +	int i, oldpage, ret = 0;
>  
>  	/* As per Marvell Release Notes - Alaska 88E1510/88E1518/88E1512/
>  	 * 88E1514 Rev A0, Errata Section 5.1:
>  	 * If EEE is intended to be used, the following register writes
>  	 * must be done once after every hardware reset.
>  	 */
> -	err = marvell_set_page(phydev, 0x00FF);
> -	if (err < 0)
> -		return err;
> +	oldpage = phy_select_page(phydev, 0x00FF);
> +	if (oldpage < 0)
> +		goto restore;
>  
>  	for (i = 0; i < ARRAY_SIZE(errata_vals); ++i) {

[ ... ]

>  	}
>  
> -	err = marvell_set_page(phydev, 0x00FB);
> -	if (err < 0)
> -		return err;
> -	err = phy_write(phydev, 07, 0xC00D);
> +restore:
> +	ret = phy_restore_page(phydev, oldpage, ret);
> +	if (ret < 0)
> +		return ret;
> +
> +	return phy_write_paged(phydev, 0x00FB, 07, 0xC00D);

[Severity: Low]
Is it intended that the PHY now gets a different sequence of MDIO accesses
when nothing fails, and not only on the error path?

Before this patch, m88e1510_config_init() did:

    write page 0xFF
    write reg17/reg16 x4
    write page 0xFB
    write reg 7 = 0xC00D

After this patch, m88e1510_eee_errata() does:

    phy_select_page()    read page, write page 0xFF
    __phy_write()        write reg17/reg16 x4
    phy_restore_page()   write original page
    phy_write_paged()    read page, write page 0xFB,
                         write reg 7 = 0xC00D,
                         write original page

The PHY now switches back to the original page (normally the copper page
after reset) between the page 0xFF part and the page 0xFB part of the
vendor errata sequence. The number of MDIO transactions also goes from 11
to about 15.

These are undocumented vendor registers, so it isn't clear whether the
extra page switch matters to the hardware.

The commit message only says:

  "This reduces the number of bus lock/unlock cycles and restores the
  previous page if one of the errata writes fails."

Could the commit message also mention the changed write sequence on the
success path? Could it also say whether this was tested on 88E1510/1518/
1512/1514 Rev A0 parts?

The last patch of the series, "net: phy: marvell: add RGMII-to-Copper mode
configuration", leaves this code as it is.

> +}
> +
> +static int m88e1510_config_init(struct phy_device *phydev)
> +{
> +	int err;
> +
> +	err = m88e1510_eee_errata(phydev);
>  	if (err < 0)
>  		return err;
>  	err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE);

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116-marvell-phy-rgmii-v2-0-e04dca67e89a%40bootlin.com

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

* Re: [PATCH net-next v2 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration
  2026-11-16 15:27 ` [PATCH net-next v2 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
  2026-11-18  8:20   ` Maxime Chevallier
@ 2026-11-19  6:29   ` netdev-bot+sashiko
  1 sibling, 0 replies; 11+ messages in thread
From: netdev-bot+sashiko @ 2026-11-19  6:29 UTC (permalink / raw)
  To: paul.louvel
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni,
	maxime.chevallier, netdev, linux-kernel, thomas.petazzoni,
	miquel.raynal, herve.codina

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] This patch breaks the SFP-removal (serdes disable) path.
- [Medium] The new RGMII config_init path does not achieve its stated
  purpose ('Add code in m88e1510_config_init() to configure the device')…

--

net: phy: marvell: add RGMII-to-Copper mode configuration

With this commit, m88e1510_config_init() programs the RGMII-to-Copper mode
in GEN_CTRL_REG_1 when the PHY interface is RGMII. It also adds a check to
m88e1510_config_mode() so that an RGMII request does not overwrite an RGMII
media mode already present in the register.

> diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> index a72d307eaf12c..9748fdd843ffd 100644
> --- a/drivers/net/phy/marvell.c
> +++ b/drivers/net/phy/marvell.c
> @@ -1341,6 +1341,23 @@ static int m88e1510_config_mode(struct phy_device *phydev, u16 mode)
>  	if (oldpage < 0)
>  		goto error;
>  
> +	ret = __phy_read(phydev, MII_88E1510_GEN_CTRL_REG_1);
> +	if (ret < 0)
> +		goto error;
> +
> +	if (mode == MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII) {
> +		switch (FIELD_GET(MII_88E1510_GEN_CTRL_REG_1_MODE_MASK, ret)) {
> +		case MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII:
> +		case MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_1000X:
> +		case MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_100FX:
> +		case MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_SGMII:
> +			ret = 0;
> +			goto error;
> +		default:
> +			break;
> +		}
> +	}

[Severity: High]
This check sits in the shared helper. Does it also change the SFP removal
path in m88e1510_port_configure_serdes()?

When an SFP module is inserted, phy_sfp_module_insert() calls
configure_mii(port, true, iface). That writes RGMII_1000X, RGMII_100FX or
RGMII_SGMII into the mode field. On removal the call chain is:

phy_sfp_module_remove()
  m88e1510_port_configure_serdes(port, false, PHY_INTERFACE_MODE_NA)
    mode = MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII;
    m88e1510_config_mode(phydev, mode)

The register still holds one of the serdes modes at that point. The new
switch matches it, sets ret = 0 and jumps to error. That skips both the
__phy_modify() of the mode field and the MII_88E1510_GEN_CTRL_REG_1_RESET
soft reset.

Does that leave the PHY in RGMII-to-fiber/SGMII mode after the module is
removed, even though the caller sees success?

On resume or re-attach, m88e1510_config_init() also requests MODE_RGMII for
RGMII interfaces, so it would hit the same early return. Is a hardware
reset the only way to get back to copper mode?

Before this patch, the disable path always wrote MODE_RGMII and then did
the soft reset.

Could this be decided explicitly, through a caller argument or driver
state, instead of from the current register value?

>  	ret = __phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1,
>  			   MII_88E1510_GEN_CTRL_REG_1_MODE_MASK, mode);
>  	if (ret < 0)
> @@ -1403,9 +1420,11 @@ static int m88e1510_config_init(struct phy_device *phydev)
>  	if (err < 0)
>  		return err;
>  
> -	/* SGMII-to-Copper mode initialization */
> +	/* RGMII/SGMII-to-Copper mode initialization */
>  	if (phydev->interface == PHY_INTERFACE_MODE_SGMII)
>  		err = m88e1510_config_mode(phydev, MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII);
> +	else if (phy_interface_is_rgmii(phydev))
> +		err = m88e1510_config_mode(phydev, MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII);

[Severity: Medium]
The commit message says:

    Do not overwrite the media interface mode configured via
    m88e1510_port_configure_serdes().

However, the check in m88e1510_config_mode() only looks at the hardware
mode field. It keeps any RGMII_1000X, RGMII_100FX or RGMII_SGMII value,
whoever wrote it.

Suppose an RGMII board comes up with GEN_CTRL_REG_1[2:0] already set to one
of those values. The source could be the bootloader, strapping, or state
left over across kexec or a driver rebind. Would this call then skip both
the mode write and the soft reset, and leave the PHY out of copper mode?

As written, the new RGMII call seems to take effect only when the field
reads 0x1 or 0x5-0x7. Is that intended?

The driver does not record whether the serdes mode came from
m88e1510_port_configure_serdes(). Could that be tracked in driver state so
the code does what the commit message describes? The same change would
also fix the SFP removal issue above.

>  	if (err < 0)
>  		return err;
>

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116-marvell-phy-rgmii-v2-0-e04dca67e89a%40bootlin.com

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

end of thread, other threads:[~2026-11-19  6:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 15:27 [PATCH net-next v2 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
2026-11-16 15:27 ` [PATCH net-next v2 1/4] net: phy: marvell: move mode configuration into standalone function Paul Louvel
2026-11-17  2:02   ` Andrew Lunn
2026-11-16 15:27 ` [PATCH net-next v2 2/4] net: phy: marvell: de-duplicate mode initialization code Paul Louvel
2026-11-17  2:03   ` Andrew Lunn
2026-11-16 15:27 ` [PATCH net-next v2 3/4] net: phy: marvell: factor out EEE errata initialization Paul Louvel
2026-11-17  2:04   ` Andrew Lunn
2026-11-19  6:29   ` netdev-bot+sashiko
2026-11-16 15:27 ` [PATCH net-next v2 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
2026-11-18  8:20   ` Maxime Chevallier
2026-11-19  6:29   ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox