Merge branch 'ptp-provide-support-for-auxiliary-clocks-for-ptp_sys_offset_extended'

Thomas Gleixner says:

====================
ptp: Provide support for auxiliary clocks for PTP_SYS_OFFSET_EXTENDED

This is a follow up to the V1 series, which can be found here:

     https://lore.kernel.org/all/20250626124327.667087805@linutronix.de

to address the merge logistics problem, which I created myself.

Changes vs. V1:

    - Make patch 1, which provides the timestamping function temporarily
      define CLOCK_AUX* if undefined so that it can be merged independently,

    - Add a missing check for CONFIG_POSIX_AUX_CLOCK in the PTP IOCTL

    - Picked up tags

Merge logistics if agreed on:

    1) Patch #1 is applied to the tip tree on top of plain v6.16-rc1 and
       tagged

    2) That tag is merged into tip:timers/ptp and the temporary CLOCK_AUX
       define is removed in a subsequent commit

    3) Network folks merge the tag and apply patches #2 + #3

So the only fallout from this are the extra merges in both trees and the
cleanup commit in the tip tree. But that way there are no dependencies and
no duplicate commits with different SHAs.

Thoughts?

Due to the above constraints there is no branch offered to pull from right
now. Sorry for the inconveniance. Should have thought about that earlier.
====================

Link: https://patch.msgid.link/20250701130923.579834908@linutronix.de
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
Paolo Abeni 2025-07-03 15:36:12 +02:00
commit 792eacd324
2 changed files with 23 additions and 35 deletions

View File

@ -325,13 +325,22 @@ static long ptp_sys_offset_extended(struct ptp_clock *ptp, void __user *arg)
if (IS_ERR(extoff))
return PTR_ERR(extoff);
if (extoff->n_samples > PTP_MAX_SAMPLES ||
extoff->rsv[0] || extoff->rsv[1] ||
(extoff->clockid != CLOCK_REALTIME &&
extoff->clockid != CLOCK_MONOTONIC &&
extoff->clockid != CLOCK_MONOTONIC_RAW))
if (extoff->n_samples > PTP_MAX_SAMPLES || extoff->rsv[0] || extoff->rsv[1])
return -EINVAL;
switch (extoff->clockid) {
case CLOCK_REALTIME:
case CLOCK_MONOTONIC:
case CLOCK_MONOTONIC_RAW:
break;
case CLOCK_AUX ... CLOCK_AUX_LAST:
if (IS_ENABLED(CONFIG_POSIX_AUX_CLOCKS))
break;
fallthrough;
default:
return -EINVAL;
}
sts.clockid = extoff->clockid;
for (unsigned int i = 0; i < extoff->n_samples; i++) {
struct timespec64 ts;
@ -340,6 +349,11 @@ static long ptp_sys_offset_extended(struct ptp_clock *ptp, void __user *arg)
err = ptp->info->gettimex64(ptp->info, &ts, &sts);
if (err)
return err;
/* Filter out disabled or unavailable clocks */
if (sts.pre_ts.tv_sec < 0 || sts.post_ts.tv_sec < 0)
return -EINVAL;
extoff->ts[i][0].sec = sts.pre_ts.tv_sec;
extoff->ts[i][0].nsec = sts.pre_ts.tv_nsec;
extoff->ts[i][1].sec = ts.tv_sec;

View File

@ -477,40 +477,14 @@ static inline ktime_t ptp_convert_timestamp(const ktime_t *hwtstamp,
static inline void ptp_read_system_prets(struct ptp_system_timestamp *sts)
{
if (sts) {
switch (sts->clockid) {
case CLOCK_REALTIME:
ktime_get_real_ts64(&sts->pre_ts);
break;
case CLOCK_MONOTONIC:
ktime_get_ts64(&sts->pre_ts);
break;
case CLOCK_MONOTONIC_RAW:
ktime_get_raw_ts64(&sts->pre_ts);
break;
default:
break;
}
}
if (sts)
ktime_get_clock_ts64(sts->clockid, &sts->pre_ts);
}
static inline void ptp_read_system_postts(struct ptp_system_timestamp *sts)
{
if (sts) {
switch (sts->clockid) {
case CLOCK_REALTIME:
ktime_get_real_ts64(&sts->post_ts);
break;
case CLOCK_MONOTONIC:
ktime_get_ts64(&sts->post_ts);
break;
case CLOCK_MONOTONIC_RAW:
ktime_get_raw_ts64(&sts->post_ts);
break;
default:
break;
}
}
if (sts)
ktime_get_clock_ts64(sts->clockid, &sts->post_ts);
}
#endif