nxt5656 / rpms / kernel

Forked from rpms/kernel 4 years ago
Clone
e293be
commit ade1bdffe90e59cd257cb9bd4f5abe4de5f14911
e293be
Author: Arnd Bergmann <arnd@arndb.de>
e293be
Date:   Mon Sep 28 22:21:31 2015 +0200
e293be
e293be
    ntp/pps: use y2038 safe types in pps_event_time
e293be
    
e293be
    The pps_event_time uses two 'timespec' structures internally, which
e293be
    suffer from the y2038 problem. The uses of this structure are
e293be
    fairly self-contained in the pps code, so this replaces them all at
e293be
    once.
e293be
    
e293be
    Unfortunately, this includes the sfc ethernet driver aside from the
e293be
    pps subsystem, so we change that one as well. Both touch the
e293be
    same data structure, and there probably is no good way to split
e293be
    the patch into smaller units.
e293be
    
e293be
    Acked-by: Richard Cochran <richardcochran@gmail.com>
e293be
    Acked-by: David S. Miller <davem@davemloft.net>
e293be
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
e293be
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
e293be
    Signed-off-by: John Stultz <john.stultz@linaro.org>
e293be
e293be
Ported to kernel-3.10.0-862.el7 by T.Kabe
e293be
diff -up ./drivers/net/ethernet/sfc/ptp.c.pps ./drivers/net/ethernet/sfc/ptp.c
e293be
--- ./drivers/net/ethernet/sfc/ptp.c.pps	2018-03-22 06:40:12.000000000 +0900
e293be
+++ ./drivers/net/ethernet/sfc/ptp.c	2018-04-18 17:22:49.000000000 +0900
e293be
@@ -646,26 +646,26 @@ static void efx_ptp_send_times(struct ef
e293be
 			       struct pps_event_time *last_time)
e293be
 {
e293be
 	struct pps_event_time now;
e293be
-	struct timespec limit;
e293be
+	struct timespec64 limit;
e293be
 	struct efx_ptp_data *ptp = efx->ptp_data;
e293be
 	int *mc_running = ptp->start.addr;
e293be
 
e293be
 	pps_get_ts(&now;;
e293be
 	limit = now.ts_real;
e293be
-	timespec_add_ns(&limit, SYNCHRONISE_PERIOD_NS);
e293be
+	timespec64_add_ns(&limit, SYNCHRONISE_PERIOD_NS);
e293be
 
e293be
 	/* Write host time for specified period or until MC is done */
e293be
-	while ((timespec_compare(&now.ts_real, &limit) < 0) &&
e293be
+	while ((timespec64_compare(&now.ts_real, &limit) < 0) &&
e293be
 	       ACCESS_ONCE(*mc_running)) {
e293be
-		struct timespec update_time;
e293be
+		struct timespec64 update_time;
e293be
 		unsigned int host_time;
e293be
 
e293be
 		/* Don't update continuously to avoid saturating the PCIe bus */
e293be
 		update_time = now.ts_real;
e293be
-		timespec_add_ns(&update_time, SYNCHRONISATION_GRANULARITY_NS);
e293be
+		timespec64_add_ns(&update_time, SYNCHRONISATION_GRANULARITY_NS);
e293be
 		do {
e293be
 			pps_get_ts(&now;;
e293be
-		} while ((timespec_compare(&now.ts_real, &update_time) < 0) &&
e293be
+		} while ((timespec64_compare(&now.ts_real, &update_time) < 0) &&
e293be
 			 ACCESS_ONCE(*mc_running));
e293be
 
e293be
 		/* Synchronise NIC with single word of time only */
e293be
@@ -721,7 +721,7 @@ efx_ptp_process_times(struct efx_nic *ef
e293be
 	struct efx_ptp_data *ptp = efx->ptp_data;
e293be
 	u32 last_sec;
e293be
 	u32 start_sec;
e293be
-	struct timespec delta;
e293be
+	struct timespec64 delta;
e293be
 	ktime_t mc_time;
e293be
 
e293be
 	if (number_readings == 0)
e293be
diff -up ./drivers/pps/kapi.c.pps ./drivers/pps/kapi.c
e293be
--- ./drivers/pps/kapi.c.pps	2018-03-22 06:40:12.000000000 +0900
e293be
+++ ./drivers/pps/kapi.c	2018-04-18 17:13:42.000000000 +0900
e293be
@@ -179,8 +179,8 @@ void pps_event(struct pps_device *pps, s
e293be
 	/* check event type */
e293be
 	BUG_ON((event & (PPS_CAPTUREASSERT | PPS_CAPTURECLEAR)) == 0);
e293be
 
e293be
-	dev_dbg(pps->dev, "PPS event at %ld.%09ld\n",
e293be
-			ts->ts_real.tv_sec, ts->ts_real.tv_nsec);
e293be
+	dev_dbg(pps->dev, "PPS event at %lld.%09ld\n",
e293be
+			(s64)ts->ts_real.tv_sec, ts->ts_real.tv_nsec);
e293be
 
e293be
 	timespec_to_pps_ktime(&ts_real, ts->ts_real);
e293be
 
e293be
diff -up ./include/linux/pps_kernel.h.pps ./include/linux/pps_kernel.h
e293be
--- ./include/linux/pps_kernel.h.pps	2018-04-15 20:28:44.000000000 +0900
e293be
+++ ./include/linux/pps_kernel.h	2018-04-18 17:19:29.000000000 +0900
e293be
@@ -48,9 +48,9 @@ struct pps_source_info {
e293be
 
e293be
 struct pps_event_time {
e293be
 #ifdef CONFIG_NTP_PPS
e293be
-	struct timespec ts_raw;
e293be
+	struct timespec64 ts_raw;
e293be
 #endif /* CONFIG_NTP_PPS */
e293be
-	struct timespec ts_real;
e293be
+	struct timespec64 ts_real;
e293be
 };
e293be
 
e293be
 /* The main struct */
e293be
@@ -105,7 +105,7 @@ extern void pps_event(struct pps_device
e293be
 struct pps_device *pps_lookup_dev(void const *cookie);
e293be
 
e293be
 static inline void timespec_to_pps_ktime(struct pps_ktime *kt,
e293be
-		struct timespec ts)
e293be
+		struct timespec64 ts)
e293be
 {
e293be
 	kt->sec = ts.tv_sec;
e293be
 	kt->nsec = ts.tv_nsec;
e293be
@@ -115,25 +115,18 @@ static inline void pps_get_ts(struct pps
e293be
 {
e293be
 	struct system_time_snapshot snap;
e293be
 	ktime_get_snapshot(&snap);
e293be
-#if defined CONFIG_X86_64
e293be
 	ts->ts_real = ktime_to_timespec64(snap.real);
e293be
 #ifdef CONFIG_NTP_PPS
e293be
 	ts->ts_raw = ktime_to_timespec64(snap.raw);
e293be
 #endif
e293be
-#else
e293be
-	ts->ts_real = ktime_to_timespec(snap.real);
e293be
-#ifdef CONFIG_NTP_PPS
e293be
-	ts->ts_raw = ktime_to_timespec(snap.raw);
e293be
-#endif
e293be
-#endif
e293be
 }
e293be
 
e293be
 /* Subtract known time delay from PPS event time(s) */
e293be
-static inline void pps_sub_ts(struct pps_event_time *ts, struct timespec delta)
e293be
+static inline void pps_sub_ts(struct pps_event_time *ts, struct timespec64 delta)
e293be
 {
e293be
-	ts->ts_real = timespec_sub(ts->ts_real, delta);
e293be
+	ts->ts_real = timespec64_sub(ts->ts_real, delta);
e293be
 #ifdef CONFIG_NTP_PPS
e293be
-	ts->ts_raw = timespec_sub(ts->ts_raw, delta);
e293be
+	ts->ts_raw = timespec64_sub(ts->ts_raw, delta);
e293be
 #endif
e293be
 }
e293be