Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4891765imd; Tue, 30 Oct 2018 08:54:12 -0700 (PDT) X-Google-Smtp-Source: AJdET5drjKbpPDHEhMnTUDS4qwIlEO8Dn3ggBqp/04sBVFtueDgK/dKMUfdqp62yFvUO+UsdMwar X-Received: by 2002:a17:902:ac86:: with SMTP id h6-v6mr18732768plr.174.1540914852165; Tue, 30 Oct 2018 08:54:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540914852; cv=none; d=google.com; s=arc-20160816; b=wAWMwf+sJQDhZiEWfLgMd084OqCyD9KH0hcnmhqVazyCIGBu1iXJ5+IIp4agqeCGA1 gNSLEaD2GvUbcJebxwWonE854EBiBYvljQVJP1nhc1vUBau3S2wKJ4dXUQ4btSCXeX6i doQ9DjJ/YuPGoAIDvAXefc8jtUdF4R6TRMFO9L/ZzWuLsG2kaJrBHEzxToOI8flEvrVj uMeYxI1QXqjXKPvTJliHYOAlQrevARarEv8M8lXTP0I4hXgOlVmyROm8CHB/W8fL0OJL AmEgabWH4Tviz+CuVcqIEsj+cLgPxzdI6aocObrQ+hHwTSffKv4UH+s5xbWJhpfiF2UN R+xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=VPLhdhOn13t3h4YktDspTKfhCKswTH0LCwd2AQH47zQ=; b=txtDAkR6uny1xrHx+I8hJgEvziU2LZ0/WCf/zreDO7WUGvDCWw9qOD7slHI7E+aR4y mC/MFO3xxLwy00Dq05s7YNaxHes0f9xwFAn8KLQEvc90qtYloP7haR9ZTfeaKyO9h8Ec 46TfG+vzN5cWoC1y5hxjcR7qfYVMxEYfI5vtPXd6LpxiCg/vsJl8JD1JBM3TtIok3P2y fRguakSompiFvwrTwomWgJd9xYiFhSRRYk10FlAdRx+4PcLmEW4nqR2Y449oToJZjArR yLQBoA9YTCClsqXAvcq/2dEGK26WaLUWnp6fneQihdnwDKqlNyxISbzP4MU72exSnjJE /09g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=cwP+Bz54; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11-v6si22698629pgs.179.2018.10.30.08.53.56; Tue, 30 Oct 2018 08:54:12 -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; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=cwP+Bz54; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727427AbeJaArN (ORCPT + 99 others); Tue, 30 Oct 2018 20:47:13 -0400 Received: from casper.infradead.org ([85.118.1.10]:55408 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726886AbeJaArN (ORCPT ); Tue, 30 Oct 2018 20:47:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To:From:Date:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=VPLhdhOn13t3h4YktDspTKfhCKswTH0LCwd2AQH47zQ=; b=cwP+Bz54JZqoMZoR0tgF3PcxvS t4FOr0aPnORZoqnx1c1R2KMUyMcw9Pd8PloUB9UQxlh/ObeIxnhhobWORda7ML2WneJB4iGKORKO/ 2HZcLoQWMQiyzdWq7Kc1HutlslNahhLqih+tE09NUUDjqA5UEJNF3lDBFihbMS26LRFhN+BdKM7FP d684kAX8xzpeYnW/bK4UUNiR255AANO+vM/jrTxCM7ifjEsmSO6mE7mddMXaimujyEU3+URLLBV/K CKle93ElEPSfUoYCiTM9Gr4PgSj1oQ+ij3VYkNDqh/JkK+Z/e+FSkgioxfUsfDTnhCNuqCFDfDYFZ b0urOyLg==; Received: from [191.33.133.96] (helo=coco.lan) by casper.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHWKK-0003SC-Hf; Tue, 30 Oct 2018 15:53:09 +0000 Date: Tue, 30 Oct 2018 12:53:03 -0300 From: Mauro Carvalho Chehab To: Linus Torvalds Cc: Harry Cutts , Benjamin Tissoires , Jiri Kosina , linux-input@vger.kernel.org, Linux Kernel Mailing List Subject: Re: Logitech high-resolution scrolling.. Message-ID: <20181030125303.0f94b6e0@coco.lan> In-Reply-To: References: X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Sun, 28 Oct 2018 14:08:31 -0700 Linus Torvalds escreveu: > On Sun, Oct 28, 2018 at 12:13 PM Linus Torvalds > wrote: > > > > So the recent change to enable the high-res scrolling really seems a > > bit *too* extreme. > > > > Is there some middle ground that turns the mouse from "look at it > > sideways and it starts scrolling" to something slightly more > > reasonable? > > Actually, I think the bug may be in the generic HID high-resolution > scrolling code, and I only notice because the Logitech support means > that now I see it. > > In particular, if you look at hid_scroll_counter_handle_scroll(), > you'll notice that it tries to turn a high-res scroll event into a > regular wheel event by using the resolution_multiplier. > > But that code looks really broken. It tries to react to a "half > multiplier" thing: > > int threshold = counter->resolution_multiplier / 2; > .. > counter->remainder += hi_res_value; > if (abs(counter->remainder) >= threshold) { > > and that's absolutely and entirely wrong. > > Imagine that the high-res wheel counter has just moved a bit up (by > one high-res) tick, so now it's at the half-way mark to the > resolution_multiplier, and we scroll up by one: > > low_res_scroll_amount = > counter->remainder / counter->resolution_multiplier > + (hi_res_value > 0 ? 1 : -1); > input_report_rel(counter->dev, REL_WHEEL, > low_res_scroll_amount); > > and then correct for it: > > counter->remainder -= > low_res_scroll_amount * counter->resolution_multiplier; > > now we went from "half resolution multiplier positive" to "half negative". > > Which means that next time that the high-res event happens by even > just one high-resolution tick in the other direction, we'll now > generate a low-resolution scroll event in the other direction. > > In other words, that function results in unstable behavior. Tiny tiny > movements back-and-forth in the high-res wheel events (which could be > just because either the sensor is unstable, or the wheel is wiggling > imperceptibly) can result in visible movement in the low-res > ("regular") wheel reporting. > > There is no "damping" function, in other words. Noise in the high > resolution reading can result in noise in the regular wheel reporting. > > So that threshold handling needs to be fixed, I feel. Either get rid > of it entirely (you need to scroll a *full* resolution_multiplier to > get a regular wheel event), or the counter->remainder needs to be > *cleared* when a wheel event has been sent so that you don't get into > the whole "back-and-forth" mode. > > Or some other damping model. I suspect there are people who have > researched what the right answer is, but I guarantee that the current > code is not the right answer. > > I suspect this also explains why I *sometimes* see that "just moving > the mouse sends wheel events", and at other times don't. It needs to > get close to that "half a resolution multiplier" stage to get into the > bad cases, but then tiny tiny perturbations can cause unstable > behavior. > > I can't be the only person seeing this, but I guess the Logitech mouse > is right now the only one that uses the new generic HID code, and I > guess not a lot of people have been *using* it. I remember I submitted in the past some patches adding a different event for the high scroll mode. I have myself a MX Anywhere 2, and even wrote some patches for Solaar[1] in order to allow selecting between low res and high res wheel modes. The problem I faced, on that time, was similar to yours: when the high res wheel was enabled, it was very hard to control the mouse, specially when using the wheel in "free" mode (with I do). I remember that the patchset I sent was not actually applied, but I didn't followed what happened after that (got sidetracked by something else). [1] https://github.com/pwr/Solaar Thanks, Mauro