From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753167AbcERKPD (ORCPT ); Wed, 18 May 2016 06:15:03 -0400 Received: from mga02.intel.com ([134.134.136.20]:48111 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752008AbcERKPA (ORCPT ); Wed, 18 May 2016 06:15:00 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,328,1459839600"; d="asc'?scan'208";a="705005713" From: Felipe Balbi To: Baolin Wang Cc: Greg KH , Mark Brown , USB , LKML Subject: Re: [PATCH] dwc3: gadget: Defer starting the gadget device until gadget is power on In-Reply-To: References: <4d6528e4b742cacf34f384b766a7c3296dfe9dbf.1463134786.git.baolin.wang@linaro.org> <87oa8aqlzh.fsf@linux.intel.com> <87d1oqqhvs.fsf@linux.intel.com> <871t56qg67.fsf@linux.intel.com> <87a8jp15cn.fsf@linux.intel.com> <874m9x11er.fsf@linux.intel.com> User-Agent: Notmuch/0.22+11~g124a67e (http://notmuchmail.org) Emacs/25.0.93.2 (x86_64-pc-linux-gnu) Date: Wed, 18 May 2016 13:12:47 +0300 Message-ID: <87bn43znc0.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Baolin Wang writes: >>> Baolin Wang writes: >>>>>>>> Make sense. >>>>>>> >>>>>>> cool, if you wanna work on it, let me know and I can give some deta= ils >>>>>>> of what I have in mind. >>>>>> >>>>>> Could you explain details to me, and I wanna continue to optimize the >>>>>> power management things. Thanks. >>>>> >>>>> I have it half-way done. Have a look at my dwc3-fix-suspend branch on >>>>> k.org. I haven't sent because I'm not getting a PME event. Can you te= st >>>>> on your end and let me know what happens? > > I applied some patches (showing below) about suspend/resume at your > dwc3-fix-suspend branch with my glue layer runtime_* callbacks on my > testing platform. > usb: dwc3: implement runtime PM > usb: dwc3: core: simplify suspend/resume operations > usb: dwc3: core: re-factor init and exit paths > usb: dwc3: core: get rid of DWC3_PM_OPS macro > usb: dwc3: gadget: fix gadget suspend/resume > usb: dwc3: gadget: re-factor ->udc_start and ->udc_stop > > Then I tested the cable connect/disconnect action to see the dwc core > resume/suspend. It looks work well on my platform, except that I did > some extra 2 modifications like below: > (1) > @@ -1485,16 +1490,11 @@ static int dwc3_gadget_run_stop(struct dwc3 > *dwc, int is_on, int suspend) > { > u32 reg; > u32 timeout =3D 500, i; > > + if (pm_runtime_suspended(dwc->dev)) > + return 0; > > (2) > @@ -1748,15 +1754,25 @@ static int dwc3_gadget_start(struct usb_gadget *g, > * even though host mode might be active. Don't actually perform > * device-specific initialization until device mode is activated. > */ > > + if (pm_runtime_suspended(dwc->dev)) { > + spin_unlock_irqrestore(&dwc->lock, flags); > + return 0; > + } > > + ret =3D __dwc3_gadget_start(dwc); > + if (ret) > + goto err1; > > So I think the dwc3 core can enter suspend mode before gadget function > is ready to call the 'usb_gadget_udc_start()' and > 'usb_udc_connect_control()', then if the dwc3 core has entered > suspended mode, we need to return success when starting the gadget, > and leave the gadget starting action from gadget resume. What do you > think about that? Thanks. Well, if this makes it work properly. Then, yeah; looks okay to me. I'll add this to the patch introducing runtime PM. Thanks a lot for testing on your side :-) =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXPEAfAAoJEIaOsuA1yqREzRcP/i9aV7VkSVL3Q1vQhp/bbAkS r+q/t9ewmPNuTEcCO7qAigQZ6G4kWUfVcmGmClYTuSh2WelZBd4msB80DTd9XyfH 9c2ObMoyhWcvyHG4CGFNo2l4uJm6yAUIDAxiya8tY3UJVi62laPN12hVMonhyRa6 yV3vYoAmiDtVmCHwOBe47tAWt7CFLTUIX+h5jmApRC744d+Ya8f9sldBNZ8WtwhN cYzdYVQkw1iI9W2MznaJkDhK1c9i6nbBYBR3PT249Du9KtqFdbMJMQ8SMTqX6W7n W1drc29Sv+q63p60mScGyqgiNRW7csfFoemSoi/OBAyZsk10NOYQ7T7VeRdW3dTR SZWyLoSP8/5lepCGjmm6TDMu3BzzkLZSy3iSRV7GviuEojOi8QbsxAHzX3S3jPfI ptmKhtNfGsD4W1GEaCaEx3sRnuvwGTY/C0MYmnj1ksFRBOMlnphl64ao/EAHtYvZ HUnPsVbpkIKk1ZPwxSeOoeSZ0zG7dzz/0zyxs9zCm/smfocramBRS5QKlzVnHdCT EkKlWhUA5Tzi9HQVYB4jHrFFm4B+yJCvLiY/rIO/lQsFtYsKLKllfFvg0zUdBTOV fUUPoZWuqcQWkZjZmn/pm3Aar/FAHt2YPcdC6wVCHgPQ7+LRtCso6/Brx+86DePX cXBvuF56A1zcRMwjiW/N =bjM5 -----END PGP SIGNATURE----- --=-=-=--