When we use a PI controller as default, after switch phc index, we create a
new servo. But we forget to init the servo sync interval, and left s->ki as
0.0. Then in function pi_sample() the freq_est_interval will always be
1000.0 and the state will keep in SERVO_UNLOCKED. The clock will never JUMP
and keep in s0. The error like

ptp4l[105873.521]: port 1: link up
ptp4l[105873.522]: port 1: FAULTY to LISTENING on INIT_COMPLETE
ptp4l[105874.467]: port 1: new foreign master 90e2ba.fffe.862e70-1
ptp4l[105875.226]: clockcheck: clock jumped forward or running faster than 
expected!
ptp4l[105878.467]: selected best master clock 90e2ba.fffe.862e70
ptp4l[105878.467]: port 1: LISTENING to UNCALIBRATED on RS_SLAVE
ptp4l[105881.226]: master offset 13475262388 s0 freq      +0 path delay    
-29183
ptp4l[105882.226]: master offset 13475328295 s0 freq      +0 path delay    
-29183
ptp4l[105883.226]: master offset 13475389438 s0 freq      +0 path delay    
-24464
ptp4l[105884.226]: master offset 13475457711 s0 freq      +0 path delay    
-26823
ptp4l[105885.226]: master offset 13475521247 s0 freq      +0 path delay    
-24464

After fix this issue, the clock could jump and switch to s2.

ptp4l[129656.126]: port 1: link up
ptp4l[129656.127]: port 1: FAULTY to LISTENING on INIT_COMPLETE
ptp4l[129656.843]: port 1: new foreign master 90e2ba.fffe.862e70-1
ptp4l[129657.714]: clockcheck: clock jumped forward or running faster than 
expected!
ptp4l[129660.843]: selected best master clock 90e2ba.fffe.862e70
ptp4l[129660.843]: port 1: LISTENING to UNCALIBRATED on RS_SLAVE
ptp4l[129663.714]: master offset 17289730150 s0 freq      +0 path delay      
-457
ptp4l[129664.714]: master offset 17289806236 s1 freq  +76091 path delay    
-10751
ptp4l[129665.714]: master offset     -10250 s2 freq  +65841 path delay    -10751
ptp4l[129665.714]: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED
ptp4l[129666.714]: master offset     -20498 s2 freq  +52518 path delay      -457
ptp4l[129667.714]: master offset      -7136 s2 freq  +59730 path delay      -457
ptp4l[129668.714]: master offset      -1971 s2 freq  +62754 path delay       521

Signed-off-by: Hangbin Liu <[email protected]>
---
 clock.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clock.c b/clock.c
index 9d224c9..3dba5ea 100644
--- a/clock.c
+++ b/clock.c
@@ -1546,6 +1546,7 @@ int clock_switch_phc(struct clock *c, int phc_index)
        c->clkid = clkid;
        c->servo = servo;
        c->servo_state = SERVO_UNLOCKED;
+       clock_sync_interval(c, 0);
        return 0;
 }
 
-- 
2.5.5


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to