From: netdev-bot+sashiko@kernel.org
To: Selvamani.Rajagopal@onsemi.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, kuba@kernel.org,
pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, parthiban.veerasooran@microchip.com,
horms@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org,
rdunlap@infradead.org, richardcochran@gmail.com, andrew@lunn.ch,
hkallweit1@gmail.com, linux@armlinux.org.uk, edumazet@kernel.org,
piergiorgio.beruto@gmail.com, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, jerry.ray@microchip.com,
ciprian.regus@analog.com
Subject: Re: [PATCH net-next v11 10/14] net: ethernet: onsemi: s2500: Add driver support for S2500
Date: Tue, 17 Nov 2026 19:53:06 +0000 [thread overview]
Message-ID: <179494518602.3136.1163755342884279987@kernel.org> (raw)
In-Reply-To: <20261113-s2500-mac-phy-support-v11-10-7a186141952c@onsemi.com>
Thank you for your contribution! Sashiko AI review found 6 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 4 · 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] The driver exposes a private `ethtool -S` counter
"rx_mismatch_drops" (s2500_mac_stat_strings[] mapped through…
- [Medium] s2500_init() raises TXCTHRESH from the spec default (>=1
credit) to >=8 credits.
- [Medium] The MAC statistic registers clear on read (as the driver's own
comment says) and are 32 bits wide, except the two 64-bit octet pairs.
- [Medium] net: s2500: S2500_PTP_MAX_ADJ_PPB overflows 32-bit long
scaled_ppm
- [Low] The S2500_MACPHY Kconfig adds `imply NET_SELFTESTS`, but this
commit has no selftest consumer.
- [Low] s2500_set_mac_filter() reprograms unicast filter slot 0 without
disabling it first.
--
net: ethernet: onsemi: s2500: Add driver support for S2500
This adds a driver for the onsemi S2500 10BASE-T1S MAC-PHY on top of the
OPEN Alliance TC6 framework, with PTP, ethtool MAC/RMON stats and
register dumps. It also adds oa_tc6_tx_credit_threshold_set() and an
OA_TC6_CONFIG_RX_CUT_THROUGH quirk to the framework, which the driver
uses to raise the TX credit threshold to 8 and enable RX cut-through.
> 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]
This isn't a bug, but does this patch need imply NET_SELFTESTS?
s2500_ethtool_ops has no .self_test in this patch. Also,
s2500_get_sset_count() and s2500_get_strings() don't handle ETH_SS_TEST
yet.
The next patch in the series ("net: ethernet: onsemi: s2500: Add selftest
support") adds .self_test = net_selftest and the ETH_SS_TEST handling.
Could the imply move to that patch too?
[ ... ]
> 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..2fc09107aed3e
> --- /dev/null
> +++ b/drivers/net/ethernet/onsemi/s2500/s2500_ethtool.c
> @@ -0,0 +1,379 @@
[ ... ]
> +static const char s2500_mac_stat_strings[][ETH_GSTRING_LEN] = {
> + "rx_mismatch_drops",
> +};
> +
> +static const u8 s2500_mac_stat_map[S2500_NUM_MAC_STATS] = {
> + S2500_MSTRXDROPPED_IDX,
> +};
[Severity: Medium]
Does "rx_mismatch_drops" duplicate a standard counter? It reports the
hardware count of frames dropped by the MAC address filter, and
include/uapi/linux/if_link.h documents rtnl_link_stats64 as:
* @rx_otherhost_dropped: Number of packets dropped due to mismatch
* in destination MAC address.
s2500_netdev_ops has no .ndo_get_stats64, so userspace can only read this
value through the private ethtool -S string.
Could the cached counter be reported as rx_otherhost_dropped through
ndo_get_stats64, and the private string dropped? The string is still
there at the end of the series.
[ ... ]
> +static void s2500_update_stats(struct s2500_info *priv)
> +{
> + u64 *data = priv->stats_data;
> + u32 *regs, *rptr, addr;
> + int ret;
[ ... ]
> + ret = oa_tc6_read_registers(priv->tc6, addr, regs,
> + S2500_NUM_STAT_REGS);
> + if (ret)
> + goto out;
> +
> + priv->stats_read_at = jiffies;
> + rptr = regs;
> +
> + /* Counters are cleared by the hardware when read, so each read
> + * returns only the delta since the previous read. Hence the
> + * values are accumulated.
[ ... ]
> + for (rptr += 2; (rptr - regs) < S2500_NUM_STAT_REGS; ++rptr)
> + *(data++) += *rptr;
> +out:
> + kfree(regs);
> +}
[Severity: Medium]
Can the 32-bit hardware counters wrap before anything reads them?
s2500_update_stats() is the only reader of these clear-on-read registers,
and it runs only when userspace queries ethtool stats. No delayed work or
timer reads them on a schedule.
At 10 Mb/s with minimum-size frames (about 14,881 frames/s), a 32-bit
frame counter fills in roughly 2^32 / 14881 seconds, about 80 hours. If
nobody queries stats in that time, the totals in priv->stats_data[] lose
counts without any warning. That covers FramesReceivedOK, the broadcast
and multicast counters, the histogram bins and the error counters.
A smaller, related point: oa_tc6_read_registers() can fail after the SPI
transfer completes, for example with -EPROTO from the header echo check.
The goto out path then throws away deltas the device has already cleared.
The data may not be reliable in that case anyway.
Do these counters need to be read periodically, for example from delayed
work?
[ ... ]
> 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..f176475cfd7ed
> --- /dev/null
> +++ b/drivers/net/ethernet/onsemi/s2500/s2500_main.c
> @@ -0,0 +1,498 @@
[ ... ]
> +/* Writes MAC address to macphy registers */
> +static int s2500_set_mac_filter(struct net_device *ndev, const u8 *mac)
> +{
[ ... ]
> + val = get_unaligned_be32(&mac[2]);
> +
> + ret = oa_tc6_write_register_mms(priv->tc6, mms,
> + S2500_REG_MAC_ADDRFILTL(0),
> + val);
> + 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(0),
> + val);
> +}
[Severity: Low]
Slot 0 stays enabled while ADDRFILTL(0) is rewritten. For a short time
the hardware matches the old high 16 bits plus the new low 32 bits,
which is neither address.
If the final ADDRFILTH(0) write fails, s2500_set_mac_address() returns
before eth_hw_addr_set():
ret = s2500_set_mac_filter(ndev, addr->sa_data);
if (ret)
return ret;
eth_hw_addr_set(ndev, addr->sa_data);
Could dev_addr then keep showing the old address while the hardware
filter holds the mixed one, so unicast reception stops?
s2500_set_multicast_mode() already clears ADDRFILTH first and enables the
slot last. Would the same order work for slot 0?
[ ... ]
> +static int s2500_init(struct s2500_info *priv)
> +{
> + u32 val;
> + int ret;
> +
> + /* Configure MAC-PHY's behavior */
> + ret = oa_tc6_tx_credit_threshold_set(priv->tc6,
> + OA_TC6_CONFIG0_TXCTHRESH_8);
> + if (ret)
> + return ret;
[Severity: Medium]
Can this threshold stall transmit? The framework only learns about new
TX credits from a data footer or after an IRQ. Once the cached tx_credits
reaches 0, the loop in oa_tc6_macphy_threaded_irq() stops:
while (tc6->int_flag ||
(tc6->waiting_tx_skb && tc6->tx_credits)) {
The irq_wake_thread() call from oa_tc6_start_xmit() doesn't help, since
tx_credits is still 0.
oa_tc6_prepare_spi_tx_buf_for_tx_skbs() uses every available credit, so
it can stop partway through a frame. Only RX cut-through is enabled, so
that partial frame can't leave the MAC-PHY buffer. Only the complete
frames queued ahead of it can free credits.
If those frames add up to fewer than 8 chunks, for example one or two
small frames, free credits never reach the threshold. IRQn then never
asserts for TX, and the queue stays stopped until unrelated RX traffic
arrives. s2500 has no ndo_tx_timeout to recover.
This depends on the S2500 TX buffer size. It looks like it needs a buffer
of about 30 chunks or fewer, since a max-size frame takes about 24 chunks
and the threshold is 8.
What is the S2500 TX buffer size? Could the commit message explain why
8 credits is safe?
[ ... ]
> diff --git a/drivers/net/ethernet/onsemi/s2500/s2500_ptp.c b/drivers/net/ethernet/onsemi/s2500/s2500_ptp.c
> --- /dev/null
> +++ b/drivers/net/ethernet/onsemi/s2500/s2500_ptp.c
> @@ -0,0 +1,156 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright 2026 Semiconductor Components Industries, LLC ("onsemi").
> + * onsemi's S2500 10BASE-T1S MAC-PHY driver
> + */
> +
> +#include "s2500_hw_def.h"
> +
> +static int s2500_ptp_get_time64(struct ptp_clock_info *ptp,
> + struct timespec64 *ts,
> + struct ptp_system_timestamp *ptp_sts)
> +{
> + struct s2500_info *priv = container_of(ptp, struct s2500_info,
> + ptp_clock_info);
> + u32 data[2];
> + u32 addr;
> + int ret;
> +
> + ptp_read_system_prets(ptp_sts);
> + addr = FIELD_PREP(S2500_REG_MMS_MASK, S2500_VS_MMS12) |
> + S2500_REG_VS_PTP_SEC;
> + ret = oa_tc6_read_registers(priv->tc6, addr, &data[0], 2);
> + ptp_read_system_postts(ptp_sts);
> +
> + if (!ret) {
> + ts->tv_sec = data[0];
> + ts->tv_nsec = data[1];
> + }
> +
> + return ret;
> +}
> +
> +static int s2500_ptp_write_time(struct s2500_info *priv,
> + const struct timespec64 *ts)
> +{
> + u32 data[2];
> + u32 addr;
> +
> + lockdep_assert_held(&priv->ptp_adj_lock);
> +
> + if (ts->tv_sec >= (1ULL << 32))
> + return -ERANGE;
> +
> + data[0] = (u32)ts->tv_sec;
> + /* bit 31 = execute set command */
> + data[1] = ts->tv_nsec | BIT(31);
> + addr = FIELD_PREP(S2500_REG_MMS_MASK, S2500_VS_MMS12) |
> + S2500_REG_VS_PTP_SETSEC;
> +
> + return oa_tc6_write_registers(priv->tc6, addr, &data[0], 2);
> +}
> +
> +static int s2500_ptp_set_time64(struct ptp_clock_info *ptp,
> + const struct timespec64 *ts)
> +{
> + struct s2500_info *priv = container_of(ptp, struct s2500_info,
> + ptp_clock_info);
> + int ret;
> +
> + mutex_lock(&priv->ptp_adj_lock);
> + ret = s2500_ptp_write_time(priv, ts);
> + mutex_unlock(&priv->ptp_adj_lock);
> +
> + return ret;
> +}
> +
> +static int s2500_ptp_set_freq(struct s2500_info *priv, long scaled_ppm)
> +{
> + u32 sign_bit = 0;
> + u64 adj;
> + u32 val;
> +
> + if (diff_by_scaled_ppm(S2500_PTP_ADJ_BASE, scaled_ppm, &adj))
> + sign_bit = 1U << 31;
> +
> + /* check overflow */
> + if (adj > S2500_PTP_ADJ_MAX)
> + return -ERANGE;
> +
> + val = (u32)adj | sign_bit;
> + return oa_tc6_write_register_mms(priv->tc6, S2500_VS_MMS12,
> + S2500_REG_VS_PTP_ADJ, val);
> +}
> +
> +static int s2500_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
> +{
> + struct s2500_info *priv = container_of(ptp, struct s2500_info,
> + ptp_clock_info);
> +
> + return s2500_ptp_set_freq(priv, scaled_ppm);
> +}
> +
> +static int s2500_ptp_step_time(struct s2500_info *priv, s64 delta)
> +{
> + struct timespec64 target, now, delta_ts;
> + ktime_t start;
> + s64 elapsed;
> + int ret;
> +
> + start = ktime_get_raw();
> + ret = s2500_ptp_get_time64(&priv->ptp_clock_info, &now, NULL);
> + if (ret)
> + return ret;
> + if (delta >= 0) {
> + delta_ts = ns_to_timespec64(delta);
> + target = timespec64_add(now, delta_ts);
> + } else {
> + delta_ts = ns_to_timespec64(-delta);
> + target = timespec64_sub(now, delta_ts);
> + }
> +
> + /* Adjust the time to take the SPI transaction time into
> + * account.
> + */
> + elapsed = ktime_to_ns(ktime_sub(ktime_get_raw(), start));
> + timespec64_add_ns(&target, elapsed);
> +
> + /* The subtraction above can take the target below the epoch */
> + if (target.tv_sec < 0)
> + return -ERANGE;
> + return s2500_ptp_write_time(priv, &target);
> +}
> +
> +static int s2500_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
> +{
> + struct s2500_info *priv = container_of(ptp, struct s2500_info,
> + ptp_clock_info);
> + int ret;
> +
> + /* Nothing to do */
> + if (delta == 0)
> + return 0;
> +
> + /* The device has no add-delta register, so the offset is applied as
> + * a read-modify-write of the time registers.
> + */
> + mutex_lock(&priv->ptp_adj_lock);
> + ret = s2500_ptp_step_time(priv, delta);
> + mutex_unlock(&priv->ptp_adj_lock);
> +
> + return ret;
> +}
> +
> +int s2500_ptp_register(struct s2500_info *priv)
> +{
> + struct ptp_clock_info *info = &priv->ptp_clock_info;
> +
> + info->max_adj = S2500_PTP_MAX_ADJ_PPB;
> + info->owner = THIS_MODULE;
> + info->adjfine = s2500_ptp_adjfine;
> + info->gettimex64 = s2500_ptp_get_time64;
> + info->settime64 = s2500_ptp_set_time64;
> + info->adjtime = s2500_ptp_adjtime;
> +
> + return oa_tc6_ptp_register(priv->tc6, info);
> +}
[Severity: Medium]
Can max_adj be larger than the PTP core can pass through on 32-bit?
S2500_PTP_MAX_ADJ_PPB is GENMASK(27, 0) / 8, which is 33,554,431 ppb.
ptp_clock_adjtime() converts tx->freq with scaled_ppm_to_ppb() and then
calls ->adjfine(). Both take the scaled_ppm value as a long:
long ppb = scaled_ppm_to_ppb(tx->freq);
if (ppb > ops->max_adj || ppb < -ops->max_adj)
return -ERANGE;
err = ops->adjfine(ops, tx->freq);
On a 32-bit kernel, LONG_MAX scaled_ppm is only about 32,767,999 ppb.
max_adj advertises requests between +32,768,000 and +33,554,431 ppb as
valid, but their scaled_ppm value truncates to a negative long. The
result still lands inside [-max_adj, max_adj]. s2500_ptp_set_freq()
then gets a large negative scaled_ppm, and diff_by_scaled_ppm()
programs S2500_REG_VS_PTP_ADJ in the opposite direction from the
request. The clock runs away from its reference instead of catching
up.
At the other end, scaled_ppm == LONG_MIN (-32,768,000 ppb) can't be
negated in diff_by_scaled_ppm(). The result sign-extends to a huge u64,
adj exceeds S2500_PTP_ADJ_MAX, and the request fails with -ERANGE even
though it is within the advertised range.
This only affects 32-bit kernels. On 64-bit, a long holds the full
range.
Would it make sense to cap max_adj to what a 32-bit scaled_ppm can
represent, for example 32,767,999 ppb? Or is there a reason the full
28-bit range of the register needs to be exposed?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-s2500-mac-phy-support-v11-0-7a186141952c%40onsemi.com
next prev parent reply other threads:[~2026-11-17 19:53 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 16:59 [PATCH net-next v11 00/14] (no cover subject) Selvamani Rajagopal via B4 Relay
2026-11-13 16:59 ` [PATCH net-next v11 01/14] dt-bindings: net: add onsemi's S2500 Selvamani Rajagopal via B4 Relay
2026-11-13 16:59 ` [PATCH net-next v11 02/14] Documentation: networking: Add timestamp related APIs to OA TC6 framework Selvamani Rajagopal via B4 Relay
2026-11-13 16:59 ` [PATCH net-next v11 03/14] net: ethernet: oa_tc6: Move oa_tc6.c to its own directory Selvamani Rajagopal via B4 Relay
2026-11-17 19:52 ` netdev-bot+sashiko
2026-11-13 16:59 ` [PATCH net-next v11 04/14] net: ethernet: oa_tc6: Move constant definitions to header file Selvamani Rajagopal via B4 Relay
2026-11-13 16:59 ` [PATCH net-next v11 05/14] net: ethernet: microchip: lan865x: Depends on PTP_1588_CLOCK_OPTIONAL Selvamani Rajagopal via B4 Relay
2026-11-17 19:53 ` netdev-bot+sashiko
2026-11-13 16:59 ` [PATCH net-next v11 06/14] net: ethernet: adi: adin1140: " Selvamani Rajagopal via B4 Relay
2026-11-13 16:59 ` [PATCH net-next v11 07/14] net: ethernet: oa_tc6: Support for hardware timestamp Selvamani Rajagopal via B4 Relay
2026-11-17 19:53 ` netdev-bot+sashiko
2026-11-13 16:59 ` [PATCH net-next v11 08/14] net: ethernet: oa_tc6: Drop frames if footer has FD bit set Selvamani Rajagopal via B4 Relay
2026-11-17 19:53 ` netdev-bot+sashiko
2026-11-13 16:59 ` [PATCH net-next v11 09/14] net: phy: ncn26000: Enable enhanced noise immunity Selvamani Rajagopal via B4 Relay
2026-11-13 16:59 ` [PATCH net-next v11 10/14] net: ethernet: onsemi: s2500: Add driver support for S2500 Selvamani Rajagopal via B4 Relay
2026-11-16 22:34 ` Selvamani Rajagopal
2026-11-17 1:44 ` Andrew Lunn
2026-11-17 1:54 ` Selvamani Rajagopal
2026-11-17 19:53 ` netdev-bot+sashiko [this message]
2026-11-13 16:59 ` [PATCH net-next v11 11/14] net: ethernet: onsemi: s2500: Add selftest support Selvamani Rajagopal via B4 Relay
2026-11-13 16:59 ` [PATCH net-next v11 12/14] net: phy: Add helper to modify only the PHY loopback bit Selvamani Rajagopal via B4 Relay
2026-11-13 16:59 ` [PATCH net-next v11 13/14] net: phy: ncn26000: Support for onsemi's S2500 internal phy Selvamani Rajagopal via B4 Relay
2026-11-17 19:53 ` netdev-bot+sashiko
2026-11-13 16:59 ` [PATCH net-next v11 14/14] net: phy: dp83867: Use genphy_loopback_no_speed() Selvamani Rajagopal via B4 Relay
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=179494518602.3136.1163755342884279987@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