Skip to contentSkip to conversation

Let the ADJ_OFFSET interface respect the ADJ_NANO flag for PHC devices.

PATCH Applied Richard Cochran 3 participants 3 messages May 24, 2020 – May 26, 2020

Subsystems (3)
lore
Share & tools
lore

Richard Cochran

author maintainer
#0 lore raw

PATCH v2 1/1 Let the ADJ_OFFSET interface respect the ADJ_NANO flag for PHC devices.

In commit 184ecc9eb260d5a3bcdddc5bebd18f285ac004e9 ("ptp: Add adjphase function to support phase offset control.") the PTP Hardware Clock interface expanded to support the ADJ_OFFSET offset mode. However, the implementation did not respect the traditional yet pedantic distinction between units of microseconds and nanoseconds signaled by the ADJ_NANO flag. This patch fixes the issue by adding logic to handle that flag.

---
 drivers/ptp/ptp_clock.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/ptp/ptp_clock.c +8 -2
index fc984a8828fb..03a246e60fd9 100644
@@ -147,8 +147,14 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx)
 			err = ops->adjfreq(ops, ppb);
 		ptp->dialed_frequency = tx->freq;
 	} else if (tx->modes & ADJ_OFFSET) {
-		if (ops->adjphase)
-			err = ops->adjphase(ops, tx->offset);
+		if (ops->adjphase) {
+			s32 offset = tx->offset;
+
+			if (!(tx->modes & ADJ_NANO))
+				offset *= NSEC_PER_USEC;
+
+			err = ops->adjphase(ops, offset);
+		}
 	} else if (tx->modes == 0) {
 		tx->freq = ptp->dialed_frequency;
 		err = 0;
Signature · 1 line
2.20.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 25 lines · Richard Cochran

In commit 184ecc9eb260d5a3bcdddc5bebd18f285ac004e9 ("ptp: Add adjphase function to support phase offset control.") the PTP Hardware Clock interface expanded to support the ADJ_OFFSET offset mode. However, the implementation did not respect the traditional yet pedantic distinction between units of microseconds and nanoseconds signaled by the ADJ_NANO flag. This patch fixes the issue by adding logic to handle that flag.

---
drivers/ptp/ptp_clock.c | 10 ++++++++--

1 file changed, 8 insertions(+), 2 deletions(-)
drivers/ptp/ptp_clock.c +1 -2
index fc984a8828fb..03a246e60fd9 100644
@@ -147,8 +147,14 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx)
 			err = ops->adjfreq(ops, ppb);
 		ptp->dialed_frequency = tx->freq;
 	} else if (tx->modes & ADJ_OFFSET) {
-		if (ops->adjphase)
-			err = ops->adjphase(ops, tx->offset);
+		if (ops->adjphase) {

drivers/ptp/ptp_clock.c static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx) · line 160

Quoted 10 lines
drivers/ptp/ptp_clock.c +7 -0
+			s32 offset = tx->offset;
+
+			if (!(tx->modes & ADJ_NANO))
+				offset *= NSEC_PER_USEC;
+
+			err = ops->adjphase(ops, offset);
+		}
 	} else if (tx->modes == 0) {
 		tx->freq = ptp->dialed_frequency;
 		err = 0;

Hi Richard,

Oops. Thank-you for the fix.

Thanks,
Vincent

maintainer Applied
#2 lore raw
In reply to Richard Cochran

From: Richard Cochran <[email protected]>
Date: Sun, 24 May 2020 11:27:10 -0700

Quoted 9 lines

In commit 184ecc9eb260d5a3bcdddc5bebd18f285ac004e9 ("ptp: Add adjphase function to support phase offset control.") the PTP Hardware Clock interface expanded to support the ADJ_OFFSET offset mode. However, the implementation did not respect the traditional yet pedantic distinction between units of microseconds and nanoseconds signaled by the ADJ_NANO flag. This patch fixes the issue by adding logic to handle that flag.

Applied, thanks Richard.