Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: marvell: prestera: disable port before changing its MAC mode
@ 2026-11-11 10:15 Imre Kaloz
  2026-11-11 10:20 ` netdev-bot+sinfo
       [not found] ` <BL1PPFB0715B38BE2E57548F95CCBDFCAF7DB712@BL1PPFB0715B38B.namprd18.prod.outlook.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Imre Kaloz @ 2026-11-11 10:15 UTC (permalink / raw)
  To: netdev
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Andrew Lunn, Elad Nachman, Oleksandr Mazur

prestera_pcs_config() writes a new mode or inband setting to a port
that is already enabled, as when phylink switches an SFP port to
inband SGMII. The firmware can then report link down and no link up
until the port is disabled and enabled again.

Disable the port before such a write. Exercising this needs a link
partner, so no in-tree test covers it.

Fixes: 52323ef75414 ("net: marvell: prestera: add phylink support")
Signed-off-by: Imre Kaloz <kaloz@kernel.org>
---
 .../net/ethernet/marvell/prestera/prestera_main.c  | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
index a82e7a8029851..39ebd1944be55 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
@@ -307,13 +307,14 @@ static int prestera_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
 			       bool permit_pause_to_mac)
 {
 	struct prestera_port *port = prestera_pcs_to_port(pcs);
-	struct prestera_port_mac_config cfg_mac;
+	struct prestera_port_mac_config cfg_mac, old;
 	int err;
 
 	err = prestera_port_cfg_mac_read(port, &cfg_mac);
 	if (err)
 		return err;
 
+	old = cfg_mac;
 	cfg_mac.admin = true;
 	cfg_mac.fec = PRESTERA_PORT_FEC_OFF;
 	cfg_mac.inband = neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED;
@@ -339,6 +340,17 @@ static int prestera_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
 		break;
 	}
 
+	/* Firmware may not report link up after the mode or inband setting of
+	 * an enabled port changes until the port is disabled and re-enabled.
+	 */
+	if (old.admin && (old.mode != cfg_mac.mode ||
+			  old.inband != cfg_mac.inband)) {
+		old.admin = false;
+		err = prestera_port_cfg_mac_write(port, &old);
+		if (err)
+			return err;
+	}
+
 	err = prestera_port_cfg_mac_write(port, &cfg_mac);
 	if (err)
 		return err;
-- 
2.47.3


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

end of thread, other threads:[~2026-11-12 18:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11 10:15 [PATCH net] net: marvell: prestera: disable port before changing its MAC mode Imre Kaloz
2026-11-11 10:20 ` netdev-bot+sinfo
     [not found] ` <BL1PPFB0715B38BE2E57548F95CCBDFCAF7DB712@BL1PPFB0715B38B.namprd18.prod.outlook.com>
2026-11-11 16:42   ` [EXTERNAL] " Imre Kaloz
     [not found]     ` <PH3PPFA2D0C836CFB7D296376875E16ECC8DB702@PH3PPFA2D0C836C.namprd18.prod.outlook.com>
2026-11-12 18:50       ` Imre Kaloz

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