From patchwork Tue Nov 7 10:39:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 118146 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3810621qgn; Tue, 7 Nov 2017 02:40:47 -0800 (PST) X-Google-Smtp-Source: ABhQp+QcDXtoDBSI3NstLxYQ3qIKg4vnjQZkn1UbTjn6AbY3hVnl+PtjFP7uAwcp5RKLtOH9wsjj X-Received: by 10.84.157.74 with SMTP id u10mr17808988plu.304.1510051247188; Tue, 07 Nov 2017 02:40:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510051247; cv=none; d=google.com; s=arc-20160816; b=txwt1Fep6qmiJpXb6pexnLNFLH9NcLz94U6eFNVIuETb404qbhNXeCQFL2XMIbXrn5 qFeeYqQ7qOKAY2+46Ku2LvjiiGliAlbcNrZxMeYGGMzv/C8HEroWuT5m0LIvupdLgs6B +mn6oiNxBXXfsYOoiY/UK1+fQUc6R1JZTM0MwjUV/GoPBGxilE6Ue4SIzHSsx3Lsvnd6 kc12jWK7QDCkCpWbBkiXTrhpYdoqZlmgWAdHU6Y7yHPCeRloeOWXC/YEl/2fYjSJyV/H +kk+w223r+hvBNswcoD2H8ls1BLDtisoe6c80GYYcnD6EnX9JExZwrP4eyC52MWOC5bX +VeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=66GLylgnH4E5/wBtzunEAvTAoEd/zXa0e5G3eQzYhDs=; b=aeC8oHkEs1X/I2Qkd8TzcR7M4KzYbVSbcPLXOUulSEuUf2fiY+yEt086B6ek0Qxaib gcNiThsMCmqbdVPSLSMgyua4pP4Xto3efh7BdJ8+gckwJYz5ZAvisHlvFji+cimDj9tH 1lUwghJOr8wBM81sU0ldpqPNdRHFXUzP74XHGIHT9FWjRiHn79g/qw9Y7h26WKNOgX7u Dqe2qeSkkdaXKx3Q7O8o4SBjmmQ0/cd6BbQB8HV6SIBpnbQMs9yp3hQt9W5XaZfScEQH uzmcrkAEDuBVHAhTrJYYiPdbl9sxQmDkMXjjJsNZP8qFTs42nBYo0lwnUPjWJYfHqHS8 5m0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r7si828883pgp.220.2017.11.07.02.40.46; Tue, 07 Nov 2017 02:40:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757157AbdKGKkk (ORCPT + 26 others); Tue, 7 Nov 2017 05:40:40 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:65056 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757132AbdKGKkh (ORCPT ); Tue, 7 Nov 2017 05:40:37 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0MKaKl-1eDOLj07rL-001zws; Tue, 07 Nov 2017 11:40:28 +0100 From: Arnd Bergmann To: Valentina Manea , Shuah Khan , Greg Kroah-Hartman Cc: Arnd Bergmann , Johan Hovold , Felipe Balbi , Krzysztof Opasiak , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] usbip: use monotonic timestamps Date: Tue, 7 Nov 2017 11:39:57 +0100 Message-Id: <20171107104010.2884193-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171107104010.2884193-1-arnd@arndb.de> References: <20171107104010.2884193-1-arnd@arndb.de> X-Provags-ID: V03:K0:1Unn8jPrpkbwU0tsIsGpZF7YHH13PmB2Nwxsww31h7PFOlPTxWT XKkOoezgNX9/0urQZVkCGmV9Dqk3v247Z/+D3oA5r4c1+u2ieT814QR+BFSk3nfTV8zq/CC dttCtjp4RbSnrig5Oz2pqdzWvEYAXRZcN6MCX4Fp4BMiAgrix7TxAYkKjjos+AfEEPKfImm POP9UfZtnjqUpcOCW8YOQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:4aX492ivHe0=:NP9JkLLSMcKRUnsSiKNtDs +TbhH4n4gl3e6y2A/Wnud52p2tuu+6EDUKkfHMeYI8AYhyr8KxQK0yV6Ln8I2oTHghqGDGcSz Q0M+GSiJEuduKsMFTIyI741k2WjKZTFXmWMy4ld/lbcLl5tFMYWdjN9NMd5Czz3A/NPj6P5N0 o3D3og3+DmRttDkvzXF/WLCgz9H6pYIEhu2IiGTszSBY59Bbd0rNCdh/tK9Cw/DJIjo8sNEbn ZqoRF6H7MhdA2j8uuV0Xhd2lO2Fs4Y5b5w0TJimAtJXg41jLp7N8lENbdso5kSjNZUT5fvgCl fH93glwPfmCpouJQ0w8w4hWiUnP5KSqdt0QA2EJdR7q5dSJZ577yNFdL5K5hCZQUMUS46ujtX T+E+bD0Nbd6ma/9w9NTs8kjSO0VHFab8tJm/tEtn8K2yrOJsZCsp41irEtJjqtM9OIe+y+8qc aY10dQbgPtap1eoqKMHLs1THq9J6MnPY8b7TDkDZTxLLgfKarbl2MnMQcBZBTbofbwVdNZo8x gGcPKYlu/GL+Pz/oYnCiH+Tl5QH1e2AmrN5HAAUMzxbVbNq2d8CIt7273qEsMoFxuaNOIvQQo px7QaotdVQNSoDinziQBakZaF8VHkA0L1CXRI1eyX3uM6qTJ2nGXWRwcbd7ud+oJw2hPTyCv5 Ortj5TvzOHgQAVVA5k/xgPQTi8D0TZNeuO3pcz1tmeHfnRyTdlXIO2gd/yS9o8Eof3EguGGpa jq429ehSTVB2gpGCWm+dtot024SaBZ2x8VLKGQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This gets rid of the deprecated do_gettimeofday() function in usbip. The comment above vgadget_get_frame() mentions that it suffers from issues with the time jumps due to suspend and settimeofday, so I'm changing it to use ktime_get_ts64() to use monotonic times that don't have this problem. I couldn't tell whether we should use CLOCK_MONOTONIC or CLOCK_MONOTONIC_RAW here, the difference being the exact rate when correcting for NTP. I picked monotonic time since it doesn't change the speed to the existing code and should be better synchronized with other machines we talk to. Signed-off-by: Arnd Bergmann --- drivers/usb/usbip/vudc.h | 2 +- drivers/usb/usbip/vudc_dev.c | 7 +++---- drivers/usb/usbip/vudc_sysfs.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) -- 2.9.0 Reviewed-by: Krzysztof Opasiak Acked-by: Shuah Khan diff --git a/drivers/usb/usbip/vudc.h b/drivers/usb/usbip/vudc.h index 44fb24193acd..8282362176d5 100644 --- a/drivers/usb/usbip/vudc.h +++ b/drivers/usb/usbip/vudc.h @@ -105,7 +105,7 @@ struct vudc { struct usbip_device ud; struct transfer_timer tr_timer; - struct timeval start_time; + struct timespec64 start_time; struct list_head urb_queue; diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c index 16fb4f85a6f6..fe07e799e481 100644 --- a/drivers/usb/usbip/vudc_dev.c +++ b/drivers/usb/usbip/vudc_dev.c @@ -136,15 +136,14 @@ struct vep *vudc_find_endpoint(struct vudc *udc, u8 address) /* gadget ops */ -/* FIXME - this will probably misbehave when suspend/resume is added */ static int vgadget_get_frame(struct usb_gadget *_gadget) { - struct timeval now; + struct timespec64 now; struct vudc *udc = usb_gadget_to_vudc(_gadget); - do_gettimeofday(&now); + ktime_get_ts64(&now); return ((now.tv_sec - udc->start_time.tv_sec) * 1000 + - (now.tv_usec - udc->start_time.tv_usec) / 1000) + (now.tv_nsec - udc->start_time.tv_nsec) / NSEC_PER_MSEC) & 0x7FF; } diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c index 7d978b824ed4..49e0123caa53 100644 --- a/drivers/usb/usbip/vudc_sysfs.c +++ b/drivers/usb/usbip/vudc_sysfs.c @@ -162,7 +162,7 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, udc->ud.status = SDEV_ST_USED; spin_unlock_irq(&udc->ud.lock); - do_gettimeofday(&udc->start_time); + ktime_get_ts64(&udc->start_time); v_start_timer(udc); udc->connected = 1; } else {