From: netdev-bot+sashiko@kernel.org
To: juraj.sladek@littleit.sk
Cc: linusw@kernel.org, luizluca@gmail.com, alvin.sipraga@analog.com,
andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
linux@armlinux.org.uk, contact@c127.dev, netdev@vger.kernel.org
Subject: Re: [PATCH net 1/2] net: dsa: realtek: rtl8365mb: reset SerDes data path when conduit comes up
Date: Sat, 28 Nov 2026 13:21:41 +0000 [thread overview]
Message-ID: <179587210150.3135.11248119595029474130@kernel.org> (raw)
In-Reply-To: <20261127-rtl8365mb-hsgmii-fix-v1-1-f2827126aa6a@littleit.sk>
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 1
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).
- [Medium] rtl8365mb_conduit_state_change()
(drivers/net/dsa/realtek/rtl8365mb_main.c) resets the port-6 SerDes…
- [Medium] The patch adds a caller of the SerDes indirect-access window
that is not serialised against the existing ones.
- [Low] rtl8365mb_conduit_state_change() reads the plain bool
mb->sds_in_use under rtnl only, with no READ_ONCE and no shared lock,…
--
net: dsa: realtek: rtl8365mb: reset SerDes data path when conduit comes up
This patch moves the SerDes data path reset out of rtl8365mb_pcs_config()
into a new helper, rtl8365mb_sds_reset_datapath(). The helper is called
again from a new .conduit_state_change() callback when the conduit becomes
operational. This fixes the FCS errors seen on the CPU port of an RTL8367S
connected to an IPQ5018 over HSGMII.
> diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
> index da06f952a053d..54d90121ecd26 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_main.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c
[ ... ]
> @@ -1492,7 +1501,13 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
> val &= ~RTL8365MB_SDS_NWAY_EN_MASK;
> val |= RTL8365MB_SDS_NWAY_RESTART_MASK;
>
> - return rtl8365mb_sds_write(priv, RTL8365MB_SDS_REG_NWAY, val);
> + ret = rtl8365mb_sds_write(priv, RTL8365MB_SDS_REG_NWAY, val);
> + if (ret)
> + return ret;
> +
> + mb->sds_in_use = true;
[Severity: Low]
mb->sds_in_use is written here under the phylink state_mutex. The new
rtl8365mb_conduit_state_change() reads it with only rtnl held, with no
READ_ONCE() and no shared lock, and then touches the SerDes:
if (!operational || !mb->sds_in_use)
return;
ret = rtl8365mb_sds_reset_datapath(priv);
Once set, the flag stays true until the next rtl8365mb_setup(). So it does
not exclude a later rtl8365mb_pcs_config() reprogramming the SerDes from
the phylink_resolve() worker.
Isn't this the flag-as-gate pattern, where a flag decides whether to touch
shared hardware state without a lock held?
On its own the effect is small. A stale read only skips one extra reset or
lets one through. A fix for the SDS window race described below would need
to do the sds_in_use check and the data path reset under the same lock that
rtl8365mb_pcs_config() and rtl8365mb_pcs_get_state() hold. Locking each SDS
access separately would not be enough.
The final patch in the series keeps the same lockless check.
> +
> + return 0;
> }
[ ... ]
> @@ -3079,6 +3094,29 @@ static int rtl8365mb_reset_chip(struct realtek_priv *priv)
[ ... ]
> +static void rtl8365mb_conduit_state_change(struct dsa_switch *ds,
> + const struct net_device *conduit,
> + bool operational)
> +{
> + struct realtek_priv *priv = ds->priv;
> + struct rtl8365mb *mb = priv->chip_data;
> + int ret;
> +
> + if (!operational || !mb->sds_in_use)
> + return;
[Severity: Medium]
Should this check which conduit changed state? The conduit argument is
not used. Nothing checks that port 6 is a CPU port, or that it is the CPU
port behind this conduit.
The DSA core does not filter these calls either.
dsa_switch_conduit_state_change() forwards every conduit's change:
net/dsa/switch.c:dsa_switch_conduit_state_change() {
...
ds->ops->conduit_state_change(ds, info->conduit, info->operational);
...
}
The SerDes PCS is not limited to CPU ports. For any SerDes interface,
rtl8365mb_phylink_mac_select_pcs() returns it:
if (rtl8365mb_interface_is_serdes(interface))
return &mb->pcs;
and rtl8365mb_pcs_config() sets sds_in_use whatever role port 6 has.
RTL8367S/RTL8367SB also have a second external interface, RGMII on port 7:
{ 6, 1, PHY_INTF(SGMII) | PHY_INTF(HSGMII) },
{ 7, 2, PHY_INTF(MII) | PHY_INTF(TMII) | PHY_INTF(RMII) | PHY_INTF(RGMII) },
This matters in two setups: port 7 is the CPU port and port 6 is an
SGMII/HSGMII user port, or ports 6 and 7 are both CPU ports. In either
case, if the port 7 conduit comes up or its carrier flaps (NETDEV_CHANGE),
won't this write DPRST_PHASE1/PHASE2 to the port 6 SerDes BMCR? That
would flush the FIFOs and resync the PLL on a port 6 link that may be
carrying traffic.
The later patch "net: dsa: realtek: rtl8365mb: soft reset switch core
after conduit comes up" keeps the same unfiltered check
(if (!mb->sds_in_use) return;). It also schedules a soft reset of the
whole switch core 3 seconds after any conduit becomes operational. By the
end of the series this would affect every switch port.
> +
> + ret = rtl8365mb_sds_reset_datapath(priv);
[Severity: Medium]
Can this race with the phylink_resolve() worker on the SerDes indirect
access window?
rtl8365mb_conduit_state_change() runs from the conduit netdev notifier
with only rtnl_lock held. Each rtl8365mb_sds_write() is three separate
regmap transactions: DATA, ADR, then CMD=RUN|WR. rtl8365mb_sds_read() is
ADR, CMD=RUN, a busy poll, then DATA. priv->map_lock only covers one
transaction at a time.
Before this patch, every SDS access came from the port 6 PCS ops, and
phylink serialises those with pl->state_mutex. phylink_resolve() takes
state_mutex but not rtnl. It can reach the SDS window two ways:
phylink_resolve()
rtl8365mb_pcs_get_state()
rtl8365mb_sds_read(priv, RTL8365MB_SDS_REG_LINK_STATUS, &status)
This path is polled, because rtl8365mb_setup() sets mb->pcs.poll = true
for in-band mode.
phylink_resolve()
phylink_major_config()
rtl8365mb_pcs_config()
This path runs when a PHY switches between SGMII and 2500BASE-X.
One possible interleaving:
conduit path resolve worker
DATA = DPRST_PHASE1
ADR = BMCR
ADR = LINK_STATUS
CMD = RUN | WR
Here PHASE1 would land in the link status register instead of BMCR.
Other interleavings are possible too. If a read is in flight, a concurrent
CMD=RUN|WR could write the read result into BMCR. The jam table writes and
the NWAY read-modify-write in rtl8365mb_pcs_config() could also be
corrupted.
The OCP PHY window in rtl8365mb_phy_ocp_read() and
rtl8365mb_phy_ocp_write() uses rtl83xx_lock() and priv->map_nolock for
this reason. Does the SDS window need a similar lock? As far as I can
tell, the final patch in the series does not add one.
> + if (ret)
> + dev_err(priv->dev, "failed to reset SerDes data path: %pe\n",
> + ERR_PTR(ret));
> +}
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127-rtl8365mb-hsgmii-fix-v1-0-f2827126aa6a%40littleit.sk
next prev parent reply other threads:[~2026-11-28 13:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 13:15 [PATCH net 0/2] net: dsa: realtek: rtl8365mb: fix CPU port on HSGMII after boot Juraj Sladek via B4 Relay
2026-11-27 13:15 ` [PATCH net 1/2] net: dsa: realtek: rtl8365mb: reset SerDes data path when conduit comes up Juraj Sladek via B4 Relay
2026-11-27 23:09 ` Mieczyslaw Nalewaj
2026-11-28 6:34 ` Juraj Sládek
2026-11-28 8:19 ` Juraj Sládek
2026-11-28 9:04 ` Mieczyslaw Nalewaj
2026-11-28 13:21 ` netdev-bot+sashiko [this message]
2026-11-27 13:15 ` [PATCH net 2/2] net: dsa: realtek: rtl8365mb: soft reset switch core after " Juraj Sladek via B4 Relay
2026-11-28 13:21 ` netdev-bot+sashiko
2026-11-28 17:55 ` Juraj Sládek
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=179587210150.3135.11248119595029474130@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=alvin.sipraga@analog.com \
--cc=andrew@lunn.ch \
--cc=contact@c127.dev \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=juraj.sladek@littleit.sk \
--cc=kuba@kernel.org \
--cc=linusw@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=luizluca@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox