Re: [PATCH] usb: gadget: file_storage: don't assume wMaxPacketSize to be 512

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

 



Hi,

On Sun, Apr 03, 2011 at 09:48:51PM +0300, Felipe Balbi wrote:
> > There's no way to avoid short packets.  If the hardware can't handle 
> > short packets, it is completely broken and there's no sense even trying 
> > to use it.  As an example, consider that the CBW packet is 31 bytes and 
> > therefore will be short at any speed.
> 
> This is good point.

Now that I look closer at the code, in case of CBW, we set outreq->length
to ep->maxpacket:

		/* Queue a request to read a Bulk-only CBW */
		set_bulk_out_req_length(fsg, bh, USB_BULK_CB_WRAP_LEN);

set_bulk_out_req_length(), alignes the size of the request to
ep->maxpacket:

static void set_bulk_out_req_length(struct fsg_dev *fsg,
		struct fsg_buffhd *bh, unsigned int length)
{
	unsigned int	rem;

	bh->bulk_out_intended_length = length;
	rem = length % fsg->bulk_out_maxpacket;
	if (rem > 0)
		length += fsg->bulk_out_maxpacket - rem;
	bh->outreq->length = length;
}

So, why didn't we use the same on the other parts of the code ? I mean:

diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index a6eacb5..24e5b49 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -1349,8 +1349,7 @@ static int do_write(struct fsg_dev *fsg)
 
                        /* amount is always divisible by 512, hence by
                         * the bulk-out maxpacket size */
-                       bh->outreq->length = bh->bulk_out_intended_length =
-                                       amount;
+                       set_bulk_out_req_length(fsg, bh, amount);
                        bh->outreq->short_not_ok = 1;
                        start_transfer(fsg, fsg->bulk_out, bh->outreq,
                                        &bh->outreq_busy, &bh->state);
@@ -2010,8 +2009,7 @@ static int throw_away_data(struct fsg_dev *fsg)
 
                        /* amount is always divisible by 512, hence by
                         * the bulk-out maxpacket size */
-                       bh->outreq->length = bh->bulk_out_intended_length =
-                                       amount;
+                       set_bulk_out_req_length(fsg, bh, amount);
                        bh->outreq->short_not_ok = 1;
                        start_transfer(fsg, fsg->bulk_out, bh->outreq,
                                        &bh->outreq_busy, &bh->state);

With that, my USB3 controller would be happy.

-- 
balbi
--
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