All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Selvamani Rajagopal" <Selvamani.Rajagopal@onsemi.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next v12 07/15] net: ethernet: oa_tc6: Support for hardware timestamp
Date: Wed, 25 Nov 2026 22:10:36 +0000	[thread overview]
Message-ID: <sashiko-outbox-234227@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 3 potential
issues to consider:
- [Medium] net: oa_tc6: waiting_tx_skb queued for TX timestamp after
  NETDEV_DOWN
- [Medium] net: oa_tc6: unacknowledged TTSC bits wedge TX timestamping
  and config
- [Medium] net: oa_tc6: unrestored INT_MASK0 on error in
  oa_tc6_set_hwtstamp_settings()
--

commit f233edafb90d63378a53bf6ad12696e270fe67d4
Author: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>

net: ethernet: oa_tc6: Support for hardware timestamp

This commit adds hardware TX and RX timestamping support, PTP clock
registration helpers, and ethtool timestamp callbacks to the OA TC6
MAC-PHY framework.

> 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;
> +	}
> +
> +	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;
> +}

[ ... ]

> +static void oa_tc6_cleanup_tx_tstamp_skbs(struct oa_tc6 *tc6, bool hold)
> +{
> +	struct sk_buff *skb, *tmp;
> +
> +	spin_lock_bh(&tc6->tx_skb_lock);
> +	list_for_each_entry_safe(skb, tmp, &tc6->ttsc_skb_list, list) {
> +		list_del(&skb->list);
> +		dev_kfree_skb(skb);
> +
> +		/* The frame was transmitted, only its timestamp is lost. */
> +		tc6->tx_hwtstamp_lost++;
> +	}
> +
> +	/* A frame still being sent can also produce a capture after close. */
> +	if (hold)
> +		tc6->ttsc_held |= tc6->ttsc_pending;
> +	tc6->ttsc_pending = 0;
> +	spin_unlock_bh(&tc6->tx_skb_lock);
> +}
> +
> +/* Release timestamp skbs on down, but keep their capture registers
> + * unavailable until the corresponding TTSC events are acknowledged.
> + */
> +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_tx_tstamp_skbs(tc6, true);
> +
> +	return NOTIFY_DONE;
> +}

[Severity: Medium]
Can an unacknowledged capture bit in tc6->ttsc_pending or tc6->ttsc_held
permanently wedge TX timestamping and block disabling HWTSTAMP_TX_ON?

The MAC-PHY only sets OA_TC6_STATUS0_TTSCAx when a frame is transmitted on
the wire.  When an interface goes down, ndo_stop() stops the PHY and
disables MAC TX before NETDEV_DOWN runs oa_tc6_cleanup_tx_tstamp_skbs(),
which moves tc6->ttsc_pending into tc6->ttsc_held.  If a frame already
transferred to the MAC-PHY buffer was not yet transmitted on the wire (or
if a multi-chunk ongoing_tx_skb is later dropped by
oa_tc6_cleanup_ongoing_tx_skb(), which only clears tc6->ttsc_pending), the
TTSC interrupt never arrives and that bit remains set in tc6->ttsc_held.

Once any bit in tc6->ttsc_pending or tc6->ttsc_held is stuck,
oa_tc6_req_tx_hwtstamp() returns early when tc6->ttsc_current_id reaches
that register without advancing tc6->ttsc_current_id to the other capture
registers, so all subsequent TX timestamp requests fail.  At the same time,
oa_tc6_hwtstamp_req_process() waits for !(tc6->ttsc_pending |
tc6->ttsc_held) before turning TX timestamping off, causing every later
HWTSTAMP_TX_OFF request in oa_tc6_hwtstamp_set() to fail with -ETIMEDOUT.

[ ... ]

> @@ -1102,6 +1397,7 @@ static u16 oa_tc6_prepare_spi_tx_buf_for_tx_skbs(struct oa_tc6 *tc6)
>  			spin_lock_bh(&tc6->tx_skb_lock);
>  			tc6->ongoing_tx_skb = tc6->waiting_tx_skb;
>  			tc6->waiting_tx_skb = NULL;
> +			oa_tc6_req_tx_hwtstamp(tc6, tc6->ongoing_tx_skb);
>  			spin_unlock_bh(&tc6->tx_skb_lock);
>  		}
>  		if (!tc6->ongoing_tx_skb)

[Severity: Medium]
Can a packet sitting in tc6->waiting_tx_skb when the interface goes down be
queued onto tc6->ttsc_skb_list after NETDEV_DOWN cleanup has already run?

CPU0                                  CPU1 (threaded IRQ)
oa_tc6_start_xmit()
  tc6->waiting_tx_skb = skb
__dev_close_many()
  clear __LINK_STATE_START
  ndo_stop()
NETDEV_DOWN
  oa_tc6_netdev_event()
    oa_tc6_cleanup_tx_tstamp_skbs()
                                      oa_tc6_prepare_spi_tx_buf_for_tx_skbs()
                                        tc6->ongoing_tx_skb = tc6->waiting_tx_skb
                                        oa_tc6_req_tx_hwtstamp()
                                          sets ttsc_pending, SKBTX_IN_PROGRESS
                                      oa_tc6_add_tx_skb_to_spi_buf()
                                        oa_tc6_queue_tx_tstamp_skb()
                                          list_add_tail(..., &tc6->ttsc_skb_list)
                                          <-- queued after NETDEV_DOWN cleanup

Because oa_tc6_req_tx_hwtstamp() does not check netif_running(tc6->netdev)
and NETDEV_DOWN does not drop or flush tc6->waiting_tx_skb, the skb (and
its socket reference held via SKBTX_IN_PROGRESS) stays stranded on
tc6->ttsc_skb_list while the interface is down, and its new
tc6->ttsc_pending bit blocks HWTSTAMP_TX_OFF in
oa_tc6_hwtstamp_req_process().

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

[ ... ]

> +	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;
> +	}
> +	spin_lock_bh(&tc6->tx_skb_lock);
> +	tc6->ts_cfg = *ts_cfg;
> +	spin_unlock_bh(&tc6->tx_skb_lock);
> +
> +	return 0;
> +}

[Severity: Medium]
If writing OA_TC6_REG_CONFIG0 fails after OA_TC6_REG_INT_MASK0 has been
updated, does this leave OA_TC6_INT_MASK0_TTSCA_MASK out of sync with
tc6->ts_cfg?

When disabling HWTSTAMP_TX_ON, a failure on the OA_TC6_REG_CONFIG0 write
leaves TTSC interrupts masked in OA_TC6_REG_INT_MASK0 while
tc6->ts_cfg.tx_type remains HWTSTAMP_TX_ON.  oa_tc6_req_tx_hwtstamp() will
continue queueing TX skbs for timestamps that never interrupt, and a retry
of oa_tc6_hwtstamp_set() with HWTSTAMP_TX_ON cannot unmask the interrupts
because oa_tc6_hwtstamp_post() sees that the requested config already
matches tc6->ts_cfg and returns 0 early.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261124-s2500-mac-phy-support-v12-0-3575855d99f9@onsemi.com?part=7

  parent reply	other threads:[~2026-11-25 22:10 UTC|newest]

Thread overview: 43+ 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
2026-11-24 22:09 ` 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
2026-11-24 22:09   ` 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
2026-11-24 22:09   ` 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
2026-11-24 22:09   ` 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
2026-11-24 22:09   ` 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
2026-11-24 22:09   ` 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
2026-11-24 22:09   ` 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
2026-11-24 22:09   ` Selvamani Rajagopal via B4 Relay
2026-11-25 18:16   ` Selvamani Rajagopal
2026-11-25 22:10   ` sashiko-bot [this message]
2026-11-29  0:36   ` netdev-bot+sashiko
2026-11-30  7:07     ` Selvamani Rajagopal
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
2026-11-24 22:09   ` 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
2026-11-24 22:09   ` 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
2026-11-24 22:09   ` 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
2026-11-24 22:09   ` 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
2026-11-24 22:10   ` 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
2026-11-24 22:10   ` 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
2026-11-24 22:10   ` 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
2026-11-24 22:10   ` Selvamani Rajagopal via B4 Relay
2026-11-25 22:10   ` sashiko-bot
2026-11-29  0:36   ` netdev-bot+sashiko
2026-11-30  7:11     ` Selvamani Rajagopal

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=sashiko-outbox-234227@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Selvamani.Rajagopal@onsemi.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.