From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D724C35247 for ; Tue, 4 Feb 2020 15:48:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 01BBF2082E for ; Tue, 4 Feb 2020 15:48:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727305AbgBDPsQ (ORCPT ); Tue, 4 Feb 2020 10:48:16 -0500 Received: from mta-out1.inet.fi ([62.71.2.226]:58200 "EHLO julia1.inet.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727317AbgBDPsQ (ORCPT ); Tue, 4 Feb 2020 10:48:16 -0500 Received: from [192.168.1.134] (84.248.30.195) by julia1.inet.fi (9.0.019.26-1) (authenticated as laujak-3) id 5E37D3E20005F751; Tue, 4 Feb 2020 17:48:13 +0200 Subject: Re: [PATCH v4] USB: HID: random timeout failures tackle try. To: Alan Stern , Lauri Jakku Cc: oneukum@suse.com, benjamin.tissoires@redhat.com, jikos@kernel.org, linux-input@vger.kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org References: From: Lauri Jakku Message-ID: <10da971f-2935-7883-1283-d9f22e73a21a@pp.inet.fi> Date: Tue, 4 Feb 2020 17:48:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org On 4.2.2020 16.57, Alan Stern wrote: > On Tue, 4 Feb 2020, Lauri Jakku wrote: > >> -- v1 ------------------------------------------------------------ >> send, 20ms apart, control messages, if error is timeout. >> >> There is multiple reports of random behaviour of USB HID devices. >> >> I have mouse that acts sometimes quite randomly, I debugged with >> logs others have published that there is HW timeouts that leave >> device in state that it is errorneus. >> >> To fix this I introduced retry mechanism in root of USB HID drivers. >> >> Fix does not slow down operations at all if there is no -ETIMEDOUT >> got from control message sending. If there is one, then sleep 20ms >> and try again. Retry count is 20 witch translates maximium of 400ms >> before giving up. >> >> NOTE: This does not sleep anymore then before, if all is golden. > How do other operating systems handle these problems? Perhaps we > should use the same approach. > > Also, if this problem only affects USB HID devices, why not put the > fix in the usbhid driver rather than the USB core? > > Alan Stern hmm, i investigate, what i know now is few mentions about mouse acting up etc. I do more research, tomorrow. I think in my mind, that the core is good place, the thing ppl are forgetting that it does not make any unnecessary sleeps and when it does it it is about 70-100ms max per loop, and they are restricted to 20. The patch does not enforce any different use, in non-timeout case it is as fast as without the patch. I can easilly debug, cause my mouse acts up and that 5 loop version that I tried on my PC+ usb keyboard + usb mouse. It was way better. And now i got confirmation from my dad (Suse user) that with latest kernel, there have been acting up. The timeout retry loop done in patch within the USB core activates only when the timeout happens, and latest version adapts the 5000ms (common) to 50ms timeout, and sleeps 20ms per loop. But, keep comments coming & suggestions .. and if someone could test too, so I do not be only one to test this :) .. -- Br, Lauri J.