netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Corallo <ntp-lists@mattcorallo.com>
To: chrony-dev@chrony.tuxfamily.org, Miroslav Lichvar <mlichvar@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [chrony-dev] Support for Multiple PPS Inputs on single PHC
Date: Thu, 16 Feb 2023 09:54:56 -0800	[thread overview]
Message-ID: <0fb552f0-b069-4641-a5c1-48529b56cdbf@bluematt.me> (raw)
In-Reply-To: <Y+3m/PpzkBN9kxJY@localhost>



On 2/16/23 12:19 AM, Miroslav Lichvar wrote:
> On Wed, Feb 15, 2023 at 10:27:15PM -0800, Matt Corallo wrote:
>> My naive solution from skimming the code would be to shove
>> formerly-discarded samples into a global limited queue and check for
>> available timestamps in `phc_poll`. However, I have no idea if the time
>> difference between when the sample was taken by the hardware and when the
>> `HCL_CookTime` call is done would impact accuracy (or maybe the opposite,
>> since we'd then be cooking time with the hardware clock right after taking
>> the HCL sample rather than when the PHC timestamp happens), or if such a
>> patch would simply be rejected as a dirty, dirty hack rather than unifying
>> the PHC read sockets across the devices into one socket (via some global
>> tracking the device -> socket mapping?) and passing the samples out
>> appropriately. Let me know what makes the most sense here.
> 
> My first thought is that this should be addressed in the kernel, so
> even different processes having open the PHC device can receive all
> extts samples. If it turns out it's too difficult to do for the
> character device (I'm not very familiar with that subsystem), maybe it
> could be done at least in sysfs (/sys/class/ptp/ptp*/fifo or a new
> file showing the last event like the PPS assert and clear).

I mean my first thought seeing an ioctl on a socket that gives an explicit channel and then receives 
crap from other channels on the same socket was "wtf" so I went and read the kernel to figure out 
why first to see if its a driver bug. I can't seem to find *any* documentation for how these ioctls 
are supposed to work, but it seems the "request" here is kinda misnomer, its really a "configure 
hardware" request, and is unrelated to future reads on the socket, or really the specific socket at all.

As for duplicating the output across sockets, ptp_chardev.c's `ptp_read` is pretty trivial - just 
pop the next sample off the queue and return it. Tweaking that to copy the sample into every reader 
is probably above my paygrade (and has a whole host of leak risk I'd probably screw up). 
`extts_fifo_show` appears to be functionally identical.

I've CC'd the MAINTAINERs for ptp to see what they think about this, though it won't let chrony 
support this without a kernel upgrade - not sure if that's an issue for chrony or not.

Matt

       reply	other threads:[~2023-02-16 18:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <72ac9741-27f5-36a5-f64c-7d81008eebbc@bluematt.me>
     [not found] ` <Y+3m/PpzkBN9kxJY@localhost>
2023-02-16 17:54   ` Matt Corallo [this message]
2023-02-16 22:54     ` [chrony-dev] Support for Multiple PPS Inputs on single PHC Richard Cochran
2023-02-17  0:58       ` Matt Corallo
2023-02-20 10:08       ` Miroslav Lichvar
2023-02-20 15:24         ` Richard Cochran
2023-02-23 20:56           ` Matt Corallo
2023-02-24  0:19             ` Richard Cochran
2023-02-24  1:18               ` Matt Corallo
2023-02-24  5:07                 ` Richard Cochran
2023-08-29 11:47                   ` Xabier Marquiegui
2023-08-29 11:47                     ` [PATCH] ptp: Demultiplexed timestamp channels Xabier Marquiegui
2023-08-29 14:07                       ` Richard Cochran
2023-08-29 14:15                         ` Richard Cochran
2023-08-30 21:41                         ` [chrony-dev] Support for Multiple PPS Inputs on single PHC Xabier Marquiegui
2023-08-30 21:41                           ` [PATCH] ptp: Demultiplexed timestamp channels Xabier Marquiegui
2023-08-30 22:01                             ` Richard Cochran
2023-09-06 10:47                               ` Xabier Marquiegui
2023-09-06 10:47                                 ` [PATCH 1/3] ptp: Replace timestamp event queue with linked list Xabier Marquiegui
2023-09-06 10:47                                 ` [PATCH 2/3] ptp: support multiple timestamp event readers Xabier Marquiegui
2023-09-06 18:13                                   ` Simon Horman
2023-09-06 22:13                                   ` kernel test robot
2023-09-06 10:47                                 ` [PATCH 3/3] ptp: support event queue reader channel masks Xabier Marquiegui
2023-09-06 18:18                                   ` kernel test robot
2023-08-31  0:29                             ` [PATCH] ptp: Demultiplexed timestamp channels kernel test robot
2023-08-31 13:28                             ` kernel test robot
2023-08-31 16:20                             ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0fb552f0-b069-4641-a5c1-48529b56cdbf@bluematt.me \
    --to=ntp-lists@mattcorallo.com \
    --cc=chrony-dev@chrony.tuxfamily.org \
    --cc=mlichvar@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).