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 v13 07/15] net: ethernet: oa_tc6: Support for hardware timestamp
Date: Thu, 03 Dec 2026 17:41:34 +0000	[thread overview]
Message-ID: <sashiko-outbox-248282@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 2 potential
issues to consider:
- [Medium] net: oa_tc6: unacknowledged TTSC bits wedge TX timestamping
  and config
- [Low] net: oa_tc6: unrestored INT_MASK0 on error in
  oa_tc6_set_hwtstamp_settings()
--

commit 078fad3eca6f074ed57b3296cfaf9ae956614687
Author: Selvamani Rajagopal <Selvamani.Rajagopal@onsemi.com>

net: ethernet: oa_tc6: Support for hardware timestamp

This commit adds hardware timestamping and PTP clock registration helpers to
the OPEN Alliance TC6 10BASE-T1x 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..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);
> +
> +	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);
> +}

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

The MAC-PHY asserts OA_TC6_STATUS0_TTSCAx only when a frame is transmitted
onto the medium, whereas TX chunks are transferred over SPI into the MAC-PHY
FIFO whenever TX credits are available.  When the interface is brought down,
the vendor driver's ndo_stop disables the MAC transmitter and stops the PHY
before NETDEV_DOWN runs oa_tc6_netdev_event() ->
oa_tc6_cleanup_tx_tstamp_skbs(tc6, true), so any timestamped frame still
buffered in the MAC-PHY FIFO (for example awaiting carrier or a PLCA transmit
opportunity) never produces a capture interrupt and its bit stays set in
tc6->ttsc_held.

Once a single capture bit is stuck, oa_tc6_req_tx_hwtstamp() returns early
when tc6->ttsc_current_id reaches that register without advancing
tc6->ttsc_current_id to try the other two registers, so every subsequent
SKBTX_HW_TSTAMP packet is sent without a timestamp.  In addition,
oa_tc6_hwtstamp_req_process() waits for !(tc6->ttsc_pending | tc6->ttsc_held)
before turning TX timestamping off, causing oa_tc6_hwtstamp_set() with
HWTSTAMP_TX_OFF to fail with -ETIMEDOUT.

Two related paths can also leave tc6->ttsc_held bits stuck:
oa_tc6_netdev_event() leaves tc6->ongoing_tx_skb in flight when latching
tc6->ttsc_pending into tc6->ttsc_held, and oa_tc6_cleanup_ongoing_tx_skb()
only clears tc6->ttsc_pending if that partially sent multi-chunk skb is later
aborted; and oa_tc6_set_hwtstamp_settings() writes OA_TC6_REG_STATUS0 to
clear pending TTSCA bits in hardware without clearing the corresponding bits
in tc6->ttsc_held.

> 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
[ ... ]
> @@ -0,0 +1,302 @@
[ ... ]
> +	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);

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

When transitioning from HWTSTAMP_TX_ON to HWTSTAMP_TX_OFF, a failure on the
OA_TC6_REG_CONFIG0 write leaves OA_TC6_INT_MASK0_TTSCA_MASK masked in
hardware while tc6->ts_cfg.tx_type remains HWTSTAMP_TX_ON, so
oa_tc6_req_tx_hwtstamp() and oa_tc6_queue_tx_tstamp_skb() continue claiming
capture registers and queuing TX skbs whose capture interrupts are masked.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-s2500-mac-phy-support-v13-0-a2908fad2693@onsemi.com?part=7

  reply	other threads:[~2026-12-03 17:41 UTC|newest]

Thread overview: 39+ 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 ` Selvamani Rajagopal
2026-12-02 17:37 ` [PATCH net-next v13 01/15] dt-bindings: net: add onsemi's S2500 Selvamani Rajagopal
2026-12-02 17:37   ` 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
2026-12-02 17:37   ` 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-02 17:37   ` Selvamani Rajagopal
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
2026-12-02 17:37   ` 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
2026-12-02 17:37   ` Selvamani Rajagopal via B4 Relay
2026-12-02 17:37 ` [PATCH net-next v13 06/15] net: ethernet: adi: adin1140: " Selvamani Rajagopal
2026-12-02 17:37   ` 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
2026-12-02 17:37   ` Selvamani Rajagopal via B4 Relay
2026-12-03 17:41   ` sashiko-bot [this message]
2026-12-03 17:46   ` netdev-bot+sashiko
2026-12-03 18:42     ` Selvamani Rajagopal
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
2026-12-02 17:37   ` 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
2026-12-02 17:37   ` 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
2026-12-02 17:37   ` 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
2026-12-02 17:37   ` 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
2026-12-02 17:37   ` 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
2026-12-02 17:37   ` 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
2026-12-02 17:37   ` 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
2026-12-02 17:37   ` Selvamani Rajagopal via B4 Relay
2026-12-03 17:46   ` netdev-bot+sashiko
2026-12-03 18:38     ` 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-248282@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.