Skip to content

Commit df084af

Browse files
author
CKI Backport Bot
committed
ptp: allow reading of currently dialed frequency to succeed on free-running clocks
JIRA: https://issues.redhat.com/browse/RHEL-115596 commit aa112cb Author: Vladimir Oltean <vladimir.oltean@nxp.com> Date: Fri Jun 13 20:47:49 2025 +0300 ptp: allow reading of currently dialed frequency to succeed on free-running clocks There is a bug in ptp_clock_adjtime() which makes it refuse the operation even if we just want to read the current clock dialed frequency, not modify anything (tx->modes == 0). That should be possible even if the clock is free-running. For context, the kernel UAPI is the same for getting and setting the frequency of a POSIX clock. For example, ptp4l errors out at clock_create() -> clockadj_get_freq() -> clock_adjtime() time, when it should logically only have failed on actual adjustments to the clock, aka if the clock was configured as slave. But in master mode it should work. This was discovered when examining the issue described in the previous commit, where ptp_clock_freerun() returned true despite n_vclocks being zero. Fixes: 73f3706 ("ptp: support ptp physical/virtual clocks conversion") Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://patch.msgid.link/20250613174749.406826-3-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>
1 parent 75fe1e0 commit df084af

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/ptp/ptp_clock.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx)
121121
struct ptp_clock_info *ops;
122122
int err = -EOPNOTSUPP;
123123

124-
if (ptp_clock_freerun(ptp)) {
124+
if (tx->modes & (ADJ_SETOFFSET | ADJ_FREQUENCY | ADJ_OFFSET) &&
125+
ptp_clock_freerun(ptp)) {
125126
pr_err("ptp: physical clock is free running\n");
126127
return -EBUSY;
127128
}

0 commit comments

Comments
 (0)