[Linuxptp-users] master offset is increased in some condition
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Takahiro S. <tsh...@gm...> - 2012-03-12 06:13:41
|
Hello, I faced the issue that the master offset is increased in some condition. The log is like below: ptp4l[4597]: master offset -337052518 s2 adj -50000000 path delay 9249190 ptp4l[4597]: master offset -369835430 s2 adj -50000000 path delay 9249190 ptp4l[4597]: master offset -402770356 s2 adj -50000000 path delay 9402100 ptp4l[4597]: master offset -435105809 s2 adj -50000000 path delay 8954993 ptp4l[4597]: master offset -468838529 s2 adj -50000000 path delay 9904481 ptp4l[4597]: master offset -501932158 s2 adj -50000000 path delay 10212862 ptp4l[4597]: master offset -534480670 s2 adj -50000000 path delay 9979646 ptp4l[4597]: master offset -567281355 s2 adj -50000000 path delay 9997963 ptp4l[4597]: master offset -600064139 s2 adj -50000000 path delay 9997963 ptp4l[4597]: master offset -633393240 s2 adj -50000000 path delay 10544184 ptp4l[4597]: master offset -666177880 s2 adj -50000000 path delay 10544184 ptp4l[4597]: master offset -698614796 s2 adj -50000000 path delay 10198444 ptp4l[4597]: master offset -730351808 s2 adj -50000000 path delay 9152352 ptp4l[4597]: master offset -763135840 s2 adj -50000000 path delay 9152352 This issue is happened in the latest linuxptp too. This issue is happened when adj is -50000000 or 50000000. If the adj is -50000000 with s2(SERVO_LOCKED), clock_ppb is called with -adj. enum servo_state clock_synchronize(struct clock *c, : : case SERVO_LOCKED: clock_ppb(c->clkid, -adj); : static void clock_ppb(clockid_t clkid, double ppb) { struct timex tx; memset(&tx, 0, sizeof(tx)); tx.modes = ADJ_FREQUENCY; tx.freq = (long) (ppb * 65.536); if (clock_adjtime(clkid, &tx) < 0) pr_err("failed to adjust the clock: %m"); } If ppb is 50000000, then the result is 50000000 * 65.536 = 3276800000. tx.freq = (long)3276800000 = -1018167296. I think the tx.freq is overflowed. This is unexpected result. I think tx.freq should be under 0x7fffffff. If so, the max adh should be 0x7fffffff/65.536 = 32767999.9847... If I chage the EG20T ptp driver, the result seems OK. static struct ptp_clock_info ptp_pch_caps = { .owner = THIS_MODULE, .name = "PCH timer", // .max_adj = 50000000, .max_adj = 32767999, // Changed the max_adj by TS. (Question) 1. Is my modification correct ? 2. Is it better to correct it in another part? Thanks and Best regards, Takahiro Shimizu |