Article View: linux.kernel.netdev
Article #24024Re: [PATCH net-next v12 15/15] net: ethernet: onsemi: s2500: Add driver support for S2500
From: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 00:36
Date: Sun, 29 Nov 2026 00:36
212 lines
15662 bytes
15662 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 2
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] s2500_update_stats() decides whether its 100 ms cache is stale
with `!time_is_after_jiffies(priv->stats_last_update +…
- [Medium] s2500_set_mac_filter() first writes
`S2500_REG_MAC_ADDRFILTH(0) = 0`, which disables the unicast filter…
- [Low] The commit message says `imply NET_SELFTESTS` was added in
drivers/net/ethernet/onsemi/s2500/Kconfig "so that users would be able…
- [Low] In s2500_update_stats(), priv->stats_last_update is read with a
plain load before spin_lock_bh(&priv->stats_lock) is taken, at the…
--
net: ethernet: onsemi: s2500: Add driver support for S2500
This commit adds a new SPI driver for the onsemi S2500 10BASE-T1S MAC-PHY,
built on the OPEN Alliance TC6 framework. It provides a PTP clock, ethtool
MAC/PHY/RMON statistics with a 100 ms cache, register dumps, three
multicast filter slots, and self-test support.
> 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? In net/Kconfig, NET_SELFTESTS has no prompt:
config NET_SELFTESTS
def_tristate PHYLIB
depends on PHYLIB && INET
S2500_MACPHY selects OA_TC6, and OA_TC6 selects PHYLIB. So whenever INET
is enabled, NET_SELFTESTS follows PHYLIB whether or not this imply is
there. A user can't switch it off.
The driver does build with NET_SELFTESTS=n, because include/net/selftests.h
provides stubs and s2500_get_sset_count() checks IS_ENABLED(). That
configuration only happens with INET=n, though.
Could the imply line be dropped, or the commit message reworded?
> + select BITREVERSE
> + select NCN26000_PHY
> + select OA_TC6
[ ... ]
> diff --git a/drivers/net/ethernet/onsemi/s2500/s2500_ethtool.c b/drivers/net/ethernet/onsemi/s2500/s2500_ethtool.c
> new file mode 100644
> index 0000000000000..77d7d172efe0d
> --- /dev/null
> +++ b/drivers/net/ethernet/onsemi/s2500/s2500_ethtool.c
> @@ -0,0 +1,389 @@
[ ... ]
> +void s2500_update_stats(struct s2500_info *priv, u64 *buf)
> +{
> + u32 regs[S2500_NUM_STAT_REGS];
> + bool have_regs = false;
> + u32 addr;
> +
> + if (!time_is_after_jiffies(priv->stats_last_update +
> + S2500_STATS_CACHE_PERIOD)) {
[Severity: Medium]
What happens if nothing calls s2500_update_stats() for more than LONG_MAX
jiffies?
stats_last_update is only refreshed after a successful register read.
While the interface is down, s2500_stop() has cancelled s2500_stats_work,
and only s2500_open() schedules it again. In that state ethtool stats
queries are the only callers.
On a 32-bit kernel with HZ=1000, about 24.8 days without a query is
enough for the signed difference in time_is_after_jiffies() to flip.
The stale timestamp then looks like it is in the future, and every later
call skips the hardware read. That includes the 3 s stats work once the
interface is back up. A skipped read never updates stats_last_update, so
this lasts for another 2^31 jiffies.
During that time rx_otherhost_dropped and the eth-mac, eth-phy and RMON
counters stay frozen. The 32-bit clear-on-read hardware counters can also
wrap in that window, so counts are lost.
Would a 64-bit timestamp checked with time_after64() avoid this? Resetting
stats_last_update in s2500_open() is another option.
> + addr = FIELD_PREP(S2500_REG_MMS_MASK, OA_TC6_MAC_MMS1) |
> + S2500_REG_MAC_STOCTETSTXL;
> + have_regs = !oa_tc6_read_registers(priv->tc6, addr, regs,
> + S2500_NUM_STAT_REGS);
> + }
> +
> + if (!have_regs && !buf)
> + return;
> +
> + spin_lock_bh(&priv->stats_lock);
> + if (have_regs) {
> + priv->stats_last_update = jiffies;
[Severity: Low]
stats_last_update is written here under stats_lock, and struct
s2500_info says the lock protects it:
/* Protects stats_data and stats_last_update. */
spinlock_t stats_lock;
The freshness check above reads it without the lock, though. Can
s2500_stats_work and an ethtool stats callback (s2500_get_eth_mac_stats(),
s2500_get_eth_phy_stats() or s2500_rmon_stats()) both see a stale
timestamp? If so, both would issue the clear-on-read register burst.
The totals still come out right. However, the caller whose read returns
an almost empty delta may copy stats_data before the other caller has
added the delta it already took from the hardware. That caller would
get a snapshot that is briefly too low. KCSAN would also report this
race.
Could the check move under the lock? Another way would be to serialize
the read and the accumulate with a mutex.
> + s2500_accumulate_stats(priv, regs);
> + }
[ ... ]
> 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..55dbf3ba032d9
> --- /dev/null
> +++ b/drivers/net/ethernet/onsemi/s2500/s2500_main.c
> @@ -0,0 +1,496 @@
[ ... ]
> +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);
> +}
[Severity: Medium]
What state is slot 0 left in if one of the four control writes in
s2500_write_filter() fails?
At that point the slot has already been disabled here. s2500_write_filter()
returns early, before the final ADDRFILTH write that sets
S2500_MAC_ADDRFILT_ENABLE. oa_tc6_perform_ctrl() can return SPI transfer
errors, or -EPROTO from the echo check.
s2500_set_mac_address() then bails out before committing the new address:
ret = s2500_set_mac_filter(ndev, addr->sa_data);
if (ret)
return ret;
eth_commit_mac_addr_change(ndev, p);
So dev_addr keeps the old address, but the hardware has no enabled unicast
filter. S2500_MAC_CTRL_ADRF is only cleared for IFF_PROMISC, so it stays
set. Would the MAC then drop every unicast frame sent to the host?
Nothing appears to restore slot 0 later:
- s2500_init() only runs at probe.
- s2500_open() only sets TXEN/RXEN.
- s2500_set_multicast_mode() and s2500_clear_mcast_filters() only touch
slots 1..S2500_N_MCAST_FILTERS.
Should the previous filter be restored on failure? Alternatively, the
writes could be ordered so that a failure can't leave slot 0 disabled.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124-s2500-mac-phy-support-v12-0-3575855d99f9%40onsemi.com
Technical Details
Message-ID:
<179591261747.3135.11963853475550921158@kernel.org>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373319-linux-kernel-netdev=dewy.ruReferences:
<20261124-s2500-mac-phy-support-v12-15-3575855d99f9@onsemi.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373319-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v12 15/15] net: ethernet: onsemi: s2500: Add driver support for S2500 Date: Sun, 29 Nov 2026 00:36:57 +0000 Organization: Usenet Network Message-ID: <179591261747.3135.11963853475550921158@kernel.org> References: <20261124-s2500-mac-phy-support-v12-15-3575855d99f9@onsemi.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1069213"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:D+bxZOe4fdPkpgPU4IA/f++GB1k= sha256:AEu0ovLhtoSS5kAwdJTDMtsD74U98e5vxoAG6ubytl4= sha1:mZGZOkEVgkiCbTsw3xg1RgglR6Q= sha256:RduhqKj3JyeYhST+pkYH6Is2xDbITtfJi9sXjk3Huu0= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 1EA51125F90; Sun, 29 Nov 2026 03:37:23 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9phG1pkO-sW4; Sun, 29 Nov 2026 03:37:19 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373319-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 4BF7C125F8A; Sun, 29 Nov 2026 03:37:11 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 14F7F2821E; Sun, 29 Nov 2026 00:37:02 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795912620; b=q0ZwT5/lFpTeZA5Zis3u0/v7n67EL2Fbsq1bxoOEbxARljqbfTid8GaeL2CC8DKoPoOt vkHALlW/MiWnPs4fMw8ZnAcLgjhcnzHJWj60SwDw9/SGSZkpddgiTTuddxMyo4YTGmzRw CcECBPozuOBw4S4yEmN1ExPEWffwCQdw/nUjh3jeXJIK05KKMomyUnk40Ylt7Co3mTQOd NpaMs/B9ho/HTIXB3nAgMyTETZahs+rErO4Rrk8hhNuhDhstM+7Jb9jEDIuNRQubtsCQV 8Oj0i5dO//BNJUlVp0a0qwIVrgwHqodMmTA/h1tSdZh907rbcdZQOXJH1snH9HSBpBQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795912620; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=60PeEo3Ku7wrtrcER6hrV7vyRX6YB0onIo+r0+UobSk=; b=m2ueJ3cDruNzEtTzYzjZglHg2/WGmzQyD3aOA1dEY9h7f7ZQ4sC6kYbdWZn8c6fGF2bb R1vQkIIB83pzdkw2MF9+DJ8HLcvFI7b2dKKv6GjMIEg6wGQce4h/3so7q19Lj4DI9k59p Wl2XKrcymUmhafXhKQ/s3xHbRS5KLzLoAN36TF+ASmXtds0RxFKM9KnVfGUEb8An+uS3r i5qm6zxiM/8O9keekgp9oX5PGyIv0puQJQtwH1jqcnDot7RO/E2QuZ3K5zqC+QNlXcJUl Dps1F5FLgaOPvq4ZtJhEFdFMvNFZg62Z3YlMStKCyiQJS/DF1tnoU33WWYuvl+iATBw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WHjn8nrL; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 694EC606A686; Sun, 29 Nov 2026 00:37:00 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WHjn8nrL X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795912619; b=4HNPX7ylF6wsjjovmc/DDxYAjQSxt4ZoAZRHtgKtD3jsjq5UB9/6ymvzRbuxeMlWSS+w M8SmIAQZP9W03lhW0HuuosroNyHlI+EH/t+bfrNUdfgm/WPRhrtFQ7ygDj8gv4lBBwcXa ZHddcAuBiyKkcprdoVLtUB/SsOW87YJXmR7CjmHnDieP8BqbtTzCyBi1oZt6Oyj2N3AhC mQXaEE0ZzMuAMw8qg4V3HQn67YnmMC1HWswvd7b78HpXhx0pEPHe0Rdn8P+DB2UXUfJm/ fHzuCdJFg1HqGsUnNcvoeIvryngQuS79JjGhGkuQ4/kbnHDEa7mwcG42IYp5o4Pl/MQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795912619; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=60PeEo3Ku7wrtrcER6hrV7vyRX6YB0onIo+r0+UobSk=; b=cr1b77d5yl+jOW1VFoaJz0HrhwjaDN2PLwMZOjWSQkxSIBcU823twNhsx9r+jiBaBrfi P6kuYwoqBY2OmGo6YSRm3B46Cb9yDfgc4WBFhaK8NoAbnlzCZH3g7sL4WW4RHYLRoDr26 UFxFX1kxBR5imDWaoB36s2Jt9RHxgcHU78KwyqA/2qRz6flz/4PjGMD6/eVI3P9gF3aNW PAMaKcGCxmdBd4uVmuFpTdlM7CZh/NIvdfwd3Rdpz1q24CltXicrECPuJ+ws0NEnseYDB 2Gxx0Gu7pCYblzOtiecs0w9UJLX95+nTZBgd3CHc79VD8YToAoxpo2xuemUDwX9av1g== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WHjn8nrL; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CA59606A330; Sun, 29 Nov 2026 00:36:59 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D86D21F00923; Sun, 29 Nov 2026 00:36:57 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795912619; bh=60PeEo3Ku7wrtrcER6hrV7vyRX6YB0onIo+r0+UobSk=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=WHjn8nrLEusSQP5SnEt/8wjbYmMybbL0dQBZReXujoj2Cir1fRRkSTWpfgDgk3mu1 pG+sAl/ntl+vkaHBLfqnTdkssD77c0479RpbP+yme4HflVw6xxXWI32qkOVHeRjPAL LcplWP+cUlD6qzgyZNtPOput087IpFspuvbPX+kwe2iffuhaQLcR3Az5FOn1lwXDzX Wki+jxDl+C3pMtw2eZIeGh+Pe9NyM3ZBvc//YWGJTZuaX+6ub7Rly8w85Els5YnbE7 1v4j1/qZLMk/MvJCEzPyuM7pv/Z1257zUPPAk57ewPcx90HC+RLqAwghmSvA5omsY0 dhmxrmWEghjkg== X-Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, parthiban.veerasooran@microchip.com, richardcochran@gmail.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, horms@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org, edumazet@kernel.org, piergiorgio.beruto@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, jerry.ray@microchip.com, ciprian.regus@analog.com X-In-Reply-To: <20261124-s2500-mac-phy-support-v12-15-3575855d99f9@onsemi.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list