From: Shivani Gupta <shivani07g@gmail.com>
To: intel-wired-lan@lists.osuosl.org,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Richard Cochran <richardcochran@gmail.com>,
Jacob Keller <jacob.e.keller@intel.com>,
Matthew Vick <matthew.vick@intel.com>,
Vinicius Costa Gomes <vinicius.gomes@intel.com>,
Kurt Kanzenbach <kurt@linutronix.de>,
Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Subject: [PATCH iwl-net 2/2] igb: Clear pending Tx timestamp requests when disabling Tx timestamping
Date: Sat, 15 Aug 2026 01:08:27 +0000 [thread overview]
Message-ID: <20260815010827.91912-3-shivani07g@gmail.com> (raw)
In-Reply-To: <20260815010827.91912-1-shivani07g@gmail.com>
Disabling Tx hardware timestamping clears TSYNCTXCTL.EN but leaves an
outstanding request in ptp_tx_skb. Re-enabling within
IGB_PTP_TX_TIMEOUT therefore finds the single timestamp slot occupied
and skips new requests until the watchdog reports a misleading timeout,
producing a blackout of up to 15 seconds.
Cancel timestamp retrieval when disabling Tx timestamping, then publish
HWTSTAMP_TX_OFF and release the pending request under ptp_tx_lock. The
transmit path tests both the configured mode and slot ownership under
the same lock, so no request can be admitted between clearing the slot
and publishing the disabled state. Updates to the saved configuration
and the watchdog mode check use that lock as well.
Suspend uses the same cleanup helper without changing the saved mode,
allowing reset to restore the requested configuration after resume.
Only count a timestamp request as skipped when hardware timestamping is
enabled and the slot is occupied. Requests carrying SKBTX_HW_TSTAMP
while the feature is disabled could never have been serviced and are
ignored without changing the counter.
Fixes: 1f6e8178d685 ("igb: Prevent dropped Tx timestamps via work items and interrupts.")
Signed-off-by: Shivani Gupta <shivani07g@gmail.com>
---
drivers/net/ethernet/intel/igb/igb_main.c | 26 +++++++++++++----------
drivers/net/ethernet/intel/igb/igb_ptp.c | 20 +++++++++++++++--
2 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index fc70f7aa4ce0..42204e3307d6 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -6565,18 +6565,22 @@ netdev_tx_t igb_xmit_frame_ring(struct sk_buff *skb,
struct igb_adapter *adapter = netdev_priv(tx_ring->netdev);
unsigned long flags;
+ /* A timestamp that was requested while Tx timestamping was
+ * not enabled can never be delivered, it is not "skipped".
+ */
spin_lock_irqsave(&adapter->ptp_tx_lock, flags);
- if (adapter->tstamp_config.tx_type == HWTSTAMP_TX_ON &&
- !adapter->ptp_tx_skb) {
- skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
- tx_flags |= IGB_TX_FLAGS_TSTAMP;
-
- adapter->ptp_tx_skb = skb_get(skb);
- adapter->ptp_tx_start = jiffies;
- if (adapter->hw.mac.type == e1000_82576)
- schedule_work(&adapter->ptp_tx_work);
- } else {
- adapter->tx_hwtstamp_skipped++;
+ if (adapter->tstamp_config.tx_type == HWTSTAMP_TX_ON) {
+ if (!adapter->ptp_tx_skb) {
+ skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
+ tx_flags |= IGB_TX_FLAGS_TSTAMP;
+
+ adapter->ptp_tx_skb = skb_get(skb);
+ adapter->ptp_tx_start = jiffies;
+ if (adapter->hw.mac.type == e1000_82576)
+ schedule_work(&adapter->ptp_tx_work);
+ } else {
+ adapter->tx_hwtstamp_skipped++;
+ }
}
spin_unlock_irqrestore(&adapter->ptp_tx_lock, flags);
}
diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index 3cc05f9198f8..adc7be6a2ee2 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -914,6 +914,9 @@ void igb_ptp_tx_hang(struct igb_adapter *adapter)
spin_lock_irqsave(&adapter->ptp_tx_lock, flags);
+ if (adapter->tstamp_config.tx_type != HWTSTAMP_TX_ON)
+ goto unlock;
+
if (!adapter->ptp_tx_skb)
goto unlock;
@@ -933,19 +936,22 @@ void igb_ptp_tx_hang(struct igb_adapter *adapter)
/**
* igb_ptp_clear_tx_tstamp - drop a pending Tx timestamp request
* @adapter: private network adapter structure
+ * @disable: whether to disable Tx timestamp admission
*
* Cancel the timestamp retrieval work and free a pending timestamp skb.
*
* Context: Must be called in sleepable context with ptp_tx_lock not held;
* cancel_work_sync() waits for igb_ptp_tx_work() which takes it.
*/
-static void igb_ptp_clear_tx_tstamp(struct igb_adapter *adapter)
+static void igb_ptp_clear_tx_tstamp(struct igb_adapter *adapter, bool disable)
{
unsigned long flags;
cancel_work_sync(&adapter->ptp_tx_work);
spin_lock_irqsave(&adapter->ptp_tx_lock, flags);
+ if (disable)
+ adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF;
dev_kfree_skb_any(adapter->ptp_tx_skb);
adapter->ptp_tx_skb = NULL;
spin_unlock_irqrestore(&adapter->ptp_tx_lock, flags);
@@ -1250,6 +1256,13 @@ static int igb_ptp_set_timestamp_mode(struct igb_adapter *adapter,
regval |= tsync_tx_ctl;
wr32(E1000_TSYNCTXCTL, regval);
+ /* Drop a possibly pending Tx timestamp request when disabling Tx
+ * timestamping. It would otherwise block new requests until it is
+ * flagged as timed out by the watchdog up to 15 seconds later.
+ */
+ if (!tsync_tx_ctl)
+ igb_ptp_clear_tx_tstamp(adapter, true);
+
/* enable/disable RX */
regval = rd32(E1000_TSYNCRXCTL);
regval &= ~(E1000_TSYNCRXCTL_ENABLED | E1000_TSYNCRXCTL_TYPE_MASK);
@@ -1310,6 +1323,7 @@ int igb_ptp_hwtstamp_set(struct net_device *netdev,
struct netlink_ext_ack *extack)
{
struct igb_adapter *adapter = netdev_priv(netdev);
+ unsigned long flags;
int err;
err = igb_ptp_set_timestamp_mode(adapter, config);
@@ -1317,7 +1331,9 @@ int igb_ptp_hwtstamp_set(struct net_device *netdev,
return err;
/* save these settings for future reference */
+ spin_lock_irqsave(&adapter->ptp_tx_lock, flags);
adapter->tstamp_config = *config;
+ spin_unlock_irqrestore(&adapter->ptp_tx_lock, flags);
return 0;
}
@@ -1461,7 +1477,7 @@ void igb_ptp_suspend(struct igb_adapter *adapter)
if (adapter->ptp_flags & IGB_PTP_OVERFLOW_CHECK)
cancel_delayed_work_sync(&adapter->ptp_overflow_work);
- igb_ptp_clear_tx_tstamp(adapter);
+ igb_ptp_clear_tx_tstamp(adapter, false);
}
/**
prev parent reply other threads:[~2026-08-15 1:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-15 1:08 [PATCH iwl-net 0/2] igb: PTP Tx timestamp state fixes Shivani Gupta
2026-08-15 1:08 ` [PATCH iwl-net 1/2] igb: Fix race condition in PTP tx code Shivani Gupta
2026-08-15 1:08 ` Shivani Gupta [this message]
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=20260815010827.91912-3-shivani07g@gmail.com \
--to=shivani07g@gmail.com \
--cc=aleksandr.loktionov@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=kurt@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.vick@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=richardcochran@gmail.com \
--cc=vinicius.gomes@intel.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