On 8/12/2020 2:40 PM, Keller, Jacob E wrote:
> 
> 
>> -----Original Message-----
>> From: Richard Cochran <richardcoch...@gmail.com>
>> Sent: Wednesday, August 12, 2020 8:40 AM
>> To: Keller, Jacob E <jacob.e.kel...@intel.com>
>> Cc: linuxptp-devel@lists.sourceforge.net
>> Subject: Re: [Linuxptp-devel] [RFC PATCH 01/15] posix_clock_open: derive PHC
>> index from device name if possible
>>
>> On Wed, Aug 05, 2020 at 04:12:02PM -0700, Jacob Keller wrote:
>>> Here, we are making the implicit assumption that all ptp clock devices
>>> will always have /dev/ptpX format. I don't think anyone is crazy enough
>>> to rename these devices...
>>
>> (Not yet, anyways  ;^)
>>
>>> An alternative (requiring kernel implementation maybe?) would be to read
>>> the phc index from the kernel somehow. It doesn't look like this is
>>> exported anywhere else besides the name.
>>
>> How about /sys/class/ptp/ptpX/clock_index ?
>>
>> Is that something you would like to code up for the lkml?
>>
>> Thanks,
>> Richard
> 
> To make this fully work we'll probably want to adjust the LinuxPTP code base 
> with a phc_index_to_dev function that scans the sys/class/ptp folder for the 
> matching clock based on the index to obtain the name. I'll see about adding 
> that as well (with a fallback to attempting /dev/ptpX if clock_index doesn't 
> exist)
> 
> Thanks,
> Jake
> 

So I looked at this, and implementing the kernel side is trivial (less
than a dozen lines of code).

However, I'm not sure how valuable it would be as a sysfs thing.

So, there are two ways to rename devices (besides modifying the kernel
to use a different naming scheme) in udev. We can either totally rename
them, or provide a symlink alias.

It looks like recent-ish versions of udev don't support renaming
non-network devices. However, symlinks still work.

If we know the actual kernel device name, then looking up the
clock_index via the sysfs works: (take the kernel name and append it to
/sys/class/ptp/ to get the folder).

But if we just have a symlink, I'm not sure how the application can get
back to the original kernel name?

I am also not sure if udev device rename actually changes the folder
names in sysfs or not. I suspect it does not, but can't confirm because
I've only got systems with newer udev that do not allow renaming other
types of devices.

I do think having clock_index exposed is valuable still, since it
provides a more guaranteed method of matching the index to the device.
It solves the case where the device has been renamed on the kernel side
at least.

If we also exposed the clock index via something like get_caps then it
would work from the device node as an ioctl.


_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to