From: Przemek Kitszel <przemyslaw.kits...@intel.com> With neither caller nor poll() itself zeroing errno value, it will contain result of previous failure, possibly from long time ago.
Reporting errno=0 up from sk_receive() would bring confusion, as "%m" is later used in pr_err() (so one would get "error Success"). Use ETIME as it fits here the best. (ETIMEDOUT instead of ETIME would look better in the code, but message printed would be worse). Prior to this patch, following log could be produced: | timed out while polling for tx timestamp increasing | tx_timestamp_timeout may correct this issue, but it is likely caused | by a driver bug PTP send sync failed : error No such device or address With this patch applied, one will get proper error in last line, "Timer expired". Signed-off-by: Przemek Kitszel <przemyslaw.kits...@intel.com> Signed-off-by: Lukasz Plachno <lukasz.plac...@intel.com> --- sk.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sk.c b/sk.c index a72aca3b7821..19395c92f08d 100644 --- a/sk.c +++ b/sk.c @@ -441,12 +441,16 @@ int sk_receive(int fd, void *buf, int buflen, /* Retry once on EINTR to avoid logging errors before exit */ if (res < 0 && errno == EINTR) res = poll(&pfd, 1, sk_tx_timeout); - if (res < 1) { - pr_err(res ? "poll for tx timestamp failed: %m" : - "timed out while polling for tx timestamp"); - pr_err("increasing tx_timestamp_timeout may correct " - "this issue, but it is likely caused by a driver bug"); + if (res < 0) { + pr_err("poll for tx timestamp failed: %m"); return -errno; + } else if (!res) { + pr_err("timed out while polling for tx timestamp"); + pr_err("increasing tx_timestamp_timeout or increasing " + "kworker priority may correct this issue, " + "but a driver bug likely causes it"); + errno = ETIME; + return -1; } else if (!(pfd.revents & sk_revents)) { pr_err("poll for tx timestamp woke up on non ERR event"); return -1; -- 2.34.1 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel