Merge "Don't exit when reading of PHC fails with EBUSY"
This commit is contained in:
commit
5136501e29
@ -2,7 +2,7 @@ From da79b26cb5749800112c38cb55b1135f78c3433a Mon Sep 17 00:00:00 2001
|
||||
Message-Id: <da79b26cb5749800112c38cb55b1135f78c3433a.1630421052.git.Jim.Somerville@windriver.com>
|
||||
From: Cole Walker <cole.walker@windriver.com>
|
||||
Date: Mon, 21 Jun 2021 15:24:03 -0400
|
||||
Subject: [PATCH 1/2] Update package versioning for STX format
|
||||
Subject: [PATCH 1/3] Update package versioning for STX format
|
||||
|
||||
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
|
||||
---
|
||||
|
@ -4,7 +4,7 @@ In-Reply-To: <da79b26cb5749800112c38cb55b1135f78c3433a.1630421052.git.Jim.Somerv
|
||||
References: <da79b26cb5749800112c38cb55b1135f78c3433a.1630421052.git.Jim.Somerville@windriver.com>
|
||||
From: Cole Walker <cole.walker@windriver.com>
|
||||
Date: Wed, 23 Jun 2021 13:21:58 -0400
|
||||
Subject: [PATCH 2/2] STX patches for default_sync and BC performance
|
||||
Subject: [PATCH 2/3] STX patches for default_sync and BC performance
|
||||
|
||||
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
|
||||
---
|
||||
|
@ -0,0 +1,40 @@
|
||||
From 0d7ba07f1c39d47b701caf2da0699f4f217d5746 Mon Sep 17 00:00:00 2001
|
||||
From: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
|
||||
Date: Mon, 1 Aug 2022 13:48:40 -0400
|
||||
Subject: [PATCH 3/3] STX patches to fix phc2sys exit with 255
|
||||
|
||||
Signed-off-by: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
|
||||
---
|
||||
SPECS/linuxptp.spec | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/SPECS/linuxptp.spec b/SPECS/linuxptp.spec
|
||||
index e4c01a8..1218533 100644
|
||||
--- a/SPECS/linuxptp.spec
|
||||
+++ b/SPECS/linuxptp.spec
|
||||
@@ -49,6 +49,11 @@ Patch13: 0004-port-Don-t-renew-raw-transport.patch
|
||||
Patch14: 0005-clockcheck-Increase-minimum-interval.patch
|
||||
# StarlingX
|
||||
Patch15: 0006-Add-option-to-disable-default-port-selection-in-phc2.patch
|
||||
+# StarlingX: Upstream commits to fix phc2sys exit with 255
|
||||
+Patch16: 0007-sysoff-Change-sysoff_measure-to-return-errno.patch
|
||||
+Patch17: 0008-sysoff-Change-log-level-of-ioctl-error-messages.patch
|
||||
+Patch18: 0009-sysoff-Retry-on-EBUSY-when-probing-supported-ioctls.patch
|
||||
+Patch19: 0010-phc2sys-Don-t-exit-when-reading-of-PHC-fails-with-EB.patch
|
||||
|
||||
BuildRequires: kernel-headers > 4.18.0-87
|
||||
BuildRequires: systemd
|
||||
@@ -78,6 +83,10 @@ Supporting legacy APIs and other platforms is not a goal.
|
||||
%patch13 -p1
|
||||
%patch14 -p1
|
||||
%patch15 -p1
|
||||
+%patch16 -p1
|
||||
+%patch17 -p1
|
||||
+%patch18 -p1
|
||||
+%patch19 -p1
|
||||
mv linuxptp-testsuite-%{testsuite_ver}* testsuite
|
||||
mv clknetsim-%{clknetsim_ver}* testsuite/clknetsim
|
||||
|
||||
--
|
||||
2.29.2
|
||||
|
@ -1,2 +1,3 @@
|
||||
0001-Update-package-versioning-for-STX-format.patch
|
||||
0002-STX-patches-for-default_sync-and-BC-performance.patch
|
||||
0003-STX-patches-to-fix-phc2sys-exit-with-255.patch
|
||||
|
@ -2,7 +2,7 @@ From 0389752e3aecf8d2b2743f16ce1408a58088bea9 Mon Sep 17 00:00:00 2001
|
||||
Message-Id: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerville@windriver.com>
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Mon, 31 May 2021 11:07:52 +0200
|
||||
Subject: [PATCH 1/6] clock: Reset state when switching port with same best
|
||||
Subject: [PATCH 1/10] clock: Reset state when switching port with same best
|
||||
clock.
|
||||
|
||||
When the best port is changed, but the ID of the best clock doesn't
|
||||
|
@ -4,7 +4,7 @@ In-Reply-To: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerv
|
||||
References: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerville@windriver.com>
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Mon, 31 May 2021 11:07:53 +0200
|
||||
Subject: [PATCH 2/6] clock: Reset clock check on best clock/port change.
|
||||
Subject: [PATCH 2/10] clock: Reset clock check on best clock/port change.
|
||||
|
||||
Reset the clock check when the best clock or port changes, together with
|
||||
the other state like current estimated delay and frequency. This avoids
|
||||
|
@ -4,7 +4,7 @@ In-Reply-To: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerv
|
||||
References: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerville@windriver.com>
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Mon, 31 May 2021 11:07:54 +0200
|
||||
Subject: [PATCH 3/6] port: Don't check timestamps from non-slave ports.
|
||||
Subject: [PATCH 3/10] port: Don't check timestamps from non-slave ports.
|
||||
|
||||
Don't perform the sanity check on receive timestamps from ports in
|
||||
non-slave states to avoid false positives in the jbod mode, where
|
||||
|
@ -4,7 +4,7 @@ In-Reply-To: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerv
|
||||
References: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerville@windriver.com>
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Mon, 31 May 2021 11:07:55 +0200
|
||||
Subject: [PATCH 4/6] port: Don't renew raw transport.
|
||||
Subject: [PATCH 4/10] port: Don't renew raw transport.
|
||||
|
||||
Renewing of the transport on announce/sync timeout is needed in the
|
||||
client-only mode to avoid getting stuck with a broken multicast socket
|
||||
|
@ -4,7 +4,7 @@ In-Reply-To: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630611367.git.Jim.Somerv
|
||||
References: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630611367.git.Jim.Somerville@windriver.com>
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Mon, 31 May 2021 11:07:56 +0200
|
||||
Subject: [PATCH 5/6] clockcheck: Increase minimum interval.
|
||||
Subject: [PATCH 5/10] clockcheck: Increase minimum interval.
|
||||
|
||||
Increase the minimum check interval to 1 second to measure the frequency
|
||||
offset more accurately and with default configuration make false
|
||||
|
@ -4,7 +4,7 @@ In-Reply-To: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerv
|
||||
References: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerville@windriver.com>
|
||||
From: Cole Walker <cole.walker@windriver.com>
|
||||
Date: Wed, 23 Jun 2021 11:14:41 -0400
|
||||
Subject: [PATCH 6/6] Add option to disable default port selection in phc2sys
|
||||
Subject: [PATCH 6/10] Add option to disable default port selection in phc2sys
|
||||
|
||||
This change serves to address an issue in phc2sys
|
||||
where the local ptp clocks are not synced together properly if the local
|
||||
|
@ -0,0 +1,93 @@
|
||||
From 6428c2628c013c408ec09355ad37eb12fa6bb20f Mon Sep 17 00:00:00 2001
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Wed, 18 May 2022 11:33:35 +0200
|
||||
Subject: [PATCH 7/10] sysoff: Change sysoff_measure() to return errno.
|
||||
|
||||
Return -errno from failed ioctl instead of the SYSOFF_* enum from the
|
||||
measurement functions to allow the callers to check for specific errors.
|
||||
|
||||
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
[commit 7824b13db9533ddebe37cf444d7aaa5d235575d3 upstream]
|
||||
Signed-off-by: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
|
||||
---
|
||||
sysoff.c | 15 ++++++++-------
|
||||
sysoff.h | 2 +-
|
||||
2 files changed, 9 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/sysoff.c b/sysoff.c
|
||||
index 2743859..5d3b907 100644
|
||||
--- a/sysoff.c
|
||||
+++ b/sysoff.c
|
||||
@@ -17,6 +17,7 @@
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
+#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
@@ -38,11 +39,11 @@ static int sysoff_precise(int fd, int64_t *result, uint64_t *ts)
|
||||
memset(&pso, 0, sizeof(pso));
|
||||
if (ioctl(fd, PTP_SYS_OFFSET_PRECISE, &pso)) {
|
||||
pr_debug("ioctl PTP_SYS_OFFSET_PRECISE: %m");
|
||||
- return SYSOFF_RUN_TIME_MISSING;
|
||||
+ return -errno;
|
||||
}
|
||||
*result = pctns(&pso.sys_realtime) - pctns(&pso.device);
|
||||
*ts = pctns(&pso.sys_realtime);
|
||||
- return SYSOFF_PRECISE;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static int64_t sysoff_estimate(struct ptp_clock_time *pct, int extended,
|
||||
@@ -98,10 +99,10 @@ static int sysoff_extended(int fd, int n_samples,
|
||||
pso.n_samples = n_samples;
|
||||
if (ioctl(fd, PTP_SYS_OFFSET_EXTENDED, &pso)) {
|
||||
pr_debug("ioctl PTP_SYS_OFFSET_EXTENDED: %m");
|
||||
- return SYSOFF_RUN_TIME_MISSING;
|
||||
+ return -errno;
|
||||
}
|
||||
*result = sysoff_estimate(&pso.ts[0][0], 1, n_samples, ts, delay);
|
||||
- return SYSOFF_EXTENDED;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static int sysoff_basic(int fd, int n_samples,
|
||||
@@ -112,10 +113,10 @@ static int sysoff_basic(int fd, int n_samples,
|
||||
pso.n_samples = n_samples;
|
||||
if (ioctl(fd, PTP_SYS_OFFSET, &pso)) {
|
||||
perror("ioctl PTP_SYS_OFFSET");
|
||||
- return SYSOFF_RUN_TIME_MISSING;
|
||||
+ return -errno;
|
||||
}
|
||||
*result = sysoff_estimate(pso.ts, 0, n_samples, ts, delay);
|
||||
- return SYSOFF_BASIC;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
int sysoff_measure(int fd, int method, int n_samples,
|
||||
@@ -130,7 +131,7 @@ int sysoff_measure(int fd, int method, int n_samples,
|
||||
case SYSOFF_BASIC:
|
||||
return sysoff_basic(fd, n_samples, result, ts, delay);
|
||||
}
|
||||
- return SYSOFF_RUN_TIME_MISSING;
|
||||
+ return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
int sysoff_probe(int fd, int n_samples)
|
||||
diff --git a/sysoff.h b/sysoff.h
|
||||
index e4de919..5480f8f 100644
|
||||
--- a/sysoff.h
|
||||
+++ b/sysoff.h
|
||||
@@ -44,7 +44,7 @@ int sysoff_probe(int fd, int n_samples);
|
||||
* @param result The estimated offset in nanoseconds.
|
||||
* @param ts The system time corresponding to the 'result'.
|
||||
* @param delay The delay in reading of the clock in nanoseconds.
|
||||
- * @return One of the SYSOFF_ enumeration values.
|
||||
+ * @return Zero on success, negative error code otherwise.
|
||||
*/
|
||||
int sysoff_measure(int fd, int method, int n_samples,
|
||||
int64_t *result, uint64_t *ts, int64_t *delay);
|
||||
--
|
||||
2.29.2
|
||||
|
@ -0,0 +1,66 @@
|
||||
From 38a530d94fc5aa73bde424d05e2e38348e64d7e5 Mon Sep 17 00:00:00 2001
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Wed, 18 May 2022 11:33:36 +0200
|
||||
Subject: [PATCH 8/10] sysoff: Change log level of ioctl error messages.
|
||||
|
||||
Change the log level of ioctl error messages to the error level to make
|
||||
them visible in default configuration, with the exception of EOPNOTSUPP
|
||||
which is expected in probing and should stay at the debug level to avoid
|
||||
confusing users.
|
||||
|
||||
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
[commit 270709323a161ff1cb83af511ce50691152c75cf upstream]
|
||||
Signed-off-by: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
|
||||
---
|
||||
sysoff.c | 14 +++++++++++---
|
||||
1 file changed, 11 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/sysoff.c b/sysoff.c
|
||||
index 5d3b907..a425275 100644
|
||||
--- a/sysoff.c
|
||||
+++ b/sysoff.c
|
||||
@@ -28,6 +28,14 @@
|
||||
|
||||
#define NS_PER_SEC 1000000000LL
|
||||
|
||||
+static void print_ioctl_error(const char *name)
|
||||
+{
|
||||
+ if (errno == EOPNOTSUPP)
|
||||
+ pr_debug("ioctl %s: %s", name, strerror(errno));
|
||||
+ else
|
||||
+ pr_err("ioctl %s: %s", name, strerror(errno));
|
||||
+}
|
||||
+
|
||||
static int64_t pctns(struct ptp_clock_time *t)
|
||||
{
|
||||
return t->sec * NS_PER_SEC + t->nsec;
|
||||
@@ -38,7 +46,7 @@ static int sysoff_precise(int fd, int64_t *result, uint64_t *ts)
|
||||
struct ptp_sys_offset_precise pso;
|
||||
memset(&pso, 0, sizeof(pso));
|
||||
if (ioctl(fd, PTP_SYS_OFFSET_PRECISE, &pso)) {
|
||||
- pr_debug("ioctl PTP_SYS_OFFSET_PRECISE: %m");
|
||||
+ print_ioctl_error("PTP_SYS_OFFSET_PRECISE");
|
||||
return -errno;
|
||||
}
|
||||
*result = pctns(&pso.sys_realtime) - pctns(&pso.device);
|
||||
@@ -98,7 +106,7 @@ static int sysoff_extended(int fd, int n_samples,
|
||||
memset(&pso, 0, sizeof(pso));
|
||||
pso.n_samples = n_samples;
|
||||
if (ioctl(fd, PTP_SYS_OFFSET_EXTENDED, &pso)) {
|
||||
- pr_debug("ioctl PTP_SYS_OFFSET_EXTENDED: %m");
|
||||
+ print_ioctl_error("PTP_SYS_OFFSET_EXTENDED");
|
||||
return -errno;
|
||||
}
|
||||
*result = sysoff_estimate(&pso.ts[0][0], 1, n_samples, ts, delay);
|
||||
@@ -112,7 +120,7 @@ static int sysoff_basic(int fd, int n_samples,
|
||||
memset(&pso, 0, sizeof(pso));
|
||||
pso.n_samples = n_samples;
|
||||
if (ioctl(fd, PTP_SYS_OFFSET, &pso)) {
|
||||
- perror("ioctl PTP_SYS_OFFSET");
|
||||
+ print_ioctl_error("PTP_SYS_OFFSET");
|
||||
return -errno;
|
||||
}
|
||||
*result = sysoff_estimate(pso.ts, 0, n_samples, ts, delay);
|
||||
--
|
||||
2.29.2
|
||||
|
@ -0,0 +1,52 @@
|
||||
From 11ae077e31d9957df01aacfa17eea5b5d548b249 Mon Sep 17 00:00:00 2001
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Wed, 18 May 2022 11:33:37 +0200
|
||||
Subject: [PATCH 9/10] sysoff: Retry on EBUSY when probing supported ioctls.
|
||||
|
||||
Handle EBUSY when probing support for a PTP_SYS_OFFSET ioctl. Try each
|
||||
ioctl up to three times before giving up on it to make the detection
|
||||
more reliable.
|
||||
|
||||
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
[commit dadd2593c7beaee9eba5828a7bd8a0b5849dd8bb upstream]
|
||||
Signed-off-by: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
|
||||
---
|
||||
sysoff.c | 14 ++++++++++----
|
||||
1 file changed, 10 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/sysoff.c b/sysoff.c
|
||||
index a425275..fc1f7ca 100644
|
||||
--- a/sysoff.c
|
||||
+++ b/sysoff.c
|
||||
@@ -145,8 +145,8 @@ int sysoff_measure(int fd, int method, int n_samples,
|
||||
int sysoff_probe(int fd, int n_samples)
|
||||
{
|
||||
int64_t junk, delay;
|
||||
+ int i, j, err;
|
||||
uint64_t ts;
|
||||
- int i;
|
||||
|
||||
if (n_samples > PTP_MAX_SAMPLES) {
|
||||
fprintf(stderr, "warning: %d exceeds kernel max readings %d\n",
|
||||
@@ -156,9 +156,15 @@ 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 < 3; j++) {
|
||||
+ err = sysoff_measure(fd, i, n_samples, &junk, &ts,
|
||||
+ &delay);
|
||||
+ if (err == -EBUSY)
|
||||
+ continue;
|
||||
+ if (err)
|
||||
+ break;
|
||||
+ return i;
|
||||
+ }
|
||||
}
|
||||
|
||||
return SYSOFF_RUN_TIME_MISSING;
|
||||
--
|
||||
2.29.2
|
||||
|
@ -0,0 +1,83 @@
|
||||
From e4fd6a930213e6f0f009eb070d51b1e14db60d1b Mon Sep 17 00:00:00 2001
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Wed, 18 May 2022 11:33:38 +0200
|
||||
Subject: [PATCH 10/10] phc2sys: Don't exit when reading of PHC fails with EBUSY.
|
||||
|
||||
Reading of the PHC can occasionally fail with some drivers, e.g. the ice
|
||||
driver returns EBUSY when it fails to get a lock. Continue in the loop
|
||||
instead of exiting on the error.
|
||||
|
||||
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
|
||||
[ commit e8dc364f9fd5fbdac5d2c5e433f28e9da0028d49 upstream
|
||||
We drop two hunks of it, namely the stuff that applies to
|
||||
clockadj_compare, because they apply to the source code
|
||||
ahead of baseline currently used by StarlingX ]
|
||||
|
||||
Signed-off-by: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
|
||||
---
|
||||
phc2sys.c | 31 +++++++++++++++++++------------
|
||||
1 file changed, 19 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/phc2sys.c b/phc2sys.c
|
||||
index 44d6872..7959015 100644
|
||||
--- a/phc2sys.c
|
||||
+++ b/phc2sys.c
|
||||
@@ -722,6 +722,7 @@ static int do_loop(struct phc2sys_private *priv, int subscriptions)
|
||||
struct clock *clock;
|
||||
uint64_t ts;
|
||||
int64_t offset, delay;
|
||||
+ int err;
|
||||
|
||||
interval.tv_sec = priv->phc_interval;
|
||||
interval.tv_nsec = (priv->phc_interval - interval.tv_sec) * 1e9;
|
||||
@@ -765,28 +766,34 @@ static int do_loop(struct phc2sys_private *priv, int subscriptions)
|
||||
if (clock->clkid == CLOCK_REALTIME &&
|
||||
priv->master->sysoff_method >= 0) {
|
||||
/* use sysoff */
|
||||
- if (sysoff_measure(CLOCKID_TO_FD(priv->master->clkid),
|
||||
- priv->master->sysoff_method,
|
||||
- priv->phc_readings,
|
||||
- &offset, &ts, &delay) < 0)
|
||||
- return -1;
|
||||
+ err = sysoff_measure(CLOCKID_TO_FD(priv->master->clkid),
|
||||
+ priv->master->sysoff_method,
|
||||
+ priv->phc_readings,
|
||||
+ &offset, &ts, &delay);
|
||||
} else if (priv->master->clkid == CLOCK_REALTIME &&
|
||||
clock->sysoff_method >= 0) {
|
||||
/* use reversed sysoff */
|
||||
- if (sysoff_measure(CLOCKID_TO_FD(clock->clkid),
|
||||
- clock->sysoff_method,
|
||||
- priv->phc_readings,
|
||||
- &offset, &ts, &delay) < 0)
|
||||
- return -1;
|
||||
- offset = -offset;
|
||||
- ts += offset;
|
||||
+ err = sysoff_measure(CLOCKID_TO_FD(clock->clkid),
|
||||
+ clock->sysoff_method,
|
||||
+ priv->phc_readings,
|
||||
+ &offset, &ts, &delay);
|
||||
+ if (!err) {
|
||||
+ offset = -offset;
|
||||
+ ts += offset;
|
||||
+ }
|
||||
} else {
|
||||
+ err = 0;
|
||||
/* use phc */
|
||||
if (!read_phc(priv->master->clkid, clock->clkid,
|
||||
priv->phc_readings,
|
||||
&offset, &ts, &delay))
|
||||
continue;
|
||||
}
|
||||
+ if (err == -EBUSY)
|
||||
+ continue;
|
||||
+ if (err)
|
||||
+ return -1;
|
||||
+
|
||||
update_clock(priv, clock, offset, ts, delay);
|
||||
}
|
||||
}
|
||||
--
|
||||
2.29.2
|
||||
|
@ -1,7 +1,7 @@
|
||||
From 63b43924294da6cb177d0509120b2e957580441c Mon Sep 17 00:00:00 2001
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Mon, 31 May 2021 11:07:52 +0200
|
||||
Subject: [PATCH] clock: Reset state when switching port with same best clock.
|
||||
Subject: [PATCH 1/10] clock: Reset state when switching port with same best clock.
|
||||
|
||||
When the best port is changed, but the ID of the best clock doesn't
|
||||
change (e.g. a passive port is activated on link failure), reset the
|
||||
|
@ -4,7 +4,7 @@ In-Reply-To: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerv
|
||||
References: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerville@windriver.com>
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Mon, 31 May 2021 11:07:53 +0200
|
||||
Subject: [PATCH 2/6] clock: Reset clock check on best clock/port change.
|
||||
Subject: [PATCH 2/10] clock: Reset clock check on best clock/port change.
|
||||
|
||||
Reset the clock check when the best clock or port changes, together with
|
||||
the other state like current estimated delay and frequency. This avoids
|
||||
|
@ -4,7 +4,7 @@ In-Reply-To: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerv
|
||||
References: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerville@windriver.com>
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Mon, 31 May 2021 11:07:54 +0200
|
||||
Subject: [PATCH 3/6] port: Don't check timestamps from non-slave ports.
|
||||
Subject: [PATCH 3/10] port: Don't check timestamps from non-slave ports.
|
||||
|
||||
Don't perform the sanity check on receive timestamps from ports in
|
||||
non-slave states to avoid false positives in the jbod mode, where
|
||||
|
@ -4,7 +4,7 @@ In-Reply-To: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerv
|
||||
References: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerville@windriver.com>
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Mon, 31 May 2021 11:07:55 +0200
|
||||
Subject: [PATCH 4/6] port: Don't renew raw transport.
|
||||
Subject: [PATCH 4/10] port: Don't renew raw transport.
|
||||
|
||||
Renewing of the transport on announce/sync timeout is needed in the
|
||||
client-only mode to avoid getting stuck with a broken multicast socket
|
||||
|
@ -4,7 +4,7 @@ In-Reply-To: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630611367.git.Jim.Somerv
|
||||
References: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630611367.git.Jim.Somerville@windriver.com>
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Mon, 31 May 2021 11:07:56 +0200
|
||||
Subject: [PATCH 5/6] clockcheck: Increase minimum interval.
|
||||
Subject: [PATCH 5/10] clockcheck: Increase minimum interval.
|
||||
|
||||
Increase the minimum check interval to 1 second to measure the frequency
|
||||
offset more accurately and with default configuration make false
|
||||
|
@ -4,7 +4,7 @@ In-Reply-To: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerv
|
||||
References: <0389752e3aecf8d2b2743f16ce1408a58088bea9.1630418391.git.Jim.Somerville@windriver.com>
|
||||
From: Cole Walker <cole.walker@windriver.com>
|
||||
Date: Wed, 23 Jun 2021 11:14:41 -0400
|
||||
Subject: [PATCH 6/6] Add option to disable default port selection in phc2sys
|
||||
Subject: [PATCH 6/10] Add option to disable default port selection in phc2sys
|
||||
|
||||
This change serves to address an issue in phc2sys
|
||||
where the local ptp clocks are not synced together properly if the local
|
||||
|
@ -0,0 +1,93 @@
|
||||
From 6428c2628c013c408ec09355ad37eb12fa6bb20f Mon Sep 17 00:00:00 2001
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Wed, 18 May 2022 11:33:35 +0200
|
||||
Subject: [PATCH 7/10] sysoff: Change sysoff_measure() to return errno.
|
||||
|
||||
Return -errno from failed ioctl instead of the SYSOFF_* enum from the
|
||||
measurement functions to allow the callers to check for specific errors.
|
||||
|
||||
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
[commit 7824b13db9533ddebe37cf444d7aaa5d235575d3 upstream]
|
||||
Signed-off-by: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
|
||||
---
|
||||
sysoff.c | 15 ++++++++-------
|
||||
sysoff.h | 2 +-
|
||||
2 files changed, 9 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/sysoff.c b/sysoff.c
|
||||
index 2743859..5d3b907 100644
|
||||
--- a/sysoff.c
|
||||
+++ b/sysoff.c
|
||||
@@ -17,6 +17,7 @@
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
+#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
@@ -38,11 +39,11 @@ static int sysoff_precise(int fd, int64_t *result, uint64_t *ts)
|
||||
memset(&pso, 0, sizeof(pso));
|
||||
if (ioctl(fd, PTP_SYS_OFFSET_PRECISE, &pso)) {
|
||||
pr_debug("ioctl PTP_SYS_OFFSET_PRECISE: %m");
|
||||
- return SYSOFF_RUN_TIME_MISSING;
|
||||
+ return -errno;
|
||||
}
|
||||
*result = pctns(&pso.sys_realtime) - pctns(&pso.device);
|
||||
*ts = pctns(&pso.sys_realtime);
|
||||
- return SYSOFF_PRECISE;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static int64_t sysoff_estimate(struct ptp_clock_time *pct, int extended,
|
||||
@@ -98,10 +99,10 @@ static int sysoff_extended(int fd, int n_samples,
|
||||
pso.n_samples = n_samples;
|
||||
if (ioctl(fd, PTP_SYS_OFFSET_EXTENDED, &pso)) {
|
||||
pr_debug("ioctl PTP_SYS_OFFSET_EXTENDED: %m");
|
||||
- return SYSOFF_RUN_TIME_MISSING;
|
||||
+ return -errno;
|
||||
}
|
||||
*result = sysoff_estimate(&pso.ts[0][0], 1, n_samples, ts, delay);
|
||||
- return SYSOFF_EXTENDED;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static int sysoff_basic(int fd, int n_samples,
|
||||
@@ -112,10 +113,10 @@ static int sysoff_basic(int fd, int n_samples,
|
||||
pso.n_samples = n_samples;
|
||||
if (ioctl(fd, PTP_SYS_OFFSET, &pso)) {
|
||||
perror("ioctl PTP_SYS_OFFSET");
|
||||
- return SYSOFF_RUN_TIME_MISSING;
|
||||
+ return -errno;
|
||||
}
|
||||
*result = sysoff_estimate(pso.ts, 0, n_samples, ts, delay);
|
||||
- return SYSOFF_BASIC;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
int sysoff_measure(int fd, int method, int n_samples,
|
||||
@@ -130,7 +131,7 @@ int sysoff_measure(int fd, int method, int n_samples,
|
||||
case SYSOFF_BASIC:
|
||||
return sysoff_basic(fd, n_samples, result, ts, delay);
|
||||
}
|
||||
- return SYSOFF_RUN_TIME_MISSING;
|
||||
+ return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
int sysoff_probe(int fd, int n_samples)
|
||||
diff --git a/sysoff.h b/sysoff.h
|
||||
index e4de919..5480f8f 100644
|
||||
--- a/sysoff.h
|
||||
+++ b/sysoff.h
|
||||
@@ -44,7 +44,7 @@ int sysoff_probe(int fd, int n_samples);
|
||||
* @param result The estimated offset in nanoseconds.
|
||||
* @param ts The system time corresponding to the 'result'.
|
||||
* @param delay The delay in reading of the clock in nanoseconds.
|
||||
- * @return One of the SYSOFF_ enumeration values.
|
||||
+ * @return Zero on success, negative error code otherwise.
|
||||
*/
|
||||
int sysoff_measure(int fd, int method, int n_samples,
|
||||
int64_t *result, uint64_t *ts, int64_t *delay);
|
||||
--
|
||||
2.29.2
|
||||
|
@ -0,0 +1,66 @@
|
||||
From 38a530d94fc5aa73bde424d05e2e38348e64d7e5 Mon Sep 17 00:00:00 2001
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Wed, 18 May 2022 11:33:36 +0200
|
||||
Subject: [PATCH 8/10] sysoff: Change log level of ioctl error messages.
|
||||
|
||||
Change the log level of ioctl error messages to the error level to make
|
||||
them visible in default configuration, with the exception of EOPNOTSUPP
|
||||
which is expected in probing and should stay at the debug level to avoid
|
||||
confusing users.
|
||||
|
||||
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
[commit 270709323a161ff1cb83af511ce50691152c75cf upstream]
|
||||
Signed-off-by: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
|
||||
---
|
||||
sysoff.c | 14 +++++++++++---
|
||||
1 file changed, 11 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/sysoff.c b/sysoff.c
|
||||
index 5d3b907..a425275 100644
|
||||
--- a/sysoff.c
|
||||
+++ b/sysoff.c
|
||||
@@ -28,6 +28,14 @@
|
||||
|
||||
#define NS_PER_SEC 1000000000LL
|
||||
|
||||
+static void print_ioctl_error(const char *name)
|
||||
+{
|
||||
+ if (errno == EOPNOTSUPP)
|
||||
+ pr_debug("ioctl %s: %s", name, strerror(errno));
|
||||
+ else
|
||||
+ pr_err("ioctl %s: %s", name, strerror(errno));
|
||||
+}
|
||||
+
|
||||
static int64_t pctns(struct ptp_clock_time *t)
|
||||
{
|
||||
return t->sec * NS_PER_SEC + t->nsec;
|
||||
@@ -38,7 +46,7 @@ static int sysoff_precise(int fd, int64_t *result, uint64_t *ts)
|
||||
struct ptp_sys_offset_precise pso;
|
||||
memset(&pso, 0, sizeof(pso));
|
||||
if (ioctl(fd, PTP_SYS_OFFSET_PRECISE, &pso)) {
|
||||
- pr_debug("ioctl PTP_SYS_OFFSET_PRECISE: %m");
|
||||
+ print_ioctl_error("PTP_SYS_OFFSET_PRECISE");
|
||||
return -errno;
|
||||
}
|
||||
*result = pctns(&pso.sys_realtime) - pctns(&pso.device);
|
||||
@@ -98,7 +106,7 @@ static int sysoff_extended(int fd, int n_samples,
|
||||
memset(&pso, 0, sizeof(pso));
|
||||
pso.n_samples = n_samples;
|
||||
if (ioctl(fd, PTP_SYS_OFFSET_EXTENDED, &pso)) {
|
||||
- pr_debug("ioctl PTP_SYS_OFFSET_EXTENDED: %m");
|
||||
+ print_ioctl_error("PTP_SYS_OFFSET_EXTENDED");
|
||||
return -errno;
|
||||
}
|
||||
*result = sysoff_estimate(&pso.ts[0][0], 1, n_samples, ts, delay);
|
||||
@@ -112,7 +120,7 @@ static int sysoff_basic(int fd, int n_samples,
|
||||
memset(&pso, 0, sizeof(pso));
|
||||
pso.n_samples = n_samples;
|
||||
if (ioctl(fd, PTP_SYS_OFFSET, &pso)) {
|
||||
- perror("ioctl PTP_SYS_OFFSET");
|
||||
+ print_ioctl_error("PTP_SYS_OFFSET");
|
||||
return -errno;
|
||||
}
|
||||
*result = sysoff_estimate(pso.ts, 0, n_samples, ts, delay);
|
||||
--
|
||||
2.29.2
|
||||
|
@ -0,0 +1,52 @@
|
||||
From 11ae077e31d9957df01aacfa17eea5b5d548b249 Mon Sep 17 00:00:00 2001
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Wed, 18 May 2022 11:33:37 +0200
|
||||
Subject: [PATCH 9/10] sysoff: Retry on EBUSY when probing supported ioctls.
|
||||
|
||||
Handle EBUSY when probing support for a PTP_SYS_OFFSET ioctl. Try each
|
||||
ioctl up to three times before giving up on it to make the detection
|
||||
more reliable.
|
||||
|
||||
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
[commit dadd2593c7beaee9eba5828a7bd8a0b5849dd8bb upstream]
|
||||
Signed-off-by: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
|
||||
---
|
||||
sysoff.c | 14 ++++++++++----
|
||||
1 file changed, 10 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/sysoff.c b/sysoff.c
|
||||
index a425275..fc1f7ca 100644
|
||||
--- a/sysoff.c
|
||||
+++ b/sysoff.c
|
||||
@@ -145,8 +145,8 @@ int sysoff_measure(int fd, int method, int n_samples,
|
||||
int sysoff_probe(int fd, int n_samples)
|
||||
{
|
||||
int64_t junk, delay;
|
||||
+ int i, j, err;
|
||||
uint64_t ts;
|
||||
- int i;
|
||||
|
||||
if (n_samples > PTP_MAX_SAMPLES) {
|
||||
fprintf(stderr, "warning: %d exceeds kernel max readings %d\n",
|
||||
@@ -156,9 +156,15 @@ 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 < 3; j++) {
|
||||
+ err = sysoff_measure(fd, i, n_samples, &junk, &ts,
|
||||
+ &delay);
|
||||
+ if (err == -EBUSY)
|
||||
+ continue;
|
||||
+ if (err)
|
||||
+ break;
|
||||
+ return i;
|
||||
+ }
|
||||
}
|
||||
|
||||
return SYSOFF_RUN_TIME_MISSING;
|
||||
--
|
||||
2.29.2
|
||||
|
@ -0,0 +1,83 @@
|
||||
From e4fd6a930213e6f0f009eb070d51b1e14db60d1b Mon Sep 17 00:00:00 2001
|
||||
From: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
Date: Wed, 18 May 2022 11:33:38 +0200
|
||||
Subject: [PATCH 10/10] phc2sys: Don't exit when reading of PHC fails with EBUSY.
|
||||
|
||||
Reading of the PHC can occasionally fail with some drivers, e.g. the ice
|
||||
driver returns EBUSY when it fails to get a lock. Continue in the loop
|
||||
instead of exiting on the error.
|
||||
|
||||
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
|
||||
|
||||
[ commit e8dc364f9fd5fbdac5d2c5e433f28e9da0028d49 upstream
|
||||
We drop two hunks of it, namely the stuff that applies to
|
||||
clockadj_compare, because they apply to the source code
|
||||
ahead of baseline currently used by StarlingX ]
|
||||
|
||||
Signed-off-by: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
|
||||
---
|
||||
phc2sys.c | 31 +++++++++++++++++++------------
|
||||
1 file changed, 19 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/phc2sys.c b/phc2sys.c
|
||||
index 44d6872..7959015 100644
|
||||
--- a/phc2sys.c
|
||||
+++ b/phc2sys.c
|
||||
@@ -722,6 +722,7 @@ static int do_loop(struct phc2sys_private *priv, int subscriptions)
|
||||
struct clock *clock;
|
||||
uint64_t ts;
|
||||
int64_t offset, delay;
|
||||
+ int err;
|
||||
|
||||
interval.tv_sec = priv->phc_interval;
|
||||
interval.tv_nsec = (priv->phc_interval - interval.tv_sec) * 1e9;
|
||||
@@ -765,28 +766,34 @@ static int do_loop(struct phc2sys_private *priv, int subscriptions)
|
||||
if (clock->clkid == CLOCK_REALTIME &&
|
||||
priv->master->sysoff_method >= 0) {
|
||||
/* use sysoff */
|
||||
- if (sysoff_measure(CLOCKID_TO_FD(priv->master->clkid),
|
||||
- priv->master->sysoff_method,
|
||||
- priv->phc_readings,
|
||||
- &offset, &ts, &delay) < 0)
|
||||
- return -1;
|
||||
+ err = sysoff_measure(CLOCKID_TO_FD(priv->master->clkid),
|
||||
+ priv->master->sysoff_method,
|
||||
+ priv->phc_readings,
|
||||
+ &offset, &ts, &delay);
|
||||
} else if (priv->master->clkid == CLOCK_REALTIME &&
|
||||
clock->sysoff_method >= 0) {
|
||||
/* use reversed sysoff */
|
||||
- if (sysoff_measure(CLOCKID_TO_FD(clock->clkid),
|
||||
- clock->sysoff_method,
|
||||
- priv->phc_readings,
|
||||
- &offset, &ts, &delay) < 0)
|
||||
- return -1;
|
||||
- offset = -offset;
|
||||
- ts += offset;
|
||||
+ err = sysoff_measure(CLOCKID_TO_FD(clock->clkid),
|
||||
+ clock->sysoff_method,
|
||||
+ priv->phc_readings,
|
||||
+ &offset, &ts, &delay);
|
||||
+ if (!err) {
|
||||
+ offset = -offset;
|
||||
+ ts += offset;
|
||||
+ }
|
||||
} else {
|
||||
+ err = 0;
|
||||
/* use phc */
|
||||
if (!read_phc(priv->master->clkid, clock->clkid,
|
||||
priv->phc_readings,
|
||||
&offset, &ts, &delay))
|
||||
continue;
|
||||
}
|
||||
+ if (err == -EBUSY)
|
||||
+ continue;
|
||||
+ if (err)
|
||||
+ return -1;
|
||||
+
|
||||
update_clock(priv, clock, offset, ts, delay);
|
||||
}
|
||||
}
|
||||
--
|
||||
2.29.2
|
||||
|
@ -4,3 +4,7 @@
|
||||
0004-port-Don-t-renew-raw-transport.patch
|
||||
0005-clockcheck-Increase-minimum-interval.patch
|
||||
0006-Add-option-to-disable-default-port-selection-in-phc2.patch
|
||||
0007-sysoff-Change-sysoff_measure-to-return-errno.patch
|
||||
0008-sysoff-Change-log-level-of-ioctl-error-messages.patch
|
||||
0009-sysoff-Retry-on-EBUSY-when-probing-supported-ioctls.patch
|
||||
0010-phc2sys-Don-t-exit-when-reading-of-PHC-fails-with-EB.patch
|
||||
|
Loading…
Reference in New Issue
Block a user