Miroslav Lichvar
2015-02-10 15:54:43 UTC
When no source is found in the automatic mode and a clock is selected as
the default source, set its state temporarily to slave to prevent the
clock from being synchronized to itself and drifting quickly away.
Also, don't use this mode with only one PTP clock and don't include the
system clock.
This fixes phc2sys with SHM servo (e.g. used by timemaster).
---
phc2sys.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/phc2sys.c b/phc2sys.c
index 3ec1907..9ff5bf9 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -332,9 +332,14 @@ static void reconfigure(struct node *node)
}
last = c;
}
- if (dst_cnt && !src) {
+ if (dst_cnt > 1 && !src) {
if (!rt || rt->dest_only) {
node->master = last;
+ /* Reset to original state in next reconfiguration. */
+ node->master->new_state = node->master->state;
+ node->master->state = PS_SLAVE;
+ if (rt)
+ rt->state = PS_SLAVE;
pr_info("no source, selecting %s as the default clock",
last->device);
return;
the default source, set its state temporarily to slave to prevent the
clock from being synchronized to itself and drifting quickly away.
Also, don't use this mode with only one PTP clock and don't include the
system clock.
This fixes phc2sys with SHM servo (e.g. used by timemaster).
---
phc2sys.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/phc2sys.c b/phc2sys.c
index 3ec1907..9ff5bf9 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -332,9 +332,14 @@ static void reconfigure(struct node *node)
}
last = c;
}
- if (dst_cnt && !src) {
+ if (dst_cnt > 1 && !src) {
if (!rt || rt->dest_only) {
node->master = last;
+ /* Reset to original state in next reconfiguration. */
+ node->master->new_state = node->master->state;
+ node->master->state = PS_SLAVE;
+ if (rt)
+ rt->state = PS_SLAVE;
pr_info("no source, selecting %s as the default clock",
last->device);
return;
--
2.1.0
2.1.0