Using a vanilla installation of Ubuntu 20.04 (kernel v5.4), the timestamps of input events from my Apple "Magic Trackpad" - 1st generation, connected over Bluetooth - are jittery. This is a kernel regression. I bisected the bug. - The problem starts with upstream kernel commit 3b51c44bd693 ("Input: allow drivers specify timestamp for input events"). After that commit, the same timestamp is always emitted. - This was partially fixed in commit 4370b231d100 ("Input: reset device timestamp on sync"), however ever since then the timestamps are jittery. The problem still exists in the current upstream 'master' (commit c45e8bccecaf). The following patch fixes the bug, however this is obviously a hack. It effectively reverts commit 3b51c44bd693: diff --git a/drivers/input/input.c b/drivers/input/input.c index 3cfd2c18eebd..8890195547d6 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -1958,7 +1958,7 @@ ktime_t *input_get_timestamp(struct input_dev *dev) { const ktime_t invalid_timestamp = ktime_set(0, 0); - if (!ktime_compare(dev->timestamp[INPUT_CLK_MONO], invalid_timestamp)) + // if (!ktime_compare(dev->timestamp[INPUT_CLK_MONO], invalid_timestamp)) input_set_timestamp(dev, ktime_get()); return dev->timestamp; Reproducing the bug ---------------------------- I used the following script as a reproducer. It relies on libinput-debug-events. This script measures the time delta between consecutive input events, then prints a "histogram" of these deltas. #!/bin/bash # log file name logFile=${1:-~/Downloads/`uname -r`} echo logFile=$logFile if [[ "$1" == '' ]]; then echo record # log some events sudo libinput debug-events | grep POINTER | tee $logFile fi # process the results lastN=0 for f in `cat $logFile | awk '{print $3}' | sed "s/s//g" | sed "s/+//g"`; do echo "$f-$lastN" | bc; lastN=$f; done | sort | uniq -c Steps to reproduce ------------------------- 1. Pair an external Apple Trackpad over Bluetooth. 2. Run the above script 3. Move your finger in circles on the external trackpad for a few seconds 4. Press ctrl+c An example output of this script before the regression ----------------------------------------------------------------------- 2 .010 371 .011 127 .012 1 .876 The above output means that: 2 times the delta was 10ms, 371 times 11ms, 127 times 12ms and 1 time 876ms. This corresponds well with the Trackpad's ~90Hz polling rate. An example output of this script after the regression --------------------------------------------------------------------- 3 .003 12 .004 16 .005 14 .006 21 .007 16 .008 20 .009 13 .010 359 .011 47 .012 20 .013 17 .014 21 .015 14 .016 16 .017 15 .018 2 .019 1 .020 38 .022 21 .023 1 1.060 I suspect that other input devices might be affected as well. The bug was reported downstream at https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1876449 Please let me know if you prefer that I open a corresponding issue in the kernel bugzilla. Best regards, Yariv