RE: [PATCH] USB: Add support for SuperSpeed isoc endpoints

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Sarah Sharp [mailto:sarah.a.sharp@xxxxxxxxxxxxxxx]
> On Fri, Feb 25, 2011 at 01:45:03PM -0800, Paul Zimmerman wrote:
> > Use the Mult and bMaxBurst values from the endpoint companion
> > descriptor to calculate the max length of an isoc transfer
> >
> > Signed-off-by: Paul Zimmerman <paulz@xxxxxxxxxxxx>
> > ---
> >  drivers/usb/core/urb.c |   11 ++++++++++-
> >  1 files changed, 10 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
> > index c14fc08..991f33e 100644
> > --- a/drivers/usb/core/urb.c
> > +++ b/drivers/usb/core/urb.c
> > @@ -366,7 +366,16 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
> >  	if (xfertype == USB_ENDPOINT_XFER_ISOC) {
> >  		int	n, len;
> >
> > -		/* FIXME SuperSpeed isoc endpoints have up to 16 bursts */
> > +		/* SuperSpeed isoc endpoints have up to 16 bursts of up to
> > +		 * 3 packets each
> > +		 */
> > +		if (dev->speed == USB_SPEED_SUPER) {
> > +			int     burst = 1 + ep->ss_ep_comp.bMaxBurst;
> > +			int     mult = 1 + ep->ss_ep_comp.bmAttributes;
> 
> Paul, please don't create new variables in an if block.  Create them at
> the top of the function.

Hi Sarah,

I'm sorry, but Linus disagrees with you. He recently expressed a preference
for variables that are only used within a block, to be defined within the
block instead of at the top of the function. Plus I am following the style that
is already used within that function. Please take a closer look.

> 
> > +			max *= burst;
> > +			max *= mult;
> > +		}
> > +
> 
> Where is max used later?

max is used about 12 lines further down:

	len = urb->iso_frame_desc[n].length;
	if (len < 0 || len > max)
		return -EMSGSIZE;

> I'll have to look further in the code to see if this actually works.  I
> don't think you can just use the endpoint calculations, because the
> driver may want to submit a slightly shorter transfer length.  It's
> really the USB core's job to check whether the buffer size is bigger
> than what the endpoint can handle.  The code should go there instead.

This code is in the USB core. Please take a closer look at the function,
this is the proper place to check. I have tested this, and without the
patch it is impossible to submit an isoc URB that is larger than a single
packet. With the patch, it works.

-- 
Paul

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux