Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: hellcreek: Convert to gettimex64()

As of commit 916444df305e ("ptp: deprecate gettime64() in favor of
gettimex64()") (new) PTP drivers should rather implement gettimex64().

In addition, this variant provides timestamps from the system clock. The
readings have to be recorded right before and after reading the lowest bits
of the PHC timestamp.

Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Kurt Kanzenbach and committed by
David S. Miller
385edf32 af398bd0

+15 -10
+15 -10
drivers/net/dsa/hirschmann/hellcreek_ptp.c
··· 27 27 } 28 28 29 29 /* Get nanoseconds from PTP clock */ 30 - static u64 hellcreek_ptp_clock_read(struct hellcreek *hellcreek) 30 + static u64 hellcreek_ptp_clock_read(struct hellcreek *hellcreek, 31 + struct ptp_system_timestamp *sts) 31 32 { 32 33 u16 nsl, nsh; 33 34 ··· 46 45 nsh = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C); 47 46 nsh = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C); 48 47 nsh = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C); 48 + ptp_read_system_prets(sts); 49 49 nsl = hellcreek_ptp_read(hellcreek, PR_SS_SYNC_DATA_C); 50 + ptp_read_system_postts(sts); 50 51 51 52 return (u64)nsl | ((u64)nsh << 16); 52 53 } 53 54 54 - static u64 __hellcreek_ptp_gettime(struct hellcreek *hellcreek) 55 + static u64 __hellcreek_ptp_gettime(struct hellcreek *hellcreek, 56 + struct ptp_system_timestamp *sts) 55 57 { 56 58 u64 ns; 57 59 58 - ns = hellcreek_ptp_clock_read(hellcreek); 60 + ns = hellcreek_ptp_clock_read(hellcreek, sts); 59 61 if (ns < hellcreek->last_ts) 60 62 hellcreek->seconds++; 61 63 hellcreek->last_ts = ns; ··· 76 72 { 77 73 u64 s; 78 74 79 - __hellcreek_ptp_gettime(hellcreek); 75 + __hellcreek_ptp_gettime(hellcreek, NULL); 80 76 if (hellcreek->last_ts > ns) 81 77 s = hellcreek->seconds * NSEC_PER_SEC; 82 78 else ··· 85 81 return s; 86 82 } 87 83 88 - static int hellcreek_ptp_gettime(struct ptp_clock_info *ptp, 89 - struct timespec64 *ts) 84 + static int hellcreek_ptp_gettimex(struct ptp_clock_info *ptp, 85 + struct timespec64 *ts, 86 + struct ptp_system_timestamp *sts) 90 87 { 91 88 struct hellcreek *hellcreek = ptp_to_hellcreek(ptp); 92 89 u64 ns; 93 90 94 91 mutex_lock(&hellcreek->ptp_lock); 95 - ns = __hellcreek_ptp_gettime(hellcreek); 92 + ns = __hellcreek_ptp_gettime(hellcreek, sts); 96 93 mutex_unlock(&hellcreek->ptp_lock); 97 94 98 95 *ts = ns_to_timespec64(ns); ··· 189 184 if (abs(delta) > MAX_SLOW_OFFSET_ADJ) { 190 185 struct timespec64 now, then = ns_to_timespec64(delta); 191 186 192 - hellcreek_ptp_gettime(ptp, &now); 187 + hellcreek_ptp_gettimex(ptp, &now, NULL); 193 188 now = timespec64_add(now, then); 194 189 hellcreek_ptp_settime(ptp, &now); 195 190 ··· 238 233 hellcreek = dw_overflow_to_hellcreek(dw); 239 234 240 235 mutex_lock(&hellcreek->ptp_lock); 241 - __hellcreek_ptp_gettime(hellcreek); 236 + __hellcreek_ptp_gettime(hellcreek, NULL); 242 237 mutex_unlock(&hellcreek->ptp_lock); 243 238 244 239 schedule_delayed_work(&hellcreek->overflow_work, ··· 414 409 hellcreek->ptp_clock_info.pps = 0; 415 410 hellcreek->ptp_clock_info.adjfine = hellcreek_ptp_adjfine; 416 411 hellcreek->ptp_clock_info.adjtime = hellcreek_ptp_adjtime; 417 - hellcreek->ptp_clock_info.gettime64 = hellcreek_ptp_gettime; 412 + hellcreek->ptp_clock_info.gettimex64 = hellcreek_ptp_gettimex; 418 413 hellcreek->ptp_clock_info.settime64 = hellcreek_ptp_settime; 419 414 hellcreek->ptp_clock_info.enable = hellcreek_ptp_enable; 420 415 hellcreek->ptp_clock_info.do_aux_work = hellcreek_hwtstamp_work;