From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bear.ext.ti.com ([192.94.94.41]:35364 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756451AbbIXQvl (ORCPT ); Thu, 24 Sep 2015 12:51:41 -0400 Date: Thu, 24 Sep 2015 11:51:36 -0500 From: Felipe Balbi To: Robert Baldyga CC: Krzysztof Opasiak , , , , , Subject: Re: [PATCH v3 1/2] usb: gadget: loopback: fix: Don't share qlen and buflen between instances Message-ID: <20150924165136.GF14151@saruman.tx.rr.com> Reply-To: References: <1442947223-13277-1-git-send-email-k.opasiak@samsung.com> <56041470.70306@samsung.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7mxbaLlpDEyR1+x6" Content-Disposition: inline In-Reply-To: <56041470.70306@samsung.com> Sender: stable-owner@vger.kernel.org List-ID: --7mxbaLlpDEyR1+x6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 24, 2015 at 05:19:12PM +0200, Robert Baldyga wrote: > On 09/22/2015 08:40 PM, Krzysztof Opasiak wrote: > > Each instance of loopback function may have different qlen > > and buflen attributes values. When linking function to > > configuration those values had been assigned to global > > variables. Linking other instance to config overwrites those > > values. > >=20 > > This commit moves those values to f_loopback structure > > to avoid overwriting. Now each function has its own instance > > of those values. > >=20 > > Cc: # 3.10+ > > Signed-off-by: Krzysztof Opasiak >=20 > Reviewed-by: Robert Baldyga doesn't seem to fit stable IMO. Care to explain why you think we need to backport this to v3.10+ ? >=20 > > --- > > drivers/usb/gadget/function/f_loopback.c | 24 +++++++++++++---------= -- > > 1 file changed, 13 insertions(+), 11 deletions(-) > >=20 > > diff --git a/drivers/usb/gadget/function/f_loopback.c b/drivers/usb/gad= get/function/f_loopback.c > > index 6e2fe63..e4bfed4 100644 > > --- a/drivers/usb/gadget/function/f_loopback.c > > +++ b/drivers/usb/gadget/function/f_loopback.c > > @@ -34,6 +34,9 @@ struct f_loopback { > > =20 > > struct usb_ep *in_ep; > > struct usb_ep *out_ep; > > + > > + unsigned qlen; > > + unsigned buflen; > > }; > > =20 > > static inline struct f_loopback *func_to_loop(struct usb_function *f) > > @@ -41,13 +44,10 @@ static inline struct f_loopback *func_to_loop(struc= t usb_function *f) > > return container_of(f, struct f_loopback, function); > > } > > =20 > > -static unsigned qlen; > > -static unsigned buflen; > > - > > /*--------------------------------------------------------------------= -----*/ > > =20 > > static struct usb_interface_descriptor loopback_intf =3D { > > - .bLength =3D sizeof loopback_intf, > > + .bLength =3D sizeof(loopback_intf), > > .bDescriptorType =3D USB_DT_INTERFACE, > > =20 > > .bNumEndpoints =3D 2, > > @@ -253,7 +253,7 @@ static void loopback_complete(struct usb_ep *ep, st= ruct usb_request *req) > > } > > =20 > > /* queue the buffer for some later OUT packet */ > > - req->length =3D buflen; > > + req->length =3D loop->buflen; > > status =3D usb_ep_queue(ep, req, GFP_ATOMIC); > > if (status =3D=3D 0) > > return; > > @@ -290,7 +290,9 @@ static void disable_loopback(struct f_loopback *loo= p) > > =20 > > static inline struct usb_request *lb_alloc_ep_req(struct usb_ep *ep, i= nt len) > > { > > - return alloc_ep_req(ep, len, buflen); > > + struct f_loopback *loop =3D ep->driver_data; > > + > > + return alloc_ep_req(ep, len, loop->buflen); > > } > > =20 > > static int enable_endpoint(struct usb_composite_dev *cdev, struct f_lo= opback *loop, > > @@ -317,7 +319,7 @@ static int enable_endpoint(struct usb_composite_dev= *cdev, struct f_loopback *lo > > * we buffer at most 'qlen' transfers; fewer if any need more > > * than 'buflen' bytes each. > > */ > > - for (i =3D 0; i < qlen && result =3D=3D 0; i++) { > > + for (i =3D 0; i < loop->qlen && result =3D=3D 0; i++) { > > req =3D lb_alloc_ep_req(ep, 0); > > if (!req) > > goto fail1; > > @@ -391,10 +393,10 @@ static struct usb_function *loopback_alloc(struct= usb_function_instance *fi) > > lb_opts->refcnt++; > > mutex_unlock(&lb_opts->lock); > > =20 > > - buflen =3D lb_opts->bulk_buflen; > > - qlen =3D lb_opts->qlen; > > - if (!qlen) > > - qlen =3D 32; > > + loop->buflen =3D lb_opts->bulk_buflen; > > + loop->qlen =3D lb_opts->qlen; > > + if (!loop->qlen) > > + loop->qlen =3D 32; > > =20 > > loop->function.name =3D "loopback"; > > loop->function.bind =3D loopback_bind; > >=20 >=20 --=20 balbi --7mxbaLlpDEyR1+x6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWBCoYAAoJEIaOsuA1yqREpmoP/296VIZ7f15TZ5sOoibgYPqO LTbD6KiWgewVfYy+EyoWXs/9zx5Gjy0F7yV7taBdhX4+hjEKBVD1AmI+n5f4gGhl 3UNZOpx8PTVWm3CWsqOS+6ybFUeDafwpB2BI4PHfMGRuYTBfha3V4UrmMYiHWhTS UGm0BcZeqsCovqjBPeWcIkh/VlE9PeMR5CxLvQCgTFx3bjfn1DP4f4eZkeB2hhF8 s+6Xqi7vPsr+Xf6JVDD1l1VUw5OA6vXeBYwKAixI3x78Us/XgUJ4Y5sjsOsfyp6S dVhfBPAz5LTY1mpKgzuJiYiKxEDdpPD/fzI30uvp0LsGepoT11CxCqglRBufCd5A kuxQvEqM1ryKmph8TQ42KVAvzwyP59hjZivkgxI7dxGoCEm1LLaJFh4y4I5b2OQj xkToJXASw3cpZ9OifkyI5Xqb/m4LV2VuIA96cGV3P02/4oO8RT3hZLsHOfwMsyAT +iMM4WR8Qko0vdfqlnx+LLBkZ9lCERkfJy7BLWrxO90kU3h1o9ZHRansUXkNNKy9 I49UjnaNaadWWj4vGBKUdJw1cdZg0RBVQdphJHDEl4YEAVAO1cVVDQyZvWJR1RKR Sp+cNQzVxDzawlz5Gag03dbBxqlcBnUPttsMd196OL5yPOYzklruXoauLfQsJMUt R9NxnVSY3qFrboHXOjS4 =u1xF -----END PGP SIGNATURE----- --7mxbaLlpDEyR1+x6--