]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
ice: Don't put stale timestamps in the skb
authorKarol Kolacinski <karol.kolacinski@intel.com>
Tue, 16 Nov 2021 12:07:14 +0000 (13:07 +0100)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 4 Jan 2022 08:49:26 +0000 (09:49 +0100)
BugLink: https://bugs.launchpad.net/bugs/1956302
[ Upstream commit 37e738b6fdb14529534dca441e0222313688fde3 ]

The driver has to check if it does not accidentally put the timestamp in
the SKB before previous timestamp gets overwritten.
Timestamp values in the PHY are read only and do not get cleared except
at hardware reset or when a new timestamp value is captured.
The cached_tstamp field is used to detect the case where a new timestamp
has not yet been captured, ensuring that we avoid sending stale
timestamp data to the stack.

Fixes: ea9b847cda64 ("ice: enable transmit timestamps for E810 devices")
Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
Tested-by: Gurucharan G <gurucharanx.g@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
drivers/net/ethernet/intel/ice/ice_ptp.c
drivers/net/ethernet/intel/ice/ice_ptp.h

index 9df546984de25a596990f5aaa8266284db299005..ac27a4fe8b94cca4ecb95a924449a93cadd721cd 100644 (file)
@@ -1182,19 +1182,16 @@ static void ice_ptp_tx_tstamp_work(struct kthread_work *work)
                if (err)
                        continue;
 
-               /* Check if the timestamp is valid */
-               if (!(raw_tstamp & ICE_PTP_TS_VALID))
+               /* Check if the timestamp is invalid or stale */
+               if (!(raw_tstamp & ICE_PTP_TS_VALID) ||
+                   raw_tstamp == tx->tstamps[idx].cached_tstamp)
                        continue;
 
-               /* clear the timestamp register, so that it won't show valid
-                * again when re-used.
-                */
-               ice_clear_phy_tstamp(hw, tx->quad, phy_idx);
-
                /* The timestamp is valid, so we'll go ahead and clear this
                 * index and then send the timestamp up to the stack.
                 */
                spin_lock(&tx->lock);
+               tx->tstamps[idx].cached_tstamp = raw_tstamp;
                clear_bit(idx, tx->in_use);
                skb = tx->tstamps[idx].skb;
                tx->tstamps[idx].skb = NULL;
index e1c787bd5b967bf929a262561dbb127dc5fb5351..8cdd6f7046b737b5a163643a24ef17c46a3a2d0d 100644 (file)
@@ -46,15 +46,21 @@ struct ice_perout_channel {
  * struct ice_tx_tstamp - Tracking for a single Tx timestamp
  * @skb: pointer to the SKB for this timestamp request
  * @start: jiffies when the timestamp was first requested
+ * @cached_tstamp: last read timestamp
  *
  * This structure tracks a single timestamp request. The SKB pointer is
  * provided when initiating a request. The start time is used to ensure that
  * we discard old requests that were not fulfilled within a 2 second time
  * window.
+ * Timestamp values in the PHY are read only and do not get cleared except at
+ * hardware reset or when a new timestamp value is captured. The cached_tstamp
+ * field is used to detect the case where a new timestamp has not yet been
+ * captured, ensuring that we avoid sending stale timestamp data to the stack.
  */
 struct ice_tx_tstamp {
        struct sk_buff *skb;
        unsigned long start;
+       u64 cached_tstamp;
 };
 
 /**