Lines Matching refs:sdev

161 	struct scsi_device *sdev = cmd->device;  in scsi_finish_command()  local
162 struct scsi_target *starget = scsi_target(sdev); in scsi_finish_command()
163 struct Scsi_Host *shost = sdev->host; in scsi_finish_command()
167 scsi_device_unbusy(sdev, cmd); in scsi_finish_command()
177 if (atomic_read(&sdev->device_blocked)) in scsi_finish_command()
178 atomic_set(&sdev->device_blocked, 0); in scsi_finish_command()
180 SCSI_LOG_MLCOMPLETE(4, sdev_printk(KERN_INFO, sdev, in scsi_finish_command()
206 int scsi_device_max_queue_depth(struct scsi_device *sdev) in scsi_device_max_queue_depth() argument
208 return max_t(int, sdev->host->can_queue, 1024); in scsi_device_max_queue_depth()
218 int scsi_change_queue_depth(struct scsi_device *sdev, int depth) in scsi_change_queue_depth() argument
220 depth = min_t(int, depth, scsi_device_max_queue_depth(sdev)); in scsi_change_queue_depth()
223 sdev->queue_depth = depth; in scsi_change_queue_depth()
227 if (sdev->request_queue) in scsi_change_queue_depth()
228 blk_set_queue_depth(sdev->request_queue, depth); in scsi_change_queue_depth()
230 sbitmap_resize(&sdev->budget_map, sdev->queue_depth); in scsi_change_queue_depth()
232 return sdev->queue_depth; in scsi_change_queue_depth()
255 int scsi_track_queue_full(struct scsi_device *sdev, int depth) in scsi_track_queue_full() argument
263 if ((jiffies >> 4) == (sdev->last_queue_full_time >> 4)) in scsi_track_queue_full()
266 sdev->last_queue_full_time = jiffies; in scsi_track_queue_full()
267 if (sdev->last_queue_full_depth != depth) { in scsi_track_queue_full()
268 sdev->last_queue_full_count = 1; in scsi_track_queue_full()
269 sdev->last_queue_full_depth = depth; in scsi_track_queue_full()
271 sdev->last_queue_full_count++; in scsi_track_queue_full()
274 if (sdev->last_queue_full_count <= 10) in scsi_track_queue_full()
277 return scsi_change_queue_depth(sdev, depth); in scsi_track_queue_full()
293 static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer, in scsi_vpd_inquiry() argument
313 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, in scsi_vpd_inquiry()
339 int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf, in scsi_get_vpd_page() argument
344 if (sdev->skip_vpd_pages) in scsi_get_vpd_page()
348 result = scsi_vpd_inquiry(sdev, buf, 0, buf_len); in scsi_get_vpd_page()
367 result = scsi_vpd_inquiry(sdev, buf, page, buf_len); in scsi_get_vpd_page()
385 static struct scsi_vpd *scsi_get_vpd_buf(struct scsi_device *sdev, u8 page) in scsi_get_vpd_buf() argument
395 result = scsi_vpd_inquiry(sdev, vpd_buf->data, page, vpd_len); in scsi_get_vpd_buf()
411 static void scsi_update_vpd_page(struct scsi_device *sdev, u8 page, in scsi_update_vpd_page() argument
416 vpd_buf = scsi_get_vpd_buf(sdev, page); in scsi_update_vpd_page()
420 mutex_lock(&sdev->inquiry_mutex); in scsi_update_vpd_page()
422 lockdep_is_held(&sdev->inquiry_mutex)); in scsi_update_vpd_page()
423 mutex_unlock(&sdev->inquiry_mutex); in scsi_update_vpd_page()
438 void scsi_attach_vpd(struct scsi_device *sdev) in scsi_attach_vpd() argument
443 if (!scsi_device_supports_vpd(sdev)) in scsi_attach_vpd()
447 vpd_buf = scsi_get_vpd_buf(sdev, 0); in scsi_attach_vpd()
453 scsi_update_vpd_page(sdev, 0x0, &sdev->vpd_pg0); in scsi_attach_vpd()
455 scsi_update_vpd_page(sdev, 0x80, &sdev->vpd_pg80); in scsi_attach_vpd()
457 scsi_update_vpd_page(sdev, 0x83, &sdev->vpd_pg83); in scsi_attach_vpd()
459 scsi_update_vpd_page(sdev, 0x89, &sdev->vpd_pg89); in scsi_attach_vpd()
475 int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer, in scsi_report_opcode() argument
482 if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3) in scsi_report_opcode()
493 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, in scsi_report_opcode()
521 int scsi_device_get(struct scsi_device *sdev) in scsi_device_get() argument
523 if (sdev->sdev_state == SDEV_DEL || sdev->sdev_state == SDEV_CANCEL) in scsi_device_get()
525 if (!get_device(&sdev->sdev_gendev)) in scsi_device_get()
527 if (!try_module_get(sdev->host->hostt->module)) in scsi_device_get()
532 put_device(&sdev->sdev_gendev); in scsi_device_get()
546 void scsi_device_put(struct scsi_device *sdev) in scsi_device_put() argument
548 struct module *mod = sdev->host->hostt->module; in scsi_device_put()
550 put_device(&sdev->sdev_gendev); in scsi_device_put()
594 struct scsi_device *sdev; in starget_for_each_device() local
596 shost_for_each_device(sdev, shost) { in starget_for_each_device()
597 if ((sdev->channel == starget->channel) && in starget_for_each_device()
598 (sdev->id == starget->id)) in starget_for_each_device()
599 fn(sdev, data); in starget_for_each_device()
622 struct scsi_device *sdev; in __starget_for_each_device() local
624 __shost_for_each_device(sdev, shost) { in __starget_for_each_device()
625 if ((sdev->channel == starget->channel) && in __starget_for_each_device()
626 (sdev->id == starget->id)) in __starget_for_each_device()
627 fn(sdev, data); in __starget_for_each_device()
650 struct scsi_device *sdev; in __scsi_device_lookup_by_target() local
652 list_for_each_entry(sdev, &starget->devices, same_target_siblings) { in __scsi_device_lookup_by_target()
653 if (sdev->sdev_state == SDEV_DEL) in __scsi_device_lookup_by_target()
655 if (sdev->lun ==lun) in __scsi_device_lookup_by_target()
656 return sdev; in __scsi_device_lookup_by_target()
675 struct scsi_device *sdev; in scsi_device_lookup_by_target() local
680 sdev = __scsi_device_lookup_by_target(starget, lun); in scsi_device_lookup_by_target()
681 if (sdev && scsi_device_get(sdev)) in scsi_device_lookup_by_target()
682 sdev = NULL; in scsi_device_lookup_by_target()
685 return sdev; in scsi_device_lookup_by_target()
708 struct scsi_device *sdev; in __scsi_device_lookup() local
710 list_for_each_entry(sdev, &shost->__devices, siblings) { in __scsi_device_lookup()
711 if (sdev->sdev_state == SDEV_DEL) in __scsi_device_lookup()
713 if (sdev->channel == channel && sdev->id == id && in __scsi_device_lookup()
714 sdev->lun ==lun) in __scsi_device_lookup()
715 return sdev; in __scsi_device_lookup()
736 struct scsi_device *sdev; in scsi_device_lookup() local
740 sdev = __scsi_device_lookup(shost, channel, id, lun); in scsi_device_lookup()
741 if (sdev && scsi_device_get(sdev)) in scsi_device_lookup()
742 sdev = NULL; in scsi_device_lookup()
745 return sdev; in scsi_device_lookup()