Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2759857yba; Fri, 10 May 2019 18:50:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlkwAQCp2RdtJBXIDfJubdpcv5I67EF6j4tsX7nxMOO6wFqKCygIJZI9tTUF4KjBu4fTOy X-Received: by 2002:a63:231c:: with SMTP id j28mr17339909pgj.430.1557539420480; Fri, 10 May 2019 18:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557539420; cv=none; d=google.com; s=arc-20160816; b=OP3hTgvtKhvu8eQ3GjaSZzs/Dbiej+LgIy6u9pcXa+B4mZzqxN4iMjOHi19c9y5uVO LE1BpkR5TUbMmgx6wK1m6TM8106W211OD0nDQc2QivwI2wDU99fkp6TmW3U9cBVwhPfB 3DiEOjsz5FLiWdFuxl1L7vQuMJhgUjcewmlWoTphZPuWuEMRVi9tDpCU6AXYbxQMzoih 4rc294rzUCpxpsR9PfsAfx17UjtwL0YE0eM/fkYmKr7Y+A0pO21TBu7tJRLTvWKS4mWL 78qOAZtpfv50RMDeBMktnMMdpecq72MVjlH9j2hJYIprPBZtamZr3jceT1Y+IFCfMjDn 6oPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=y/W/2cNv1gk37ZrIawWoRoy8V5VC1etKE/D5Fomh9Gk=; b=Ki3hSQpJih9oj9Iud4JwqEap8KEXVvVQOPI2EIxhty5hfq6DLmAyYOkjJzMu2jpqCi JvaSQz1/+2cSjlXwjjdpIeJlzp0vYsXJlWk0j4NvG9qoKKBbL0exYPxk/prlSKurAvu7 ZIaKsFqn2OHjKF10VMXMM7yTeb7VFGBrDbo+KeL1B4gb5xIF08GusMgL/Rh707GcOprK AyPx7n+jnDR3rWhkQtEVSxgbjbp1+lzJYfAyZMjRWS4MmdHWoWX2DZ+VUNCQl1XPi2Rb Eb2ATxF1wC+UOVjk0hrbbuJSFFRVERJQEQMP0gooFKWPRWmxQN7pUBxxD3vXjNUnCWzL 5uXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=XtgM9GTp; 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=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v22si9150377pff.62.2019.05.10.18.49.51; Fri, 10 May 2019 18:50:20 -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=pass header.i=@synopsys.com header.s=mail header.b=XtgM9GTp; 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=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728364AbfEKBsJ (ORCPT + 99 others); Fri, 10 May 2019 21:48:09 -0400 Received: from dc8-smtprelay2.synopsys.com ([198.182.47.102]:49490 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728079AbfEKBsJ (ORCPT ); Fri, 10 May 2019 21:48:09 -0400 Received: from mailhost.synopsys.com (dc8-mailhost2.synopsys.com [10.13.135.210]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id F3DE0C0124; Sat, 11 May 2019 01:48:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1557539292; bh=R+2S9hsN1O5pmtXZq6Xo+Py+Mo7znMvzY7NQ1w6aRuc=; h=From:To:CC:Subject:Date:References:From; b=XtgM9GTpl55k80QjAD+ci8SIxofSWGqGw4Q2n8jHKiThjsShWvcNufFXyjng5/QtE TN2HKLtUnKK+YdklZzJ3FoBQVxvDglqn0O6enSYPn6U4BRQaeSpGFbsA8YQCdKwmVB Ooj/KewOyep5Q9rTGcgvFOoYJjlgdowldf/DeI56hWZcNfUWcfqLfmheCo3hXggcr2 aZXLmA9kkn2MWg+oDiHwo1lEFhRY0Q5qRnVrUS8lit+HebE+7Y8fO9TaPrIEGkpODH 6OrjYqK9xfEh6GhKr1ruFaLcYXNQE2wepPEUEV2evzNlNiri5MFMG5onSMz0v8d4jV +K95ofipmBklw== Received: from us01wehtc1.internal.synopsys.com (us01wehtc1-vip.internal.synopsys.com [10.12.239.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPS id 1D1E4A0077; Sat, 11 May 2019 01:48:07 +0000 (UTC) Received: from us01wembx1.internal.synopsys.com ([169.254.1.223]) by us01wehtc1.internal.synopsys.com ([::1]) with mapi id 14.03.0415.000; Fri, 10 May 2019 18:48:07 -0700 From: Thinh Nguyen To: Anurag Kumar Vulisha , Thinh Nguyen , Greg Kroah-Hartman , Rob Herring , Mark Rutland , "Felipe Balbi" , "Claus H. Stovgaard" CC: "linux-usb@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "v.anuragkumar@gmail.com" Subject: Re: [PATCH v2 3/3] usb: dwc3: gadget: Add support for disabling U1 and U2 entries Thread-Topic: [PATCH v2 3/3] usb: dwc3: gadget: Add support for disabling U1 and U2 entries Thread-Index: AQHVBXNg9QMnfODDx0qS+2/7kcKJQQ== Date: Sat, 11 May 2019 01:48:06 +0000 Message-ID: <30102591E157244384E984126FC3CB4F639EA444@us01wembx1.internal.synopsys.com> References: <1557302091-7455-1-git-send-email-anurag.kumar.vulisha@xilinx.com> <1557302091-7455-4-git-send-email-anurag.kumar.vulisha@xilinx.com> <30102591E157244384E984126FC3CB4F639E9823@us01wembx1.internal.synopsys.com> <30102591E157244384E984126FC3CB4F639E9E8F@us01wembx1.internal.synopsys.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.13.184.19] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi,=0A= =0A= Anurag Kumar Vulisha wrote:=0A= > Hi Thinh,=0A= >=0A= >> -----Original Message-----=0A= >> From: Thinh Nguyen [mailto:Thinh.Nguyen@synopsys.com]=0A= >> Sent: Friday, May 10, 2019 5:30 AM=0A= >> To: Anurag Kumar Vulisha ; Thinh Nguyen=0A= >> ; Greg Kroah-Hartman=0A= >> ; Rob Herring ; Mark Rut= land=0A= >> ; Felipe Balbi ; Claus H. Stovga= ard=0A= >> =0A= >> Cc: linux-usb@vger.kernel.org; devicetree@vger.kernel.org; linux-=0A= >> kernel@vger.kernel.org; v.anuragkumar@gmail.com=0A= >> Subject: Re: [PATCH v2 3/3] usb: dwc3: gadget: Add support for disabling= U1 and U2=0A= >> entries=0A= >>=0A= >> Hi Anurag,=0A= >>=0A= >> Anurag Kumar Vulisha wrote:=0A= >>>>> + return -EINVAL;=0A= >>>>>=0A= >>>>> reg =3D dwc3_readl(dwc->regs, DWC3_DCTL);=0A= >>>>> if (set)=0A= >>>>> @@ -626,7 +630,10 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc,= =0A= >> struct=0A= >>>>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c=0A= >>>>> index e293400..f2d3112 100644=0A= >>>>> --- a/drivers/usb/dwc3/gadget.c=0A= >>>>> +++ b/drivers/usb/dwc3/gadget.c=0A= >>>>> @@ -2073,6 +2073,24 @@ static int dwc3_gadget_stop(struct usb_gadget = *g)=0A= >>>>> return 0;=0A= >>>>> }=0A= >>>>>=0A= >>>>> +static void dwc3_gadget_config_params(struct usb_gadget *g,=0A= >>>>> + struct usb_dcd_config_params *params)=0A= >>>>> +{=0A= >>>>> + struct dwc3 *dwc =3D gadget_to_dwc(g);=0A= >>>>> +=0A= >>>>> + /* U1 Device exit Latency */=0A= >>>>> + if (dwc->dis_u1_entry_quirk)=0A= >>>>> + params->bU1devExitLat =3D 0;=0A= >>>> It doesn't make sense to have exit latency of 0. Rejecting=0A= >>>> SET_FEATURE(enable U1/U2) should already let the host know that the=0A= >>>> device doesn't support U1/U2.=0A= >>>>=0A= >>> I am okay to remove this, but I feel that it is better to report zero v= alue instead=0A= >>> of a non-zero value in exit latency of BOS when U1 or U2 entries are no= t supported.=0A= >>> Advantage of reporting 0 is that some hosts doesn't even send=0A= >> SET_FEATURE(U1/U2)=0A= >>> requests on seeing zero value in BOS descriptor. Also there can be case= s where U1 is=0A= >>> disabled and U2 entry is allowed or vice versa, for these kind of cases= the driver can=0A= >>> set zero exit latency value for U1 and non-zero exit latency value for = U2 . Based on=0A= >> this=0A= >>> I think it would be better to report 0 when U1/U2 states are not enable= d. Please=0A= >> provide=0A= >>> your opinion on this.=0A= >> Hm... I assume you're testing against linux usb stack and xhci host. If= =0A= >> that's the case, it looks like host will still request the device to=0A= >> enter U1/U2 despite the device rejecting SET_FEATURE(enable U1/U2). This= =0A= >> needs to be fixed. I think what you have is fine to workaround this issu= e.=0A= > Thanks . Will send the next series with the other fixes that you have sug= gested=0A= >=0A= > Best Regards,=0A= > Anurag Kumar Vulisha=0A= >=0A= =0A= I want to try something. Can you see if this helps with your performance=0A= test without setting the U1/U2 exit latency to 0?=0A= (No need to change what you have in your patch. This is just for testing).= =0A= =0A= diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c=0A= index 2f94568ba385..619351c581cf 100644=0A= --- a/drivers/usb/core/hub.c=0A= +++ b/drivers/usb/core/hub.c=0A= @@ -4057,8 +4057,18 @@ static void usb_enable_link_state(struct usb_hcd=0A= *hcd, struct usb_device *udev,=0A= /* Only a configured device will accept the Set Feature=0A= * U1/U2_ENABLE=0A= */=0A= - if (udev->actconfig)=0A= - usb_set_device_initiated_lpm(udev, state, true);=0A= + if (udev->actconfig) {=0A= + if (usb_set_device_initiated_lpm(udev, state,=0A= true)) {=0A= + /*=0A= + * Don't request U1/U2 entry if the device= =0A= + * cannot enable U1/U2.=0A= + */=0A= + usb_set_lpm_timeout(udev, state, 0);=0A= + =0A= hcd->driver->disable_usb3_lpm_timeout(hcd, udev,=0A= + =0A= state);=0A= + return;=0A= + }=0A= + }=0A= =0A= /* As soon as usb_set_lpm_timeout(timeout) returns 0, the= =0A= * hub-initiated LPM is enabled. Thus, LPM is enabled no=0A= =0A= =0A= Thanks,=0A= Thinh=0A=