From: Felipe Balbi Subject: Re: [RFC/PATCH 2/3] usb:gadget: Add SuperSpeed function power management Date: Fri, 29 Jul 2011 07:51:37 +0300 Message-ID: <20110729045136.GA9069@legolas.emea.dhcp.ti.com> References: <1309703373-22476-1-git-send-email-ablay@codeaurora.org> <1309703373-22476-3-git-send-email-ablay@codeaurora.org> <20110727143432.GQ5134@legolas.emea.dhcp.ti.com> <34c7abb33b7982065bda8f597b340dc0.squirrel@www.codeaurora.org> Reply-To: balbi@ti.com Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="kdhy+KQ/ef+27j+Z" Return-path: Received: from na3sys009aog104.obsmtp.com ([74.125.149.73]:39387 "EHLO na3sys009aog104.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752452Ab1G2Evl (ORCPT ); Fri, 29 Jul 2011 00:51:41 -0400 Content-Disposition: inline In-Reply-To: <34c7abb33b7982065bda8f597b340dc0.squirrel@www.codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org List-Id: linux-arm-msm@vger.kernel.org To: Amit Blay Cc: balbi@ti.com, greg@kroah.com, linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, tlinder@codeaurora.org --kdhy+KQ/ef+27j+Z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable hi, On Thu, Jul 28, 2011 at 09:15:46AM -0700, Amit Blay wrote: > >> Interface: GET_STATUS & SET_FEATURE(FUNC_SUSPEND). > > > > if it's targeted to an interface, why don't you just let the gadget > > driver handle it ? composite.c tracks all functions already and we > > should just call function->setup() to let the correct function handle > > this. >=20 > Your question is regarding why we added the function->func_suspend & > function->get_status callbacks in the first place? (I'm asking because > this is not covered by this patch...) yes, that's really unnecessary. > If we let both requests to be handled by function->setup(), then to > support SuperSpeed, we'll have to change each and every function's setup() > to respond back with a correct default value. > The advantage of adding function->func_suspend & function->get_status is > that if the function doesn't supply those functions, the default can be > handled by the composite setup() function. just handle as any other USB request. When it's implemented by the gadget driver, we will handle it and return success, otherwise (namely if f->setup() can't handle it) we stall. > >> +++ b/drivers/usb/gadget/zero.c > >> @@ -239,7 +239,11 @@ static void zero_autoresume(unsigned long _c) > >> * because of some direct user request. > >> */ > >> if (g->speed !=3D USB_SPEED_UNKNOWN) { > >> - int status =3D usb_gadget_wakeup(g); > >> + /* > >> + * The single interface of the current configuration > >> + * triggers the wakeup. > >> + */ > >> + int status =3D usb_gadget_wakeup(g, 1); > > > > no no, I think this should be handled by the function itself (f_*.c). >=20 > Yes you are right, the function should handle this. The next patch > (usb:gadget: SuperSpeed function power management testing support) adds > this exact capability to f_sourcesink. The function invokes the UDC's > func_wake callback. not sure this is the right thing to do though. > But in this change above, I tried (with minimal changes) to keep the > current functionality of gadget zero's autoresume, which uses > usb_gadget_wakeup(). Since there is no device remote wakeup in SuperSpeed, > only function wake, calling usb_gadget_wakeup() has no real meaning in > non-SuperSpeed speeds. >=20 > The complete solution will be to move the autoresume feature from gadget > zero into the functions, f_sourcesink & f_loopback. This is the way wakeup you shouldn't simply move it there. USB2 still has remote wakeup right ? > should be done in SuperSpeed, as I understand it. That means that both > functions will arm a timer on device suspend. When the timer expires, in > SuperSpeed it should call the UDC's func_wake callback. For lower speeds, > it should call usb_gadget_wakeup() to trigger device remote wakeup. > What do you think? not sure. To me, you should only to a remote wakeup (or function wake) if the user wants to use the device. Otherwise, why are you waking up the host ? > >> -static inline int usb_gadget_wakeup(struct usb_gadget *gadget) > >> +static inline int usb_gadget_wakeup(struct usb_gadget *gadget, int > >> interface_id) > >> { > >> - if (!gadget->ops->wakeup) > >> - return -EOPNOTSUPP; > >> - return gadget->ops->wakeup(gadget); > >> + if (gadget->speed =3D=3D USB_SPEED_SUPER) { > >> + if (!gadget->ops->func_wakeup) > >> + return -EOPNOTSUPP; > >> + > >> + return gadget->ops->func_wakeup(gadget, interface_id); > > > > I really don't like this... You're just abusing this interface. Either > > add a separate one (which I still don't think it's the right approach) > > or just let the gadget driver handle it, meaning that composite.c would > > call into f_*.c and the drivers which don't use composite.c will handle > > it their own way. >=20 > This change is meant to keep usb_gadget_wakeup() API backwards compatible, > meaning that this API will still work in SuperSpeed. > Of course, if a new USB class will utilize function wake, the new function > will call gadget->ops->func_wakeup(). then change it correctly, don't just hack around it ;-) > The solution I suggested above will address this comment as well, but the > downside is that it is not backward compatible, meaning, it requires to > change each gadget that is using usb_gadget_wakeup(). so ? It won't break anything if you do it right. Only USB3-capable gadget drivers have function wakeup... so start with the functions which have USB3 descriptors... --=20 balbi --kdhy+KQ/ef+27j+Z Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQEcBAEBAgAGBQJOMjxYAAoJEAv8Txj19kN14CYH/iQ1gVPY1SbRsO6UjioJ7M59 lTJBhbPoscBGRitKDX3l6c8OA2SMOXNJ5PseFGuJi16EmDSkBqb63wtCUQuqpJ6S yeDEsv/unscxWff23dqJKj5J65fRwHd7EfS7BoKxZblaieLQ1ezTWcbT/aRaYdi7 aUB0hQMki+8no3n0WysbPXmFT9Qd2zFxdghX6fT/XLSQUUhxifKn9Rc4hPuOvmif UQwOppxTvuMNnpgvMAhW8basPeSGhVUmX4G9Zpw2JqRnmGDO6Ss0blRTTpZCFoKY lnAzIZk2o1Y8Gul+t3BCfiguhXfmmsGrO4/C9sXik+iB1MrlMhQqIXH5kQDxwYo= =dtAT -----END PGP SIGNATURE----- --kdhy+KQ/ef+27j+Z--