> -----Original Message-----
> From: Miroslav Lichvar <mlich...@redhat.com>
> Sent: Thursday, March 10, 2022 3:23 AM
> To: linuxptp-devel@lists.sourceforge.net
> Subject: [Linuxptp-devel] [PATCH] phc2sys: Don't exit when reading of PHC 
> fails.
> 
> Reading of the PHC can occasionally fail with some drivers, e.g. the ice
> driver returns -EBUSY when it fails to get a lock. Change do_loop() to
> ignore the error instead of exiting.
> 
> Signed-off-by: Miroslav Lichvar <mlich...@redhat.com>
> ---

Yep. Thanks for fixing this. I'd like to clarify why ice does sometimes return 
-EBUSY for reviewers on this list.

The ice hardware has a semaphore to protect accesses to the clock register. 
Multiple functions might access the clock at the same time. The semaphore 
prevents this. If we fail to acquire the semaphore in a short time, we give up 
on the gettime function and exit with -EBUSY.

Does the inner call log a debug message? if not perhaps we might want to add 
such a debug message to this as well?

Thanks,
Jake


>  phc2sys.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/phc2sys.c b/phc2sys.c
> index 15dd689..281ec9d 100644
> --- a/phc2sys.c
> +++ b/phc2sys.c
> @@ -730,7 +730,7 @@ static int do_loop(struct phc2sys_private *priv)
>                                                  priv->master->sysoff_method,
>                                                  priv->phc_readings,
>                                                  &offset, &ts, &delay) < 0)
> -                                     return -1;
> +                                     continue;
>                       } else if (priv->master->clkid == CLOCK_REALTIME &&
>                                  clock->sysoff_method >= 0) {
>                               /* use reversed sysoff */
> @@ -738,7 +738,7 @@ static int do_loop(struct phc2sys_private *priv)
>                                                  clock->sysoff_method,
>                                                  priv->phc_readings,
>                                                  &offset, &ts, &delay) < 0)
> -                                     return -1;
> +                                     continue;
>                               offset = -offset;
>                               ts += offset;
>                       } else {
> @@ -747,7 +747,7 @@ static int do_loop(struct phc2sys_private *priv)
>                                                    clock->clkid,
>                                                    priv->phc_readings,
>                                                    &offset, &ts, &delay))
> -                                     return -1;
> +                                     continue;
>                       }
>                       update_clock(priv, clock, offset, ts, delay);
>               }
> --
> 2.35.1
> 
> 
> 
> _______________________________________________
> Linuxptp-devel mailing list
> Linuxptp-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


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

Reply via email to