On 11/17/2022 1:34 PM, Geva, Erez wrote:
On Thu, 2022-11-17 at 18:27 +0000, Keller, Jacob E wrote:
-----Original Message-----
From: Geva, Erez <erez.geva....@siemens.com>
Sent: Thursday, November 17, 2022 9:13 AM
To: Keller, Jacob E <jacob.e.kel...@intel.com>; linuxptp-
de...@lists.sourceforge.net
Subject: Re: [Linuxptp-devel] [PATCH 2/2] phc_ctl: use
PTP_CLOCK_GETCAPS2
ioctl if available
On Tue, 2022-11-15 at 16:43 -0800, Jacob Keller wrote:
The PTP_CLOCK_GETCAPS2 ioctl is provided by kernel as a
replacement
for the
original PTP_CLOCK_GETCAPS ioctl. This was done in order to
provide
ioctls
which guarantee reserved fields are properly initialized. In
practice
the
PTP_CLOCK_GETCAPS2 and PTP_CLOCK_GETCAPS both behave identically
since
Exactly, that is why I send a patch to add the new 'adjust_phase'
in
do_caps(), without changing the ioctl itself :-)
The reason PTP_CLOCK_GETCAPS2 was created was around the same time as
the other ioctls were fixed to properly a) validate reserved fields
and b) ensure that all reported reserved fields were zeroed.
Functionally its 100% identical to PTP_CLOCK_GETCAPS because this
ioctl already did the right thing.
The reason I propose switching to PTP_CLOCK_GETCAPS2 over
PTP_CLOCK_GETCAPS is because it reduces cognitive burden to REMEMBER
that the old PTP_CLOCK_GETCAPS is ok. All I remembered was "the non-2
ioctls might be broken and not receive new features".
PTP_CLOCK_GETCAPS always zeroed the caps structure. However, it
is
good
practice to use the newer version consistently.
But, it can also breaks when using the new linuxptp version build
on
new machine, but used with old kernel.
It may be reasonable in few years, when these old kernels becomes
obsolete.
This uses a fallback to PTP_CLOCK_GETCAPS if PTP_CLOCK_GETCAPS2 is
not found.
The problem is the fallback works only on build.
But if the build system is newer than the running system, the fallback
will fail, as you will use the PTP_CLOCK_GETCAPS2 which does not exist
on the running old system.
Fair. We likely have the same problem with some of the other "2" ioctls,
since they're handled in a similar way. I think we do the Right(TM)
thing for the sysoff.c where we probe the kernel at run-time. This could
be done here but is probably not really worth it considering that
PTP_CLOCK_GETCAPS functions the same way as PTP_CLOCK_GETCAPS2 for all
kernels I checked... So I guess this is somewhat less likely.
I'm not sure if our other PTP ioctls are checked properly like this at
run time...
If I may, this is the classic gap, Hardware companies fail to
understand.
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel