Hi Richard,

Today I get two machines that support HW timestamp. After more testing, I find
some issues. The first one is as follows.

On Wed, Aug 16, 2017 at 09:32:11PM +0800, Hangbin Liu wrote:
> -static void clock_reinit(struct clock *clock)
> +static void clock_reinit(struct node *node, struct clock *clock)
>  {
> +     struct port *p;
> +     int state, timestamping, ret;

        int state, timestamping, ret = -1;

> +     int phc_index = -1;
> +     char iface[IFNAMSIZ];
> +     clockid_t clkid = CLOCK_INVALID;
> +
> +     LIST_FOREACH(p, &node->ports, list) {
> +             if (p->clock == clock) {
> +                     ret = run_pmc_port_properties(node, 1000, p->number,
> +                                                   &state, &timestamping,
> +                                                   iface);
> +                     if (ret == -1) {
> +                             /* port does not exist, ignore the port */
> +                             continue;
> +                     }
> +                     if (ret <= 0) {
> +                             pr_err("failed to get port properties");
> +                             return;
> +                     }
> +                     if (timestamping == TS_SOFTWARE) {
> +                             /* ignore ports with software time stamping */
> +                             continue;
> +                     }
> +
> +                     p->state = normalize_state(state);
> +             }
> +     }
> +
> +     if (strcmp(clock->device, iface)) {

If no clock find or run_pmc_port_properties() return -1, the iface will be
random strings since it's not initialized. Then strcmp will return none zero
and set clock->device to wrong iface.

So we should init ret and make sure run_pmc_port_properties() returns correct.

        if (ret != -1 && strcmp(clock->device, iface)) {

> +             free(clock->device);
> +             clock->device = strdup(iface);
> +             clkid = clock_open(clock->device, &phc_index);
> +             if (clkid == CLOCK_INVALID)
> +                     return;
> +             phc_close(clock->clkid);
> +             clock->clkid = clkid;
> +             clock->phc_index = phc_index;
> +     }
> +
>       servo_reset(clock->servo);
>       clock->servo_state = SERVO_UNLOCKED;

The second issue is after failover, the offset will be very large. I'm still
investigating how to fix it. Maybe increase step_threshold?

I will wait for your comments about other issues and fix them toghther.

Thanks
Hangbin

------------------------------------------------------------------------------
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
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to