Lines Matching refs:sdev
160 struct scsi_device *sdev = cmd->device;
161 struct scsi_target *starget = scsi_target(sdev);
162 struct Scsi_Host *shost = sdev->host;
166 scsi_device_unbusy(sdev, cmd);
176 if (atomic_read(&sdev->device_blocked))
177 atomic_set(&sdev->device_blocked, 0);
179 SCSI_LOG_MLCOMPLETE(4, sdev_printk(KERN_INFO, sdev,
205 int scsi_device_max_queue_depth(struct scsi_device *sdev)
207 return min_t(int, sdev->host->can_queue, 4096);
212 * @sdev: SCSI Device in question
217 int scsi_change_queue_depth(struct scsi_device *sdev, int depth)
219 depth = min_t(int, depth, scsi_device_max_queue_depth(sdev));
222 sdev->queue_depth = depth;
226 if (sdev->request_queue)
227 blk_set_queue_depth(sdev->request_queue, depth);
229 sbitmap_resize(&sdev->budget_map, sdev->queue_depth);
231 return sdev->queue_depth;
237 * @sdev: SCSI Device in question
254 int scsi_track_queue_full(struct scsi_device *sdev, int depth)
262 if ((jiffies >> 4) == (sdev->last_queue_full_time >> 4))
265 sdev->last_queue_full_time = jiffies;
266 if (sdev->last_queue_full_depth != depth) {
267 sdev->last_queue_full_count = 1;
268 sdev->last_queue_full_depth = depth;
270 sdev->last_queue_full_count++;
273 if (sdev->last_queue_full_count <= 10)
276 return scsi_change_queue_depth(sdev, depth);
282 * @sdev: The device to ask
292 static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
312 result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buffer, len,
336 static int scsi_get_vpd_size(struct scsi_device *sdev, u8 page)
341 if (sdev->no_vpd_size)
349 result = scsi_vpd_inquiry(sdev, vpd, 0, sizeof(vpd));
363 result = scsi_vpd_inquiry(sdev, vpd, page, SCSI_VPD_HEADER_SIZE);
368 dev_warn_once(&sdev->sdev_gendev,
379 * @sdev: The device to ask
390 int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf,
395 if (!scsi_device_supports_vpd(sdev))
398 vpd_len = scsi_get_vpd_size(sdev, page);
409 result = scsi_vpd_inquiry(sdev, buf, page, vpd_len);
413 dev_warn_once(&sdev->sdev_gendev,
423 * @sdev: The device to ask
428 static struct scsi_vpd *scsi_get_vpd_buf(struct scsi_device *sdev, u8 page)
433 vpd_len = scsi_get_vpd_size(sdev, page);
446 result = scsi_vpd_inquiry(sdev, vpd_buf->data, page, vpd_len);
452 dev_warn_once(&sdev->sdev_gendev,
465 static void scsi_update_vpd_page(struct scsi_device *sdev, u8 page,
470 vpd_buf = scsi_get_vpd_buf(sdev, page);
474 mutex_lock(&sdev->inquiry_mutex);
476 lockdep_is_held(&sdev->inquiry_mutex));
477 mutex_unlock(&sdev->inquiry_mutex);
485 * @sdev: The device to ask
492 void scsi_attach_vpd(struct scsi_device *sdev)
497 if (!scsi_device_supports_vpd(sdev))
501 vpd_buf = scsi_get_vpd_buf(sdev, 0);
507 scsi_update_vpd_page(sdev, 0x0, &sdev->vpd_pg0);
509 scsi_update_vpd_page(sdev, 0x80, &sdev->vpd_pg80);
511 scsi_update_vpd_page(sdev, 0x83, &sdev->vpd_pg83);
513 scsi_update_vpd_page(sdev, 0x89, &sdev->vpd_pg89);
515 scsi_update_vpd_page(sdev, 0xb0, &sdev->vpd_pgb0);
517 scsi_update_vpd_page(sdev, 0xb1, &sdev->vpd_pgb1);
519 scsi_update_vpd_page(sdev, 0xb2, &sdev->vpd_pgb2);
526 * @sdev: scsi device to query
538 int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
549 if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3)
555 dev_warn_once(&sdev->sdev_gendev,
575 result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buffer,
593 static bool scsi_cdl_check_cmd(struct scsi_device *sdev, u8 opcode, u16 sa,
600 ret = scsi_report_opcode(sdev, buf, SCSI_CDL_CHECK_BUF_LEN, opcode, sa);
627 * @sdev: The device to check
629 void scsi_cdl_check(struct scsi_device *sdev)
640 if (sdev->scsi_level < SCSI_SPC_5) {
641 sdev->cdl_supported = 0;
647 sdev->cdl_supported = 0;
653 scsi_cdl_check_cmd(sdev, READ_16, 0, buf) ||
654 scsi_cdl_check_cmd(sdev, WRITE_16, 0, buf) ||
655 scsi_cdl_check_cmd(sdev, VARIABLE_LENGTH_CMD, READ_32, buf) ||
656 scsi_cdl_check_cmd(sdev, VARIABLE_LENGTH_CMD, WRITE_32, buf);
663 sdev->use_16_for_rw = 1;
664 sdev->use_10_for_rw = 0;
666 sdev->cdl_supported = 1;
668 sdev->cdl_supported = 0;
677 * @sdev: The target device
680 int scsi_cdl_enable(struct scsi_device *sdev, bool enable)
689 if (!sdev->cdl_supported)
693 vpd = rcu_dereference(sdev->vpd_pg89);
705 ret = scsi_mode_sense(sdev, 0x08, 0x0a, 0xf2, buf, sizeof(buf),
721 ret = scsi_mode_select(sdev, 1, 0, buf_data, len, 5 * HZ, 3,
725 scsi_print_sense_hdr(sdev,
726 dev_name(&sdev->sdev_gendev), &sshdr);
731 sdev->cdl_enable = enable;
738 * @sdev: device to get a reference to
747 int scsi_device_get(struct scsi_device *sdev)
749 if (sdev->sdev_state == SDEV_DEL || sdev->sdev_state == SDEV_CANCEL)
751 if (!try_module_get(sdev->host->hostt->module))
753 if (!get_device(&sdev->sdev_gendev))
758 module_put(sdev->host->hostt->module);
766 * @sdev: device to release a reference on.
772 void scsi_device_put(struct scsi_device *sdev)
774 struct module *mod = sdev->host->hostt->module;
776 put_device(&sdev->sdev_gendev);
820 struct scsi_device *sdev;
822 shost_for_each_device(sdev, shost) {
823 if ((sdev->channel == starget->channel) &&
824 (sdev->id == starget->id))
825 fn(sdev, data);
848 struct scsi_device *sdev;
850 __shost_for_each_device(sdev, shost) {
851 if ((sdev->channel == starget->channel) &&
852 (sdev->id == starget->id))
853 fn(sdev, data);
876 struct scsi_device *sdev;
878 list_for_each_entry(sdev, &starget->devices, same_target_siblings) {
879 if (sdev->sdev_state == SDEV_DEL)
881 if (sdev->lun ==lun)
882 return sdev;
901 struct scsi_device *sdev;
906 sdev = __scsi_device_lookup_by_target(starget, lun);
907 if (sdev && scsi_device_get(sdev))
908 sdev = NULL;
911 return sdev;
934 struct scsi_device *sdev;
936 list_for_each_entry(sdev, &shost->__devices, siblings) {
937 if (sdev->sdev_state == SDEV_DEL)
939 if (sdev->channel == channel && sdev->id == id &&
940 sdev->lun ==lun)
941 return sdev;
962 struct scsi_device *sdev;
966 sdev = __scsi_device_lookup(shost, channel, id, lun);
967 if (sdev && scsi_device_get(sdev))
968 sdev = NULL;
971 return sdev;