From patchwork Thu Dec 7 18:13:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 10100765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C835D602BF for ; Thu, 7 Dec 2017 18:14:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEB18285A7 for ; Thu, 7 Dec 2017 18:14:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3193285B9; Thu, 7 Dec 2017 18:14:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56B68285A7 for ; Thu, 7 Dec 2017 18:14:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754744AbdLGSOI (ORCPT ); Thu, 7 Dec 2017 13:14:08 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:44300 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753914AbdLGSNT (ORCPT ); Thu, 7 Dec 2017 13:13:19 -0500 Received: by mail-pf0-f194.google.com with SMTP id m26so5260463pfj.11; Thu, 07 Dec 2017 10:13:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lqQzXJb5xllZi/3efMXqCuD/hY+pnJB80agHzxJBBfk=; b=OBxZIQ+Hy1xEFiyHl5/8WRv7GeEHyJbYux4yMEvH0lDuZhWOXGqxYgL5onLnSDl3i3 uV9QWkeUgcKk6UOdbbpcPXBACm7lDMDCOH3+raRlVe8isFgNyvVJMoqG3WnVpyH6w0jp t0euRBApxr1kNLGFs9+pYWAPhxfCIeQeJs/iaWN/RKa05ja5DcbDHAVnmD8zTikLIHIW YAfljEAiujwpj8Pdmt0TUVaRvj1nlZIkRgMbUeTeiBv/IHgKTxeaVuxteFfSFyYiq+SE mptOUE0YluXooIl2ezs/fEzIqllHC3Dw4lYe2ETyYO/xDZG1Vd2kMM7wTKJt8mJvQXTX yvKA== 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=lqQzXJb5xllZi/3efMXqCuD/hY+pnJB80agHzxJBBfk=; b=qbf99kS4GGGFrrp4fXopmXKv/AZ8PPfuNSMa/hUGqsS1PGVX+rbLM9tq7r2jPY6Hs5 MMGUO4U5UwpQmBGtOX37vcATiz5Qxn08/8WS/Na7ccFUXwJU7W2/RHUIXykKNVqeYQGY 79dtn8UmJaVcuQcZI1bEikzxCr0Xtxa+qpP4c73n9JzJM0QmWbhC04qVuP4TMc17Roz/ Dd8BErArIV5GMVItRsZZ9ux4iBnEfp+ajwQTYqUfFiydx+Jt+caDOR4wV/2fCBX4Px02 0YrUiEyM/wM8bS31CrlTvqaD1JB7ye8PNzdhXFYKjkVZAcEWeJ1bOL6FLiApDDPvCR1O xaJQ== X-Gm-Message-State: AJaThX5x8O6NN/aOLbyzfQa7rVcsWvomW+g33k43RqEcbqaV6ne3KNjO Xn48qXVasW4h8ZpGAIK/mIc= X-Google-Smtp-Source: AGs4zMbNNNhHjvuxX/KE3f6q8c8uxgBa5J183ujrD7fyDFEWn2hqTPpi12VM/TRX9VxafpvJjOJz8w== X-Received: by 10.99.95.12 with SMTP id t12mr27289794pgb.40.1512670398855; Thu, 07 Dec 2017 10:13:18 -0800 (PST) Received: from deepa-ubuntu.hsd1.ca.comcast.net ([2601:647:5000:6620:8c9c:e0f7:c7ba:c1de]) by smtp.gmail.com with ESMTPSA id t202sm8634299pgb.75.2017.12.07.10.13.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 10:13:18 -0800 (PST) From: Deepa Dinamani To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: peter.hutterer@who-t.net, arnd@arndb.de, y2038@lists.linaro.org Subject: [PATCH v4 1/4] uinput: Use monotonic times for uinput timestamps. Date: Thu, 7 Dec 2017 10:13:03 -0800 Message-Id: <20171207181306.5623-2-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171207181306.5623-1-deepa.kernel@gmail.com> References: <20171207181306.5623-1-deepa.kernel@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP struct timeval which is part of struct input_event to maintain the event times is not y2038 safe. Real time timestamps are also not ideal for input_event as this time can go backwards as noted in the patch a80b83b7b8 by John Stultz. The patch switches the timestamps to use monotonic time from realtime time. This is assuming no one is using absolute times from these timestamps. The structure to maintain input events will be changed in a different patch. Signed-off-by: Deepa Dinamani Reviewed-by: Arnd Bergmann --- drivers/input/misc/uinput.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 39ddd9a73feb..d521aecbc078 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c @@ -84,11 +84,14 @@ static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) { struct uinput_device *udev = input_get_drvdata(dev); + struct timespec64 ts; udev->buff[udev->head].type = type; udev->buff[udev->head].code = code; udev->buff[udev->head].value = value; - do_gettimeofday(&udev->buff[udev->head].time); + ktime_get_ts64(&ts); + udev->buff[udev->head].time.tv_sec = ts.tv_sec; + udev->buff[udev->head].time.tv_usec = ts.tv_nsec / NSEC_PER_USEC; udev->head = (udev->head + 1) % UINPUT_BUFFER_SIZE; wake_up_interruptible(&udev->waitq);