Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp872638imm; Tue, 3 Jul 2018 01:14:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdbusQjXCW/+oLC9VxJsDk6YtsS/v6dH8e2RTIpfP/2swpDP+SeVCyEFMTcrAYG4R9Xo+u+ X-Received: by 2002:a17:902:be04:: with SMTP id r4-v6mr11062290pls.324.1530605692547; Tue, 03 Jul 2018 01:14:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530605692; cv=none; d=google.com; s=arc-20160816; b=pesCLoxoNV2+ZK8Kt0HSpV5lGIPhlGB5GhrNodBE8GHYgjWjPwlTV/2LHguJUrxp4s iZTcgUjgr2Psqu7I/cIZh8x0Ox7ptCaj2WgB1a+/W7iYOZpv5ZbnWHezBpnY7aDPeUhM fvgQEXI9p21RzlVRtfGThEJkvcoErn+TdfecLxSLUnMdJjtcI0keSul/8ziYJDamJH/2 kvAdhXMuNSg6RU60NDeT5A/5aYFCakAPBumzNmm5HUxDx+NrPVoApu4TOYph41LQzTNz 8WK3CCw5nQ28Am0BCJBHUX17toIWtSXsFbeQoleTDTGW1u9EBdj085riHno1VE595Emx d7iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:arc-authentication-results; bh=VUxrYlkhLwclZtZG0gVRoTyNf6AUAukIXhqzK4jm45E=; b=Jgr7hpM5xgNOO6Ja2NRXjUTEHWHK86ZyI0g3nNiwpVtNYwary5Wb4gH4fIstHnZ/oh y1tXOlJbP6vS0rgZ+/ZI8Evf6APxg5l3fxEaBrKJDXTbiODvigYMcNtKNhvVCOkQo3Oq HZIqJtuPtQVHFNu4KcX0SQMAP+JN6Z8ImEhpwtMv6Fj4QkKK8Cb6fVoJca+XYtn8NSD8 4BljCvl1RW/L8RRMcPHYDIlbn+Fg+8VTefOehzOKkE0rfQ8rne9Nyj2Re06Wd/jmpdEN Xm/jGAGR97V6itTtwChiUGSMbdLIirAD/sbS6r/geXh2QDZmH1tB27Xbb8brI6H6guv2 n1tg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t128-v6si637352pfc.194.2018.07.03.01.14.38; Tue, 03 Jul 2018 01:14:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754621AbeGCIN6 (ORCPT + 99 others); Tue, 3 Jul 2018 04:13:58 -0400 Received: from mail-qk0-f170.google.com ([209.85.220.170]:37817 "EHLO mail-qk0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753835AbeGCINz (ORCPT ); Tue, 3 Jul 2018 04:13:55 -0400 Received: by mail-qk0-f170.google.com with SMTP id t79-v6so519031qke.4 for ; Tue, 03 Jul 2018 01:13:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=VUxrYlkhLwclZtZG0gVRoTyNf6AUAukIXhqzK4jm45E=; b=rZFJm2rTIE4zT/HHEsw/bEBRZES/1R50dNa/0HGJ5GEBWlCjPWeZYlpD0MUJyylCFk AneyYlKzS7pNWXXrARepMDC/bo8gjupNSJbBCF14tXOkqqyD/GlZS52DNucJTRSg8Rx7 TLPYzOzmMLr0GW6cIADZ92DwXkKwKsVbus8UBa7Ug5C1mirysRG3g8zrrSjAMafmDvcy 7E0VHERXUNaezNceeRLBv3QyqI7elPOkDRXRKVaoNDQ8GkugYRExNYXKllCEfmGTz0qR co130jlb7ZuVmaRNcPWujFl0hvtOv+JZf+DQwDS5kRKbFDxcA9xdv2so8dcbzONpkqT2 IAxw== X-Gm-Message-State: APt69E1SFIhmG2EmAsGZKTa6v3tRKr+TwqZQWiyr78s+9sLLzMKJFctR tBgdkpg/ddTBTGuqrD9G3DOOdmR3VluExmBP214N0Q== X-Received: by 2002:ae9:e009:: with SMTP id m9-v6mr23436150qkk.320.1530605634837; Tue, 03 Jul 2018 01:13:54 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac8:2fca:0:0:0:0:0 with HTTP; Tue, 3 Jul 2018 01:13:54 -0700 (PDT) In-Reply-To: <29ad484c1b357fd7fd670a6f252d097677b808f8.1530402641.git.joeypabalinas@gmail.com> References: <29ad484c1b357fd7fd670a6f252d097677b808f8.1530402641.git.joeypabalinas@gmail.com> From: Benjamin Tissoires Date: Tue, 3 Jul 2018 10:13:54 +0200 Message-ID: Subject: Re: [PATCH 3/4] HID: multitouch: drop reports containing invalid values To: Joey Pabalinas Cc: "open list:HID CORE LAYER" , lkml , Jiri Kosina , Daniel Martin Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joey, On Sun, Jul 1, 2018 at 2:19 AM, Joey Pabalinas wrote: > Avoid processing reports containing invalid values to reduce > multitouch input stutter. > > Signed-off-by: Joey Pabalinas > > 1 file changed, 9 insertions(+) > > diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c > index c0654db0b736543ca0..08b50e5908cecdda66 100644 > --- a/drivers/hid/hid-multitouch.c > +++ b/drivers/hid/hid-multitouch.c > @@ -694,10 +694,19 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input) > { > if ((td->mtclass.quirks & MT_QUIRK_CONTACT_CNT_ACCURATE) && > td->num_received >= td->num_expected) > return; > > + /* drop invalid values after counting them */ > + if (td->curdata.x == 0xffff && > + td->curdata.y == 0xffff && > + td->curdata.w == 0xffff && > + td->curdata.h == 0xffff) { You can't really use plain values like that. There is a tiny chance these values are valid on an other device. IIRC, MS spec says that we should ignore out of band values if they are tagged as such. Such input are tagged with NULL values (http://www.usb.org/developers/hidpage/HID1_11.pdf page 31) and MS spec mentioned this. All in all, if you have this bit set, you need to compare the value with the logical_max/min for each field. I never encountered a device that required this, so you are probably the lucky one :) Cheers, Benjamin > + td->num_received++; > + return; > + } > + > if (td->curvalid || (td->mtclass.quirks & MT_QUIRK_ALWAYS_VALID)) { > int active; > int slotnum = mt_compute_slot(td, input); > struct mt_slot *s = &td->curdata; > struct input_mt *mt = input->mt; > -- > 2.18.0 >