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, willemb@google.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 v13 07/15] net: ethernet: oa_tc6: Support for hardware timestamp
Date: Thu, 03 Dec 2026 17:46:31 +0000 [thread overview]
Message-ID: <179631999173.3146.3476539071105534145@kernel.org> (raw)
In-Reply-To: <20261202-s2500-mac-phy-support-v13-7-a2908fad2693@onsemi.com>
Thank you for your contribution! Sashiko AI review found 6 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 5
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] Nothing times out or reclaims a TX timestamp capture register
(TTSCA/B/C), or the skb parked on it, if the MAC-PHY never reports the…
- [Low] The commit message does not match the code on how short RX frames
are counted.
- [Low] oa_tc6_init() now registers a netdevice notifier for every OA TC6
device, including LAN865X and ADIN1140, which never register a PHC and…
- [Low] If an in-flight frame that already holds a TX timestamp capture
register is discarded, oa_tc6_cleanup_ongoing_tx_skb() clears the…
- [Low] oa_tc6_set_hwtstamp_settings() programs the hardware in three
separate writes: STATUS0 (W1C, conditional), then INT_MASK0, then…
- [Low] The new NETDEV_DOWN notifier adds a writer of
netdev->stats.tx_dropped that runs at the same time as the threaded…
--
net: ethernet: oa_tc6: Support for hardware timestamp
This adds hardware timestamp support to the OPEN Alliance TC6 framework.
It provides PTP clock registration helpers and exports hwtstamp and
ethtool helpers for vendor drivers. TX timestamps are tracked through
three capture registers, RX timestamps are parsed from the 8 bytes the
MAC-PHY prepends, and a netdevice notifier releases skbs waiting for a
TX timestamp on interface down.
> diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
> index 341d13c97f91f..3bb274d0f647d 100644
> --- a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
> +++ b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c
[ ... ]
> @@ -49,6 +62,222 @@ 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);
> +
[ ... ]
> + 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]
What frees a capture register if the MAC-PHY never reports the TTSCAx
event for it?
Only oa_tc6_events_handle() clears ttsc_held, and only when a PTP clock
is registered and STATUS0 has the matching bit set. On ifdown,
oa_tc6_netdev_event()->oa_tc6_cleanup_tx_tstamp_skbs(tc6, true) does:
if (hold)
tc6->ttsc_held |= tc6->ttsc_pending;
tc6->ttsc_pending = 0;
A down/up cycle therefore turns the pending bit into a held bit instead
of freeing the register. Until then, oa_tc6_queue_tx_tstamp_skb() keeps
the skb on ttsc_skb_list with no expiry, and the skb keeps its socket's
wmem charge.
When the register at ttsc_current_id is busy, the check above returns
without advancing ttsc_current_id. Does one stuck register then make
every later TX timestamp request fail, even with the other two registers
free?
TX_OFF also seems affected. oa_tc6_hwtstamp_req_process() only claims a
TX_OFF request when nothing is pending or held:
if (tc6->ts_cfg_new.tx_type == HWTSTAMP_TX_ON ||
!(tc6->ttsc_pending | tc6->ttsc_held)) {
With a stuck bit, wouldn't every attempt to turn TX timestamping off get
-ETIMEDOUT from oa_tc6_hwtstamp_post()? FTSE would stay set and the TTSC
interrupts unmasked until unbind.
One possible trigger in this series: s2500_stop()->s2500_shutdown()
clears TXEN before NETDEV_DOWN, while a TSC-tagged frame may still be
buffered in the MAC-PHY. A frame the MAC-PHY drops, for example after
collisions, could leave its register stuck in the same way.
The commit message and the oa_tc6_hwtstamp_set() kernel-doc mention the
100 ms -ETIMEDOUT and "may wait for outstanding TX timestamps". They do
not say TX timestamping can stay unusable in this case. Do these
registers need a timeout or some other way to be released?
[ ... ]
> +static int oa_tc6_update_ts_in_rx_skb(struct oa_tc6 *tc6)
> +{
> + unsigned int expected_len = ETH_HLEN;
> + struct sk_buff *skb = tc6->rx_skb;
> + struct oa_tc6_ts_info_rx *ski;
> + __be32 ts_val[2];
> + u32 ts[2];
> +
> + ski = oa_tc6_tsinfo_rx(skb);
> + if (ski->rtsa)
> + expected_len += OA_TC6_TSTAMP_SZ;
> +
> + if (skb->len < expected_len) {
> + tc6->netdev->stats.rx_length_errors++;
> + tc6->netdev->stats.rx_errors++;
> + return -EINVAL;
> + }
[Severity: Low]
The commit message says:
RX frame shorter than ETH_HLEN (plus 8 bytes when timestamp is
present) is dropped now and counted in rx_length_errors and
rx_dropped.
The code increments rx_length_errors and rx_errors. The caller,
oa_tc6_submit_rx_skb(), then calls oa_tc6_free_rx_skb(), which updates
no counter, so rx_dropped is never incremented. Should the commit
message say rx_errors instead of rx_dropped?
This drop path also applies to every OA TC6 user, not only timestamping
hardware.
[ ... ]
> @@ -624,6 +860,14 @@ static void oa_tc6_cleanup_ongoing_rx_skb(struct oa_tc6 *tc6)
>
> static void oa_tc6_cleanup_ongoing_tx_skb(struct oa_tc6 *tc6)
> {
> + if (tc6->ongoing_tx_skb &&
> + oa_tc6_tsinfo_tx(tc6->ongoing_tx_skb)->tsc) {
> + u8 tsc = oa_tc6_tsinfo_tx(tc6->ongoing_tx_skb)->tsc;
> +
> + spin_lock_bh(&tc6->tx_skb_lock);
> + tc6->ttsc_pending &= ~BIT(tsc - OA_TC6_TTSCA_REG_ID);
> + spin_unlock_bh(&tc6->tx_skb_lock);
> + }
> oa_tc6_drop_tx_skb(tc6, tc6->ongoing_tx_skb);
> tc6->ongoing_tx_skb = NULL;
> }
[Severity: Low]
Should tx_hwtstamp_lost be incremented here as well?
oa_tc6_req_tx_hwtstamp() has already claimed a register for this skb and
set SKBTX_IN_PROGRESS, but the timestamp is never delivered. struct
ethtool_ts_stats defines @lost as requests "where the timestamping
information from the hardware never arrived for submission with the
skb". oa_tc6_cleanup_tx_tstamp_skbs() does increment tx_hwtstamp_lost
for each skb it drops.
This path is reached through oa_tc6_free_ongoing_skbs() from the device
error branch of oa_tc6_try_spi_transfer(), from oa_tc6_disable_traffic()
and from oa_tc6_exit().
> @@ -649,6 +893,26 @@ static void oa_tc6_free_pending_skbs(struct oa_tc6 *tc6)
[ ... ]
> +static int oa_tc6_netdev_event(struct notifier_block *nb, unsigned long event,
> + void *ptr)
> +{
> + struct oa_tc6 *tc6 = container_of(nb, struct oa_tc6, netdev_nb);
> +
> + if (event == NETDEV_DOWN &&
> + netdev_notifier_info_to_dev(ptr) == tc6->netdev) {
> + oa_tc6_cleanup_waiting_tx_skb(tc6);
[Severity: Low]
Can a tx_dropped update be lost here?
oa_tc6_cleanup_waiting_tx_skb() releases tx_skb_lock before it drops the
skb:
spin_lock_bh(&tc6->tx_skb_lock);
skb = oa_tc6_detach_waiting_tx_skb(tc6);
spin_unlock_bh(&tc6->tx_skb_lock);
oa_tc6_drop_tx_skb(tc6, skb);
oa_tc6_drop_tx_skb() then does a plain tc6->netdev->stats.tx_dropped++.
The threaded IRQ handler keeps running across ifdown. Its error path,
oa_tc6_try_spi_transfer()->oa_tc6_free_ongoing_skbs()->
oa_tc6_cleanup_ongoing_tx_skb(), does the same unlocked increment.
Until now, oa_tc6_cleanup_waiting_tx_skb() was only called from teardown
paths that are serialized against the IRQ thread.
> + oa_tc6_cleanup_tx_tstamp_skbs(tc6, true);
> + }
> +
> + return NOTIFY_DONE;
> }
[ ... ]
> @@ -1463,6 +1785,14 @@ struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev,
> goto phy_exit;
> }
>
> + tc6->netdev_nb.notifier_call = oa_tc6_netdev_event;
> + ret = register_netdevice_notifier(&tc6->netdev_nb);
[Severity: Low]
This notifier is registered for every OA TC6 device, including LAN865X
and ADIN1140, which never register a PHC.
On NETDEV_DOWN, oa_tc6_netdev_event() frees the queued non-timestamp
waiting_tx_skb through oa_tc6_drop_tx_skb(), which increments
tx_dropped. Before this patch the queued frame stayed in waiting_tx_skb
across ifdown.
The commit message only says:
A netdevice notifier registered in oa_tc6_init() releases the skbs
waiting for a TX timestamp when the interface goes down.
"Drop the queued TX frame on interface down" appears only in the v13
changelog below the --- line, which does not end up in git.
Could the commit message say that a queued normal frame is dropped on
ifdown for all OA TC6 devices? Could it also say that each probed device
registers a global netdevice notifier?
> + if (ret) {
> + dev_err(&tc6->spi->dev,
> + "Failed to register netdev notifier: %d\n", ret);
> + goto phy_exit;
> + }
[ ... ]
> 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..1806aa81a2852
> --- /dev/null
> +++ b/drivers/net/ethernet/oa_tc6/oa_tc6_tstamp.c
[ ... ]
> +static int oa_tc6_set_hwtstamp_settings(struct oa_tc6 *tc6,
> + const struct hwtstamp_config *ts_cfg)
> +{
[ ... ]
> + ret = oa_tc6_write_register(tc6, OA_TC6_REG_INT_MASK0, irqm);
> + if (ret) {
> + dev_err(&tc6->spi->dev, "failed to write IRQM register\n");
> + return ret;
> + }
> +
> + ret = oa_tc6_write_register(tc6, OA_TC6_REG_CONFIG0, cfg0);
> + if (ret) {
> + dev_err(&tc6->spi->dev, "failed to write CFG0 register\n");
> + return ret;
> + }
[Severity: Low]
If this CONFIG0 write fails, INT_MASK0 has already been changed and is
not restored, while tc6->ts_cfg keeps the old configuration. Can the
hardware and the driver then disagree about the timestamping state?
Take TX_ON to TX_OFF as an example. TTSCAA/B/C are now masked, FTSE
stays enabled, and ts_cfg.tx_type is still HWTSTAMP_TX_ON.
oa_tc6_req_tx_hwtstamp() would keep tagging frames with a TSC whose
captures no longer raise an interrupt. Wouldn't those skbs stay on
ttsc_skb_list and their registers stay pending?
In the opposite case, TX_OFF to TX_ON with a failed CONFIG0 write, the
TTSC interrupts are left unmasked while ts_cfg still says off.
> + spin_lock_bh(&tc6->tx_skb_lock);
> + tc6->ts_cfg = *ts_cfg;
> + spin_unlock_bh(&tc6->tx_skb_lock);
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-s2500-mac-phy-support-v13-0-a2908fad2693%40onsemi.com
next prev parent reply other threads:[~2026-12-03 17:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 17:37 [PATCH net-next v13 00/15] Support for onsemi's S2500 10BASE-T1S MAC-PHY Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 01/15] dt-bindings: net: add onsemi's S2500 Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 02/15] Documentation: networking: Add timestamp related APIs to OA TC6 framework Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 03/15] net: ethernet: oa_tc6: Move oa_tc6.c to its own directory Selvamani Rajagopal via B4 Relay
2026-12-03 17:46 ` netdev-bot+sashiko
2026-12-02 17:37 ` [PATCH net-next v13 04/15] net: ethernet: oa_tc6: Move constant definitions to header file Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 05/15] net: ethernet: microchip: lan865x: Depends on PTP_1588_CLOCK_OPTIONAL Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 06/15] net: ethernet: adi: adin1140: " Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 07/15] net: ethernet: oa_tc6: Support for hardware timestamp Selvamani Rajagopal via B4 Relay
2026-12-03 17:41 ` sashiko-bot
2026-12-03 17:46 ` netdev-bot+sashiko [this message]
2026-12-02 17:37 ` [PATCH net-next v13 08/15] net: ethernet: oa_tc6: Drop frames if footer has FD bit set Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 09/15] net: ethernet: oa_tc6: Support for vendor specific MMS Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 10/15] net: ethernet: oa_tc6: APIs to customize CONFIG0 settings Selvamani Rajagopal via B4 Relay
2026-12-03 17:46 ` netdev-bot+sashiko
2026-12-02 17:37 ` [PATCH net-next v13 11/15] net: phy: ncn26000: Enable enhanced noise immunity Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 12/15] net: phy: Add helper to modify only the PHY loopback bit Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 13/15] net: phy: ncn26000: Support for onsemi's S2500 internal phy Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 14/15] net: phy: dp83867: Use genphy_loopback_no_speed() Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 15/15] net: ethernet: onsemi: s2500: Add driver support for S2500 Selvamani Rajagopal via B4 Relay
2026-12-03 17:46 ` 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=179631999173.3146.3476539071105534145@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 \
--cc=willemb@google.com \
/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