diff options
Diffstat (limited to 'drivers/scsi/scsi.c')
-rw-r--r-- | drivers/scsi/scsi.c | 282 |
1 files changed, 168 insertions, 114 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 0fb1709ce5e3..1a9fba6a9f92 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -122,6 +122,11 @@ static const char *const scsi_device_types[] = { | |||
122 | "Automation/Drive ", | 122 | "Automation/Drive ", |
123 | }; | 123 | }; |
124 | 124 | ||
125 | /** | ||
126 | * scsi_device_type - Return 17 char string indicating device type. | ||
127 | * @type: type number to look up | ||
128 | */ | ||
129 | |||
125 | const char * scsi_device_type(unsigned type) | 130 | const char * scsi_device_type(unsigned type) |
126 | { | 131 | { |
127 | if (type == 0x1e) | 132 | if (type == 0x1e) |
@@ -136,32 +141,45 @@ const char * scsi_device_type(unsigned type) | |||
136 | EXPORT_SYMBOL(scsi_device_type); | 141 | EXPORT_SYMBOL(scsi_device_type); |
137 | 142 | ||
138 | struct scsi_host_cmd_pool { | 143 | struct scsi_host_cmd_pool { |
139 | struct kmem_cache *slab; | 144 | struct kmem_cache *cmd_slab; |
140 | unsigned int users; | 145 | struct kmem_cache *sense_slab; |
141 | char *name; | 146 | unsigned int users; |
142 | unsigned int slab_flags; | 147 | char *cmd_name; |
143 | gfp_t gfp_mask; | 148 | char *sense_name; |
149 | unsigned int slab_flags; | ||
150 | gfp_t gfp_mask; | ||
144 | }; | 151 | }; |
145 | 152 | ||
146 | static struct scsi_host_cmd_pool scsi_cmd_pool = { | 153 | static struct scsi_host_cmd_pool scsi_cmd_pool = { |
147 | .name = "scsi_cmd_cache", | 154 | .cmd_name = "scsi_cmd_cache", |
155 | .sense_name = "scsi_sense_cache", | ||
148 | .slab_flags = SLAB_HWCACHE_ALIGN, | 156 | .slab_flags = SLAB_HWCACHE_ALIGN, |
149 | }; | 157 | }; |
150 | 158 | ||
151 | static struct scsi_host_cmd_pool scsi_cmd_dma_pool = { | 159 | static struct scsi_host_cmd_pool scsi_cmd_dma_pool = { |
152 | .name = "scsi_cmd_cache(DMA)", | 160 | .cmd_name = "scsi_cmd_cache(DMA)", |
161 | .sense_name = "scsi_sense_cache(DMA)", | ||
153 | .slab_flags = SLAB_HWCACHE_ALIGN|SLAB_CACHE_DMA, | 162 | .slab_flags = SLAB_HWCACHE_ALIGN|SLAB_CACHE_DMA, |
154 | .gfp_mask = __GFP_DMA, | 163 | .gfp_mask = __GFP_DMA, |
155 | }; | 164 | }; |
156 | 165 | ||
157 | static DEFINE_MUTEX(host_cmd_pool_mutex); | 166 | static DEFINE_MUTEX(host_cmd_pool_mutex); |
158 | 167 | ||
168 | /** | ||
169 | * __scsi_get_command - Allocate a struct scsi_cmnd | ||
170 | * @shost: host to transmit command | ||
171 | * @gfp_mask: allocation mask | ||
172 | * | ||
173 | * Description: allocate a struct scsi_cmd from host's slab, recycling from the | ||
174 | * host's free_list if necessary. | ||
175 | */ | ||
159 | struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask) | 176 | struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask) |
160 | { | 177 | { |
161 | struct scsi_cmnd *cmd; | 178 | struct scsi_cmnd *cmd; |
179 | unsigned char *buf; | ||
162 | 180 | ||
163 | cmd = kmem_cache_alloc(shost->cmd_pool->slab, | 181 | cmd = kmem_cache_alloc(shost->cmd_pool->cmd_slab, |
164 | gfp_mask | shost->cmd_pool->gfp_mask); | 182 | gfp_mask | shost->cmd_pool->gfp_mask); |
165 | 183 | ||
166 | if (unlikely(!cmd)) { | 184 | if (unlikely(!cmd)) { |
167 | unsigned long flags; | 185 | unsigned long flags; |
@@ -173,19 +191,32 @@ struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask) | |||
173 | list_del_init(&cmd->list); | 191 | list_del_init(&cmd->list); |
174 | } | 192 | } |
175 | spin_unlock_irqrestore(&shost->free_list_lock, flags); | 193 | spin_unlock_irqrestore(&shost->free_list_lock, flags); |
194 | |||
195 | if (cmd) { | ||
196 | buf = cmd->sense_buffer; | ||
197 | memset(cmd, 0, sizeof(*cmd)); | ||
198 | cmd->sense_buffer = buf; | ||
199 | } | ||
200 | } else { | ||
201 | buf = kmem_cache_alloc(shost->cmd_pool->sense_slab, | ||
202 | gfp_mask | shost->cmd_pool->gfp_mask); | ||
203 | if (likely(buf)) { | ||
204 | memset(cmd, 0, sizeof(*cmd)); | ||
205 | cmd->sense_buffer = buf; | ||
206 | } else { | ||
207 | kmem_cache_free(shost->cmd_pool->cmd_slab, cmd); | ||
208 | cmd = NULL; | ||
209 | } | ||
176 | } | 210 | } |
177 | 211 | ||
178 | return cmd; | 212 | return cmd; |
179 | } | 213 | } |
180 | EXPORT_SYMBOL_GPL(__scsi_get_command); | 214 | EXPORT_SYMBOL_GPL(__scsi_get_command); |
181 | 215 | ||
182 | /* | 216 | /** |
183 | * Function: scsi_get_command() | 217 | * scsi_get_command - Allocate and setup a scsi command block |
184 | * | 218 | * @dev: parent scsi device |
185 | * Purpose: Allocate and setup a scsi command block | 219 | * @gfp_mask: allocator flags |
186 | * | ||
187 | * Arguments: dev - parent scsi device | ||
188 | * gfp_mask- allocator flags | ||
189 | * | 220 | * |
190 | * Returns: The allocated scsi command structure. | 221 | * Returns: The allocated scsi command structure. |
191 | */ | 222 | */ |
@@ -202,7 +233,6 @@ struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, gfp_t gfp_mask) | |||
202 | if (likely(cmd != NULL)) { | 233 | if (likely(cmd != NULL)) { |
203 | unsigned long flags; | 234 | unsigned long flags; |
204 | 235 | ||
205 | memset(cmd, 0, sizeof(*cmd)); | ||
206 | cmd->device = dev; | 236 | cmd->device = dev; |
207 | init_timer(&cmd->eh_timeout); | 237 | init_timer(&cmd->eh_timeout); |
208 | INIT_LIST_HEAD(&cmd->list); | 238 | INIT_LIST_HEAD(&cmd->list); |
@@ -217,6 +247,12 @@ struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, gfp_t gfp_mask) | |||
217 | } | 247 | } |
218 | EXPORT_SYMBOL(scsi_get_command); | 248 | EXPORT_SYMBOL(scsi_get_command); |
219 | 249 | ||
250 | /** | ||
251 | * __scsi_put_command - Free a struct scsi_cmnd | ||
252 | * @shost: dev->host | ||
253 | * @cmd: Command to free | ||
254 | * @dev: parent scsi device | ||
255 | */ | ||
220 | void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd, | 256 | void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd, |
221 | struct device *dev) | 257 | struct device *dev) |
222 | { | 258 | { |
@@ -230,19 +266,19 @@ void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd, | |||
230 | } | 266 | } |
231 | spin_unlock_irqrestore(&shost->free_list_lock, flags); | 267 | spin_unlock_irqrestore(&shost->free_list_lock, flags); |
232 | 268 | ||
233 | if (likely(cmd != NULL)) | 269 | if (likely(cmd != NULL)) { |
234 | kmem_cache_free(shost->cmd_pool->slab, cmd); | 270 | kmem_cache_free(shost->cmd_pool->sense_slab, |
271 | cmd->sense_buffer); | ||
272 | kmem_cache_free(shost->cmd_pool->cmd_slab, cmd); | ||
273 | } | ||
235 | 274 | ||
236 | put_device(dev); | 275 | put_device(dev); |
237 | } | 276 | } |
238 | EXPORT_SYMBOL(__scsi_put_command); | 277 | EXPORT_SYMBOL(__scsi_put_command); |
239 | 278 | ||
240 | /* | 279 | /** |
241 | * Function: scsi_put_command() | 280 | * scsi_put_command - Free a scsi command block |
242 | * | 281 | * @cmd: command block to free |
243 | * Purpose: Free a scsi command block | ||
244 | * | ||
245 | * Arguments: cmd - command block to free | ||
246 | * | 282 | * |
247 | * Returns: Nothing. | 283 | * Returns: Nothing. |
248 | * | 284 | * |
@@ -263,12 +299,13 @@ void scsi_put_command(struct scsi_cmnd *cmd) | |||
263 | } | 299 | } |
264 | EXPORT_SYMBOL(scsi_put_command); | 300 | EXPORT_SYMBOL(scsi_put_command); |
265 | 301 | ||
266 | /* | 302 | /** |
267 | * Function: scsi_setup_command_freelist() | 303 | * scsi_setup_command_freelist - Setup the command freelist for a scsi host. |
268 | * | 304 | * @shost: host to allocate the freelist for. |
269 | * Purpose: Setup the command freelist for a scsi host. | ||
270 | * | 305 | * |
271 | * Arguments: shost - host to allocate the freelist for. | 306 | * Description: The command freelist protects against system-wide out of memory |
307 | * deadlock by preallocating one SCSI command structure for each host, so the | ||
308 | * system can always write to a swap file on a device associated with that host. | ||
272 | * | 309 | * |
273 | * Returns: Nothing. | 310 | * Returns: Nothing. |
274 | */ | 311 | */ |
@@ -282,16 +319,24 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost) | |||
282 | 319 | ||
283 | /* | 320 | /* |
284 | * Select a command slab for this host and create it if not | 321 | * Select a command slab for this host and create it if not |
285 | * yet existant. | 322 | * yet existent. |
286 | */ | 323 | */ |
287 | mutex_lock(&host_cmd_pool_mutex); | 324 | mutex_lock(&host_cmd_pool_mutex); |
288 | pool = (shost->unchecked_isa_dma ? &scsi_cmd_dma_pool : &scsi_cmd_pool); | 325 | pool = (shost->unchecked_isa_dma ? &scsi_cmd_dma_pool : &scsi_cmd_pool); |
289 | if (!pool->users) { | 326 | if (!pool->users) { |
290 | pool->slab = kmem_cache_create(pool->name, | 327 | pool->cmd_slab = kmem_cache_create(pool->cmd_name, |
291 | sizeof(struct scsi_cmnd), 0, | 328 | sizeof(struct scsi_cmnd), 0, |
292 | pool->slab_flags, NULL); | 329 | pool->slab_flags, NULL); |
293 | if (!pool->slab) | 330 | if (!pool->cmd_slab) |
331 | goto fail; | ||
332 | |||
333 | pool->sense_slab = kmem_cache_create(pool->sense_name, | ||
334 | SCSI_SENSE_BUFFERSIZE, 0, | ||
335 | pool->slab_flags, NULL); | ||
336 | if (!pool->sense_slab) { | ||
337 | kmem_cache_destroy(pool->cmd_slab); | ||
294 | goto fail; | 338 | goto fail; |
339 | } | ||
295 | } | 340 | } |
296 | 341 | ||
297 | pool->users++; | 342 | pool->users++; |
@@ -301,29 +346,36 @@ int scsi_setup_command_freelist(struct Scsi_Host *shost) | |||
301 | /* | 346 | /* |
302 | * Get one backup command for this host. | 347 | * Get one backup command for this host. |
303 | */ | 348 | */ |
304 | cmd = kmem_cache_alloc(shost->cmd_pool->slab, | 349 | cmd = kmem_cache_alloc(shost->cmd_pool->cmd_slab, |
305 | GFP_KERNEL | shost->cmd_pool->gfp_mask); | 350 | GFP_KERNEL | shost->cmd_pool->gfp_mask); |
306 | if (!cmd) | 351 | if (!cmd) |
307 | goto fail2; | 352 | goto fail2; |
308 | list_add(&cmd->list, &shost->free_list); | 353 | |
354 | cmd->sense_buffer = kmem_cache_alloc(shost->cmd_pool->sense_slab, | ||
355 | GFP_KERNEL | | ||
356 | shost->cmd_pool->gfp_mask); | ||
357 | if (!cmd->sense_buffer) | ||
358 | goto fail2; | ||
359 | |||
360 | list_add(&cmd->list, &shost->free_list); | ||
309 | return 0; | 361 | return 0; |
310 | 362 | ||
311 | fail2: | 363 | fail2: |
312 | if (!--pool->users) | 364 | if (cmd) |
313 | kmem_cache_destroy(pool->slab); | 365 | kmem_cache_free(shost->cmd_pool->cmd_slab, cmd); |
314 | return -ENOMEM; | 366 | mutex_lock(&host_cmd_pool_mutex); |
367 | if (!--pool->users) { | ||
368 | kmem_cache_destroy(pool->cmd_slab); | ||
369 | kmem_cache_destroy(pool->sense_slab); | ||
370 | } | ||
315 | fail: | 371 | fail: |
316 | mutex_unlock(&host_cmd_pool_mutex); | 372 | mutex_unlock(&host_cmd_pool_mutex); |
317 | return -ENOMEM; | 373 | return -ENOMEM; |
318 | |||
319 | } | 374 | } |
320 | 375 | ||
321 | /* | 376 | /** |
322 | * Function: scsi_destroy_command_freelist() | 377 | * scsi_destroy_command_freelist - Release the command freelist for a scsi host. |
323 | * | 378 | * @shost: host whose freelist is going to be destroyed |
324 | * Purpose: Release the command freelist for a scsi host. | ||
325 | * | ||
326 | * Arguments: shost - host that's freelist is going to be destroyed | ||
327 | */ | 379 | */ |
328 | void scsi_destroy_command_freelist(struct Scsi_Host *shost) | 380 | void scsi_destroy_command_freelist(struct Scsi_Host *shost) |
329 | { | 381 | { |
@@ -332,12 +384,16 @@ void scsi_destroy_command_freelist(struct Scsi_Host *shost) | |||
332 | 384 | ||
333 | cmd = list_entry(shost->free_list.next, struct scsi_cmnd, list); | 385 | cmd = list_entry(shost->free_list.next, struct scsi_cmnd, list); |
334 | list_del_init(&cmd->list); | 386 | list_del_init(&cmd->list); |
335 | kmem_cache_free(shost->cmd_pool->slab, cmd); | 387 | kmem_cache_free(shost->cmd_pool->sense_slab, |
388 | cmd->sense_buffer); | ||
389 | kmem_cache_free(shost->cmd_pool->cmd_slab, cmd); | ||
336 | } | 390 | } |
337 | 391 | ||
338 | mutex_lock(&host_cmd_pool_mutex); | 392 | mutex_lock(&host_cmd_pool_mutex); |
339 | if (!--shost->cmd_pool->users) | 393 | if (!--shost->cmd_pool->users) { |
340 | kmem_cache_destroy(shost->cmd_pool->slab); | 394 | kmem_cache_destroy(shost->cmd_pool->cmd_slab); |
395 | kmem_cache_destroy(shost->cmd_pool->sense_slab); | ||
396 | } | ||
341 | mutex_unlock(&host_cmd_pool_mutex); | 397 | mutex_unlock(&host_cmd_pool_mutex); |
342 | } | 398 | } |
343 | 399 | ||
@@ -441,8 +497,12 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) | |||
441 | } | 497 | } |
442 | #endif | 498 | #endif |
443 | 499 | ||
444 | /* | 500 | /** |
445 | * Assign a serial number to the request for error recovery | 501 | * scsi_cmd_get_serial - Assign a serial number to a command |
502 | * @host: the scsi host | ||
503 | * @cmd: command to assign serial number to | ||
504 | * | ||
505 | * Description: a serial number identifies a request for error recovery | ||
446 | * and debugging purposes. Protected by the Host_Lock of host. | 506 | * and debugging purposes. Protected by the Host_Lock of host. |
447 | */ | 507 | */ |
448 | static inline void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd *cmd) | 508 | static inline void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
@@ -452,14 +512,12 @@ static inline void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd | |||
452 | cmd->serial_number = host->cmd_serial_number++; | 512 | cmd->serial_number = host->cmd_serial_number++; |
453 | } | 513 | } |
454 | 514 | ||
455 | /* | 515 | /** |
456 | * Function: scsi_dispatch_command | 516 | * scsi_dispatch_command - Dispatch a command to the low-level driver. |
457 | * | 517 | * @cmd: command block we are dispatching. |
458 | * Purpose: Dispatch a command to the low-level driver. | ||
459 | * | ||
460 | * Arguments: cmd - command block we are dispatching. | ||
461 | * | 518 | * |
462 | * Notes: | 519 | * Return: nonzero return request was rejected and device's queue needs to be |
520 | * plugged. | ||
463 | */ | 521 | */ |
464 | int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | 522 | int scsi_dispatch_cmd(struct scsi_cmnd *cmd) |
465 | { | 523 | { |
@@ -585,7 +643,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | |||
585 | 643 | ||
586 | /** | 644 | /** |
587 | * scsi_req_abort_cmd -- Request command recovery for the specified command | 645 | * scsi_req_abort_cmd -- Request command recovery for the specified command |
588 | * cmd: pointer to the SCSI command of interest | 646 | * @cmd: pointer to the SCSI command of interest |
589 | * | 647 | * |
590 | * This function requests that SCSI Core start recovery for the | 648 | * This function requests that SCSI Core start recovery for the |
591 | * command by deleting the timer and adding the command to the eh | 649 | * command by deleting the timer and adding the command to the eh |
@@ -606,9 +664,9 @@ EXPORT_SYMBOL(scsi_req_abort_cmd); | |||
606 | * @cmd: The SCSI Command for which a low-level device driver (LLDD) gives | 664 | * @cmd: The SCSI Command for which a low-level device driver (LLDD) gives |
607 | * ownership back to SCSI Core -- i.e. the LLDD has finished with it. | 665 | * ownership back to SCSI Core -- i.e. the LLDD has finished with it. |
608 | * | 666 | * |
609 | * This function is the mid-level's (SCSI Core) interrupt routine, which | 667 | * Description: This function is the mid-level's (SCSI Core) interrupt routine, |
610 | * regains ownership of the SCSI command (de facto) from a LLDD, and enqueues | 668 | * which regains ownership of the SCSI command (de facto) from a LLDD, and |
611 | * the command to the done queue for further processing. | 669 | * enqueues the command to the done queue for further processing. |
612 | * | 670 | * |
613 | * This is the producer of the done queue who enqueues at the tail. | 671 | * This is the producer of the done queue who enqueues at the tail. |
614 | * | 672 | * |
@@ -617,7 +675,7 @@ EXPORT_SYMBOL(scsi_req_abort_cmd); | |||
617 | static void scsi_done(struct scsi_cmnd *cmd) | 675 | static void scsi_done(struct scsi_cmnd *cmd) |
618 | { | 676 | { |
619 | /* | 677 | /* |
620 | * We don't have to worry about this one timing out any more. | 678 | * We don't have to worry about this one timing out anymore. |
621 | * If we are unable to remove the timer, then the command | 679 | * If we are unable to remove the timer, then the command |
622 | * has already timed out. In which case, we have no choice but to | 680 | * has already timed out. In which case, we have no choice but to |
623 | * let the timeout function run, as we have no idea where in fact | 681 | * let the timeout function run, as we have no idea where in fact |
@@ -660,10 +718,11 @@ static struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd) | |||
660 | return *(struct scsi_driver **)cmd->request->rq_disk->private_data; | 718 | return *(struct scsi_driver **)cmd->request->rq_disk->private_data; |
661 | } | 719 | } |
662 | 720 | ||
663 | /* | 721 | /** |
664 | * Function: scsi_finish_command | 722 | * scsi_finish_command - cleanup and pass command back to upper layer |
723 | * @cmd: the command | ||
665 | * | 724 | * |
666 | * Purpose: Pass command off to upper layer for finishing of I/O | 725 | * Description: Pass command off to upper layer for finishing of I/O |
667 | * request, waking processes that are waiting on results, | 726 | * request, waking processes that are waiting on results, |
668 | * etc. | 727 | * etc. |
669 | */ | 728 | */ |
@@ -708,18 +767,14 @@ void scsi_finish_command(struct scsi_cmnd *cmd) | |||
708 | } | 767 | } |
709 | EXPORT_SYMBOL(scsi_finish_command); | 768 | EXPORT_SYMBOL(scsi_finish_command); |
710 | 769 | ||
711 | /* | 770 | /** |
712 | * Function: scsi_adjust_queue_depth() | 771 | * scsi_adjust_queue_depth - Let low level drivers change a device's queue depth |
713 | * | 772 | * @sdev: SCSI Device in question |
714 | * Purpose: Allow low level drivers to tell us to change the queue depth | 773 | * @tagged: Do we use tagged queueing (non-0) or do we treat |
715 | * on a specific SCSI device | 774 | * this device as an untagged device (0) |
716 | * | 775 | * @tags: Number of tags allowed if tagged queueing enabled, |
717 | * Arguments: sdev - SCSI Device in question | 776 | * or number of commands the low level driver can |
718 | * tagged - Do we use tagged queueing (non-0) or do we treat | 777 | * queue up in non-tagged mode (as per cmd_per_lun). |
719 | * this device as an untagged device (0) | ||
720 | * tags - Number of tags allowed if tagged queueing enabled, | ||
721 | * or number of commands the low level driver can | ||
722 | * queue up in non-tagged mode (as per cmd_per_lun). | ||
723 | * | 778 | * |
724 | * Returns: Nothing | 779 | * Returns: Nothing |
725 | * | 780 | * |
@@ -742,8 +797,8 @@ void scsi_adjust_queue_depth(struct scsi_device *sdev, int tagged, int tags) | |||
742 | 797 | ||
743 | spin_lock_irqsave(sdev->request_queue->queue_lock, flags); | 798 | spin_lock_irqsave(sdev->request_queue->queue_lock, flags); |
744 | 799 | ||
745 | /* Check to see if the queue is managed by the block layer | 800 | /* Check to see if the queue is managed by the block layer. |
746 | * if it is, and we fail to adjust the depth, exit */ | 801 | * If it is, and we fail to adjust the depth, exit. */ |
747 | if (blk_queue_tagged(sdev->request_queue) && | 802 | if (blk_queue_tagged(sdev->request_queue) && |
748 | blk_queue_resize_tags(sdev->request_queue, tags) != 0) | 803 | blk_queue_resize_tags(sdev->request_queue, tags) != 0) |
749 | goto out; | 804 | goto out; |
@@ -772,20 +827,17 @@ void scsi_adjust_queue_depth(struct scsi_device *sdev, int tagged, int tags) | |||
772 | } | 827 | } |
773 | EXPORT_SYMBOL(scsi_adjust_queue_depth); | 828 | EXPORT_SYMBOL(scsi_adjust_queue_depth); |
774 | 829 | ||
775 | /* | 830 | /** |
776 | * Function: scsi_track_queue_full() | 831 | * scsi_track_queue_full - track QUEUE_FULL events to adjust queue depth |
832 | * @sdev: SCSI Device in question | ||
833 | * @depth: Current number of outstanding SCSI commands on this device, | ||
834 | * not counting the one returned as QUEUE_FULL. | ||
777 | * | 835 | * |
778 | * Purpose: This function will track successive QUEUE_FULL events on a | 836 | * Description: This function will track successive QUEUE_FULL events on a |
779 | * specific SCSI device to determine if and when there is a | 837 | * specific SCSI device to determine if and when there is a |
780 | * need to adjust the queue depth on the device. | 838 | * need to adjust the queue depth on the device. |
781 | * | 839 | * |
782 | * Arguments: sdev - SCSI Device in question | 840 | * Returns: 0 - No change needed, >0 - Adjust queue depth to this new depth, |
783 | * depth - Current number of outstanding SCSI commands on | ||
784 | * this device, not counting the one returned as | ||
785 | * QUEUE_FULL. | ||
786 | * | ||
787 | * Returns: 0 - No change needed | ||
788 | * >0 - Adjust queue depth to this new depth | ||
789 | * -1 - Drop back to untagged operation using host->cmd_per_lun | 841 | * -1 - Drop back to untagged operation using host->cmd_per_lun |
790 | * as the untagged command depth | 842 | * as the untagged command depth |
791 | * | 843 | * |
@@ -824,10 +876,10 @@ int scsi_track_queue_full(struct scsi_device *sdev, int depth) | |||
824 | EXPORT_SYMBOL(scsi_track_queue_full); | 876 | EXPORT_SYMBOL(scsi_track_queue_full); |
825 | 877 | ||
826 | /** | 878 | /** |
827 | * scsi_device_get - get an addition reference to a scsi_device | 879 | * scsi_device_get - get an additional reference to a scsi_device |
828 | * @sdev: device to get a reference to | 880 | * @sdev: device to get a reference to |
829 | * | 881 | * |
830 | * Gets a reference to the scsi_device and increments the use count | 882 | * Description: Gets a reference to the scsi_device and increments the use count |
831 | * of the underlying LLDD module. You must hold host_lock of the | 883 | * of the underlying LLDD module. You must hold host_lock of the |
832 | * parent Scsi_Host or already have a reference when calling this. | 884 | * parent Scsi_Host or already have a reference when calling this. |
833 | */ | 885 | */ |
@@ -849,8 +901,8 @@ EXPORT_SYMBOL(scsi_device_get); | |||
849 | * scsi_device_put - release a reference to a scsi_device | 901 | * scsi_device_put - release a reference to a scsi_device |
850 | * @sdev: device to release a reference on. | 902 | * @sdev: device to release a reference on. |
851 | * | 903 | * |
852 | * Release a reference to the scsi_device and decrements the use count | 904 | * Description: Release a reference to the scsi_device and decrements the use |
853 | * of the underlying LLDD module. The device is freed once the last | 905 | * count of the underlying LLDD module. The device is freed once the last |
854 | * user vanishes. | 906 | * user vanishes. |
855 | */ | 907 | */ |
856 | void scsi_device_put(struct scsi_device *sdev) | 908 | void scsi_device_put(struct scsi_device *sdev) |
@@ -867,7 +919,7 @@ void scsi_device_put(struct scsi_device *sdev) | |||
867 | } | 919 | } |
868 | EXPORT_SYMBOL(scsi_device_put); | 920 | EXPORT_SYMBOL(scsi_device_put); |
869 | 921 | ||
870 | /* helper for shost_for_each_device, thus not documented */ | 922 | /* helper for shost_for_each_device, see that for documentation */ |
871 | struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *shost, | 923 | struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *shost, |
872 | struct scsi_device *prev) | 924 | struct scsi_device *prev) |
873 | { | 925 | { |
@@ -895,6 +947,8 @@ EXPORT_SYMBOL(__scsi_iterate_devices); | |||
895 | /** | 947 | /** |
896 | * starget_for_each_device - helper to walk all devices of a target | 948 | * starget_for_each_device - helper to walk all devices of a target |
897 | * @starget: target whose devices we want to iterate over. | 949 | * @starget: target whose devices we want to iterate over. |
950 | * @data: Opaque passed to each function call. | ||
951 | * @fn: Function to call on each device | ||
898 | * | 952 | * |
899 | * This traverses over each device of @starget. The devices have | 953 | * This traverses over each device of @starget. The devices have |
900 | * a reference that must be released by scsi_host_put when breaking | 954 | * a reference that must be released by scsi_host_put when breaking |
@@ -946,13 +1000,13 @@ EXPORT_SYMBOL(__starget_for_each_device); | |||
946 | * @starget: SCSI target pointer | 1000 | * @starget: SCSI target pointer |
947 | * @lun: SCSI Logical Unit Number | 1001 | * @lun: SCSI Logical Unit Number |
948 | * | 1002 | * |
949 | * Looks up the scsi_device with the specified @lun for a give | 1003 | * Description: Looks up the scsi_device with the specified @lun for a given |
950 | * @starget. The returned scsi_device does not have an additional | 1004 | * @starget. The returned scsi_device does not have an additional |
951 | * reference. You must hold the host's host_lock over this call and | 1005 | * reference. You must hold the host's host_lock over this call and |
952 | * any access to the returned scsi_device. | 1006 | * any access to the returned scsi_device. |
953 | * | 1007 | * |
954 | * Note: The only reason why drivers would want to use this is because | 1008 | * Note: The only reason why drivers should use this is because |
955 | * they're need to access the device list in irq context. Otherwise you | 1009 | * they need to access the device list in irq context. Otherwise you |
956 | * really want to use scsi_device_lookup_by_target instead. | 1010 | * really want to use scsi_device_lookup_by_target instead. |
957 | **/ | 1011 | **/ |
958 | struct scsi_device *__scsi_device_lookup_by_target(struct scsi_target *starget, | 1012 | struct scsi_device *__scsi_device_lookup_by_target(struct scsi_target *starget, |
@@ -974,9 +1028,9 @@ EXPORT_SYMBOL(__scsi_device_lookup_by_target); | |||
974 | * @starget: SCSI target pointer | 1028 | * @starget: SCSI target pointer |
975 | * @lun: SCSI Logical Unit Number | 1029 | * @lun: SCSI Logical Unit Number |
976 | * | 1030 | * |
977 | * Looks up the scsi_device with the specified @channel, @id, @lun for a | 1031 | * Description: Looks up the scsi_device with the specified @channel, @id, @lun |
978 | * give host. The returned scsi_device has an additional reference that | 1032 | * for a given host. The returned scsi_device has an additional reference that |
979 | * needs to be release with scsi_host_put once you're done with it. | 1033 | * needs to be released with scsi_device_put once you're done with it. |
980 | **/ | 1034 | **/ |
981 | struct scsi_device *scsi_device_lookup_by_target(struct scsi_target *starget, | 1035 | struct scsi_device *scsi_device_lookup_by_target(struct scsi_target *starget, |
982 | uint lun) | 1036 | uint lun) |
@@ -996,19 +1050,19 @@ struct scsi_device *scsi_device_lookup_by_target(struct scsi_target *starget, | |||
996 | EXPORT_SYMBOL(scsi_device_lookup_by_target); | 1050 | EXPORT_SYMBOL(scsi_device_lookup_by_target); |
997 | 1051 | ||
998 | /** | 1052 | /** |
999 | * scsi_device_lookup - find a device given the host (UNLOCKED) | 1053 | * __scsi_device_lookup - find a device given the host (UNLOCKED) |
1000 | * @shost: SCSI host pointer | 1054 | * @shost: SCSI host pointer |
1001 | * @channel: SCSI channel (zero if only one channel) | 1055 | * @channel: SCSI channel (zero if only one channel) |
1002 | * @pun: SCSI target number (physical unit number) | 1056 | * @id: SCSI target number (physical unit number) |
1003 | * @lun: SCSI Logical Unit Number | 1057 | * @lun: SCSI Logical Unit Number |
1004 | * | 1058 | * |
1005 | * Looks up the scsi_device with the specified @channel, @id, @lun for a | 1059 | * Description: Looks up the scsi_device with the specified @channel, @id, @lun |
1006 | * give host. The returned scsi_device does not have an additional reference. | 1060 | * for a given host. The returned scsi_device does not have an additional |
1007 | * You must hold the host's host_lock over this call and any access to the | 1061 | * reference. You must hold the host's host_lock over this call and any access |
1008 | * returned scsi_device. | 1062 | * to the returned scsi_device. |
1009 | * | 1063 | * |
1010 | * Note: The only reason why drivers would want to use this is because | 1064 | * Note: The only reason why drivers would want to use this is because |
1011 | * they're need to access the device list in irq context. Otherwise you | 1065 | * they need to access the device list in irq context. Otherwise you |
1012 | * really want to use scsi_device_lookup instead. | 1066 | * really want to use scsi_device_lookup instead. |
1013 | **/ | 1067 | **/ |
1014 | struct scsi_device *__scsi_device_lookup(struct Scsi_Host *shost, | 1068 | struct scsi_device *__scsi_device_lookup(struct Scsi_Host *shost, |
@@ -1033,9 +1087,9 @@ EXPORT_SYMBOL(__scsi_device_lookup); | |||
1033 | * @id: SCSI target number (physical unit number) | 1087 | * @id: SCSI target number (physical unit number) |
1034 | * @lun: SCSI Logical Unit Number | 1088 | * @lun: SCSI Logical Unit Number |
1035 | * | 1089 | * |
1036 | * Looks up the scsi_device with the specified @channel, @id, @lun for a | 1090 | * Description: Looks up the scsi_device with the specified @channel, @id, @lun |
1037 | * give host. The returned scsi_device has an additional reference that | 1091 | * for a given host. The returned scsi_device has an additional reference that |
1038 | * needs to be release with scsi_host_put once you're done with it. | 1092 | * needs to be released with scsi_device_put once you're done with it. |
1039 | **/ | 1093 | **/ |
1040 | struct scsi_device *scsi_device_lookup(struct Scsi_Host *shost, | 1094 | struct scsi_device *scsi_device_lookup(struct Scsi_Host *shost, |
1041 | uint channel, uint id, uint lun) | 1095 | uint channel, uint id, uint lun) |