From patchwork Fri Jun 30 19:21:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 782962 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3wzmdT0XdMz9s87; Sat, 1 Jul 2017 05:22:53 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="VXlev6MJ"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1dR1VB-000492-Uh; Fri, 30 Jun 2017 19:22:49 +0000 Received: from mail-qk0-f170.google.com ([209.85.220.170]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1dR1UM-0003gC-8N for kernel-team@lists.ubuntu.com; Fri, 30 Jun 2017 19:21:58 +0000 Received: by mail-qk0-f170.google.com with SMTP id d78so108386649qkb.1 for ; Fri, 30 Jun 2017 12:21:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B6mc/l5GR7T1bIkRRiqJoOAJin3IWav6YBMj5DVSACA=; b=VXlev6MJGHSP/KVj9cl+4M1HrlKErLdNPnhJuWH1xVVmnUJu8feTtB+wMZm1OSqOxm 36SQCMffCQg47wpAW7vw6FpcMLY0fc+uy4Zwo4igpGWGEFhzR9i5uXVDmUYzfA9aVmxi EfDDp1BiDd9HLfrllsbHsfaMwBzAbXgbIvCA/n6Y7d1LPNLWACvsLrOmqizSmhVwZMY4 2ZJxaYSwsPKgwuO//nykC1W7NHDexuB+O3IVyc1A4noO8oHwOoKcY98BMjjj0XUdj/L5 zosF5qqFaNKa3E3CzSJ/gSr2hfim46Ke5DGKP3oagnsINdwDt/RewL2jB18z5DxH+U2c nS6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=B6mc/l5GR7T1bIkRRiqJoOAJin3IWav6YBMj5DVSACA=; b=jnXeUK3496FpJIr9J5ur2RHLYRasF10bhSSIh097Jg6l3ON6MavRAPWdLRAM/wiIAW BTmpjqnH7CESL3rEjHF2mgTJAf4MzzshLsv4+nI5mYrEkw52PH5+KKynPgMV5iGohM4j tddYzTWWX391EaAx0a/mTKjasMoto9xGAzgtE5gR7wo2r3ItTipKAzIjV7s/JaU2JWhO V5VS1UkM/2hRqgoHsnW/pXcOfLHqFc6RChig5bbKUKCn7Pg8qLw1o1YK/jXypxqsuBZS SILLnNZGuoeVUi6gpbVsZ1fqpUTrTt5J+Q2gOkSyznjPhTAgEKO8qwsoNHEBAsq9u5qI 2oow== X-Gm-Message-State: AKS2vOwTlLDtas8bucHozZurxoPd+6rOYUeJ/P3SmSHKCSz0OfhHkDzN JH/59o2uKsgwnXlGp3U= X-Received: by 10.55.161.148 with SMTP id k142mr26103110qke.168.1498850516808; Fri, 30 Jun 2017 12:21:56 -0700 (PDT) Received: from localhost.localdomain ([191.8.93.72]) by smtp.gmail.com with ESMTPSA id p24sm6945617qki.49.2017.06.30.12.21.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Jun 2017 12:21:56 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [xenial][PATCH v2 7/8] hv_utils: drop .getcrosststamp() support from PTP driver Date: Fri, 30 Jun 2017 16:21:33 -0300 Message-Id: <1498850494-31277-8-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498850494-31277-1-git-send-email-marcelo.cerri@canonical.com> References: <1498850494-31277-1-git-send-email-marcelo.cerri@canonical.com> Cc: alexng@microsoft.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Vitaly Kuznetsov Turns out that our implementation of .getcrosststamp() never actually worked. Hyper-V is sending time samples every 5 seconds and this is too much for get_device_system_crosststamp() as it's interpolation algorithm (which nobody is currently using in kernel, btw) accounts for a 'slow' device but we're not slow in Hyper-V, our time reference is too far away. .getcrosststamp() is not currently used, get_device_system_crosststamp() almost always returns -EINVAL and client falls back to using PTP_SYS_OFFSET so this patch doesn't change much. I also tried doing interpolation manually (e.g. the same way hv_ptp_gettime() works and it turns out that we're getting even lower quality: PTP_SYS_OFFSET_PRECISE with manual interpolation: * PHC0 0 3 37 4 -3974ns[-5338ns] +/- 977ns * PHC0 0 3 77 7 +2227ns[+3184ns] +/- 576ns * PHC0 0 3 177 10 +3060ns[+5220ns] +/- 548ns * PHC0 0 3 377 12 +3937ns[+4371ns] +/- 1414ns * PHC0 0 3 377 6 +764ns[+1240ns] +/- 1047ns * PHC0 0 3 377 7 -1210ns[-3731ns] +/- 479ns * PHC0 0 3 377 9 +153ns[-1019ns] +/- 406ns * PHC0 0 3 377 12 -872ns[-1793ns] +/- 443ns * PHC0 0 3 377 5 +701ns[+3599ns] +/- 426ns * PHC0 0 3 377 5 -923ns[ -375ns] +/- 1062ns PTP_SYS_OFFSET: * PHC0 0 3 7 5 +72ns[+8020ns] +/- 251ns * PHC0 0 3 17 5 -885ns[-3661ns] +/- 254ns * PHC0 0 3 37 6 -454ns[-5732ns] +/- 258ns * PHC0 0 3 77 10 +1183ns[+3754ns] +/- 164ns * PHC0 0 3 377 5 +579ns[+1137ns] +/- 110ns * PHC0 0 3 377 7 +501ns[+1064ns] +/- 96ns * PHC0 0 3 377 9 +1641ns[+3342ns] +/- 106ns * PHC0 0 3 377 8 -47ns[ +77ns] +/- 160ns * PHC0 0 3 377 5 +54ns[ +107ns] +/- 102ns * PHC0 0 3 377 8 -354ns[ -617ns] +/- 89ns This fact wasn't noticed during the initial testing of the PTP device somehow but got revealed now. Let's just drop .getcrosststamp() implementation for now as it doesn't seem to be suitable for us. Signed-off-by: Vitaly Kuznetsov Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman (cherry picked from linux-next commit 4f9bac039a64f6306b613a0d90e6b7e75d7ab0c4) Signed-off-by: Marcelo Henrique Cerri --- drivers/hv/hv_util.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c index b2cc46e3dd86..0c18c63f6166 100644 --- a/drivers/hv/hv_util.c +++ b/drivers/hv/hv_util.c @@ -220,7 +220,6 @@ static struct adj_time_work wrk; static struct { u64 host_time; u64 ref_time; - struct system_time_snapshot snap; spinlock_t lock; } host_ts; @@ -253,7 +252,6 @@ static inline void adj_guesttime(u64 hosttime, u64 reftime, u8 adj_flags) cur_reftime = hyperv_cs->read(hyperv_cs); host_ts.host_time = hosttime; host_ts.ref_time = cur_reftime; - ktime_get_snapshot(&host_ts.snap); /* * TimeSync v4 messages contain reference time (guest's Hyper-V @@ -528,46 +526,12 @@ static int hv_ptp_gettime(struct ptp_clock_info *info, struct timespec64 *ts) return 0; } -static int hv_ptp_get_syncdevicetime(ktime_t *device, - struct system_counterval_t *system, - void *ctx) -{ - system->cs = hyperv_cs; - system->cycles = host_ts.ref_time; - *device = ns_to_ktime((host_ts.host_time - WLTIMEDELTA) * 100); - - return 0; -} - -static int hv_ptp_getcrosststamp(struct ptp_clock_info *ptp, - struct system_device_crosststamp *xtstamp) -{ - unsigned long flags; - int ret; - - spin_lock_irqsave(&host_ts.lock, flags); - - /* - * host_ts contains the last time sample from the host and the snapshot - * of system time. We don't need to calculate the time delta between - * the reception and now as get_device_system_crosststamp() does the - * required interpolation. - */ - ret = get_device_system_crosststamp(hv_ptp_get_syncdevicetime, - NULL, &host_ts.snap, xtstamp); - - spin_unlock_irqrestore(&host_ts.lock, flags); - - return ret; -} - static struct ptp_clock_info ptp_hyperv_info = { .name = "hyperv", .enable = hv_ptp_enable, .adjtime = hv_ptp_adjtime, .adjfreq = hv_ptp_adjfreq, .gettime64 = hv_ptp_gettime, - .getcrosststamp = hv_ptp_getcrosststamp, .settime64 = hv_ptp_settime, .owner = THIS_MODULE, };