Message ID | 20230607214102.2113-1-jason.gerecke@wacom.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Jiri Kosina |
Headers | show |
Series | HID: wacom: Use ktime_t rather than int when dealing with timestamps | expand |
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 <jason.gerecke@wacom.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> 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 >
Hi Jason,
kernel test robot noticed the following build errors:
[auto build test ERROR on hid/for-next]
[also build test ERROR on linus/master v6.4-rc5 next-20230608]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jason-Gerecke/HID-wacom-Use-ktime_t-rather-than-int-when-dealing-with-timestamps/20230608-054255
base: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next
patch link: https://lore.kernel.org/r/20230607214102.2113-1-jason.gerecke%40wacom.com
patch subject: [PATCH] HID: wacom: Use ktime_t rather than int when dealing with timestamps
config: arc-randconfig-c003-20230608 (https://download.01.org/0day-ci/archive/20230608/202306082127.6r7qAALi-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 12.3.0
reproduce (this is a W=1 build):
mkdir -p ~/bin
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git remote add hid https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git
git fetch hid for-next
git checkout hid/for-next
b4 shazam https://lore.kernel.org/r/20230607214102.2113-1-jason.gerecke@wacom.com
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=arc olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=arc SHELL=/bin/bash
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306082127.6r7qAALi-lkp@intel.com/
All errors (new ones prefixed by >>, old ones prefixed by <<):
>> ERROR: modpost: "__divdi3" [drivers/hid/wacom.ko] undefined!
Hi Jason, kernel test robot noticed the following build errors: [auto build test ERROR on hid/for-next] [also build test ERROR on linus/master v6.4-rc5 next-20230608] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Jason-Gerecke/HID-wacom-Use-ktime_t-rather-than-int-when-dealing-with-timestamps/20230608-054255 base: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next patch link: https://lore.kernel.org/r/20230607214102.2113-1-jason.gerecke%40wacom.com patch subject: [PATCH] HID: wacom: Use ktime_t rather than int when dealing with timestamps config: arm-randconfig-r036-20230608 (https://download.01.org/0day-ci/archive/20230608/202306082249.cMqfu24Y-lkp@intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) reproduce (this is a W=1 build): mkdir -p ~/bin wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install arm cross compiling tool for clang build # apt-get install binutils-arm-linux-gnueabi git remote add hid https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git git fetch hid for-next git checkout hid/for-next b4 shazam https://lore.kernel.org/r/20230607214102.2113-1-jason.gerecke@wacom.com # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=arm olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202306082249.cMqfu24Y-lkp@intel.com/ All errors (new ones prefixed by >>): >> ld.lld: error: undefined symbol: __aeabi_ldivmod >>> referenced by wacom_wac.c >>> drivers/hid/wacom_wac.o:(wacom_wac_irq) in archive vmlinux.a >>> did you mean: __aeabi_idivmod >>> defined in: arch/arm/lib/lib.a(lib1funcs.o)
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 {
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 <jason.gerecke@wacom.com> --- drivers/hid/wacom_wac.c | 4 ++-- drivers/hid/wacom_wac.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)