Received: by 10.223.185.116 with SMTP id b49csp1333176wrg; Wed, 21 Feb 2018 16:57:03 -0800 (PST) X-Google-Smtp-Source: AH8x224sfD4b2LoYmWKml4uXLgEcwTvIsC7WitVg7ufrj7YmobNPp8/1i/N0e9Gt4oUHaGe36xaN X-Received: by 2002:a17:902:365:: with SMTP id 92-v6mr4851587pld.127.1519261023789; Wed, 21 Feb 2018 16:57:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519261023; cv=none; d=google.com; s=arc-20160816; b=DgaeMWmp9W/i8enLNiynwANKC/+S5jOgLZnuRmfcaHIvMbkJI+2I/w7D5r9fniVIyD IutPXdEsSmZ3XaL27oOMiKZU7WfAZ9smc/ua3GUNQYMTlR0koQ7ImnfEk+X05aHHrLx+ ifJvzUZO+gYx+9U01VC2sK7eCSLafW8t/NSHGxgxjOQ6v9Kpym357mjfKRtNeAukpGwf 9r9e4fuo9/NdpPqaQRCb0Y9m0IC8eRJRdmpR/pFmJ9T6KnUqv2eO0jAn5R6mk5dCTHnY YTSbvzD6GH2JwmH2LlztN9MbMjNUE1EhWf0w240H9j/evFl2VLcBuSxBnYIl444E9Pf4 Vu7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=haMQbohAktrjzeke0oIcC3n2Ae82vBDcaAJZC5yEDFE=; b=UGOUR9/Z6BCJ6nar+AEHayOMwCJwQuQvUMLLvD0gfkKOuEneVforyP1QynXULYhs3C 5lX8zBRNHtatWyRHCjPRotDR/Bs9sTGWYVPup2/fv4X0f9WoGdaj3HXOuAllgHUxz5PT VtHv/T4An3AqDdXcTnkWH5/zYKry3/6zIqnwgC51VydmOVw0+8zGmu0slQ/IMKYZQogi UUmiwmouQqKm5lIeQG1dJyN4UWuqFfwLSTwBHgVjezpTl65DDhcf9iF1K8ci4pdm5eig +tstIA04HphasOG5lESdsQ/ai7V0V2UjfPrLE8xtTPUBqk2Jx1iAZOIIT0avW81UcvTW 740w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y15-v6si166868plr.77.2018.02.21.16.56.48; Wed, 21 Feb 2018 16:57:03 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751611AbeBVAzC (ORCPT + 99 others); Wed, 21 Feb 2018 19:55:02 -0500 Received: from hs01.dk-develop.de ([213.136.71.231]:35025 "EHLO hs01.dk-develop.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751413AbeBVAzB (ORCPT ); Wed, 21 Feb 2018 19:55:01 -0500 Received: from danilo-linux.fritz.box (ipbcc13fda.dynamic.kabel-deutschland.de [188.193.63.218]) by hs01.dk-develop.de (Postfix) with ESMTPSA id CF1891320F3D; Thu, 22 Feb 2018 01:46:24 +0100 (CET) From: Danilo Krummrich To: gregkh@linuxfoundation.org, felipe.balbi@linux.intel.com Cc: linux-usb@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, kai.heng.feng@canonical.com, Danilo Krummrich Subject: [PATCH] usb: quirks: add control message delay for 1b1c:1b20 Date: Thu, 22 Feb 2018 01:46:18 +0100 Message-Id: <20180222004618.3854-1-danilokrummrich@dk-develop.de> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Corsair Strafe RGB keyboard does not respond to usb control messages sometimes and hence generates timeouts. Commit de3af5bf259d ("usb: quirks: add delay init quirk for Corsair Strafe RGB keyboard") tried to fix those timeouts by adding USB_QUIRK_DELAY_INIT. Unfortunately, even with this quirk timeouts of usb_control_msg() can still be seen, but with a lower frequency (approx. 1 out of 15): [ 29.103520] usb 1-8: string descriptor 0 read error: -110 [ 34.363097] usb 1-8: can't set config #1, error -110 Adding further delays to different locations where usb control messages are issued just moves the timeouts to other locations, e.g.: [ 35.400533] usbhid 1-8:1.0: can't add hid device: -110 [ 35.401014] usbhid: probe of 1-8:1.0 failed with error -110 The only way to reliably avoid those issues is having a pause after each usb control message. In approx. 200 boot cycles no more timeouts were seen. Addionaly, keep USB_QUIRK_DELAY_INIT as it turned out to be necessary to have the delay in hub_port_connect() after hub_port_init(). The overall boot time seems not to be influenced by these additional delays, even on fast machines. Signed-off-by: Danilo Krummrich --- drivers/usb/core/message.c | 5 +++++ drivers/usb/core/quirks.c | 3 ++- include/linux/usb/quirks.h | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 77001bcfc504..cbab2a99ce16 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -150,6 +150,10 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout); + /* Linger a bit, prior to the next control message. */ + if (dev->quirks & USB_QUIRK_DELAY_CTRL_MSG) + msleep(200); + kfree(dr); return ret; @@ -642,6 +646,7 @@ int usb_get_descriptor(struct usb_device *dev, unsigned char type, USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, (type << 8) + index, 0, buf, size, USB_CTRL_GET_TIMEOUT); + if (result <= 0 && result != -ETIMEDOUT) continue; if (result > 1 && ((u8 *)buf)[1] != type) { diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index 4024926c1d68..4450bec7f3af 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c @@ -227,7 +227,8 @@ static const struct usb_device_id usb_quirk_list[] = { USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, /* Corsair Strafe RGB */ - { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT }, + { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT | + USB_QUIRK_DELAY_CTRL_MSG }, /* Corsair K70 LUX */ { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT }, diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h index f1fcec2fd5f8..b7a99ce56bc9 100644 --- a/include/linux/usb/quirks.h +++ b/include/linux/usb/quirks.h @@ -63,4 +63,7 @@ */ #define USB_QUIRK_DISCONNECT_SUSPEND BIT(12) +/* Device needs a pause after every control message. */ +#define USB_QUIRK_DELAY_CTRL_MSG BIT(13) + #endif /* __LINUX_USB_QUIRKS_H */ -- 2.14.1