Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp276781yba; Fri, 3 May 2019 01:25:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvIdyFG2IyNP3EUHC9DkVoeu+1TOIEU1yJU8PDNgDyTDkgUxFWv9NOUKBLTMwidvAGMgfT X-Received: by 2002:a63:ff0f:: with SMTP id k15mr8490893pgi.407.1556871942527; Fri, 03 May 2019 01:25:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556871942; cv=none; d=google.com; s=arc-20160816; b=KmyU9vACgv9mLNxl4Czb+DaLgETCTpeqPfRaFXyvaUVvtiBwJf4ZNqrj7cwpeW97bq 2MIUxzNuF+AvShq1JPNBhXmILqAUO4K3ryQI4SKb4q4hwIKt029Bii6MzWlJZ1NZJyim XRcnq30CrKcO3FUvEiL6lX5ZMdRHls5zvi3dFwO71yXvbWqsIDQg95aYRgzqH4fyCaal 6NZDUcYiwoUjqZO2eEKD6bZY5K5NDuToBhGy0ljwnv7VE0a0e+J35sv/W9Qh1UuHuSgQ 1ThAkoiyFF5aNaPbhXOgMDy00H/92c+Hlj0ZBW8z1dHD837+nWcRKXDMDLfE2YMNxyRf Ogsw== 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 :dkim-signature; bh=SzOqCEoi/RMSfvrSTXJ0eRwO8LREf+nR0SENYAUxBVw=; b=AIGCT7/V2ztPPc2+vBxzGFrWNqhEdNMb2XLfySOxoKI94KS3FtSXSH05x/KXfWEVK7 /s934znx+0ODJIfEf1PQyocmKIusFFsrrZwiXlJ1ZEKorfqVe90y9Z88RB0R+7jVr27O AfjxYNUZH4GFnKJL9NhpEWNLbu2wCip7yrNxAEDetitgKZ2Fa1R+VcvdlB5cx+pKP1ui 3+uLv1fr6TkfGyVV4k0KcTWhpUknZYErFkShqylpSVswjJ4NHU24uTosZBGmXwgBQ0oy EJqpVLS+VEkAlfpMD89V4x3zLUrco+HLFWtM1Nji3UjZU8x6/ubmmIaR+ludAfx3Lczx wl1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=dCEEATTn; dkim=fail header.i=@synopsys.onmicrosoft.com header.s=selector1-synopsys-com header.b=STTkZKmC; 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 cm8si1734935plb.159.2019.05.03.01.25.27; Fri, 03 May 2019 01:25:42 -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=dCEEATTn; dkim=fail header.i=@synopsys.onmicrosoft.com header.s=selector1-synopsys-com header.b=STTkZKmC; 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 S1727335AbfECIUR (ORCPT + 99 others); Fri, 3 May 2019 04:20:17 -0400 Received: from dc2-smtprelay2.synopsys.com ([198.182.61.142]:44434 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725793AbfECIUQ (ORCPT ); Fri, 3 May 2019 04:20:16 -0400 Received: from mailhost.synopsys.com (dc8-mailhost1.synopsys.com [10.13.135.209]) (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 4ACE4C0159; Fri, 3 May 2019 08:20:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1556871612; bh=ev67Stj8Ed6IH7ye+6gIzDKkiT6vgQ7ftgweF+BDnNc=; h=From:To:CC:Subject:Date:References:From; b=dCEEATTn3JgBqd9Sf4DNufaAaejA5dqOb3lRFq2AtplazchpExGQy/pOdKNxj41n0 72WIjyIwpatbOM8A0LVfv9YRQ1rLtgQC8crwBiV/fdSS3V2uAcZQVgsY/T36+6oq5y BOI5N/aY4ctAcjcVVUKd9UVu3YaK3VNG2ulO+6M4yLJMkelLknUAQE5gacGjJs5p2R fOhDHgON/4hi5wk2l6HfkMrBs6AHqV/8JuK5xLO7TrRX13g98+gsMCGv0GMiwxxaoG a9A2DPy6CGYat2jyPUP1StPu8sukW4VKzGlbd4GIBhOEc4wDgC1osX1BvW6p9QCbTa /QLDLSvIE7vBQ== Received: from US01WEHTC2.internal.synopsys.com (us01wehtc2.internal.synopsys.com [10.12.239.237]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPS id 28813A005D; Fri, 3 May 2019 08:20:11 +0000 (UTC) Received: from US01HYBRID2.internal.synopsys.com (10.15.246.24) by US01WEHTC2.internal.synopsys.com (10.12.239.237) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 3 May 2019 01:20:11 -0700 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (10.13.134.195) by mrs.synopsys.com (10.15.246.24) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 3 May 2019 01:20:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=synopsys.onmicrosoft.com; s=selector1-synopsys-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SzOqCEoi/RMSfvrSTXJ0eRwO8LREf+nR0SENYAUxBVw=; b=STTkZKmC2EaUwtk2LnupenYQ1y8juDrEzji1glMkzFiqMwSUh4ppPQJ19cTznbbYclRAnLto75MWeCr02O5ZeEO10vxQk18zGhTZifzC+NWHioe+h6EPdhcqATuXcxBuilvRTawaWN/Nrh5A22XvZDzU0inlURc27NXXnWxrHcY= Received: from SN1PR12MB2431.namprd12.prod.outlook.com (52.132.195.146) by SN1PR12MB2509.namprd12.prod.outlook.com (52.132.196.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1856.10; Fri, 3 May 2019 08:20:09 +0000 Received: from SN1PR12MB2431.namprd12.prod.outlook.com ([fe80::1982:4b45:2adf:9a1f]) by SN1PR12MB2431.namprd12.prod.outlook.com ([fe80::1982:4b45:2adf:9a1f%4]) with mapi id 15.20.1856.012; Fri, 3 May 2019 08:20:09 +0000 From: Artur Petrosyan To: Doug Anderson CC: Minas Harutyunyan , Felipe Balbi , "heiko@sntech.de" , "Alan Stern" , "amstan@chromium.org" , "linux-rockchip@lists.infradead.org" , William Wu , "linux-usb@vger.kernel.org" , Stefan Wahren , Randy Li , "zyw@rock-chips.com" , "mka@chromium.org" , "ryandcase@chromium.org" , Amelie Delaunay , "jwerner@chromium.org" , "dinguyen@opensource.altera.com" , "Elaine Zhang" , Greg Kroah-Hartman , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 1/5] usb: dwc2: bus suspend/resume for hosts with DWC2_POWER_DOWN_PARAM_NONE Thread-Topic: [PATCH v2 1/5] usb: dwc2: bus suspend/resume for hosts with DWC2_POWER_DOWN_PARAM_NONE Thread-Index: AQHU9XvT/eL2bASAskajIQu3Y3ICkw== Date: Fri, 3 May 2019 08:20:09 +0000 Message-ID: References: <20190418001356.124334-1-dianders@chromium.org> <20190418001356.124334-2-dianders@chromium.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=arturp@synopsys.com; x-originating-ip: [84.53.141.186] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7cb46ea9-9584-441e-b4cb-08d6cfa02804 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020);SRVR:SN1PR12MB2509; x-ms-traffictypediagnostic: SN1PR12MB2509: x-ms-exchange-purlcount: 3 x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:849; x-forefront-prvs: 0026334A56 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(396003)(136003)(39850400004)(366004)(376002)(55674003)(199004)(189003)(102836004)(26005)(55016002)(9686003)(53546011)(6436002)(229853002)(6306002)(68736007)(966005)(476003)(6506007)(81156014)(81166006)(4326008)(446003)(8676002)(74316002)(7416002)(7736002)(305945005)(6916009)(486006)(25786009)(86362001)(99286004)(186003)(53936002)(8936002)(73956011)(66066001)(6116002)(3846002)(6246003)(478600001)(5660300002)(66556008)(256004)(14444005)(316002)(33656002)(66476007)(66446008)(14454004)(66946007)(76116006)(91956017)(71190400001)(2906002)(15650500001)(71200400001)(52536014)(54906003)(7696005)(64756008)(76176011);DIR:OUT;SFP:1102;SCL:1;SRVR:SN1PR12MB2509;H:SN1PR12MB2431.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: synopsys.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: pRi0aiEbfO5wqX2cwvLLp/ax4KrsZ2HypcXfe8VVnzHrBJrjRiFmCu5lJjz1RqFinGurabwHfrkZP1cj7LUjcIGNI3eT3waYMu5Awp8oFw87j4b5B05xyyuKTPjvn/lf+FaVQmPr2EhUILzP8BGK8NY8B7oGFkse/viA0ZVtt8V1TeMXVbTJ3MQXq+jJarIv5KYuDrFL7fMMEnYhhcNqFo5Pw1rUU+Rofk4f0CuxJSd/Jtw+29yMf85BabaFRKrTKq9pimXqD/t6rDovZn7P+qfZsIsag0mbAnlcgkMtimjZUg6H1cDacxZ55998OgMUwzxOsVJL0vBghYziUKXpnu9oHwIcEqL3F82ti9gBToPbVgLMIs/KbVjSk9wpFjgiCDahQZTzZPOyC4/14h/py0G4mnWo+DJve7GREqynuqc= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 7cb46ea9-9584-441e-b4cb-08d6cfa02804 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 May 2019 08:20:09.0886 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: c33c9f88-1eb7-4099-9700-16013fd9e8aa X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2509 X-OriginatorOrg: synopsys.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/1/2019 05:57, Doug Anderson wrote:=0A= > Hi,=0A= > =0A= > On Mon, Apr 29, 2019 at 11:06 PM Artur Petrosyan=0A= > wrote:=0A= >>=0A= >> Hi,=0A= >>=0A= >> On 4/29/2019 21:34, Doug Anderson wrote:=0A= >>> Hi,=0A= >>>=0A= >>> On Mon, Apr 29, 2019 at 1:43 AM Artur Petrosyan=0A= >>> wrote:=0A= >>>>=0A= >>>> Hi,=0A= >>>>=0A= >>>> On 4/18/2019 04:15, Douglas Anderson wrote:=0A= >>>>> This is an attempt to rehash commit 0cf884e819e0 ("usb: dwc2: add bus= =0A= >>>>> suspend/resume for dwc2") on ToT. That commit was reverted in commit= =0A= >>>>> b0bb9bb6ce01 ("Revert "usb: dwc2: add bus suspend/resume for dwc2"")= =0A= >>>>> because apparently it broke the Altera SOCFPGA.=0A= >>>>>=0A= >>>>> With all the changes that have happened to dwc2 in the meantime, it's= =0A= >>>>> possible that the Altera SOCFPGA will just magically work with this= =0A= >>>>> change now. ...and it would be good to get bus suspend/resume=0A= >>>>> implemented.=0A= >>>>>=0A= >>>>> This change is a forward port of one that's been living in the Chrome= =0A= >>>>> OS 3.14 kernel tree.=0A= >>>>>=0A= >>>>> Signed-off-by: Douglas Anderson =0A= >>>>> ---=0A= >>>>> This patch was last posted at:=0A= >>>>>=0A= >>>>> https://urldefense.proofpoint.com/v2/url?u=3Dhttps-3A__lkml.kernel.or= g_r_1446237173-2D15263-2D1-2Dgit-2Dsend-2Demail-2Ddianders-40chromium.org&d= =3DDwIDAg&c=3DDPL6_X_6JkXFx7AXWqB0tg&r=3D9hPBFKCJ_nBjJhGVrrlYOeOQjP_HlVzYqr= C_D7niMJI&m=3DMMfe-4lZePyty6F5zfQ54kiYGuJWNulyRat944LkOsc&s=3DnExFpAPP_0plZ= fO5LMG1B-mqt1vyCvE35elVcyVgs8Y&e=3D=0A= >>>>>=0A= >>>>> ...and appears to have died the death of silence. Maybe it could get= =0A= >>>>> some bake time in linuxnext if we can't find any proactive testing?= =0A= >>>>>=0A= >>>>> I will also freely admit that I don't know tons about the theory=0A= >>>>> behind this patch. I'm mostly just re-hashing the original commit=0A= >>>>> from Kever that was reverted since:=0A= >>>>> * Turning on partial power down on rk3288 doesn't "just work". I=0A= >>>>> don't get hotplug events. This is despite dwc2 auto-detecting t= hat=0A= >>>>> we are power optimized.=0A= >>>> What do you mean by doesn't "just work" ? It seem to me that even afte= r=0A= >>>> adding this patch you don't get issues fixed.=0A= >>>> You mention that you don't get the hotplug events. Please provide dwc2= =0A= >>>> debug logs and register dumps on this issue.=0A= >>>=0A= >>> I mean that partial power down in the currently upstream driver=0A= >>> doesn't work. AKA: if I turn on partial power down in the upstream=0A= >>> driver then hotplug events break. I can try to provide some logs. On= =0A= >>> what exact version of the code do you want logs? Just your series?=0A= >>> Just my series? Mainline? Some attempt at combining both series? As= =0A= >>> I said things seem to sorta work with the combined series. I can try= =0A= >>> to clarify if that's the series you want me to test with. ...or I can= =0A= >>> wait for your next version?=0A= >> As I said this patch doesn't fix the issue with hotplug. With this patch= =0A= >> or without the hotplug behaves as it was. I have tested it on our setup.= =0A= >>=0A= >> Have you debugged your patch? Does it make any difference on your setup= =0A= >> ? Does it fix the issue with hotplug?=0A= > =0A= > I think we're still not taking on the same page.=0A= > =0A= > My patch makes no attempt to make partial power down mode work. My=0A= > patch attempts to make things work a little better when using=0A= > DWC2_POWER_DOWN_PARAM_NONE. There is no use testing my patch with=0A= > partial power down as it shouldn't have any impact there.=0A= > =0A= > =0A= >>> I am by no means an expert on dwc2, but an assumption made in my patch= =0A= >>> is that even cores that can't support partial power down can still=0A= >>> save some amount of power when hcd_suspend is called.=0A= >> Have you tried to debug dwc2 with power_down =3D=3D DWC2_POWER_DOWN_PARA= M_NONE ?=0A= >>>=0A= >>> Some evidence that this should be possible: looking at mainline Linux= =0A= >>> and at dwc2_port_suspend(), I see:=0A= >>>=0A= >>> * It is currently called even when we have DWC2_POWER_DOWN_PARAM_NONE= =0A= >> Currently (without your and my patches) (looking at mainline Linux) the= =0A= >> function dwc2_port_suspend() is called anyway because its call is issued= =0A= >> by the system. But it performs entering to suspend only in case of=0A= >> DWC2_POWER_DOWN_PARAM_PARTIAL.=0A= >>=0A= >> This is not an assumption. What I am pointing out is based on debugging= =0A= >> and before making assumptions without debugging for me seems not ok.=0A= >>=0A= >> Currently without your patch and without my patches. In the=0A= >> dwc2_port_suspend() it will enter to suspend only in case that=0A= >> power_down =3D=3D DWC2_POWER_DOWN_PARAM_PARTIAL. Because if you look at = the=0A= >> code more carefully you will see=0A= >>=0A= >> if (hsotg->params.power_down !=3D DWC2_POWER_DOWN_PARAM_PARTIAL= )=0A= >> goto skip_power_saving;=0A= >>=0A= >> This says if power_down is not DWC2_POWER_DOWN_PARAM_PARTIAL then skip= =0A= >> power saving.=0A= >>=0A= >> So but after your patch. If power_down is DWC2_POWER_DOWN_PARAM_NONE it= =0A= >> tries to suspend.=0A= > =0A= > We must be looking at different code. I'm looking at Linux's tree, AKA:= =0A= > =0A= > https://urldefense.proofpoint.com/v2/url?u=3Dhttps-3A__git.kernel.org_pub= _scm_linux_kernel_git_torvalds_linux.git_tree_drivers_usb_dwc2_hcd.c-23n348= 8&d=3DDwIFaQ&c=3DDPL6_X_6JkXFx7AXWqB0tg&r=3D9hPBFKCJ_nBjJhGVrrlYOeOQjP_HlVz= YqrC_D7niMJI&m=3DIWkDOOGTr0q-H1piDv2KOZe_Hnrz18g6rXFx-DsTuv4&s=3DAHu2iOKkyb= liRGtIfN7cF5p070UdvUKTYJsyAKYojis&e=3D=0A= Here you are looking at the old code. After that there are several of =0A= changes related to suspend/resume functions.=0A= =0A= This is the link to the code with changes. Latest version of those =0A= functions.=0A= =0A= https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/dri= vers/usb/dwc2/hcd.c#n4489=0A= =0A= Your changes are sitting on that latest version of code. Not the old =0A= version of it.=0A= =0A= > =0A= > I took a mainline kernel ("v5.1-rc7-5-g83a50840e72a") and added=0A= > printouts in dwc2_port_suspend() next to where it set HPRT0_SUSP and=0A= > PCGCTL_STOPPCLK in dwc2_port_suspend().=0A= I think you did this tests on the old version of the code=0A= =0A= I have tested the flow myself with the mainline Kernel on =0A= "torvalds/master" and not HPRT0_SUSP nor PCGCTL_STOPPCLK are not being set.= =0A= =0A= So here you need to review those things again.=0A= =0A= > =0A= > [ 454.906364] dwc2 ff540000.usb: I'm setting HPRT0_SUSP=0A= > [ 454.906367] dwc2 ff540000.usb: I'm setting PCGCTL_STOPPCLK=0A= > =0A= > ...and just to confirm:=0A= > =0A= > # grep '^power' /sys/kernel/debug/*.usb/params=0A= > /sys/kernel/debug/ff540000.usb/params:power_down : 0= =0A= > /sys/kernel/debug/ff580000.usb/params:power_down : 0= =0A= > =0A= > So I'm really quite convinced that on mainline Linux with=0A= > DWC2_POWER_DOWN_PARAM_NONE that dwc2_port_suspend() sets HPRT0_SUSP=0A= > and PCGCTL_STOPPCLK.=0A= > =0A= > =0A= >>> ...I believe that the net effect of my patch ends up doing both those= =0A= >>> same two things in hcd_suspend. That is: when power_down is=0A= >>> DWC2_POWER_DOWN_PARAM_NONE I believe my patch is really just doing the= =0A= >>> same thing that dwc2_port_suspend() would do in the same case. Is=0A= >>> that not OK?=0A= >> No if your patch is doing the same thing as it was doing before what is= =0A= >> the purpose of the patch ?=0A= > =0A= > The purpose is to make _dwc2_hcd_suspend() work more correctly in the=0A= > case where power_down is DWC2_POWER_DOWN_PARAM_NONE >=0A= > =0A= >> My testes show that your patch doesn't fix the issue related partial=0A= >> power down.=0A= > =0A= > Right. I have been trying to say that my patch doesn't do anything at=0A= > all for partial power down. I am simply trying to make=0A= > DWC2_POWER_DOWN_PARAM_NONE work more correctly.=0A= > =0A= > I haven't run all the power consumption tests in quite a long time and=0A= > I'll try to get it hooked up tomorrow to confirm that my patch really=0A= > truly is still needed to help with power consumption. I did confirm=0A= > that at least there are cases where _dwc2_hcd_suspend() is called and=0A= > my patch is what sets the important bits.=0A= > =0A= > -Doug=0A= > =0A= =0A= =0A= -- =0A= Regards,=0A= Artur=0A=