Devicetree
 help / color / mirror / Atom feed
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
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	[thread overview]
Message-ID: <179591261747.3135.11963853475550921158@kernel.org> (raw)
In-Reply-To: <20261124-s2500-mac-phy-support-v12-15-3575855d99f9@onsemi.com>

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

      parent reply	other threads:[~2026-11-29  0:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 22:09 [PATCH net-next v12 00/15] Support for onsemi's S2500 10BASE-T1S MAC-PHY Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 01/15] dt-bindings: net: add onsemi's S2500 Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 02/15] Documentation: networking: Add timestamp related APIs to OA TC6 framework Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 03/15] net: ethernet: oa_tc6: Move oa_tc6.c to its own directory Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 04/15] net: ethernet: oa_tc6: Move constant definitions to header file Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 05/15] net: ethernet: microchip: lan865x: Depends on PTP_1588_CLOCK_OPTIONAL Selvamani Rajagopal via B4 Relay
2026-11-25 18:04   ` Selvamani Rajagopal
2026-11-24 22:09 ` [PATCH net-next v12 06/15] net: ethernet: adi: adin1140: " Selvamani Rajagopal via B4 Relay
2026-11-25 18:04   ` Selvamani Rajagopal
2026-11-24 22:09 ` [PATCH net-next v12 07/15] net: ethernet: oa_tc6: Support for hardware timestamp Selvamani Rajagopal via B4 Relay
2026-11-25 18:16   ` Selvamani Rajagopal
2026-11-25 22:10   ` sashiko-bot
2026-11-29  0:36   ` netdev-bot+sashiko
2026-11-24 22:09 ` [PATCH net-next v12 08/15] net: ethernet: oa_tc6: Drop frames if footer has FD bit set Selvamani Rajagopal via B4 Relay
2026-11-24 22:09 ` [PATCH net-next v12 09/15] net: ethernet: oa_tc6: Support for vendor specific MMS Selvamani Rajagopal via B4 Relay
2026-11-24 22:37   ` Selvamani Rajagopal
2026-11-24 22:09 ` [PATCH net-next v12 10/15] net: ethernet: oa_tc6: APIs to customize CONFIG0 settings Selvamani Rajagopal via B4 Relay
2026-11-29  0:36   ` netdev-bot+sashiko
2026-11-24 22:09 ` [PATCH net-next v12 11/15] net: phy: ncn26000: Enable enhanced noise immunity Selvamani Rajagopal via B4 Relay
2026-11-24 22:10 ` [PATCH net-next v12 12/15] net: phy: Add helper to modify only the PHY loopback bit Selvamani Rajagopal via B4 Relay
2026-11-24 22:10 ` [PATCH net-next v12 13/15] net: phy: ncn26000: Support for onsemi's S2500 internal phy Selvamani Rajagopal via B4 Relay
2026-11-24 22:10 ` [PATCH net-next v12 14/15] net: phy: dp83867: Use genphy_loopback_no_speed() Selvamani Rajagopal via B4 Relay
2026-11-24 22:10 ` [PATCH net-next v12 15/15] net: ethernet: onsemi: s2500: Add driver support for S2500 Selvamani Rajagopal via B4 Relay
2026-11-25 22:10   ` sashiko-bot
2026-11-29  0:36   ` netdev-bot+sashiko [this message]

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=179591261747.3135.11963853475550921158@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=Selvamani.Rajagopal@onsemi.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=ciprian.regus@analog.com \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=jerry.ray@microchip.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=parthiban.veerasooran@microchip.com \
    --cc=piergiorgio.beruto@gmail.com \
    --cc=rdunlap@infradead.org \
    --cc=richardcochran@gmail.com \
    --cc=robh@kernel.org \
    --cc=skhan@linuxfoundation.org \
    /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