When probing support for a PTP_SYS_OFFSET ioctl, assume errors other than EOPNOTSUPP and EINVAL are temporary errors (some drivers are known to return with EBUSY or EIO). Try the ioctl up to 100 times before giving up on it to make the detection more reliable.
Signed-off-by: Miroslav Lichvar <mlich...@redhat.com> --- sysoff.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sysoff.c b/sysoff.c index 0678df6..660d8aa 100644 --- a/sysoff.c +++ b/sysoff.c @@ -138,7 +138,7 @@ int sysoff_probe(int fd, int n_samples) { int64_t junk, delay; uint64_t ts; - int i; + int i, j, err; if (n_samples > PTP_MAX_SAMPLES) { fprintf(stderr, "warning: %d exceeds kernel max readings %d\n", @@ -148,9 +148,14 @@ int sysoff_probe(int fd, int n_samples) } for (i = 0; i < SYSOFF_LAST; i++) { - if (sysoff_measure(fd, i, n_samples, &junk, &ts, &delay) < 0) - continue; - return i; + for (j = 0; j < 100; j++) { + err = sysoff_measure(fd, i, n_samples, &junk, &ts, + &delay); + if (!err) + return i; + if (err == -EOPNOTSUPP || err == -EINVAL) + break; + } } return SYSOFF_RUN_TIME_MISSING; -- 2.35.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel