Re: [Linuxptp-users] Synchronization fault with stmmac
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Richard C. <ric...@gm...> - 2014-03-25 11:56:40
|
On Tue, Mar 25, 2014 at 12:30:01PM +0100, Richard Cochran wrote: > On Tue, Mar 25, 2014 at 09:52:32AM +0100, Mohamed Belaouad wrote: > > > Also, what we would like to know is: is the max ppb adjustment check > > done in the PTP subsystem (I have not found anything about it in > > drivers/ptp, maybe wrong location?) or should it be handled in the > > driver? > > There is no check in the kernel. I guess that ptp_clock_adjtime could > return ERANGE in such a case. Is this (untested patch) what you are asking for? Thanks, Richard --- diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c index e25d2bc..239d02f 100644 --- a/drivers/ptp/ptp_clock.c +++ b/drivers/ptp/ptp_clock.c @@ -142,7 +142,10 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct timex *tx) delta = ktime_to_ns(kt); err = ops->adjtime(ops, delta); } else if (tx->modes & ADJ_FREQUENCY) { - err = ops->adjfreq(ops, scaled_ppm_to_ppb(tx->freq)); + s32 delta = scaled_ppm_to_ppb(tx->freq); + if (delta > ops->max_adj || delta < -ops->max_adj) + return -ERANGE; + err = ops->adjfreq(ops, delta); ptp->dialed_frequency = tx->freq; } else if (tx->modes == 0) { tx->freq = ptp->dialed_frequency; |