Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932952Ab0BCVHh (ORCPT ); Wed, 3 Feb 2010 16:07:37 -0500 Received: from gate.lvk.cs.msu.su ([158.250.17.1]:40332 "EHLO mail.lvk.cs.msu.su" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932900Ab0BCVHO (ORCPT ); Wed, 3 Feb 2010 16:07:14 -0500 X-Spam-ASN: From: Alexander Gordeev To: linux-kernel@vger.kernel.org Cc: linuxpps@ml.enneenne.com, "Nikita V\. Youshchenko" , stas@lvk.cs.msu.su, Alexander Gordeev Subject: [PATCH 0/5] pps: time synchronization over LPT Date: Wed, 3 Feb 2010 23:56:46 +0300 Message-Id: X-Mailer: git-send-email 1.6.5 X-AV-Checked: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4222 Lines: 83 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 the actual parallel port PPS generator and client were added. (I know that not yet mainlined LinuxPPS patches provide an own parallel port client but it is actually a hack on lp driver which I didn't like at all.) This patchset is tested against the vanilla 2.6.32.7 kernel. But we are actually using it on 2.6.31.12-rt20 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: http://lvk.cs.msu.su/~lasaine/timesync/linux-2.6-timesync.git Alexander Gordeev (5): ntp: add hardpps implementation 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 | 263 +++++++++++++++++++++++ drivers/pps/kapi.c | 45 ++++- drivers/pps/pps.c | 67 ++++++- include/linux/pps.h | 7 + include/linux/pps_kernel.h | 39 ++++- include/linux/time.h | 2 + include/linux/timex.h | 1 + kernel/time/Kconfig | 7 + kernel/time/ntp.c | 346 +++++++++++++++++++++++++++++- kernel/time/timekeeping.c | 34 +++ 18 files changed, 1065 insertions(+), 16 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/