A fix was committed upstream and backported to the stable kernels:

The commit in Linux 5.4 stable (v5.4.53):
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.4.y&id=e93ab4628452e0869c24204ac495e558b4163149

The commit in Linux 5.7 stable (v5.7.10):
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.7.y&id=996b680d729c4e5aa7087080cc9e469a4f7b86d7

This bug can be closed once Ubuntu's kernel contains these upstream
changes.

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/1876449

Title:
  Apple external Trackpad event timestamps are jittery

Status in linux package in Ubuntu:
  Confirmed

Bug description:
  Using a vanilla installation of Ubuntu 20.04, the timestamps of input
  events from my Apple "Magic Trackpad" - 1st generation, connected over
  Bluetooth - are jittery.

  This is a regression, the timestamps were fine when using Ubuntu
  19.10.

  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;

  
  Steps to reproduce
  ------------------

  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

  1. Pair an external Apple Trackpad over Blutooth.
  2. Run the above script
  3. Move your finger in circles on the touchpad 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.

  ProblemType: Bug
  DistroRelease: Ubuntu 20.04
  Package: linux-image-5.4.0-28-generic 5.4.0-28.32
  ProcVersionSignature: Ubuntu 5.4.0-28.32-generic 5.4.30
  Uname: Linux 5.4.0-28-generic x86_64
  ApportVersion: 2.20.11-0ubuntu27
  Architecture: amd64
  AudioDevicesInUse:
   USER        PID ACCESS COMMAND
   /dev/snd/controlC0:  yariv      1783 F.... pulseaudio
  CasperMD5CheckResult: skip
  Date: Sat May  2 13:58:34 2020
  InstallationDate: Installed on 2019-07-13 (293 days ago)
  InstallationMedia: Ubuntu 19.04 "Disco Dingo" - Release amd64 (20190416)
  MachineType: Gigabyte Technology Co., Ltd. Z170X-UD5 TH
  ProcFB: 0 i915drmfb
  ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-5.4.0-28-generic 
root=UUID=6deee348-bb50-4b88-837b-108413e4d8f2 ro quiet splash 
btusb.enable_autosuspend=0 vt.handoff=7
  RelatedPackageVersions:
   linux-restricted-modules-5.4.0-28-generic N/A
   linux-backports-modules-5.4.0-28-generic  N/A
   linux-firmware                            1.187
  RfKill:
   0: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no
  SourcePackage: linux
  UpgradeStatus: Upgraded to focal on 2020-04-28 (3 days ago)
  dmi.bios.date: 03/09/2018
  dmi.bios.vendor: American Megatrends Inc.
  dmi.bios.version: F22g
  dmi.board.asset.tag: Default string
  dmi.board.name: Z170X-UD5 TH-CF
  dmi.board.vendor: Gigabyte Technology Co., Ltd.
  dmi.board.version: x.x
  dmi.chassis.asset.tag: Default string
  dmi.chassis.type: 3
  dmi.chassis.vendor: Default string
  dmi.chassis.version: Default string
  dmi.modalias: 
dmi:bvnAmericanMegatrendsInc.:bvrF22g:bd03/09/2018:svnGigabyteTechnologyCo.,Ltd.:pnZ170X-UD5TH:pvrDefaultstring:rvnGigabyteTechnologyCo.,Ltd.:rnZ170X-UD5TH-CF:rvrx.x:cvnDefaultstring:ct3:cvrDefaultstring:
  dmi.product.family: Default string
  dmi.product.name: Z170X-UD5 TH
  dmi.product.sku: Default string
  dmi.product.version: Default string
  dmi.sys.vendor: Gigabyte Technology Co., Ltd.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1876449/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to     : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to