On 24/12/2020 23:30, Vladimir Oltean wrote:
On Thu, Dec 24, 2020 at 06:36:18PM +0200, Grygorii Strashko wrote:
Add dbg print about clock state change events in clock_reinit() in the
form:
     pru10: state change DISABLED -> MASTER
     pru20: state change MASTER -> UNCALIBRATED

Signed-off-by: Grygorii Strashko <grygorii.stras...@ti.com>
---
  phc2sys.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/phc2sys.c b/phc2sys.c
index 38a7a2d..b15127d 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -348,6 +348,9 @@ static void clock_reinit(struct phc2sys_private *priv, 
struct clock *clock,
                        stats_reset(clock->delay_stats);
                }
        }
+
+       pr_debug("%s: state change %s -> %s", clock->device,
+                ps_str[clock->state], ps_str[new_state]);
  }
static struct clock *find_dst_clock(struct phc2sys_private *priv,
--
2.17.1


This looks useful.

But you might want to fix up this call path in reconfigure:

        } else if (rt) {
                if (rt->state != PS_MASTER) {
                        rt->state = PS_MASTER;
                        clock_reinit(priv, rt, rt->state);
                }
                LIST_INSERT_HEAD(&priv->dst_clocks, rt, dst_list);
                pr_info("selecting %s for synchronization", rt->device);
        }

Because rt->state is assigned before calling clock_reinit(), I think it
would print something like:

CLOCK_REALTIME: state changed MASTER -> MASTER


yeh. I saw it, but was not sure. Seems below should work, so can send follow up 
patch if ok

====
diff --git a/phc2sys.c b/phc2sys.c
index fd80afd..65cd7b5 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -460,8 +460,8 @@ static void reconfigure(struct phc2sys_private *priv)
                rt->state = PS_SLAVE;
        } else if (rt) {
                if (rt->state != PS_MASTER) {
+                       clock_reinit(priv, rt, PS_MASTER);
                        rt->state = PS_MASTER;
-                       clock_reinit(priv, rt, rt->state);
                }
                LIST_INSERT_HEAD(&priv->dst_clocks, rt, dst_list);
                pr_info("selecting %s for synchronization", rt->device);



--
Best regards,
grygorii


_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to