mbox series

[net-next,0/2] ptp: Introduce .getfine callback to ptp_clock_info

Message ID 20221202201528.26634-1-rrameshbabu@nvidia.com (mailing list archive)
Headers show
Series ptp: Introduce .getfine callback to ptp_clock_info | expand

Message

Rahul Rameshbabu Dec. 2, 2022, 8:15 p.m. UTC
The current state of the ptp driver provides the ability to query the frequency
of the ptp clock device by caching the frequency values used in previous
adjustments done through the ptp driver. This works great when the ptp driver is
the only means for changing the clock frequency. However, some devices support
ways to adjust the frequency outside the ptp driver stack. When this occurs, the
ptp cached value is inaccurate. Also, if the device for some reason does not
start with a frequency of zero, the initial frequency queried before the first
frequency adjustment would be inaccurate.

The changes proposed enable a callback that various drivers can implement to
provide the frequency, in units of scaled ppm, of the ptp clock. When the
callback is implemented, it will be called to provide the frequency value
instead of the cached dialed_frequency value.

There are cases in linuxptp usage where the caching of the frequency has proven
to be inadequate. One example was the case where concurrent ptp4l processes
adjust frequency, but the cached frequency values in the ptp4l processes are
stale. Permitting implementers the ability to provide the frequency would
resolve issues involving stale frequency values due to changes occurring outside
the ptp driver stack.

https://sourceforge.net/p/linuxptp/mailman/message/37720193/

Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>

Rahul Rameshbabu (2):
  ptp: Add .getfine function to support reporting frequency offset from
    hardware
  net/mlx5: Implement ptp_clock_info .getfine function

 .../ethernet/mellanox/mlx5/core/lib/clock.c   | 35 +++++++++++++++++++
 drivers/ptp/ptp_clock.c                       | 18 +++++++++-
 include/linux/ptp_clock_kernel.h              |  6 ++++
 3 files changed, 58 insertions(+), 1 deletion(-)

Comments

Richard Cochran Dec. 2, 2022, 8:45 p.m. UTC | #1
On Fri, Dec 02, 2022 at 12:15:27PM -0800, Rahul Rameshbabu wrote:
> The current state of the ptp driver provides the ability to query the frequency
> of the ptp clock device by caching the frequency values used in previous
> adjustments done through the ptp driver. This works great when the ptp driver is
> the only means for changing the clock frequency. However, some devices support
> ways to adjust the frequency outside the ptp driver stack.

The kernel provides no other way to adjust the frequency.

So NAK on this series.

Thanks,
Richard
Jacob Keller Dec. 2, 2022, 10:11 p.m. UTC | #2
On 12/2/2022 12:45 PM, Richard Cochran wrote:
> On Fri, Dec 02, 2022 at 12:15:27PM -0800, Rahul Rameshbabu wrote:
>> The current state of the ptp driver provides the ability to query the frequency
>> of the ptp clock device by caching the frequency values used in previous
>> adjustments done through the ptp driver. This works great when the ptp driver is
>> the only means for changing the clock frequency. However, some devices support
>> ways to adjust the frequency outside the ptp driver stack.
> 
> The kernel provides no other way to adjust the frequency.
> 
> So NAK on this series.
> 
> Thanks,
> Richard
> 

Agreed. Just because your driver does something silly such as modifying 
the frequency out of band of PTP stack doesn't mean we need to support it.

As for running multiple ptp4l instances on the same PTP clock, we 
already have the ability to report the frequency out to user space. The 
ptp4l application checks this at init but then begins assuming that it 
is the only software controlling the clock. That seems like a reasonable 
assumption to me. If you want to write your own user space software 
which handles this, you already have the mechanism to do so.

Thanks,
Jake