* [PATCH net-next v3 1/4] net: phy: marvell: move mode configuration into standalone function
2026-11-20 17:05 [PATCH net-next v3 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
@ 2026-11-20 17:05 ` Paul Louvel
2026-11-20 17:05 ` [PATCH net-next v3 2/4] net: phy: marvell: de-duplicate mode initialization code Paul Louvel
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Paul Louvel @ 2026-11-20 17:05 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>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
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 [flat|nested] 6+ messages in thread* [PATCH net-next v3 2/4] net: phy: marvell: de-duplicate mode initialization code
2026-11-20 17:05 [PATCH net-next v3 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
2026-11-20 17:05 ` [PATCH net-next v3 1/4] net: phy: marvell: move mode configuration into standalone function Paul Louvel
@ 2026-11-20 17:05 ` Paul Louvel
2026-11-20 17:05 ` [PATCH net-next v3 3/4] net: phy: marvell: factor out EEE errata initialization Paul Louvel
2026-11-20 17:05 ` [PATCH net-next v3 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
3 siblings, 0 replies; 6+ messages in thread
From: Paul Louvel @ 2026-11-20 17:05 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>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
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 [flat|nested] 6+ messages in thread* [PATCH net-next v3 3/4] net: phy: marvell: factor out EEE errata initialization
2026-11-20 17:05 [PATCH net-next v3 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
2026-11-20 17:05 ` [PATCH net-next v3 1/4] net: phy: marvell: move mode configuration into standalone function Paul Louvel
2026-11-20 17:05 ` [PATCH net-next v3 2/4] net: phy: marvell: de-duplicate mode initialization code Paul Louvel
@ 2026-11-20 17:05 ` Paul Louvel
2026-11-20 17:05 ` [PATCH net-next v3 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
3 siblings, 0 replies; 6+ messages in thread
From: Paul Louvel @ 2026-11-20 17:05 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>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
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 [flat|nested] 6+ messages in thread* [PATCH net-next v3 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration
2026-11-20 17:05 [PATCH net-next v3 0/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
` (2 preceding siblings ...)
2026-11-20 17:05 ` [PATCH net-next v3 3/4] net: phy: marvell: factor out EEE errata initialization Paul Louvel
@ 2026-11-20 17:05 ` Paul Louvel
2026-11-24 18:01 ` netdev-bot+sashiko
3 siblings, 1 reply; 6+ messages in thread
From: Paul Louvel @ 2026-11-20 17:05 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.
Signed-off-by: Paul Louvel (Schneider Electric) <paul.louvel@bootlin.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
drivers/net/phy/marvell.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index a72d307eaf12..423d146426ff 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1403,9 +1403,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 [flat|nested] 6+ messages in thread* Re: [PATCH net-next v3 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration
2026-11-20 17:05 ` [PATCH net-next v3 4/4] net: phy: marvell: add RGMII-to-Copper mode configuration Paul Louvel
@ 2026-11-24 18:01 ` netdev-bot+sashiko
0 siblings, 0 replies; 6+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 18:01 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] On RGMII-attached 88E151x PHYs with an SFP cage,
m88e1510_config_init() (drivers/net/phy/marvell.c:1409-1410) now…
- [Medium] Before this patch, m88e1510_config_init() did not touch
GEN_CTRL_REG_1[2:0] for RGMII-attached 88E1510/1512/1514/1518 PHYs.
--
net: phy: marvell: add RGMII-to-Copper mode configuration
This commit extends m88e1510_config_init() so it programs the
GEN_CTRL_REG_1 mode field when the interface is any rgmii variant. The mode
written is RGMII-to-Copper. Before, only the SGMII-to-Copper case was
handled.
> diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> index a72d307eaf12c..423d146426ff5 100644
> --- a/drivers/net/phy/marvell.c
> +++ b/drivers/net/phy/marvell.c
> @@ -1403,9 +1403,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: High]
Can this overwrite the serdes mode that was set for an SFP module on
88E1512 boards with an RGMII host and an SFP cage?
When a module is inserted, m88e1510_port_configure_serdes() writes the same
MODE field:
drivers/net/phy/marvell.c:m88e1510_port_configure_serdes() {
...
case PHY_INTERFACE_MODE_1000BASEX:
mode = MII_88E1510_GEN_CTRL_REG_1_MODE_RGMII_1000X;
...
return m88e1510_config_mode(phydev, mode);
}
That write happens only through phy_sfp_module_insert()->configure_mii(),
once per insertion event. The SFP upstream is registered at phy_probe()
time, and sfp_sm_module() reports the insertion from SFP_MOD_WAITDEV. So
the module is normally configured before the MAC attaches the PHY.
After that, each of these paths runs config_init again:
phy_attach_direct()->phy_init_hw()->m88e1510_config_init()
mdio_bus_phy_resume()->phy_init_hw()->m88e1510_config_init()
phy_abort_cable_test()->phy_init_hw()->m88e1510_config_init()
SIOCSMIIREG with BMCR_RESET -> phy_init_hw()->m88e1510_config_init()
With this change, phy_interface_is_rgmii() is true on these boards. MODE is
forced back to RGMII-to-Copper and the PHY gets a soft reset. Nothing calls
configure_mii again after phy_init_hw(). Would the SFP link then stay down
until the module is physically re-plugged?
Before this patch, config_init did not touch the mode for RGMII, and the
88E1510 driver entry has no .soft_reset. That meant the SFP mode survived
phy_init_hw(). This RGMII-host SFP setup is the one supported by commit
b697d9d38a5a ("net: phy: marvell: add SFP support for 88E1510") and commit
1384e1383829 ("net: phy: marvell: Support SFP through phy_port interface").
The commit message does not mention how the change interacts with them.
[Severity: Medium]
Does this also override a fibre or auto-media mode that was set outside the
kernel, for example by straps or the bootloader, on RGMII-attached
88E151x PHYs?
The 88E1510 entry advertises PHY_GBIT_FIBRE_FEATURES. Since commit
6cfb3bcc0641 ("Marvell phy: check link status in case of fiber link."),
marvell_read_status() checks the fibre page for non-SGMII hosts:
drivers/net/phy/marvell.c:marvell_read_status() {
...
if (linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT,
phydev->supported) &&
phydev->interface != PHY_INTERFACE_MODE_SGMII) {
err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE);
...
}
If MODE is forced to 000 (RGMII-to-Copper) on every config_init, the fibre
side looks disabled on such boards. marvell_read_status() would then never
see a fibre link.
Also, m88e1510_config_mode() always sets MII_88E1510_GEN_CTRL_REG_1_RESET,
even when the mode does not change. Every RGMII user now gets a mode soft
reset on each config_init, where before only SGMII did. Should the commit
message describe this change in behaviour, and the failure that motivated
the patch?
> if (err < 0)
> return err;
>
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-marvell-phy-rgmii-v3-0-c11c99798931%40bootlin.com
^ permalink raw reply [flat|nested] 6+ messages in thread