]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
USB: usb-storage: use adaptive DMA mask
authorAlan Stern <stern@rowland.harvard.edu>
Thu, 27 Mar 2008 18:52:57 +0000 (14:52 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 25 Apr 2008 04:16:46 +0000 (21:16 -0700)
This patch (as1060) makes usb-storage set the DMA alignment mask for
SCSI slaves to match the maxpacket size of the bulk-IN endpoint,
rather than always setting it to 511.  For full-speed devices that
mask is too restrictive, and wireless USB devices can have maxpacket
sizes larger than 512.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/storage/scsiglue.c

index 5405ba8cd9d26bafe5740df75987942e1e8ba0ac..521f0297aef92af7fd247c8d27d199b80e82cc23 100644 (file)
@@ -73,6 +73,7 @@ static const char* host_info(struct Scsi_Host *host)
 static int slave_alloc (struct scsi_device *sdev)
 {
        struct us_data *us = host_to_us(sdev->host);
+       struct usb_host_endpoint *bulk_in_ep;
 
        /*
         * Set the INQUIRY transfer length to 36.  We don't use any of
@@ -84,12 +85,13 @@ static int slave_alloc (struct scsi_device *sdev)
        /* Scatter-gather buffers (all but the last) must have a length
         * divisible by the bulk maxpacket size.  Otherwise a data packet
         * would end up being short, causing a premature end to the data
-        * transfer.  Since high-speed bulk pipes have a maxpacket size
-        * of 512, we'll use that as the scsi device queue's DMA alignment
-        * mask.  Guaranteeing proper alignment of the first buffer will
-        * have the desired effect because, except at the beginning and
-        * the end, scatter-gather buffers follow page boundaries. */
-       blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));
+        * transfer.  We'll use the maxpacket value of the bulk-IN pipe
+        * to set the SCSI device queue's DMA alignment mask.
+        */
+       bulk_in_ep = us->pusb_dev->ep_in[usb_pipeendpoint(us->recv_bulk_pipe)];
+       blk_queue_update_dma_alignment(sdev->request_queue,
+                       le16_to_cpu(bulk_in_ep->desc.wMaxPacketSize) - 1);
+                       /* wMaxPacketSize must be a power of 2 */
 
        /*
         * The UFI spec treates the Peripheral Qualifier bits in an