From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758762AbcIMO7e (ORCPT ); Tue, 13 Sep 2016 10:59:34 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:59048 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752971AbcIMO7d (ORCPT ); Tue, 13 Sep 2016 10:59:33 -0400 From: Arnd Bergmann To: Deepa Dinamani Cc: Dmitry Torokhov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org Subject: Re: [PATCH 3/4] input: Deprecate real timestamps beyond year 2106 Date: Tue, 13 Sep 2016 16:59:28 +0200 Message-ID: <295456784.VzTNlDXujm@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <1473775805-2242-4-git-send-email-deepa.kernel@gmail.com> References: <1473775805-2242-1-git-send-email-deepa.kernel@gmail.com> <1473775805-2242-4-git-send-email-deepa.kernel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:/a+zWcUCSEQXqr0IoWZd/T6s416GmFsYQTBsM2O7YyolewD3Xx6 dsCfelXpJjfE00MWZYAcfwbginllGxUD4d7YxEElae8TIj3DUGNN4odLJ2XCWox1pBRCvOw UWRCLfK/xx36ZZsOmyEQq5X/jCwBCr0fbTCe260Nbh4TcIq4mX4IaM5Fz69Jy+QBBoGq7xR /O7OYoaqVMre0H+H2fooQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:w8xiydQNCYs=:CqMmG+XKz8pI+Vpu6GDs4B E2HkzxmPZoLdt34J55qNqnpzreUhNDIS49hE4FSPnX1WTkQUHDBOCF2B55/FHd7Ku0G4WrRFH fevHEDvIda3Z/Asay8ACJhlI5Peoptr7HkjCsZpNtSkWI4T1zyvfAq5mcs7yo+lilRLlbbRcG 9RNCETlNx5p/ouoPbhl3f433avT8q1qYTksrqc8sNG3jqqAq10ppMqLmYLJ9CKRMZjVS8FFnf feH0wjhj4HqwoZ3orIdO3W16ITUCITZ561kSnKkpml2ivnd5OofxNGh+/7SkVlaDNra4Nok8d l2AioGXtQ/ESngfIc8vmFRpYF7qNiNeguVoP9O9p5NC+t4JYt2u9M1bgGP+j+c+N1GvNBxi/J IjP5dq9FE20Q5VRYZSEPbUIYOwPXqxy3XcB9nd/sSHmBZtSuwOBD+l658P+oiuRSTRWXms+zR KQw5W6gLr/DTzV92x1aPnpaeEih4r0QWhRHey2BW+hZuiRSH3Otus5oD/c9epvjQlaM/Rv42i 51UXbFZektz0i0gI7UPypiOsXofuONfPHzEDaErFx77F+xlA913aRpTKxy07IIXEgY9/Txlcs CX1gdMSQO2zDO3iTOnH64FbGtBE3w1/ey++FU+VxJ2dZa7C86L5Pu70yiS8/D3RjJXKjH2MHB fN79QB482pRxhozpQHkcdK+DIwccl08K69RFxD0+zwdA2eW368AhzPTWedeAKWJWyQ16Rf/Z/ 7BGG7JLOyWl362pW Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday, September 13, 2016 7:10:04 AM CEST Deepa Dinamani wrote: > struct timeval is not y2038 safe. > All usage of timeval in the kernel will be replaced by > y2038 safe structures. > > struct input_event maintains time for each input event. > Real time timestamps are not ideal for input as this > time can go backwards as noted in the patch a80b83b7b8 > by John Stultz. Hence, having the input_event.time fields > only big enough for monotonic and boot times are > sufficient. > > Leave the original input_event as is. This is to maintain > backward compatibility with existing userspace interfaces > that use input_event. > Introduce a new replacement struct raw_input_event. > This replaces timeval with struct input_timeval. This structure > maintains time in __kernel_ulong_t or compat_ulong_t to allow > for architectures to override types as in the case of x32. > > The change requires any userspace utilities reading or writing > from event nodes to update their reading format to match > raw_input_event.The changes to the popular libraries will be > posted along with the kernel changes. > The driver version is also updated to reflect the change in > event format. > > Suggested-by: Arnd Bergmann > Signed-off-by: Deepa Dinamani Looks very nice! Two small suggestions from my side: > diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h > index e794f7b..1379899 100644 > --- a/include/uapi/linux/input.h > +++ b/include/uapi/linux/input.h > @@ -21,7 +21,23 @@ > /* > * The event structure itself > */ > +struct input_timeval { > + __kernel_ulong_t tv_sec; > + __kernel_ulong_t tv_usec; > +}; > + > +struct raw_input_event { > + struct input_timeval time; > + __u16 type; > + __u16 code; > + __s32 value; > +}; Maybe a comment here that this is intentionally "unsigned" so we can count until 2106 instead of 2038. > +/* Userspace structure. > + * Definition maintained here for userspace that is not yet updated to use > + * struct raw_input_event. > + * Not to be used anywhere within the kernel. > + */ > struct input_event { > struct timeval time; > __u16 type; > @@ -29,11 +45,32 @@ struct input_event { > __s32 value; > }; > > +static inline void > +raw_input_to_input_event(struct raw_input_event *raw, struct input_event *ev) > +{ > + ev->time.tv_sec = raw->time.tv_sec; > + ev->time.tv_usec = raw->time.tv_usec; > + ev->type = raw->type; > + ev->code = raw->code; > + ev->value = raw->value; > +} > + > +static inline void > +input_to_raw_event(struct input_event *ev, struct raw_input_event *raw) > +{ > + raw->time.tv_sec = ev->time.tv_sec; > + raw->time.tv_usec = ev->time.tv_usec; > + raw->type = ev->type; > + raw->code = ev->code; > + raw->value = ev->value; > +} Here, an "#ifndef __KERNEL__" guard might help to enforce what you write in the comment. Arnd