Skip to content

Commit 5a89b27

Browse files
cjubrankuba-moo
authored andcommitted
ptp: Allow exposing cycles only for clocks with free-running counter
The PTP core falls back to gettimex64 and getcrosststamp when getcycles64 or getcyclesx64 are not implemented. This causes the CYCLES ioctls to retrieve PHC real time instead of free-running cycles. Reject PTP_SYS_OFFSET_{PRECISE,EXTENDED}_CYCLES for clocks without free-running counter support since the result would represent PHC real time and system time rather than cycles and system time. Fixes: faf23f5 ("ptp: Add ioctl commands to expose raw cycle counter values") Signed-off-by: Carolina Jubran <cjubran@nvidia.com> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com> Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev> Link: https://patch.msgid.link/20251029083813.2276997-1-cjubran@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 01534d7 commit 5a89b27

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/ptp/ptp_chardev.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,14 @@ long ptp_ioctl(struct posix_clock_context *pccontext, unsigned int cmd,
561561
return ptp_mask_en_single(pccontext->private_clkdata, argptr);
562562

563563
case PTP_SYS_OFFSET_PRECISE_CYCLES:
564+
if (!ptp->has_cycles)
565+
return -EOPNOTSUPP;
564566
return ptp_sys_offset_precise(ptp, argptr,
565567
ptp->info->getcrosscycles);
566568

567569
case PTP_SYS_OFFSET_EXTENDED_CYCLES:
570+
if (!ptp->has_cycles)
571+
return -EOPNOTSUPP;
568572
return ptp_sys_offset_extended(ptp, argptr,
569573
ptp->info->getcyclesx64);
570574
default:

0 commit comments

Comments
 (0)