diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2008-03-27 14:52:57 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-04-25 00:16:46 -0400 |
commit | 148d9fe4c91a6356dae1b05b76b8133586c26be4 (patch) | |
tree | 46156fcacfb5a402c9f222a06257b3926ff17497 /drivers/usb/storage | |
parent | cc901bbb2e2a4e4f96da3d70dae332882c10054b (diff) |
USB: usb-storage: use adaptive DMA mask
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>
Diffstat (limited to 'drivers/usb/storage')
-rw-r--r-- | drivers/usb/storage/scsiglue.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 5405ba8cd9d2..521f0297aef9 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c | |||
@@ -73,6 +73,7 @@ static const char* host_info(struct Scsi_Host *host) | |||
73 | static int slave_alloc (struct scsi_device *sdev) | 73 | static int slave_alloc (struct scsi_device *sdev) |
74 | { | 74 | { |
75 | struct us_data *us = host_to_us(sdev->host); | 75 | struct us_data *us = host_to_us(sdev->host); |
76 | struct usb_host_endpoint *bulk_in_ep; | ||
76 | 77 | ||
77 | /* | 78 | /* |
78 | * Set the INQUIRY transfer length to 36. We don't use any of | 79 | * 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) | |||
84 | /* Scatter-gather buffers (all but the last) must have a length | 85 | /* Scatter-gather buffers (all but the last) must have a length |
85 | * divisible by the bulk maxpacket size. Otherwise a data packet | 86 | * divisible by the bulk maxpacket size. Otherwise a data packet |
86 | * would end up being short, causing a premature end to the data | 87 | * would end up being short, causing a premature end to the data |
87 | * transfer. Since high-speed bulk pipes have a maxpacket size | 88 | * transfer. We'll use the maxpacket value of the bulk-IN pipe |
88 | * of 512, we'll use that as the scsi device queue's DMA alignment | 89 | * to set the SCSI device queue's DMA alignment mask. |
89 | * mask. Guaranteeing proper alignment of the first buffer will | 90 | */ |
90 | * have the desired effect because, except at the beginning and | 91 | bulk_in_ep = us->pusb_dev->ep_in[usb_pipeendpoint(us->recv_bulk_pipe)]; |
91 | * the end, scatter-gather buffers follow page boundaries. */ | 92 | blk_queue_update_dma_alignment(sdev->request_queue, |
92 | blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1)); | 93 | le16_to_cpu(bulk_in_ep->desc.wMaxPacketSize) - 1); |
94 | /* wMaxPacketSize must be a power of 2 */ | ||
93 | 95 | ||
94 | /* | 96 | /* |
95 | * The UFI spec treates the Peripheral Qualifier bits in an | 97 | * The UFI spec treates the Peripheral Qualifier bits in an |