Re: [PATCH net-next v12 07/15] net: ethernet: oa_tc6: Support for hardware timestamp
From: netdev-bot+sashiko
Date: Sat Nov 28 2026 - 19:37:03 EST
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