Re: [PATCH net-next v13 15/15] net: ethernet: onsemi: s2500: Add driver support for S2500
From: netdev-bot+sashiko
Date: Thu Dec 03 2026 - 12:46:59 EST
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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] A failed live MAC address change can leave unicast receive
permanently broken.
- [Low] The commit message says `imply NET_SELFTESTS` was added "so that
users would be able to disable self-test and still compile".
--
net: ethernet: onsemi: s2500: Add driver support for S2500
This adds a driver for the onsemi S2500 10BASE-T1S MAC-PHY, built on the
OPEN Alliance TC6 framework. It covers PTP, ethtool statistics and
register dumps, and unicast and multicast address filtering. It also
adds self-test support through net_selftest.
> diff --git a/drivers/net/ethernet/onsemi/s2500/Kconfig b/drivers/net/ethernet/onsemi/s2500/Kconfig
> new file mode 100644
> index 0000000000000..4bd28dc560e64
> --- /dev/null
> +++ b/drivers/net/ethernet/onsemi/s2500/Kconfig
> @@ -0,0 +1,20 @@
[ ... ]
> +config S2500_MACPHY
> + tristate "S2500 support"
> + depends on SPI
> + depends on PTP_1588_CLOCK_OPTIONAL
> + imply NET_SELFTESTS
[Severity: Low]
The commit message says:
Support self-test. Also Add imply NET_SELFTESTS in Kconfig
so that users would be able to disable self-test and still
compile.
Is that accurate? NET_SELFTESTS in net/Kconfig has no prompt:
config NET_SELFTESTS
def_tristate PHYLIB
depends on PHYLIB && INET
S2500_MACPHY selects OA_TC6, and OA_TC6 selects PHYLIB, so PHYLIB is
always at least as high as S2500_MACPHY. For a symbol with no prompt,
the implied value is combined with the default, and the default is
already PHYLIB. So this line doesn't change the value of NET_SELFTESTS,
and users can't turn self-tests off on their own.
Building with NET_SELFTESTS=n (for example with INET=n) works because of
the stubs in include/net/selftests.h, not because of the imply.
The guard in s2500_get_sset_count() also looks unnecessary, because the
stub net_selftest_get_count() already returns 0:
case ETH_SS_TEST:
if (!IS_ENABLED(CONFIG_NET_SELFTESTS))
return -EOPNOTSUPP;
return net_selftest_get_count();
Could the commit message be updated to say what the imply actually does?
> diff --git a/drivers/net/ethernet/onsemi/s2500/s2500_main.c b/drivers/net/ethernet/onsemi/s2500/s2500_main.c
> new file mode 100644
> index 0000000000000..88e0aec94bdbe
> --- /dev/null
> +++ b/drivers/net/ethernet/onsemi/s2500/s2500_main.c
> @@ -0,0 +1,504 @@
[ ... ]
> +/* Writes MAC address to macphy registers */
> +static int s2500_write_filter(struct s2500_info *priv, int slot,
> + const u8 *mac)
> +{
> + u8 mms = OA_TC6_MAC_MMS1;
> + u32 val;
> + int ret;
> +
> + ret = oa_tc6_write_register_mms(priv->tc6, mms,
> + S2500_REG_MAC_ADDRMASKL(slot),
> + 0xffffffff);
> + if (ret)
> + return ret;
[ ... ]
> + val = S2500_MAC_ADDRFILT_ENABLE | get_unaligned_be16(mac);
> +
> + return oa_tc6_write_register_mms(priv->tc6, mms,
> + S2500_REG_MAC_ADDRFILTH(slot), val);
> +}
> +
> +static int s2500_set_mac_filter(struct net_device *ndev, const u8 *mac)
> +{
> + struct s2500_info *priv = netdev_priv(ndev);
> + int ret;
> +
> + /* Disable slot 0 before programming its address. */
> + ret = oa_tc6_write_register_mms(priv->tc6, OA_TC6_MAC_MMS1,
> + S2500_REG_MAC_ADDRFILTH(0), 0);
> + if (ret)
> + return ret;
> +
> + return s2500_write_filter(priv, 0, mac);
> +}
[ ... ]
> +static int s2500_set_mac_address(struct net_device *ndev, void *p)
> +{
> + struct sockaddr *addr = p;
> + int ret;
> +
> + ret = eth_prepare_mac_addr_change(ndev, p);
> + if (ret)
> + return ret;
> +
> + ret = s2500_set_mac_filter(ndev, addr->sa_data);
> + if (ret)
> + return ret;
[Severity: Medium]
What happens to unicast receive if one of the writes in
s2500_write_filter() fails here?
IFF_LIVE_ADDR_CHANGE is set, so this can run while the interface is up
with RXEN and ADRF set. s2500_set_mac_filter() first writes
ADDRFILTH(0) = 0. s2500_write_filter() then makes four separate control
writes and sets S2500_MAC_ADDRFILT_ENABLE only in the last one.
Any of those writes can fail. Examples are -EPROTO from
oa_tc6_check_ctrl_write_reply() when the echo does not match, or an SPI
transfer error.
On that path s2500_set_mac_address() returns the error without
reprogramming slot 0 with the old ndev->dev_addr. Slot 0 stays disabled
while ADRF is still set. Wouldn't the MAC-PHY then drop every unicast
frame for this node, while dev_addr still holds the old address?
Nothing else seems to reprogram slot 0 afterwards.
s2500_set_rx_mode() only touches promiscuous mode and multicast slots
1-3, and s2500_open() does not call s2500_init(). The problem would
therefore survive a down/up cycle until a later MAC change succeeds or
the driver is re-probed.
Would it make sense to write ndev->dev_addr back into slot 0 when this
fails?
> +
> + eth_commit_mac_addr_change(ndev, p);
> + return 0;
> +}
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-s2500-mac-phy-support-v13-0-a2908fad2693%40onsemi.com