From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751874AbdAMOu6 (ORCPT ); Fri, 13 Jan 2017 09:50:58 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35330 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751609AbdAMOu5 (ORCPT ); Fri, 13 Jan 2017 09:50:57 -0500 Date: Fri, 13 Jan 2017 15:50:48 +0100 From: Richard Cochran To: Vitaly Kuznetsov Cc: Thomas Gleixner , devel@linuxdriverproject.org, linux-kernel@vger.kernel.org, Haiyang Zhang , "K. Y. Srinivasan" , John Stultz , Alex Ng , Stephen Hemminger Subject: Re: [PATCH RFC] hv_utils: implement Hyper-V PTP source Message-ID: <20170113145048.GA29706@localhost.localdomain> References: <20170113130543.7212-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170113130543.7212-1-vkuznets@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 13, 2017 at 02:05:43PM +0100, Vitaly Kuznetsov wrote: > Instead of doing in-kernel time adjustments offload the work to an > NTP client by exposing TimeSync messages as a PTP device. Users my now > decide what they want to use as a source. > > I tested the solution with chrony, the config was: > > refclock PHC /dev/ptp0 poll 3 precision 1e-9 > > The result I'm seeing is accurate enough, the time delta between the guest > and the host is almost always within [-10us, +10us], the in-kernel solution > was giving us comparable results. This approach is much nicer than the previous one. > +static int hv_ptp_enable(struct ptp_clock_info *info, > + struct ptp_clock_request *request, int on) > +{ > + return -EOPNOTSUPP; > +} > + > +static int hv_ptp_gettime(struct ptp_clock_info *info, struct timespec64 *ts) > +{ > + u64 newtime; > + unsigned long flags; > + > + spin_lock_irqsave(&host_ts.lock, flags); > + newtime = host_ts.host_time + get_timeadj_latency(host_ts.ref_time); > + *ts = ns_to_timespec64((newtime - WLTIMEDELTA) * 100); > + spin_unlock_irqrestore(&host_ts.lock, flags); > + > + return 0; > +} > + > +struct ptp_clock_info ptp_hyperv_info = { > + .name = "hyperv", > + .enable = hv_ptp_enable, > + .gettime64 = hv_ptp_gettime, The code in drivers/ptp/ptp_clock.c calls .adjfreq (or adjfine) .adjtime .settime64 unconditionally, so you need to implement these returning EOPNOTSUPP. (See also Documentation/ptp/ptp.txt) > + .owner = THIS_MODULE, > +}; Thanks, Richard