aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/scsiglue.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/storage/scsiglue.c')
-rw-r--r--drivers/usb/storage/scsiglue.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 3fcde9f0fa5f..09779f6a8179 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -1,8 +1,6 @@
1/* Driver for USB Mass Storage compliant devices 1/* Driver for USB Mass Storage compliant devices
2 * SCSI layer glue code 2 * SCSI layer glue code
3 * 3 *
4 * $Id: scsiglue.c,v 1.26 2002/04/22 03:39:43 mdharm Exp $
5 *
6 * Current development and maintenance by: 4 * Current development and maintenance by:
7 * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) 5 * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
8 * 6 *
@@ -73,7 +71,6 @@ static const char* host_info(struct Scsi_Host *host)
73static int slave_alloc (struct scsi_device *sdev) 71static int slave_alloc (struct scsi_device *sdev)
74{ 72{
75 struct us_data *us = host_to_us(sdev->host); 73 struct us_data *us = host_to_us(sdev->host);
76 struct usb_host_endpoint *bulk_in_ep;
77 74
78 /* 75 /*
79 * Set the INQUIRY transfer length to 36. We don't use any of 76 * Set the INQUIRY transfer length to 36. We don't use any of
@@ -82,16 +79,22 @@ static int slave_alloc (struct scsi_device *sdev)
82 */ 79 */
83 sdev->inquiry_len = 36; 80 sdev->inquiry_len = 36;
84 81
85 /* Scatter-gather buffers (all but the last) must have a length 82 /* USB has unusual DMA-alignment requirements: Although the
86 * divisible by the bulk maxpacket size. Otherwise a data packet 83 * starting address of each scatter-gather element doesn't matter,
87 * would end up being short, causing a premature end to the data 84 * the length of each element except the last must be divisible
88 * transfer. We'll use the maxpacket value of the bulk-IN pipe 85 * by the Bulk maxpacket value. There's currently no way to
89 * to set the SCSI device queue's DMA alignment mask. 86 * express this by block-layer constraints, so we'll cop out
87 * and simply require addresses to be aligned at 512-byte
88 * boundaries. This is okay since most block I/O involves
89 * hardware sectors that are multiples of 512 bytes in length,
90 * and since host controllers up through USB 2.0 have maxpacket
91 * values no larger than 512.
92 *
93 * But it doesn't suffice for Wireless USB, where Bulk maxpacket
94 * values can be as large as 2048. To make that work properly
95 * will require changes to the block layer.
90 */ 96 */
91 bulk_in_ep = us->pusb_dev->ep_in[usb_pipeendpoint(us->recv_bulk_pipe)]; 97 blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));
92 blk_queue_update_dma_alignment(sdev->request_queue,
93 le16_to_cpu(bulk_in_ep->desc.wMaxPacketSize) - 1);
94 /* wMaxPacketSize must be a power of 2 */
95 98
96 /* 99 /*
97 * The UFI spec treates the Peripheral Qualifier bits in an 100 * The UFI spec treates the Peripheral Qualifier bits in an
@@ -116,10 +119,10 @@ static int slave_configure(struct scsi_device *sdev)
116 * while others have trouble with more than 64K. At this time we 119 * while others have trouble with more than 64K. At this time we
117 * are limiting both to 32K (64 sectores). 120 * are limiting both to 32K (64 sectores).
118 */ 121 */
119 if (us->flags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) { 122 if (us->fflags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) {
120 unsigned int max_sectors = 64; 123 unsigned int max_sectors = 64;
121 124
122 if (us->flags & US_FL_MAX_SECTORS_MIN) 125 if (us->fflags & US_FL_MAX_SECTORS_MIN)
123 max_sectors = PAGE_CACHE_SIZE >> 9; 126 max_sectors = PAGE_CACHE_SIZE >> 9;
124 if (sdev->request_queue->max_sectors > max_sectors) 127 if (sdev->request_queue->max_sectors > max_sectors)
125 blk_queue_max_sectors(sdev->request_queue, 128 blk_queue_max_sectors(sdev->request_queue,
@@ -148,7 +151,7 @@ static int slave_configure(struct scsi_device *sdev)
148 * majority of devices work fine, but a few still can't 151 * majority of devices work fine, but a few still can't
149 * handle it. The sd driver will simply assume those 152 * handle it. The sd driver will simply assume those
150 * devices are write-enabled. */ 153 * devices are write-enabled. */
151 if (us->flags & US_FL_NO_WP_DETECT) 154 if (us->fflags & US_FL_NO_WP_DETECT)
152 sdev->skip_ms_page_3f = 1; 155 sdev->skip_ms_page_3f = 1;
153 156
154 /* A number of devices have problems with MODE SENSE for 157 /* A number of devices have problems with MODE SENSE for
@@ -158,13 +161,13 @@ static int slave_configure(struct scsi_device *sdev)
158 /* Some disks return the total number of blocks in response 161 /* Some disks return the total number of blocks in response
159 * to READ CAPACITY rather than the highest block number. 162 * to READ CAPACITY rather than the highest block number.
160 * If this device makes that mistake, tell the sd driver. */ 163 * If this device makes that mistake, tell the sd driver. */
161 if (us->flags & US_FL_FIX_CAPACITY) 164 if (us->fflags & US_FL_FIX_CAPACITY)
162 sdev->fix_capacity = 1; 165 sdev->fix_capacity = 1;
163 166
164 /* A few disks have two indistinguishable version, one of 167 /* A few disks have two indistinguishable version, one of
165 * which reports the correct capacity and the other does not. 168 * which reports the correct capacity and the other does not.
166 * The sd driver has to guess which is the case. */ 169 * The sd driver has to guess which is the case. */
167 if (us->flags & US_FL_CAPACITY_HEURISTICS) 170 if (us->fflags & US_FL_CAPACITY_HEURISTICS)
168 sdev->guess_capacity = 1; 171 sdev->guess_capacity = 1;
169 172
170 /* Some devices report a SCSI revision level above 2 but are 173 /* Some devices report a SCSI revision level above 2 but are
@@ -213,7 +216,7 @@ static int slave_configure(struct scsi_device *sdev)
213 216
214 /* Some devices choke when they receive a PREVENT-ALLOW MEDIUM 217 /* Some devices choke when they receive a PREVENT-ALLOW MEDIUM
215 * REMOVAL command, so suppress those commands. */ 218 * REMOVAL command, so suppress those commands. */
216 if (us->flags & US_FL_NOT_LOCKABLE) 219 if (us->fflags & US_FL_NOT_LOCKABLE)
217 sdev->lockable = 0; 220 sdev->lockable = 0;
218 221
219 /* this is to satisfy the compiler, tho I don't think the 222 /* this is to satisfy the compiler, tho I don't think the
@@ -238,7 +241,7 @@ static int queuecommand(struct scsi_cmnd *srb,
238 } 241 }
239 242
240 /* fail the command if we are disconnecting */ 243 /* fail the command if we are disconnecting */
241 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { 244 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
242 US_DEBUGP("Fail command during disconnect\n"); 245 US_DEBUGP("Fail command during disconnect\n");
243 srb->result = DID_NO_CONNECT << 16; 246 srb->result = DID_NO_CONNECT << 16;
244 done(srb); 247 done(srb);
@@ -248,7 +251,7 @@ static int queuecommand(struct scsi_cmnd *srb,
248 /* enqueue the command and wake up the control thread */ 251 /* enqueue the command and wake up the control thread */
249 srb->scsi_done = done; 252 srb->scsi_done = done;
250 us->srb = srb; 253 us->srb = srb;
251 up(&(us->sema)); 254 complete(&us->cmnd_ready);
252 255
253 return 0; 256 return 0;
254} 257}
@@ -280,9 +283,9 @@ static int command_abort(struct scsi_cmnd *srb)
280 * with the reset). Note that we must retain the host lock while 283 * with the reset). Note that we must retain the host lock while
281 * calling usb_stor_stop_transport(); otherwise it might interfere 284 * calling usb_stor_stop_transport(); otherwise it might interfere
282 * with an auto-reset that begins as soon as we release the lock. */ 285 * with an auto-reset that begins as soon as we release the lock. */
283 set_bit(US_FLIDX_TIMED_OUT, &us->flags); 286 set_bit(US_FLIDX_TIMED_OUT, &us->dflags);
284 if (!test_bit(US_FLIDX_RESETTING, &us->flags)) { 287 if (!test_bit(US_FLIDX_RESETTING, &us->dflags)) {
285 set_bit(US_FLIDX_ABORTING, &us->flags); 288 set_bit(US_FLIDX_ABORTING, &us->dflags);
286 usb_stor_stop_transport(us); 289 usb_stor_stop_transport(us);
287 } 290 }
288 scsi_unlock(us_to_host(us)); 291 scsi_unlock(us_to_host(us));
@@ -329,7 +332,7 @@ void usb_stor_report_device_reset(struct us_data *us)
329 struct Scsi_Host *host = us_to_host(us); 332 struct Scsi_Host *host = us_to_host(us);
330 333
331 scsi_report_device_reset(host, 0, 0); 334 scsi_report_device_reset(host, 0, 0);
332 if (us->flags & US_FL_SCM_MULT_TARG) { 335 if (us->fflags & US_FL_SCM_MULT_TARG) {
333 for (i = 1; i < host->max_id; ++i) 336 for (i = 1; i < host->max_id; ++i)
334 scsi_report_device_reset(host, 0, i); 337 scsi_report_device_reset(host, 0, i);
335 } 338 }
@@ -400,7 +403,7 @@ static int proc_info (struct Scsi_Host *host, char *buffer,
400 pos += sprintf(pos, " Quirks:"); 403 pos += sprintf(pos, " Quirks:");
401 404
402#define US_FLAG(name, value) \ 405#define US_FLAG(name, value) \
403 if (us->flags & value) pos += sprintf(pos, " " #name); 406 if (us->fflags & value) pos += sprintf(pos, " " #name);
404US_DO_ALL_FLAGS 407US_DO_ALL_FLAGS
405#undef US_FLAG 408#undef US_FLAG
406 409