Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752471AbcC3KxW (ORCPT ); Wed, 30 Mar 2016 06:53:22 -0400 Received: from mga11.intel.com ([192.55.52.93]:4044 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752132AbcC3KxV (ORCPT ); Wed, 30 Mar 2016 06:53:21 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,415,1455004800"; d="asc'?scan'208";a="921720397" From: Felipe Balbi To: Michal Nazarewicz , "Felipe F. Tonello" , linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Robert Baldyga Subject: Re: [PATCH] usb: gadget: f_midi: Fixed a bug when buflen was smaller than wMaxPacketSize In-Reply-To: References: <1457552370-29404-1-git-send-email-eu@felipetonello.com> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/25.0.90.3 (x86_64-pc-linux-gnu) Date: Wed, 30 Mar 2016 13:51:17 +0300 Message-ID: <87wpokp7bu.fsf@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2986 Lines: 91 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Michal Nazarewicz writes: > [ text/plain ] > On Wed, Mar 09 2016, Felipe F. Tonello wrote: >> buflen by default (256) is smaller than wMaxPacketSize (512) in high-spe= ed >> devices. >> >> That caused the OUT endpoint to freeze if the host send any data packet = of >> length greater than 256 bytes. >> >> This is an example dump of what happended on that enpoint: >> HOST: [DATA][Length=3D260][...] >> DEVICE: [NAK] >> HOST: [PING] >> DEVICE: [NAK] >> HOST: [PING] >> DEVICE: [NAK] >> ... >> HOST: [PING] >> DEVICE: [NAK] >> >> This patch fixes this problem by setting the minimum usb_request's buffe= r size >> for the OUT endpoint as its wMaxPacketSize. >> >> Signed-off-by: Felipe F. Tonello > > Acked-by: Michal Nazarewicz > > But see comment below: > >> --- >> drivers/usb/gadget/function/f_midi.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/f= unction/f_midi.c >> index 8475e3dc82d4..826ba641f29d 100644 >> --- a/drivers/usb/gadget/function/f_midi.c >> +++ b/drivers/usb/gadget/function/f_midi.c >> @@ -366,7 +366,9 @@ static int f_midi_set_alt(struct usb_function *f, un= signed intf, unsigned alt) >> /* allocate a bunch of read buffers and queue them all at once. */ >> for (i =3D 0; i < midi->qlen && err =3D=3D 0; i++) { >> struct usb_request *req =3D >> - midi_alloc_ep_req(midi->out_ep, midi->buflen); >> + midi_alloc_ep_req(midi->out_ep, >> + max_t(unsigned, midi->buflen, >> + bulk_out_desc.wMaxPacketSize)); > > Or, just: > > + midi_alloc_ep_req(midi->out_ep, > + bulk_out_desc.wMaxPacketSize); > > Packet cannot be greater than wMaxPacketSize so there is no need to > allocate more (if buflen > wMaxPacketSize). a USB packet, right. that's correct. But a struct usb_request can point to whatever size buffer it wants and UDC is required to split that into wMaxPacketSize transfers. =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJW+6+mAAoJEIaOsuA1yqRE4b0P/iDYWVQvD6Kdy9tuIQiWAKDv kWp8rdI/Ay8EBy9Ro6RDpl//qp+DiSzFwUFiKIx4V9qxCqi55eL3zrfkQWdzjg1n gOu0XlbR0n+H7JXS/ys9w9V44jefQSvImGIEnn71igyzy7lJ9oBerSacVB4F2PwJ H+9BzgSJ9rzhY/R/ngHkgTBzEmibtoKIivJSIK/qOUMBcnt/bR9/caCVdvKNmitf FPoe2py7tVySvg11sBIHbL7GbLQZxQHakaFB5AFVvhC1jT2jo0FQNeIgTa3i3dYU aDUK9vYXtHNDXC+Y7RVDq3/QI0XO/TEKSMsd06q0sgmg2rryrIBtlelRB+MxIFZM 5aekdUqfe1EFwyPGVpBOuC/rWdtb4tMl7btHBrIV8NmSU5g0QN+W2Wry1Ia3IRRW 3qilKsEHcoiUbcBhGZ0IkUeTd93PGzdQyUw9eBy0T3+8VTIh+zIZi3wSevS2B7CT jMvrIYrJOYY1OSx94MfYzUpCM5d7jl64JZpme1cJj8sQruJ4iP5LArNVT1K7+NBr PCLD2Lt/KPBuwgr3DKd0Bgc2roPDErmtQ5LLHujsUO246GmXitpLTUWxBOwkK05d Sc0S/YXe7B6K2H2YMDnmGMIAMGLca/zlizyEljY3ZFXuL+x2RAk7R37Z8BbQ8XKv Ghzr9H1Kz5p+ipboEbH5 =bUgl -----END PGP SIGNATURE----- --=-=-=--