[lkml]   [2010]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Subject[PATCHv2 0/6] pps: time synchronization over LPT
    This patchset adds a complete solution (well, the kernel part) for fast
    high-precision time synchronization between computers using their LPT
    ports. My tests show that it is able to achieve synchronization in the
    order of 1-2 microseconds and keep it for as long as needed. We are
    using this facility in my company for distributed real-time simulation.

    The idea is to have a single master computer whose local clock is used
    as a standard. It then provides time information through both PPS
    high-precision signal over LPT and NTP over network. Then any other
    computer can combine these two time sources (this is what ntpd can do).
    Client-side ntpd constantly checks that the local time divergence from
    the master's time is less then 128ms. If this is true it uses PPS
    signal to further decrease the difference. ntpd can try to do itself
    but it's too slow and imprecise. This is really a job for the kernel.

    All stuff related to the PPS signals in Linux kernel is handled by the
    code from LinuxPPS project. It can be controlled from user-space
    through PPSAPI (RFC 2783) and ntpd can use it to pass control over
    synchronization to the kernel. Unfortunately this is an optional
    feature of PPSAPI and it was not implemented. Also Linux code from
    NTPv4 reference model was missing all the pieces that deal with PPS.
    This patchset closes both gaps to achieve the highest precision and
    speed. It:

    * adds missing hardpps() function to the NTPv4 Linux kernel code

    * adds getnstime_raw_and_real() to atomically get both MONOTONIC_RAW
    and REALTIME clock timestamps for hardpps()

    * adds missing optional PPSAPI method to bind the particular PPS
    source to feed information to the time subsystem through hardpps()

    Also it adds the actual parallel port PPS generator and client.

    This patchset is tested against the vanilla kernel. But we are
    actually using it on rt-preempt kernel most of the time.
    Also there is a version which should be applied on top of LinuxPPS out
    of tree patches (i.e. all clients and low-level irq timestamps stuff).
    Those who are interested in other versions of the patchset can find
    them in my git repository:

    There is one problem however: hardpps() works bad when used on top
    of 2.6.33-rc* with CONFIG_NO_HZ enabled. The reason for this is commit
    a092ff0f90cae22b2ac8028ecd2c6f6c1a9e4601. Without it hardpps() is able
    to sync to 1us precision in about 10 seconds. With it

    v1 -> v2:
    * fix issues pointed out by John Stultz:
    * style fixes
    * add a about the authorship of the original code
    * replace timespec with pps_normtime struct where timespec is used
    in a wrong way
    * fix seqlock usage in hardpps()
    * unbind kernel consumer on device removal
    * send raw timestamp instead of the last difference to hardpps() which
    simplifies the code and is less error-prone
    * update comments in the kernel consumer code to match the reality
    * split the patch that adds MONOTONIC_RAW timestmaps into two
    * other small fixes

    Alexander Gordeev (6):
    ntp: add hardpps implementation
    pps: unify timestamp gathering
    pps: capture MONOTONIC_RAW timestamps as well
    pps: add kernel consumer support
    pps: add parallel port PPS signal generator
    pps: add parallel port PPS client

    Documentation/ioctl/ioctl-number.txt | 2 +-
    drivers/pps/Kconfig | 5 +
    drivers/pps/Makefile | 1 +
    drivers/pps/clients/Kconfig | 16 ++
    drivers/pps/clients/Makefile | 9 +
    drivers/pps/clients/pps_parport.c | 211 +++++++++++++++
    drivers/pps/generators/Kconfig | 17 ++
    drivers/pps/generators/Makefile | 9 +
    drivers/pps/generators/pps_gen_parport.c | 264 +++++++++++++++++++
    drivers/pps/kapi.c | 41 +++-
    drivers/pps/pps.c | 67 +++++-
    include/linux/pps.h | 7 +
    include/linux/pps_kernel.h | 30 ++-
    include/linux/time.h | 2 +
    include/linux/timex.h | 1 +
    kernel/time/Kconfig | 7 +
    kernel/time/ntp.c | 420 ++++++++++++++++++++++++++++-
    kernel/time/timekeeping.c | 34 +++
    18 files changed, 1119 insertions(+), 24 deletions(-)
    create mode 100644 drivers/pps/clients/Kconfig
    create mode 100644 drivers/pps/clients/Makefile
    create mode 100644 drivers/pps/clients/pps_parport.c
    create mode 100644 drivers/pps/generators/Kconfig
    create mode 100644 drivers/pps/generators/Makefile
    create mode 100644 drivers/pps/generators/pps_gen_parport.c

     \ /
      Last update: 2010-02-24 13:31    [W:0.023 / U:207.160 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site