Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1207755imu; Fri, 7 Dec 2018 16:49:27 -0800 (PST) X-Google-Smtp-Source: AFSGD/UlMKHVZNP89drjpznUjBFe2RuWcklWx0koIbyi2zVZONhFHkypioLLJXOY9ZLXEamgv2fn X-Received: by 2002:a17:902:654a:: with SMTP id d10mr4030542pln.324.1544230167170; Fri, 07 Dec 2018 16:49:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544230167; cv=none; d=google.com; s=arc-20160816; b=MToghtfVM6SLdmzhe7h8S12AGab5DxNMhttnkg1eCLxCtpxiH1dNvc9NtXC3p2DMqJ h4yLFeJ9C/D2zVjCeWid3JhC6jwIIzz53dMqSnq5Iu/ajZhzLZorqorolvU0ee+jgbPg y3AkdqnkXy2PA6ZtA+xaTvfggr6f8eSFaMrC61A47OWGwuXB096VB6QQJT/XibjAIMiG JFEmIItGxCoLXprUnmGLtEfVxiq1PuZWTIMe5UaAYZifYy7AGb5LWsZHOFwRO1yyM8/7 s/tpZkX207VaqUgCPKHkbxa6Pe/ZrsvIhJLdDIW18d66NgYSb5no4b9DEy6PCc6ARBj1 hIZQ== 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:date:subject:cc:to:from :dkim-signature; bh=NRkbgoAqHLBXEpXwn4nVEYMfs9jWYNDOZepIs2hElB8=; b=US8uOiYRGf1Rm2fdteN5KScQzfG44O91uOAyyxv3+/7E5C4IV7gpUGV9wrxh8hVky3 3gxZSK/fnethgRDrAAshVSRzySnDHT66rbvcKus4UqFXHYyfcehxYCBMNxfzThTh0Qv/ +nFrjtZ+BAFQ+ghoaL2T8rV9PZ4a2Rh5Qq/zGm7BX0+nHD2vjySpHLQ/juGuZMwSMAa0 e1deUseeg7TQGuKNPLv6fT/7zu7cLhLTR0SnAq9oV1Jy6ih2ol86RVOcBTuakpfegBo9 h4UMTKW5AbkwYNuWvR8gY0gfswheVvJLcNNvjizS9mvMHBQZmNOreoFycx9m1JF83wkT uehA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Oc9KzfhW; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5si4271564pfn.259.2018.12.07.16.49.11; Fri, 07 Dec 2018 16:49:27 -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; dkim=pass header.i=@chromium.org header.s=google header.b=Oc9KzfhW; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726143AbeLHAsC (ORCPT + 99 others); Fri, 7 Dec 2018 19:48:02 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:44123 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726041AbeLHAsA (ORCPT ); Fri, 7 Dec 2018 19:48:00 -0500 Received: by mail-qt1-f193.google.com with SMTP id n32so6508781qte.11 for ; Fri, 07 Dec 2018 16:47:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NRkbgoAqHLBXEpXwn4nVEYMfs9jWYNDOZepIs2hElB8=; b=Oc9KzfhWC3PqPIseWX5ytSqyfD4ysuNYv0HOKyu7la8rPFf0aqmJ/tpD5xEMgjKGob l/wBeD84lm9duF01JwQRf9yuQKDIajQDQ7w/e5IbDAeOtx1e4wHGFj866d9TKBzZnTzb N8SB0+yJSRzGFEsUMb8TurR0w7wqY25XtPeSo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NRkbgoAqHLBXEpXwn4nVEYMfs9jWYNDOZepIs2hElB8=; b=s/2yFnkN3SQJofn8oxZakO7a0aqec/qoDanl9uePzT0l05PJ+wDz5zr3ONmBk/xv8I cJ4X1UBAFcr3zeJ8zq6yGFy1LzPbrEW1hNr6VZ/gcerE8DHDRkWJ9rCo+X6+AOwT683x 8yehw+vx+td5theDpWca8fjdTEJJDmdJIyKfrZulgR1ASGv6W4zgRvm2MGBvUXJOEBCS Gpr0sncWOqJePX9zn54tgY9A7005rwtZLvP198qx0TcznVbT7kg5uSZB2U8/kBXRRwcR oT9PbIC25Vp65n9BVUAyy5QFuvck40OE0Xj+lHEPTRynRwG7urhLhkwzVOCmvVGeuns5 hcoQ== X-Gm-Message-State: AA+aEWaFEHq3nOmMNWTc3hfr+vmKOsMgMaR42lYrbpk0g5rMHAFjPoex U+rzWW9u5xEQrB6Coemw591quBmOOQpxoA== X-Received: by 2002:a0c:d174:: with SMTP id c49mr3954918qvh.231.1544230079305; Fri, 07 Dec 2018 16:47:59 -0800 (PST) Received: from kdgwill07.nyc.corp.google.com ([2620:0:1003:510:59af:10e9:2d49:6b0a]) by smtp.googlemail.com with ESMTPSA id u50sm3528231qta.23.2018.12.07.16.47.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Dec 2018 16:47:58 -0800 (PST) From: Kyle Williams X-Google-Original-From: Kyle Williams To: linux-kernel@vger.kernel.org Cc: kdgwill@chromium.org, Greg Kroah-Hartman , Alan Stern , Mathias Nyman , Nicolas Boichat , Jon Flatley , Felipe Balbi , Kai-Heng Feng , Danilo Krummrich , Kuppuswamy Sathyanarayanan , =?UTF-8?q?Maxence=20Dupr=C3=A8s?= , Kamil Lulko , Emmanuel Pescosta , linux-usb@vger.kernel.org Subject: [PATCH v2] USB: quirks: disable LPM for Logitech UVC devices Date: Fri, 7 Dec 2018 19:46:38 -0500 Message-Id: <20181208004641.240699-1-kdgwill@google.com> X-Mailer: git-send-email 2.20.0.rc2.403.gdbc3b29805-goog In-Reply-To: <20181207222138.GB161210@google.com> References: <20181207222138.GB161210@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kyle Williams Description: Some USB device / host controller combinations seem to have problems with Link Power management. In particular it is described that the combination of certain Logitech uvc devices and other powered media devices such causes 'not enough bandwidth for new device state' error. This patch enables the USB_QUIRK_NO_LPM quirk entries for all connected Logitech UVC devices indicating LPM should remain disabled for the device. Signed-off-by: Kyle Williams --- Changes in v2: - changed commit message - disble lpm for all logitech uvc devices instead of listing manually - changes to allow the lpm to correctly be disabled after enumeration drivers/usb/core/hub.c | 87 +++++++++++++++++++++------------------ drivers/usb/core/quirks.c | 2 +- 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 0f9381b69a3b..8f366ec4d21b 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -365,6 +365,51 @@ static void usb_set_lpm_parameters(struct usb_device *udev) usb_set_lpm_sel(udev, &udev->u2_params); } +/* + * There are reports of USB 3.0 devices that say they support USB 2.0 Link PM + * when they're plugged into a USB 2.0 port, but they don't work when LPM is + * enabled. + * + * Only enable USB 2.0 Link PM if the port is internal (hardwired), or the + * device says it supports the new USB 2.0 Link PM errata by setting the BESL + * support bit in the BOS descriptor. + */ +static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev) +{ + struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); + int connect_type = USB_PORT_CONNECT_TYPE_UNKNOWN; + + if (!udev->usb2_hw_lpm_capable || !udev->bos) + return; + + if (hub) + connect_type = hub->ports[udev->portnum - 1]->connect_type; + + if ((udev->bos->ext_cap->bmAttributes & cpu_to_le32(USB_BESL_SUPPORT)) + || connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) { + udev->usb2_hw_lpm_allowed = 1; + usb_set_usb2_hardware_lpm(udev, 1); + } +} + +void usb_update_device_lpm(struct usb_hcd *hcd, struct usb_device *udev) +{ + int retval; + + if (udev->wusb == 0 && le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0201) { + retval = usb_get_bos_descriptor(udev); + if (!retval) { + udev->lpm_capable = usb_device_supports_lpm(udev); + usb_set_lpm_parameters(udev); + } + } + + /* notify HCD that we have a device connected and addressed */ + if (hcd->driver->update_device) + hcd->driver->update_device(hcd, udev); + hub_set_initial_usb2_lpm_policy(udev); +} + /* USB 2.0 spec Section 11.24.4.5 */ static int get_hub_descriptor(struct usb_device *hdev, struct usb_hub_descriptor *desc) @@ -2295,7 +2340,6 @@ static int usb_enumerate_device_otg(struct usb_device *udev) return err; } - /** * usb_enumerate_device - Read device configs/intfs/otg (usbcore-internal) * @udev: newly addressed device (in ADDRESS state) @@ -2351,6 +2395,8 @@ static int usb_enumerate_device(struct usb_device *udev) usb_detect_interface_quirks(udev); + usb_update_device_lpm(hcd, udev); + return 0; } @@ -4402,33 +4448,6 @@ static int hub_set_address(struct usb_device *udev, int devnum) return retval; } -/* - * There are reports of USB 3.0 devices that say they support USB 2.0 Link PM - * when they're plugged into a USB 2.0 port, but they don't work when LPM is - * enabled. - * - * Only enable USB 2.0 Link PM if the port is internal (hardwired), or the - * device says it supports the new USB 2.0 Link PM errata by setting the BESL - * support bit in the BOS descriptor. - */ -static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev) -{ - struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); - int connect_type = USB_PORT_CONNECT_TYPE_UNKNOWN; - - if (!udev->usb2_hw_lpm_capable || !udev->bos) - return; - - if (hub) - connect_type = hub->ports[udev->portnum - 1]->connect_type; - - if ((udev->bos->ext_cap->bmAttributes & cpu_to_le32(USB_BESL_SUPPORT)) || - connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) { - udev->usb2_hw_lpm_allowed = 1; - usb_set_usb2_hardware_lpm(udev, 1); - } -} - static int hub_enable_device(struct usb_device *udev) { struct usb_hcd *hcd = bus_to_hcd(udev->bus); @@ -4779,19 +4798,9 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, usb_detect_quirks(udev); - if (udev->wusb == 0 && le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0201) { - retval = usb_get_bos_descriptor(udev); - if (!retval) { - udev->lpm_capable = usb_device_supports_lpm(udev); - usb_set_lpm_parameters(udev); - } - } + usb_update_device_lpm(hcd, udev); retval = 0; - /* notify HCD that we have a device connected and addressed */ - if (hcd->driver->update_device) - hcd->driver->update_device(hcd, udev); - hub_set_initial_usb2_lpm_policy(udev); fail: if (retval) { hub_port_disable(hub, port1, 0); diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index 0690fcff0ea2..bbbb7e6df958 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c @@ -440,7 +440,7 @@ static const struct usb_device_id usb_quirk_list[] = { static const struct usb_device_id usb_interface_quirk_list[] = { /* Logitech UVC Cameras */ { USB_VENDOR_AND_INTERFACE_INFO(0x046d, USB_CLASS_VIDEO, 1, 0), - .driver_info = USB_QUIRK_RESET_RESUME }, + .driver_info = USB_QUIRK_RESET_RESUME | USB_QUIRK_NO_LPM }, { } /* terminating entry must be last */ }; -- 2.20.0.rc2.403.gdbc3b29805-goog