Lines Matching refs:sdev

160 	struct scsi_device *sdev = cmd->device;  in scsi_finish_command()  local
161 struct scsi_target *starget = scsi_target(sdev); in scsi_finish_command()
162 struct Scsi_Host *shost = sdev->host; in scsi_finish_command()
166 scsi_device_unbusy(sdev, cmd); in scsi_finish_command()
176 if (atomic_read(&sdev->device_blocked)) in scsi_finish_command()
177 atomic_set(&sdev->device_blocked, 0); in scsi_finish_command()
179 SCSI_LOG_MLCOMPLETE(4, sdev_printk(KERN_INFO, sdev, in scsi_finish_command()
205 int scsi_device_max_queue_depth(struct scsi_device *sdev) in scsi_device_max_queue_depth() argument
207 return min_t(int, sdev->host->can_queue, 4096); in scsi_device_max_queue_depth()
217 int scsi_change_queue_depth(struct scsi_device *sdev, int depth) in scsi_change_queue_depth() argument
219 depth = min_t(int, depth, scsi_device_max_queue_depth(sdev)); in scsi_change_queue_depth()
222 sdev->queue_depth = depth; in scsi_change_queue_depth()
226 if (sdev->request_queue) in scsi_change_queue_depth()
227 blk_set_queue_depth(sdev->request_queue, depth); in scsi_change_queue_depth()
229 sbitmap_resize(&sdev->budget_map, sdev->queue_depth); in scsi_change_queue_depth()
231 return sdev->queue_depth; in scsi_change_queue_depth()
254 int scsi_track_queue_full(struct scsi_device *sdev, int depth) in scsi_track_queue_full() argument
262 if ((jiffies >> 4) == (sdev->last_queue_full_time >> 4)) in scsi_track_queue_full()
265 sdev->last_queue_full_time = jiffies; in scsi_track_queue_full()
266 if (sdev->last_queue_full_depth != depth) { in scsi_track_queue_full()
267 sdev->last_queue_full_count = 1; in scsi_track_queue_full()
268 sdev->last_queue_full_depth = depth; in scsi_track_queue_full()
270 sdev->last_queue_full_count++; in scsi_track_queue_full()
273 if (sdev->last_queue_full_count <= 10) in scsi_track_queue_full()
276 return scsi_change_queue_depth(sdev, depth); in scsi_track_queue_full()
292 static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer, in scsi_vpd_inquiry() argument
312 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, in scsi_vpd_inquiry()
324 static int scsi_get_vpd_size(struct scsi_device *sdev, u8 page) in scsi_get_vpd_size() argument
335 result = scsi_vpd_inquiry(sdev, vpd_header, page, sizeof(vpd_header)); in scsi_get_vpd_size()
340 dev_warn_once(&sdev->sdev_gendev, in scsi_get_vpd_size()
362 int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf, in scsi_get_vpd_page() argument
367 if (!scsi_device_supports_vpd(sdev)) in scsi_get_vpd_page()
370 vpd_len = scsi_get_vpd_size(sdev, page); in scsi_get_vpd_page()
381 result = scsi_vpd_inquiry(sdev, buf, page, vpd_len); in scsi_get_vpd_page()
385 dev_warn_once(&sdev->sdev_gendev, in scsi_get_vpd_page()
400 static struct scsi_vpd *scsi_get_vpd_buf(struct scsi_device *sdev, u8 page) in scsi_get_vpd_buf() argument
405 vpd_len = scsi_get_vpd_size(sdev, page); in scsi_get_vpd_buf()
418 result = scsi_vpd_inquiry(sdev, vpd_buf->data, page, vpd_len); in scsi_get_vpd_buf()
424 dev_warn_once(&sdev->sdev_gendev, in scsi_get_vpd_buf()
437 static void scsi_update_vpd_page(struct scsi_device *sdev, u8 page, in scsi_update_vpd_page() argument
442 vpd_buf = scsi_get_vpd_buf(sdev, page); in scsi_update_vpd_page()
446 mutex_lock(&sdev->inquiry_mutex); in scsi_update_vpd_page()
448 lockdep_is_held(&sdev->inquiry_mutex)); in scsi_update_vpd_page()
449 mutex_unlock(&sdev->inquiry_mutex); in scsi_update_vpd_page()
464 void scsi_attach_vpd(struct scsi_device *sdev) in scsi_attach_vpd() argument
469 if (!scsi_device_supports_vpd(sdev)) in scsi_attach_vpd()
473 vpd_buf = scsi_get_vpd_buf(sdev, 0); in scsi_attach_vpd()
479 scsi_update_vpd_page(sdev, 0x0, &sdev->vpd_pg0); in scsi_attach_vpd()
481 scsi_update_vpd_page(sdev, 0x80, &sdev->vpd_pg80); in scsi_attach_vpd()
483 scsi_update_vpd_page(sdev, 0x83, &sdev->vpd_pg83); in scsi_attach_vpd()
485 scsi_update_vpd_page(sdev, 0x89, &sdev->vpd_pg89); in scsi_attach_vpd()
487 scsi_update_vpd_page(sdev, 0xb0, &sdev->vpd_pgb0); in scsi_attach_vpd()
489 scsi_update_vpd_page(sdev, 0xb1, &sdev->vpd_pgb1); in scsi_attach_vpd()
491 scsi_update_vpd_page(sdev, 0xb2, &sdev->vpd_pgb2); in scsi_attach_vpd()
507 int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer, in scsi_report_opcode() argument
514 if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3) in scsi_report_opcode()
520 dev_warn_once(&sdev->sdev_gendev, in scsi_report_opcode()
534 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, in scsi_report_opcode()
562 int scsi_device_get(struct scsi_device *sdev) in scsi_device_get() argument
564 if (sdev->sdev_state == SDEV_DEL || sdev->sdev_state == SDEV_CANCEL) in scsi_device_get()
566 if (!get_device(&sdev->sdev_gendev)) in scsi_device_get()
568 if (!try_module_get(sdev->host->hostt->module)) in scsi_device_get()
573 put_device(&sdev->sdev_gendev); in scsi_device_get()
587 void scsi_device_put(struct scsi_device *sdev) in scsi_device_put() argument
589 struct module *mod = sdev->host->hostt->module; in scsi_device_put()
591 put_device(&sdev->sdev_gendev); in scsi_device_put()
635 struct scsi_device *sdev; in starget_for_each_device() local
637 shost_for_each_device(sdev, shost) { in starget_for_each_device()
638 if ((sdev->channel == starget->channel) && in starget_for_each_device()
639 (sdev->id == starget->id)) in starget_for_each_device()
640 fn(sdev, data); in starget_for_each_device()
663 struct scsi_device *sdev; in __starget_for_each_device() local
665 __shost_for_each_device(sdev, shost) { in __starget_for_each_device()
666 if ((sdev->channel == starget->channel) && in __starget_for_each_device()
667 (sdev->id == starget->id)) in __starget_for_each_device()
668 fn(sdev, data); in __starget_for_each_device()
691 struct scsi_device *sdev; in __scsi_device_lookup_by_target() local
693 list_for_each_entry(sdev, &starget->devices, same_target_siblings) { in __scsi_device_lookup_by_target()
694 if (sdev->sdev_state == SDEV_DEL) in __scsi_device_lookup_by_target()
696 if (sdev->lun ==lun) in __scsi_device_lookup_by_target()
697 return sdev; in __scsi_device_lookup_by_target()
716 struct scsi_device *sdev; in scsi_device_lookup_by_target() local
721 sdev = __scsi_device_lookup_by_target(starget, lun); in scsi_device_lookup_by_target()
722 if (sdev && scsi_device_get(sdev)) in scsi_device_lookup_by_target()
723 sdev = NULL; in scsi_device_lookup_by_target()
726 return sdev; in scsi_device_lookup_by_target()
749 struct scsi_device *sdev; in __scsi_device_lookup() local
751 list_for_each_entry(sdev, &shost->__devices, siblings) { in __scsi_device_lookup()
752 if (sdev->sdev_state == SDEV_DEL) in __scsi_device_lookup()
754 if (sdev->channel == channel && sdev->id == id && in __scsi_device_lookup()
755 sdev->lun ==lun) in __scsi_device_lookup()
756 return sdev; in __scsi_device_lookup()
777 struct scsi_device *sdev; in scsi_device_lookup() local
781 sdev = __scsi_device_lookup(shost, channel, id, lun); in scsi_device_lookup()
782 if (sdev && scsi_device_get(sdev)) in scsi_device_lookup()
783 sdev = NULL; in scsi_device_lookup()
786 return sdev; in scsi_device_lookup()