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 07/15] net: ethernet: oa_tc6: Support for hardware timestamp
Date: Sun, 29 Nov 2026 00:36:50 +0000	[thread overview]
Message-ID: <179591261088.3135.11468838555901711637@kernel.org> (raw)
In-Reply-To: <20261124-s2500-mac-phy-support-v12-7-3575855d99f9@onsemi.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 3 · 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 TX timestamp capture register is never released if its TTSC
  capture event never arrives.
- [Medium] net: oa_tc6: unrestored INT_MASK0 on error in
  oa_tc6_set_hwtstamp_settings()
- [Medium] net: oa_tc6: waiting_tx_skb queued for TX timestamp after
  NETDEV_DOWN
- [Low] oa_tc6_hwtstamp_post() does not return -EIO for every request
  after traffic handling has stopped, although the documentation says it…

--

net: ethernet: oa_tc6: Support for hardware timestamp

This commit adds hardware timestamping support to the OPEN Alliance TC6
framework. It adds PTP clock registration helpers and exports helpers for
ndo_hwtstamp_set/get and ethtool get_ts_info/get_ts_stats. TX timestamps
use the three TTSC capture registers signalled through STATUS0. RX
timestamps are parsed from the 8 bytes the MAC-PHY prepends to received
frames.

> diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
> index 341d13c97f91f..22aaecd814ecd 100644
> --- a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
> +++ b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c

[ ... ]

> @@ -49,6 +62,236 @@ static int oa_tc6_get_parity(u32 p)

[ ... ]

> +/* Pause new timestamp requests while an off request is pending. */
> +static void oa_tc6_req_tx_hwtstamp(struct oa_tc6 *tc6, struct sk_buff *skb)
> +{
> +	u8 tsc;
> +
> +	lockdep_assert_held(&tc6->tx_skb_lock);
> +
> +	if (!skb || !(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP))
> +		return;
> +
> +	if (tc6->ts_cfg.tx_type != HWTSTAMP_TX_ON ||
> +	    (tc6->ts_cfg_req &&
> +	     tc6->ts_cfg_new.tx_type != HWTSTAMP_TX_ON))
> +		return;
> +
> +	tsc = tc6->ttsc_current_id;
> +	if ((tc6->ttsc_pending | tc6->ttsc_held) &
> +	    BIT(tsc - OA_TC6_TTSCA_REG_ID)) {
> +		tc6->tx_hwtstamp_err++;
> +		return;
> +	}

[Severity: Medium]
Can a frame that was sitting in waiting_tx_skb when the interface
went down still claim a capture register here?

On dev_close, ndo_stop() runs before NETDEV_DOWN. The vendor stop
callbacks stop the TX queue, stop the PHY and clear the MAC TXEN.
Nothing drops tc6->waiting_tx_skb.

oa_tc6_netdev_event() then calls oa_tc6_cleanup_tx_tstamp_skbs(tc6,
true). That empties ttsc_skb_list, moves ttsc_pending into ttsc_held
and clears ttsc_pending, but it also leaves waiting_tx_skb alone.

When the threaded IRQ handler runs after that,
oa_tc6_prepare_spi_tx_buf_for_tx_skbs() promotes waiting_tx_skb to
ongoing_tx_skb and calls oa_tc6_req_tx_hwtstamp(). That function
checks ts_cfg and ts_cfg_req but not netif_running(). So it sets a
fresh bit in ttsc_pending and marks SKBTX_IN_PROGRESS.

When the last chunk is written, oa_tc6_queue_tx_tstamp_skb() finds
that bit set and adds the skb to ttsc_skb_list. The NETDEV_DOWN
cleanup has already finished by then.

With the MAC transmitter disabled, no TTSC capture should arrive for
this frame while the interface is down, or ever if the MAC-PHY
discards it. Doesn't the skb then stay on ttsc_skb_list, keeping its
socket and wmem charge pinned?

The stale ttsc_pending bit also has side effects.
oa_tc6_hwtstamp_req_process() won't apply a HWTSTAMP_TX_OFF request
while it is set, so those requests end in -ETIMEDOUT from
oa_tc6_hwtstamp_post(). And oa_tc6_req_tx_hwtstamp() stops handing
out registers once ttsc_current_id reaches it.

Should the NETDEV_DOWN handling also drop waiting_tx_skb? Or should
oa_tc6_req_tx_hwtstamp() refuse new requests when the interface is
not running?

[Severity: Medium]
What happens if the capture event for a claimed register never arrives?

If the bit for ttsc_current_id stays set in ttsc_pending or ttsc_held,
this returns without advancing ttsc_current_id and without trying the
other two registers.

Once the rotation reaches the stuck register, won't every later
SKBTX_HW_TSTAMP frame go out without a timestamp request, even when TTSCB
and TTSCC are free?

As far as I can tell, ttsc_held is only cleared in oa_tc6_events_handle(),
and only when STATUS0 reports TTSCAx for that register:

	tc6->ttsc_held &= ~ttsc_held;

The NETDEV_DOWN notifier also moves pending bits into held:

oa_tc6_netdev_event()
    oa_tc6_cleanup_tx_tstamp_skbs(tc6, true)
        tc6->ttsc_held |= tc6->ttsc_pending;

So an ifdown/ifup cycle doesn't seem to recover a stuck register either.

The s2500 driver later in the series calls s2500_stop()->s2500_shutdown(),
which clears TXEN and stops the PHY before the NETDEV_DOWN notifier runs.

If a timestamp-requesting frame is still buffered in the MAC-PHY at that
point, could it never be transmitted? Its register would then stay held
until the driver is unbound.

A stuck bit also seems to block turning TX timestamping off.
oa_tc6_hwtstamp_req_process() only applies a config that is not TX_ON
when:

	!(tc6->ttsc_pending | tc6->ttsc_held)

Wouldn't every HWTSTAMP_TX_OFF request then end in -ETIMEDOUT from
oa_tc6_hwtstamp_post()? CONFIG0.FTSE and the TTSC interrupt unmask would
stay programmed.

While the interface stays up, the skb on ttsc_skb_list for a lost capture
never expires. The skb, its socket and its wmem charge stay pinned until
ifdown.

oa_tc6_process_extended_status() already reads STATUS1 in the same burst
(regs[1]) but doesn't use it. If STATUS1 reports missed captures per
register, could it be used to release a stuck register? Alternatively,
could a timeout release it?

The commit message says:

    If the next timestamp capture register is still in use, the frame is
    sent without a timestamp request and the TX timestamp error counter
    is incremented.
    ...
    three timestamp capture registers are plenty

Once a single capture is lost, doesn't TX hardware timestamping stop for
good, rather than affecting only one frame?

> +
> +	tc6->ttsc_pending |= BIT(tsc - OA_TC6_TTSCA_REG_ID);
> +	tc6->ttsc_current_id = oa_tc6_next_tsc(tsc);
> +	oa_tc6_tsinfo_tx(skb)->tsc = tsc;
> +	skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
> +}

[ ... ]

> diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_tstamp.c b/drivers/net/ethernet/oa_tc6/oa_tc6_tstamp.c
> new file mode 100644
> index 0000000000000..aaffa18c4128e
> --- /dev/null
> +++ b/drivers/net/ethernet/oa_tc6/oa_tc6_tstamp.c
> @@ -0,0 +1,304 @@

[ ... ]

> +static int oa_tc6_hwtstamp_post(struct oa_tc6 *tc6,
> +				const struct hwtstamp_config *ts_cfg)
> +{
> +	unsigned long wait = msecs_to_jiffies(OA_TC6_TS_CFG_WAIT_MS);
> +
> +	spin_lock_bh(&tc6->tx_skb_lock);
> +	if (tc6->ts_cfg.flags == ts_cfg->flags &&
> +	    tc6->ts_cfg.tx_type == ts_cfg->tx_type &&
> +	    tc6->ts_cfg.rx_filter == ts_cfg->rx_filter) {
> +		spin_unlock_bh(&tc6->tx_skb_lock);
> +		return 0;
> +	}
> +
> +	if (tc6->disable_traffic) {
> +		spin_unlock_bh(&tc6->tx_skb_lock);
> +		return -EIO;
> +	}

[Severity: Medium]
What state is left behind if this CONFIG0 write fails? By then
INT_MASK0 has already been written, but tc6->ts_cfg still holds the
old config.

Consider turning TX timestamping off. oa_tc6_hwtstamp_req_process()
has already cleared ts_cfg_req. This function then sets
OA_TC6_INT_MASK0_TTSCA_MASK in INT_MASK0, and the CONFIG0 write fails.
The hardware is left with FTSE still enabled but the TTSC capture
interrupts masked. In software, ts_cfg.tx_type is still
HWTSTAMP_TX_ON.

With ts_cfg_req clear and ts_cfg still TX_ON,
oa_tc6_req_tx_hwtstamp() keeps claiming capture registers, and
oa_tc6_queue_tx_tstamp_skb() keeps adding skbs to ttsc_skb_list.

With the TTSCAx bits masked, would oa_tc6_events_handle() only see
these captures when some other unmasked STATUS0 event triggers the
read? If so, do the skbs and their ttsc_pending bits just pile up?

Retrying with HWTSTAMP_TX_ON doesn't recover the mask either.
oa_tc6_hwtstamp_post() compares the request against the stale
tc6->ts_cfg, finds it equal, and returns 0 without reprogramming
INT_MASK0. The STATUS0 write-one-to-clear above may also have
acknowledged a capture by then.

Should INT_MASK0 be restored on this error path? Alternatively, could
the writes be arranged so a partial failure leaves the hardware
consistent with tc6->ts_cfg?

[Severity: Low]
The kernel-doc for oa_tc6_hwtstamp_set() and
Documentation/networking/oa-tc6-framework.rst both say -EIO is returned
once traffic handling has stopped.

The equality check above runs before the disable_traffic check. After
oa_tc6_disable_traffic() has run, does a request that repeats the current
config return 0 instead of -EIO?

oa_tc6_disable_traffic() sets disable_traffic, but it neither resets
ts_cfg nor brings the interface down. The netif_running() check in
oa_tc6_hwtstamp_set() therefore still passes.

Should the disable_traffic check come before the equality check?

> +	tc6->ts_cfg_new = *ts_cfg;
> +	tc6->ts_cfg_req = true;
> +	spin_unlock_bh(&tc6->tx_skb_lock);
> +	irq_wake_thread(tc6->spi->irq, tc6);

[ ... ]

-- 
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 [this message]
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

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=179591261088.3135.11468838555901711637@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