]> www.infradead.org Git - users/hch/misc.git/commitdiff
igc: move ktime snapshot into PTM retry loop
authorChristopher S M Hall <christopher.s.hall@intel.com>
Tue, 1 Apr 2025 23:35:31 +0000 (16:35 -0700)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Fri, 11 Apr 2025 16:13:28 +0000 (09:13 -0700)
Move ktime_get_snapshot() into the loop. If a retry does occur, a more
recent snapshot will result in a more accurate cross-timestamp.

Fixes: a90ec8483732 ("igc: Add support for PTP getcrosststamp()")
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Tested-by: Mor Bar-Gabay <morx.bar.gabay@intel.com>
Tested-by: Avigail Dahan <avigailx.dahan@intel.com>
Signed-off-by: Christopher S M Hall <christopher.s.hall@intel.com>
Reviewed-by: Corinna Vinschen <vinschen@redhat.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/igc/igc_ptp.c

index c640e346342be80fb53e68455d510fc6491366cd..516abe7405deee94866c22ccc3d101db1a21dbb6 100644 (file)
@@ -1011,16 +1011,16 @@ static int igc_phc_get_syncdevicetime(ktime_t *device,
        int err, count = 100;
        ktime_t t1, t2_curr;
 
-       /* Get a snapshot of system clocks to use as historic value. */
-       ktime_get_snapshot(&adapter->snapshot);
-
+       /* Doing this in a loop because in the event of a
+        * badly timed (ha!) system clock adjustment, we may
+        * get PTM errors from the PCI root, but these errors
+        * are transitory. Repeating the process returns valid
+        * data eventually.
+        */
        do {
-               /* Doing this in a loop because in the event of a
-                * badly timed (ha!) system clock adjustment, we may
-                * get PTM errors from the PCI root, but these errors
-                * are transitory. Repeating the process returns valid
-                * data eventually.
-                */
+               /* Get a snapshot of system clocks to use as historic value. */
+               ktime_get_snapshot(&adapter->snapshot);
+
                igc_ptm_trigger(hw);
 
                err = readx_poll_timeout(rd32, IGC_PTM_STAT, stat,