net/mlx5e: Replace PTP clock lock from RW lock to seq lock
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / lib / clock.h
index 02e2e4575e4f88c1068a02709057b753b63a9485..263cb6e2aeee52e5bbdbd698ab3556531529a14a 100644 (file)
@@ -46,11 +46,13 @@ static inline int mlx5_clock_get_ptp_index(struct mlx5_core_dev *mdev)
 static inline ktime_t mlx5_timecounter_cyc2time(struct mlx5_clock *clock,
                                                u64 timestamp)
 {
+       unsigned int seq;
        u64 nsec;
 
-       read_lock(&clock->lock);
-       nsec = timecounter_cyc2time(&clock->tc, timestamp);
-       read_unlock(&clock->lock);
+       do {
+               seq = read_seqbegin(&clock->lock);
+               nsec = timecounter_cyc2time(&clock->tc, timestamp);
+       } while (read_seqretry(&clock->lock, seq));
 
        return ns_to_ktime(nsec);
 }