Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5224111yba; Mon, 13 May 2019 07:24:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzT2tpzzibP48BDL0BQytrz1K8OtoljogOxsAIxIzY5kkXYcAyPpmwdeowaybBh3u5ezHHI X-Received: by 2002:a17:902:714e:: with SMTP id u14mr24840178plm.218.1557757499311; Mon, 13 May 2019 07:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557757499; cv=none; d=google.com; s=arc-20160816; b=AbB0YGkhgZ30HquMIyCPJXsKFOKbzNPLO/Ip8DvdrLJ9aK1GNMxhMAjTnJo+kVXxrh cbt4QI6Dr08XoRBYOGt+ssYLlwC/bctV3oj/e/ArV0Gh7YxIqBfqH4yG9gPH2mGaO12q +561zEfrVcjN4IXhIzzyHFVEjKa5DUzJJEZ9d/IViptCnz6QaRXZog55qoiWtrxutnPP 8RtC1fVuf/59w1cUHLzF3KbcodsVQNx6bR1YXTolhCtW1EQy9b7hK3dwxR/tLtSEspmN wE9pjAr84LcbpOStr54hlPTjK7xJEA2+b/YuzopB/1RTqu6SI07/ZtPPeYzfx2pK8QYP sNGQ== 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:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=slQVvJZG7QeySqlRadxAtHyxYd/B7bliewWncjPkULE=; b=NnwkekA36CFeNhdMZDGWhdMlulJevLGt9Kd6fqtuNk3XT3agTEUUx/sBBo8XsJZXO9 l3o6UfEBzkqrN0NmL6P1MibPVI7T/4Lk3b8cIAXVvgF2HInOb2BFuNFuC4ylon7gnJ95 YK13ZHDic6CdvhKCzzMrPfYclvZdHqqxX+yJAHE+G2J++afQaXjC4myZipYhKa2N1RVi hpQcHwrg6G+/i5Hn19mw4TTDQEgM6hQB7jp4RkKMHdVzYrAUEHuGG+DouIIGv7hG3pJZ cD8/FPNuXjNNEFA1BSD13z8gKO+JBuE1ZZeS50TTn465yvIPc7RhM8E9I5AEAIGPrxhH sd3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xilinx.onmicrosoft.com header.s=selector1-xilinx-com header.b=uGAbkFYC; 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 l22si15295237pgc.523.2019.05.13.07.24.42; Mon, 13 May 2019 07:24:59 -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=@xilinx.onmicrosoft.com header.s=selector1-xilinx-com header.b=uGAbkFYC; 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 S1729587AbfEMOPN (ORCPT + 99 others); Mon, 13 May 2019 10:15:13 -0400 Received: from mail-eopbgr810079.outbound.protection.outlook.com ([40.107.81.79]:44112 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726274AbfEMOPN (ORCPT ); Mon, 13 May 2019 10:15:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=slQVvJZG7QeySqlRadxAtHyxYd/B7bliewWncjPkULE=; b=uGAbkFYCelywDXRlfLHw29DRntk6APFfB3w3K04oRubs3r+jhOeYcf5BPVSssj6MG2o7m2sH7mMIV3KRbYdaLKGdmZppla1mWe/vsTdwjIZo+ixwIo2akzGycD/jK9ETtzTI7EFnfDntVl9CcFhp2tEu2v6Du0nYaw124z74a/M= Received: from BYAPR02MB5591.namprd02.prod.outlook.com (20.177.230.89) by BYAPR02MB5125.namprd02.prod.outlook.com (20.176.254.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.22; Mon, 13 May 2019 14:15:07 +0000 Received: from BYAPR02MB5591.namprd02.prod.outlook.com ([fe80::2c0d:4fbd:2c4:31b6]) by BYAPR02MB5591.namprd02.prod.outlook.com ([fe80::2c0d:4fbd:2c4:31b6%5]) with mapi id 15.20.1878.024; Mon, 13 May 2019 14:15:07 +0000 From: Anurag Kumar Vulisha To: 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: AQHVBXNeXBGr58NUnEy04Lh8niwnw6ZpIN9Q Date: Mon, 13 May 2019 14:15:07 +0000 Message-ID: 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> <30102591E157244384E984126FC3CB4F639EA444@us01wembx1.internal.synopsys.com> In-Reply-To: <30102591E157244384E984126FC3CB4F639EA444@us01wembx1.internal.synopsys.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=anuragku@xilinx.com; x-originating-ip: [149.199.50.133] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 152adb53-0e11-4ef4-4fd1-08d6d7ad6719 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020);SRVR:BYAPR02MB5125; x-ms-traffictypediagnostic: BYAPR02MB5125: x-ld-processed: 657af505-d5df-48d0-8300-c31994686c5c,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-forefront-prvs: 0036736630 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(366004)(396003)(136003)(376002)(346002)(13464003)(199004)(189003)(186003)(76116006)(4326008)(256004)(3846002)(26005)(14444005)(446003)(74316002)(2906002)(476003)(86362001)(11346002)(486006)(25786009)(6116002)(68736007)(14454004)(53936002)(33656002)(5660300002)(305945005)(66946007)(73956011)(7736002)(8936002)(102836004)(66476007)(66556008)(64756008)(66446008)(66066001)(7416002)(6506007)(53546011)(81166006)(478600001)(52536014)(76176011)(81156014)(6246003)(8676002)(99286004)(6436002)(7696005)(55016002)(316002)(9686003)(71200400001)(71190400001)(54906003)(110136005)(229853002);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR02MB5125;H:BYAPR02MB5591.namprd02.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: xilinx.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: s5ozpolqEg/6xD2fAHE2v2ARkSTKkMmy80LQHiW2zFwJPTnb5c4TFNdTf6f8LkTUrDT5aifXR/AyiEU/6hT+xWiwf7/ICeXsVK8cvm/sOaU65Ifkfm1EPT6Jh8AmPQvwqN7kpnLlXEZbj7Wh14st5RQeCkwx48inUCjzUYCAgjfdrXh9/V7Zluk/Ys3bU5b3ISUnTU4PgBb/kSKwZXBOV8EMHOnvZ5yiGCp+FAyR8R3UsF4hkC3exrWk/Jda687tbma324CUgTEeht00FWJ0VcxzW+6pRchZqtwUDdcalorFZIyGiw8uy/BCnsSGvNe0ESdgkfom60xbrTTN/cZ0v7d9iXQ4F7t6XnaycRj39wp8U5kR3ePk0UU4G6MAAxwACLaMqKvd3L0Cw1Tzb0Tku3cY0S3JF8vRjDz42kOPj5E= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-Network-Message-Id: 152adb53-0e11-4ef4-4fd1-08d6d7ad6719 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 May 2019 14:15:07.7250 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR02MB5125 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Thinh, >-----Original Message----- >From: Thinh Nguyen [mailto:Thinh.Nguyen@synopsys.com] >Sent: Saturday, May 11, 2019 7:18 AM >To: Anurag Kumar Vulisha ; Thinh Nguyen >; Greg Kroah-Hartman >; Rob Herring ; Mark Rutla= nd >; Felipe Balbi ; Claus H. Stovgaar= d > >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 U= 1 and U2 >entries > >Hi, > >Anurag Kumar Vulisha wrote: >> Hi Thinh, >> >>> -----Original Message----- >>> From: Thinh Nguyen [mailto:Thinh.Nguyen@synopsys.com] >>> Sent: Friday, May 10, 2019 5:30 AM >>> To: Anurag Kumar Vulisha ; Thinh Nguyen >>> ; Greg Kroah-Hartman >>> ; Rob Herring ; Mark Ru= tland >>> ; Felipe Balbi ; Claus H. Stovg= aard >>> >>> 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 disablin= g U1 and >U2 >>> entries >>> >>> Hi Anurag, >>> >>> Anurag Kumar Vulisha wrote: >>>>>> + return -EINVAL; >>>>>> >>>>>> reg =3D dwc3_readl(dwc->regs, DWC3_DCTL); >>>>>> if (set) >>>>>> @@ -626,7 +630,10 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc= , >>> struct >>>>>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c >>>>>> index e293400..f2d3112 100644 >>>>>> --- a/drivers/usb/dwc3/gadget.c >>>>>> +++ b/drivers/usb/dwc3/gadget.c >>>>>> @@ -2073,6 +2073,24 @@ static int dwc3_gadget_stop(struct usb_gadget= *g) >>>>>> return 0; >>>>>> } >>>>>> >>>>>> +static void dwc3_gadget_config_params(struct usb_gadget *g, >>>>>> + struct usb_dcd_config_params *params) >>>>>> +{ >>>>>> + struct dwc3 *dwc =3D gadget_to_dwc(g); >>>>>> + >>>>>> + /* U1 Device exit Latency */ >>>>>> + if (dwc->dis_u1_entry_quirk) >>>>>> + params->bU1devExitLat =3D 0; >>>>> It doesn't make sense to have exit latency of 0. Rejecting >>>>> SET_FEATURE(enable U1/U2) should already let the host know that the >>>>> device doesn't support U1/U2. >>>>> >>>> I am okay to remove this, but I feel that it is better to report zero = value instead >>>> of a non-zero value in exit latency of BOS when U1 or U2 entries are n= ot >supported. >>>> Advantage of reporting 0 is that some hosts doesn't even send >>> SET_FEATURE(U1/U2) >>>> requests on seeing zero value in BOS descriptor. Also there can be cas= es where >U1 is >>>> disabled and U2 entry is allowed or vice versa, for these kind of case= s the driver >can >>>> set zero exit latency value for U1 and non-zero exit latency value for= U2 . Based >on >>> this >>>> I think it would be better to report 0 when U1/U2 states are not enabl= ed. Please >>> provide >>>> your opinion on this. >>> Hm... I assume you're testing against linux usb stack and xhci host. If >>> that's the case, it looks like host will still request the device to >>> enter U1/U2 despite the device rejecting SET_FEATURE(enable U1/U2). Thi= s >>> needs to be fixed. I think what you have is fine to workaround this iss= ue. >> Thanks . Will send the next series with the other fixes that you have su= ggested >> >> Best Regards, >> Anurag Kumar Vulisha >> > >I want to try something. Can you see if this helps with your performance >test without setting the U1/U2 exit latency to 0? >(No need to change what you have in your patch. This is just for testing). > With your patch , the link doesn't enter into U1/U2 and I am also getting better performance Thanks, Anurag Kumar Vulisha >diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c >index 2f94568ba385..619351c581cf 100644 >--- a/drivers/usb/core/hub.c >+++ b/drivers/usb/core/hub.c >@@ -4057,8 +4057,18 @@ static void usb_enable_link_state(struct usb_hcd >*hcd, struct usb_device *udev, > /* Only a configured device will accept the Set Feature > * U1/U2_ENABLE > */ >- if (udev->actconfig) >- usb_set_device_initiated_lpm(udev, state, true); >+ if (udev->actconfig) { >+ if (usb_set_device_initiated_lpm(udev, state, >true)) { >+ /* >+ * Don't request U1/U2 entry if the device >+ * cannot enable U1/U2. >+ */ >+ usb_set_lpm_timeout(udev, state, 0); >+ >hcd->driver->disable_usb3_lpm_timeout(hcd, udev, >+ >state); >+ return; >+ } >+ } > > /* As soon as usb_set_lpm_timeout(timeout) returns 0, the > * hub-initiated LPM is enabled. Thus, LPM is enabled no > >