From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752735AbcERLXs (ORCPT ); Wed, 18 May 2016 07:23:48 -0400 Received: from mga14.intel.com ([192.55.52.115]:59181 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750790AbcERLXr (ORCPT ); Wed, 18 May 2016 07:23:47 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,328,1459839600"; d="asc'?scan'208";a="979520289" 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> <87bn43znc0.fsf@linux.intel.com> <8760ubzmve.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 14:21:32 +0300 Message-ID: <8737pfzk5f.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: >>>>> @@ -1748,15 +1754,25 @@ static int dwc3_gadget_start(struct usb_gadge= t *g, >>>>> * even though host mode might be active. Don't actually perf= orm >>>>> * device-specific initialization until device mode is activa= ted. >>>>> */ >>>>> >>>>> + 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. >>> >>> OK. >> >> I've updated the branch with slightly modified version of your >> changes. Can you test again just to make sure it still works ? >> >> Basically, here's what I did: >> >> on dwc3_gadget_start: >> >> - __dwc3_gadget_start(dwc); >> + if (pm_runtime_active(dwc->dev)) >> + __dwc3_gadget_start(dwc); >> + > > Great. > >> >> on run_stop, I kept the same thing. >> >> you just need to replace "usb: dwc3: implement runtime PM" with the new >> version from my branch. > > Yeah, it can work well on my platform with your new patch. cool, thanks again :-) I'll drop my "not for merging note" and add your "Tested-by" (assuming it's okay for you that I do it). cheers =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXPFA8AAoJEIaOsuA1yqREykoP/3ftSo2/ASD8q+PUHmHg11Q/ 3AGfhbCMt6FoAcvvi1tVeyf4GSYuR0W+8kRzSY+cID7Of3YtIXr5oqMcPPp7ACGk CXo37ooN/L47ccsyuDupR8drx3ACEB8assH2g7voX6rlRYq5pjj8ODxTmdAytnOr 0BgCPMPwOyOBVHOOnraSNiN/zeAcSS0/v0L0OBx1inROxnlgNbpkTjcXO8Sl3m/o 1rJ8UHE+UEK9bnR/cLF4/33GHUyHA5JNrpiQ4EPjdqJt+NHVG0pdJ5su5puyhqKF fpZH637DK5wIv8bOO5IyhMC/UO7B255XZwoStcWsV0hkK+Xv0Pj0bK+dxAG0J9vY zus/uf09W0zkRTwlQEqEBo0SpOkuN1Mpdt1RezhFYeIt5VzryuxHV5q/5UjrKRhf dPzeF3Y+xOy+Zpj4WdZi8ORzYJd//6gazTA1WbYmvUauW552mMLiZFAAiLRkcNFH aopdwWXmxPwKXEg6z+ehSvHKayYr0mZWkhYgqWnIsagriVYDFT6v+jg8ATgiYFqT RdUG15FzRMJdvWNX/5+A1uig5gIGYtZyuoDZfDLcs+dg5C7l5d5luEY/0uOaB8zN tFn9cD50irz1P2uAZbdL3ie+f+QloHqIuCGfm0Fwb7/X3wI+AANQfKbCKZOO8zNl QHHrr343+lL13f2GA80p =0Kdh -----END PGP SIGNATURE----- --=-=-=--