From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D86D21F00923; Sun, 29 Nov 2026 00:36:57 +0000 (UTC) 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== Subject: Re: [PATCH net-next v12 15/15] net: ethernet: onsemi: s2500: Add driver support for S2500 From: netdev-bot+sashiko@kernel.org To: Selvamani.Rajagopal@onsemi.com 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 Date: Sun, 29 Nov 2026 00:36:57 +0000 Message-ID: <179591261747.3135.11963853475550921158@kernel.org> In-Reply-To: <20261124-s2500-mac-phy-support-v12-15-3575855d99f9@onsemi.com> References: <20261124-s2500-mac-phy-support-v12-15-3575855d99f9@onsemi.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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