From: Imre Kaloz <kaloz@kernel.org>
To: netdev@vger.kernel.org
Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Elad Nachman <enachman@marvell.com>,
Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Subject: [PATCH net v2] net: marvell: prestera: disable port before changing its MAC mode
Date: Mon, 16 Nov 2026 00:08:12 +0100 [thread overview]
Message-ID: <20261115230812.29644-1-kaloz@kernel.org> (raw)
prestera_pcs_config() writes a new mode, speed or inband setting to an
enabled port. The firmware can then report link down until the port is
disabled and enabled again.
Disable the port before such a write. 2500BASE-X and SGMII share one MAC
mode, so SGMII sets its own speed and the speed is compared as well.
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>
---
Changes in v2:
- Also disable the port on a speed change and set the SGMII speed, so
that a switch between 2500BASE-X and SGMII, which share one MAC mode,
is covered.
- Elad's Reviewed-by from v1 is not carried over, given the changes to the logic.
- Link to v1: https://lore.kernel.org/netdev/20261111101521.9878-1-kaloz@kernel.org/
.../ethernet/marvell/prestera/prestera_main.c | 17 ++++++++++++++++-
1 file changed, 16 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..3173145573600 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;
@@ -329,6 +330,7 @@ static int prestera_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
cfg_mac.mode = PRESTERA_MAC_MODE_SGMII;
break;
case PHY_INTERFACE_MODE_SGMII:
+ cfg_mac.speed = SPEED_1000;
cfg_mac.mode = PRESTERA_MAC_MODE_SGMII;
break;
case PHY_INTERFACE_MODE_1000BASEX:
@@ -339,6 +341,19 @@ static int prestera_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
break;
}
+ /* Firmware may not report link up after the mode, speed 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.speed != cfg_mac.speed ||
+ 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
next reply other threads:[~2026-11-15 23:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 23:08 Imre Kaloz [this message]
2026-11-15 23:13 ` [PATCH net v2] net: marvell: prestera: disable port before changing its MAC mode netdev-bot+sinfo
2026-11-21 0:10 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261115230812.29644-1-kaloz@kernel.org \
--to=kaloz@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=enachman@marvell.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oleksandr.mazur@plvision.eu \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.