From a914140bd460b921ab6fd6fb29eb572f77d83a5b Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 10 Apr 2024 12:05:57 +0200 Subject: [PATCH] sys_linux: disable other external timestamping channels Use new ioctls added in Linux 6.7 to disable receiving events from other channels when enabling external timestamping on a PHC. This should save some CPU time when other applications or chronyd instances are using other channels of the same PHC. --- sys_linux.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys_linux.c b/sys_linux.c index 6849637..5fe9c0e 100644 --- a/sys_linux.c +++ b/sys_linux.c @@ -990,6 +990,14 @@ SYS_Linux_SetPHCExtTimestamping(int fd, int pin, int channel, return 0; } +#if defined(PTP_MASK_CLEAR_ALL) && defined(PTP_MASK_EN_SINGLE) + /* Disable events from other channels on this descriptor */ + if (ioctl(fd, PTP_MASK_CLEAR_ALL)) + DEBUG_LOG("ioctl(%s) failed : %s", "PTP_MASK_CLEAR_ALL", strerror(errno)); + else if (ioctl(fd, PTP_MASK_EN_SINGLE, &channel)) + DEBUG_LOG("ioctl(%s) failed : %s", "PTP_MASK_EN_SINGLE", strerror(errno)); +#endif + return 1; }