Skip to content

Commit 792eacd

Browse files
author
Paolo Abeni
committed
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/[email protected] 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 kernel-patches#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 kernel-patches#2 + kernel-patches#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/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 4f38a6d + 17c395b commit 792eacd

File tree

2 files changed

+23
-35
lines changed

2 files changed

+23
-35
lines changed

drivers/ptp/ptp_chardev.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,22 @@ static long ptp_sys_offset_extended(struct ptp_clock *ptp, void __user *arg)
325325
if (IS_ERR(extoff))
326326
return PTR_ERR(extoff);
327327

328-
if (extoff->n_samples > PTP_MAX_SAMPLES ||
329-
extoff->rsv[0] || extoff->rsv[1] ||
330-
(extoff->clockid != CLOCK_REALTIME &&
331-
extoff->clockid != CLOCK_MONOTONIC &&
332-
extoff->clockid != CLOCK_MONOTONIC_RAW))
328+
if (extoff->n_samples > PTP_MAX_SAMPLES || extoff->rsv[0] || extoff->rsv[1])
333329
return -EINVAL;
334330

331+
switch (extoff->clockid) {
332+
case CLOCK_REALTIME:
333+
case CLOCK_MONOTONIC:
334+
case CLOCK_MONOTONIC_RAW:
335+
break;
336+
case CLOCK_AUX ... CLOCK_AUX_LAST:
337+
if (IS_ENABLED(CONFIG_POSIX_AUX_CLOCKS))
338+
break;
339+
fallthrough;
340+
default:
341+
return -EINVAL;
342+
}
343+
335344
sts.clockid = extoff->clockid;
336345
for (unsigned int i = 0; i < extoff->n_samples; i++) {
337346
struct timespec64 ts;
@@ -340,6 +349,11 @@ static long ptp_sys_offset_extended(struct ptp_clock *ptp, void __user *arg)
340349
err = ptp->info->gettimex64(ptp->info, &ts, &sts);
341350
if (err)
342351
return err;
352+
353+
/* Filter out disabled or unavailable clocks */
354+
if (sts.pre_ts.tv_sec < 0 || sts.post_ts.tv_sec < 0)
355+
return -EINVAL;
356+
343357
extoff->ts[i][0].sec = sts.pre_ts.tv_sec;
344358
extoff->ts[i][0].nsec = sts.pre_ts.tv_nsec;
345359
extoff->ts[i][1].sec = ts.tv_sec;

include/linux/ptp_clock_kernel.h

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -477,40 +477,14 @@ static inline ktime_t ptp_convert_timestamp(const ktime_t *hwtstamp,
477477

478478
static inline void ptp_read_system_prets(struct ptp_system_timestamp *sts)
479479
{
480-
if (sts) {
481-
switch (sts->clockid) {
482-
case CLOCK_REALTIME:
483-
ktime_get_real_ts64(&sts->pre_ts);
484-
break;
485-
case CLOCK_MONOTONIC:
486-
ktime_get_ts64(&sts->pre_ts);
487-
break;
488-
case CLOCK_MONOTONIC_RAW:
489-
ktime_get_raw_ts64(&sts->pre_ts);
490-
break;
491-
default:
492-
break;
493-
}
494-
}
480+
if (sts)
481+
ktime_get_clock_ts64(sts->clockid, &sts->pre_ts);
495482
}
496483

497484
static inline void ptp_read_system_postts(struct ptp_system_timestamp *sts)
498485
{
499-
if (sts) {
500-
switch (sts->clockid) {
501-
case CLOCK_REALTIME:
502-
ktime_get_real_ts64(&sts->post_ts);
503-
break;
504-
case CLOCK_MONOTONIC:
505-
ktime_get_ts64(&sts->post_ts);
506-
break;
507-
case CLOCK_MONOTONIC_RAW:
508-
ktime_get_raw_ts64(&sts->post_ts);
509-
break;
510-
default:
511-
break;
512-
}
513-
}
486+
if (sts)
487+
ktime_get_clock_ts64(sts->clockid, &sts->post_ts);
514488
}
515489

516490
#endif

0 commit comments

Comments
 (0)