Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp90577rwd; Wed, 7 Jun 2023 20:04:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7W2E46YUU0RO8tyc0vO1nBzRYg3ZBO+uYKqI9szeOClkx1vbM2aDpGe69csF7KrmLEMJXc X-Received: by 2002:a05:6a20:7fa5:b0:10b:4539:fa0a with SMTP id d37-20020a056a207fa500b0010b4539fa0amr6501397pzj.1.1686193446534; Wed, 07 Jun 2023 20:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686193446; cv=none; d=google.com; s=arc-20160816; b=nvFHtBB8Zq26HcmmxxmMbS16oqSB5IXO7KjW6i9FEU39cOm1aDvJSlS8MQ2rSwcgoe gX2kp1rD41ItEvDVhQ7WJy5PhcsAnK5dQpn5rT1B7iMI4Z4MTQd5P0d/H4TssiAmnS/v 0Mub3954k0MyhLV7TQRySp1PxqC/yWvl5ZoE+MtVM/dz7igMEharc5Ve8ov9AqVOsaR3 v0E89vV3Tam2QlLGJBbhZse+Sw4NLzA5a3z52A9IFWwQsoRuWevAyks2U2/001zS6KPf Ga2bFA6lEUg+xciI9X0i47ZEHKL+tEie0oi1+Rb5Wpx0AqDFyLEiC4ZmbItPk376Gtgr NYZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=feG13tHn2eFFa/kfOQnMAGH3Yu0x2pEJQhtv4nEbQgY=; b=wB2yosMgJ1//fF5A506W5kilMX31bFcInjoN1cl3VysKrfsWWd09BMfWlI2old+STN TKp665OjO51tuHOfKCLfmkCMt3wM5+AFQGzKy2soKBbd5UvpaIk6gH/hvG7XDDEbva5e RSI3YEh0VSrxeAGqJ+Nh+Qg4zGYPCrmh4bFcZrFxZGDIJqgsh1A55m0pcF/gA9ciyXG7 ddEuGZ4TlCHMl00kNjb49PwbWO3cutyKrFFgYFp6Jq4ZWQ6W9kBNe3Z0zdFOXk6V0jYR XyZXAK/6iciedIJrsQNPk1tUoi2isBuR56yc1GIT/K8C08kZuFDBF4BwEpSV01G5NvEz wb8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@who-t.net header.s=fm3 header.b=oGSi83rh; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=EoIgrdkO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k16-20020a628410000000b00653a95c829asi88374pfd.256.2023.06.07.20.03.54; Wed, 07 Jun 2023 20:04:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@who-t.net header.s=fm3 header.b=oGSi83rh; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=EoIgrdkO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233843AbjFHCva (ORCPT + 99 others); Wed, 7 Jun 2023 22:51:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233812AbjFHCvV (ORCPT ); Wed, 7 Jun 2023 22:51:21 -0400 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A16E31BDF; Wed, 7 Jun 2023 19:51:17 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id AD50832007BE; Wed, 7 Jun 2023 22:51:15 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 07 Jun 2023 22:51:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=who-t.net; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1686192675; x=1686279075; bh=fe G13tHn2eFFa/kfOQnMAGH3Yu0x2pEJQhtv4nEbQgY=; b=oGSi83rhDGLe3v8JDu hvAZ6SSI/Rj1lort7dp9CaDIuwuJOtfd4sM1idvqDee/bvTgpHUm76q5wKliAay5 14+rkSI8xc8mof0elbKdBA12/yNFSUuxEKGRAhzmeTzxqxrnce+Rao3hI9j7rlH2 nxQACgTw2T1vwa0pFrY8iw+VRjlAOoKjXQan4c77avGk+siJYBat3R8E6c0qj3s1 RFHKhFmznH20qgGAWwBpNhpCBl8r7GnvePwDYIySSHXfhGJo/XT4yiquyuXMEQ9g AgTebApTlFcMm6/0izRFoX8gB21MZqwWvVn7/XPIJags0ku+5EbTFBdngb1KBewl HEsQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1686192675; x=1686279075; bh=feG13tHn2eFFa /kfOQnMAGH3Yu0x2pEJQhtv4nEbQgY=; b=EoIgrdkOh/4UTUBOd/IsLvhFDhfNz PqlxYPnmzEffPTME77d205NcE28ebANJ2uw1usiQv76+Inv4T8BtaS+MOdH3q6i/ 8hEyfGm1Tbs+XSWhJt99+xvKVxtgb2A+qT6wT4gGpLXtDqNX5k3/kZ5pCH0q9gNv GHs65Nnc4VJTgI7vbdLkN1xVKWdjmzTLogSZ3SmrI05dnWoZeCWZyaIDZXXV5ED5 bikx6+1YFsPNMTYS/LmtWJIQp8lnP4nmX6kL4T80pjolnVhIsrIirGl02ylWKzua k8m5rSW8KuT5Loqpuv+StmP0t1j36JuKyOtcDbsPjFkVSKzmRv+1b9beA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgedthedgieefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgvthgv rhcujfhuthhtvghrvghruceophgvthgvrhdrhhhuthhtvghrvghrseifhhhoqdhtrdhnvg htqeenucggtffrrghtthgvrhhnpeefgfejvefgudfhfeevudekueegtdeutdejhffhhfdv keejhfehheefgfehteejffenucffohhmrghinhepfhhrvggvuggvshhkthhophdrohhrgh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvght vghrrdhhuhhtthgvrhgvrhesfihhohdqthdrnhgvth X-ME-Proxy: Feedback-ID: i7ce144cd:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Jun 2023 22:51:12 -0400 (EDT) Date: Thu, 8 Jun 2023 12:51:06 +1000 From: Peter Hutterer To: Jason Gerecke Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Tissoires , Jiri Kosina , Ping Cheng , Aaron Armstrong Skomra , Joshua Dickens , Jason Gerecke Subject: Re: [PATCH] HID: wacom: Use ktime_t rather than int when dealing with timestamps Message-ID: <20230608025106.GA4142460@quokka> References: <20230607214102.2113-1-jason.gerecke@wacom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230607214102.2113-1-jason.gerecke@wacom.com> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 07, 2023 at 02:41:02PM -0700, Jason Gerecke wrote: > Code which interacts with timestamps needs to use the ktime_t type > returned by functions like ktime_get. The int type does not offer > enough space to store these values, and attempting to use it is a > recipe for problems. In this particular case, overflows would occur > when calculating/storing timestamps leading to incorrect values being > reported to userspace. In some cases these bad timestamps cause input > handling in userspace to appear hung. > > Link: https://gitlab.freedesktop.org/libinput/libinput/-/issues/901 > Fixes: 17d793f3ed53 ("HID: wacom: insert timestamp to packed Bluetooth (BT) events") > Signed-off-by: Jason Gerecke Reviewed-by: Peter Hutterer Cheers, Peter > --- > drivers/hid/wacom_wac.c | 4 ++-- > drivers/hid/wacom_wac.h | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c > index 2ccf83837134..2f16e47e4b69 100644 > --- a/drivers/hid/wacom_wac.c > +++ b/drivers/hid/wacom_wac.c > @@ -1314,7 +1314,7 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) > struct input_dev *pen_input = wacom->pen_input; > unsigned char *data = wacom->data; > int number_of_valid_frames = 0; > - int time_interval = 15000000; > + ktime_t time_interval = 15000000; > ktime_t time_packet_received = ktime_get(); > int i; > > @@ -1359,7 +1359,7 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) > bool range = frame[0] & 0x20; > bool invert = frame[0] & 0x10; > int frames_number_reversed = number_of_valid_frames - i - 1; > - int event_timestamp = time_packet_received - frames_number_reversed * time_interval; > + ktime_t event_timestamp = time_packet_received - frames_number_reversed * time_interval; > > if (!valid) > continue; > diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h > index 1a40bb8c5810..ee21bb260f22 100644 > --- a/drivers/hid/wacom_wac.h > +++ b/drivers/hid/wacom_wac.h > @@ -324,7 +324,7 @@ struct hid_data { > int ps_connected; > bool pad_input_event_flag; > unsigned short sequence_number; > - int time_delayed; > + ktime_t time_delayed; > }; > > struct wacom_remote_data { > -- > 2.41.0 >