Lines Matching refs:sdev

169 	struct scsi_device *sdev = cmd->device;  in scsi_finish_command()  local
170 struct scsi_target *starget = scsi_target(sdev); in scsi_finish_command()
171 struct Scsi_Host *shost = sdev->host; in scsi_finish_command()
175 scsi_device_unbusy(sdev, cmd); in scsi_finish_command()
185 if (atomic_read(&sdev->device_blocked)) in scsi_finish_command()
186 atomic_set(&sdev->device_blocked, 0); in scsi_finish_command()
188 SCSI_LOG_MLCOMPLETE(4, sdev_printk(KERN_INFO, sdev, in scsi_finish_command()
214 int scsi_device_max_queue_depth(struct scsi_device *sdev) in scsi_device_max_queue_depth() argument
216 return max_t(int, sdev->host->can_queue, 1024); in scsi_device_max_queue_depth()
226 int scsi_change_queue_depth(struct scsi_device *sdev, int depth) in scsi_change_queue_depth() argument
228 depth = min_t(int, depth, scsi_device_max_queue_depth(sdev)); in scsi_change_queue_depth()
231 sdev->queue_depth = depth; in scsi_change_queue_depth()
235 if (sdev->request_queue) in scsi_change_queue_depth()
236 blk_set_queue_depth(sdev->request_queue, depth); in scsi_change_queue_depth()
238 sbitmap_resize(&sdev->budget_map, sdev->queue_depth); in scsi_change_queue_depth()
240 return sdev->queue_depth; in scsi_change_queue_depth()
263 int scsi_track_queue_full(struct scsi_device *sdev, int depth) in scsi_track_queue_full() argument
271 if ((jiffies >> 4) == (sdev->last_queue_full_time >> 4)) in scsi_track_queue_full()
274 sdev->last_queue_full_time = jiffies; in scsi_track_queue_full()
275 if (sdev->last_queue_full_depth != depth) { in scsi_track_queue_full()
276 sdev->last_queue_full_count = 1; in scsi_track_queue_full()
277 sdev->last_queue_full_depth = depth; in scsi_track_queue_full()
279 sdev->last_queue_full_count++; in scsi_track_queue_full()
282 if (sdev->last_queue_full_count <= 10) in scsi_track_queue_full()
285 return scsi_change_queue_depth(sdev, depth); in scsi_track_queue_full()
301 static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer, in scsi_vpd_inquiry() argument
321 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, in scsi_vpd_inquiry()
347 int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf, in scsi_get_vpd_page() argument
352 if (sdev->skip_vpd_pages) in scsi_get_vpd_page()
356 result = scsi_vpd_inquiry(sdev, buf, 0, buf_len); in scsi_get_vpd_page()
375 result = scsi_vpd_inquiry(sdev, buf, page, buf_len); in scsi_get_vpd_page()
393 static struct scsi_vpd *scsi_get_vpd_buf(struct scsi_device *sdev, u8 page) in scsi_get_vpd_buf() argument
403 result = scsi_vpd_inquiry(sdev, vpd_buf->data, page, vpd_len); in scsi_get_vpd_buf()
419 static void scsi_update_vpd_page(struct scsi_device *sdev, u8 page, in scsi_update_vpd_page() argument
424 vpd_buf = scsi_get_vpd_buf(sdev, page); in scsi_update_vpd_page()
428 mutex_lock(&sdev->inquiry_mutex); in scsi_update_vpd_page()
430 lockdep_is_held(&sdev->inquiry_mutex)); in scsi_update_vpd_page()
431 mutex_unlock(&sdev->inquiry_mutex); in scsi_update_vpd_page()
446 void scsi_attach_vpd(struct scsi_device *sdev) in scsi_attach_vpd() argument
451 if (!scsi_device_supports_vpd(sdev)) in scsi_attach_vpd()
455 vpd_buf = scsi_get_vpd_buf(sdev, 0); in scsi_attach_vpd()
461 scsi_update_vpd_page(sdev, 0x0, &sdev->vpd_pg0); in scsi_attach_vpd()
463 scsi_update_vpd_page(sdev, 0x80, &sdev->vpd_pg80); in scsi_attach_vpd()
465 scsi_update_vpd_page(sdev, 0x83, &sdev->vpd_pg83); in scsi_attach_vpd()
467 scsi_update_vpd_page(sdev, 0x89, &sdev->vpd_pg89); in scsi_attach_vpd()
483 int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer, in scsi_report_opcode() argument
490 if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3) in scsi_report_opcode()
501 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, in scsi_report_opcode()
529 int scsi_device_get(struct scsi_device *sdev) in scsi_device_get() argument
531 if (sdev->sdev_state == SDEV_DEL || sdev->sdev_state == SDEV_CANCEL) in scsi_device_get()
533 if (!get_device(&sdev->sdev_gendev)) in scsi_device_get()
535 if (!try_module_get(sdev->host->hostt->module)) in scsi_device_get()
540 put_device(&sdev->sdev_gendev); in scsi_device_get()
554 void scsi_device_put(struct scsi_device *sdev) in scsi_device_put() argument
556 struct module *mod = sdev->host->hostt->module; in scsi_device_put()
558 put_device(&sdev->sdev_gendev); in scsi_device_put()
602 struct scsi_device *sdev; in starget_for_each_device() local
604 shost_for_each_device(sdev, shost) { in starget_for_each_device()
605 if ((sdev->channel == starget->channel) && in starget_for_each_device()
606 (sdev->id == starget->id)) in starget_for_each_device()
607 fn(sdev, data); in starget_for_each_device()
630 struct scsi_device *sdev; in __starget_for_each_device() local
632 __shost_for_each_device(sdev, shost) { in __starget_for_each_device()
633 if ((sdev->channel == starget->channel) && in __starget_for_each_device()
634 (sdev->id == starget->id)) in __starget_for_each_device()
635 fn(sdev, data); in __starget_for_each_device()
658 struct scsi_device *sdev; in __scsi_device_lookup_by_target() local
660 list_for_each_entry(sdev, &starget->devices, same_target_siblings) { in __scsi_device_lookup_by_target()
661 if (sdev->sdev_state == SDEV_DEL) in __scsi_device_lookup_by_target()
663 if (sdev->lun ==lun) in __scsi_device_lookup_by_target()
664 return sdev; in __scsi_device_lookup_by_target()
683 struct scsi_device *sdev; in scsi_device_lookup_by_target() local
688 sdev = __scsi_device_lookup_by_target(starget, lun); in scsi_device_lookup_by_target()
689 if (sdev && scsi_device_get(sdev)) in scsi_device_lookup_by_target()
690 sdev = NULL; in scsi_device_lookup_by_target()
693 return sdev; in scsi_device_lookup_by_target()
716 struct scsi_device *sdev; in __scsi_device_lookup() local
718 list_for_each_entry(sdev, &shost->__devices, siblings) { in __scsi_device_lookup()
719 if (sdev->sdev_state == SDEV_DEL) in __scsi_device_lookup()
721 if (sdev->channel == channel && sdev->id == id && in __scsi_device_lookup()
722 sdev->lun ==lun) in __scsi_device_lookup()
723 return sdev; in __scsi_device_lookup()
744 struct scsi_device *sdev; in scsi_device_lookup() local
748 sdev = __scsi_device_lookup(shost, channel, id, lun); in scsi_device_lookup()
749 if (sdev && scsi_device_get(sdev)) in scsi_device_lookup()
750 sdev = NULL; in scsi_device_lookup()
753 return sdev; in scsi_device_lookup()