Lines Matching +full:u +full:- +full:blox

1 // SPDX-License-Identifier: GPL-2.0-only
7 * generic mid-level SCSI driver
16 * Thomas Wuensche <tw@fgb1.fgb.mw.tu-muenchen.de>
19 * add scatter-gather, multiple outstanding request, and other
23 * support added by Michael Neuffer <mike@i-connect.net>
27 * Bjorn Ekwall <bj0rn@blox.se>
36 * Jiffies wrap fixes (host->resetting), 3 Dec 1998 Andrea Arcangeli
80 * Note - the initial logging level can be set here to log events at boot time.
134 if (((level > 0) && (cmd->result || disposition != SUCCESS)) || in scsi_log_completion()
138 if (scsi_status_is_check_condition(cmd->result)) in scsi_log_completion()
143 scsi_host_busy(cmd->device->host), in scsi_log_completion()
144 cmd->device->host->host_failed); in scsi_log_completion()
151 * scsi_finish_command - cleanup and pass command back to upper layer
160 struct scsi_device *sdev = cmd->device; in scsi_finish_command()
162 struct Scsi_Host *shost = sdev->host; in scsi_finish_command()
172 if (atomic_read(&shost->host_blocked)) in scsi_finish_command()
173 atomic_set(&shost->host_blocked, 0); in scsi_finish_command()
174 if (atomic_read(&starget->target_blocked)) in scsi_finish_command()
175 atomic_set(&starget->target_blocked, 0); 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()
181 "(result %x)\n", cmd->result)); in scsi_finish_command()
187 if (drv->done) in scsi_finish_command()
188 good_bytes = drv->done(cmd); in scsi_finish_command()
192 * residue if drv->done() error processing indicates no in scsi_finish_command()
196 good_bytes -= scsi_get_resid(cmd); in scsi_finish_command()
207 return min_t(int, sdev->host->can_queue, 4096); in scsi_device_max_queue_depth()
211 * scsi_change_queue_depth - change a device's queue depth
219 if (!sdev->budget_map.map) in scsi_change_queue_depth()
220 return -EINVAL; in scsi_change_queue_depth()
225 sdev->queue_depth = depth; in scsi_change_queue_depth()
229 if (sdev->request_queue) in scsi_change_queue_depth()
230 blk_set_queue_depth(sdev->request_queue, depth); in scsi_change_queue_depth()
232 sbitmap_resize(&sdev->budget_map, sdev->queue_depth); in scsi_change_queue_depth()
234 return sdev->queue_depth; in scsi_change_queue_depth()
239 * scsi_track_queue_full - track QUEUE_FULL events to adjust queue depth
249 * * 0 - No change needed
250 * * >0 - Adjust queue depth to this new depth,
251 * * -1 - Drop back to untagged operation using host->cmd_per_lun as the
261 if (!sdev->budget_map.map) in scsi_track_queue_full()
269 if ((jiffies >> 4) == (sdev->last_queue_full_time >> 4)) in scsi_track_queue_full()
272 sdev->last_queue_full_time = jiffies; in scsi_track_queue_full()
273 if (sdev->last_queue_full_depth != depth) { in scsi_track_queue_full()
274 sdev->last_queue_full_count = 1; in scsi_track_queue_full()
275 sdev->last_queue_full_depth = depth; in scsi_track_queue_full()
277 sdev->last_queue_full_count++; in scsi_track_queue_full()
280 if (sdev->last_queue_full_count <= 10) in scsi_track_queue_full()
288 * scsi_vpd_inquiry - Request a device provide us with a VPD page
306 return -EINVAL; in scsi_vpd_inquiry()
322 return -EIO; in scsi_vpd_inquiry()
329 return -EIO; in scsi_vpd_inquiry()
333 return -EIO; in scsi_vpd_inquiry()
348 if (sdev->no_vpd_size) in scsi_get_vpd_size()
361 dev_warn_once(&sdev->sdev_gendev, in scsi_get_vpd_size()
367 result -= SCSI_VPD_HEADER_SIZE; in scsi_get_vpd_size()
382 dev_warn_once(&sdev->sdev_gendev, in scsi_get_vpd_size()
392 * scsi_get_vpd_page - Get Vital Product Data from a SCSI device
402 * supported or its content cannot be retrieved, -EINVAL is returned.
410 return -EINVAL; in scsi_get_vpd_page()
414 return -EINVAL; in scsi_get_vpd_page()
425 return -EINVAL; in scsi_get_vpd_page()
427 dev_warn_once(&sdev->sdev_gendev, in scsi_get_vpd_page()
436 * scsi_get_vpd_buf - Get Vital Product Data from a SCSI device
460 result = scsi_vpd_inquiry(sdev, vpd_buf->data, page, vpd_len); in scsi_get_vpd_buf()
466 dev_warn_once(&sdev->sdev_gendev, in scsi_get_vpd_buf()
474 vpd_buf->len = result; in scsi_get_vpd_buf()
488 mutex_lock(&sdev->inquiry_mutex); in scsi_update_vpd_page()
490 lockdep_is_held(&sdev->inquiry_mutex)); in scsi_update_vpd_page()
491 mutex_unlock(&sdev->inquiry_mutex); in scsi_update_vpd_page()
498 * scsi_attach_vpd - Attach Vital Product Data to a SCSI device structure
519 for (i = 4; i < vpd_buf->len; i++) { in scsi_attach_vpd()
520 switch (vpd_buf->data[i]) { in scsi_attach_vpd()
522 scsi_update_vpd_page(sdev, 0x0, &sdev->vpd_pg0); in scsi_attach_vpd()
525 scsi_update_vpd_page(sdev, 0x80, &sdev->vpd_pg80); in scsi_attach_vpd()
528 scsi_update_vpd_page(sdev, 0x83, &sdev->vpd_pg83); in scsi_attach_vpd()
531 scsi_update_vpd_page(sdev, 0x89, &sdev->vpd_pg89); in scsi_attach_vpd()
534 scsi_update_vpd_page(sdev, 0xb0, &sdev->vpd_pgb0); in scsi_attach_vpd()
537 scsi_update_vpd_page(sdev, 0xb1, &sdev->vpd_pgb1); in scsi_attach_vpd()
540 scsi_update_vpd_page(sdev, 0xb2, &sdev->vpd_pgb2); in scsi_attach_vpd()
543 scsi_update_vpd_page(sdev, 0xb7, &sdev->vpd_pgb7); in scsi_attach_vpd()
553 * scsi_report_opcode - Find out if a given command is supported
562 * have a service action, @sa must be 0. Returns -EINVAL if RSOC fails,
577 if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3) in scsi_report_opcode()
578 return -EINVAL; in scsi_report_opcode()
583 dev_warn_once(&sdev->sdev_gendev, in scsi_report_opcode()
584 "%s: len %u bytes, opcode 0x%02x needs %u\n", in scsi_report_opcode()
586 return -EINVAL; in scsi_report_opcode()
610 return -EINVAL; in scsi_report_opcode()
636 * See SPC-6, One_command parameter data format for in scsi_cdl_check_cmd()
639 * - rwcdlp == 0: then cdlp indicates support for the A mode page when in scsi_cdl_check_cmd()
642 * - rwcdlp == 1: then cdlp indicates support for the T2A mode page in scsi_cdl_check_cmd()
654 * scsi_cdl_check - Check if a SCSI device supports Command Duration Limits
663 * Support for CDL was defined in SPC-5. Ignore devices reporting an in scsi_cdl_check()
668 if (sdev->scsi_level < SCSI_SPC_5) { in scsi_cdl_check()
669 sdev->cdl_supported = 0; in scsi_cdl_check()
675 sdev->cdl_supported = 0; in scsi_cdl_check()
691 sdev->use_16_for_rw = 1; in scsi_cdl_check()
692 sdev->use_10_for_rw = 0; in scsi_cdl_check()
694 sdev->cdl_supported = 1; in scsi_cdl_check()
701 scsi_cdl_enable(sdev, sdev->cdl_enable); in scsi_cdl_check()
703 sdev->cdl_supported = 0; in scsi_cdl_check()
710 * scsi_cdl_enable - Enable or disable a SCSI device supports for Command
720 if (!sdev->cdl_supported) in scsi_cdl_enable()
721 return -EOPNOTSUPP; in scsi_cdl_enable()
726 if (sdev->is_ata) { in scsi_cdl_enable()
735 return -EINVAL; in scsi_cdl_enable()
739 data.length - data.header_length - in scsi_cdl_enable()
767 dev_name(&sdev->sdev_gendev), &sshdr); in scsi_cdl_enable()
773 sdev->cdl_enable = enable; in scsi_cdl_enable()
779 * scsi_device_get - get an additional reference to a scsi_device
791 if (sdev->sdev_state == SDEV_DEL || sdev->sdev_state == SDEV_CANCEL) in scsi_device_get()
793 if (!try_module_get(sdev->host->hostt->module)) in scsi_device_get()
795 if (!get_device(&sdev->sdev_gendev)) in scsi_device_get()
800 module_put(sdev->host->hostt->module); in scsi_device_get()
802 return -ENXIO; in scsi_device_get()
807 * scsi_device_put - release a reference to a scsi_device
816 struct module *mod = sdev->host->hostt->module; in scsi_device_put()
818 put_device(&sdev->sdev_gendev); in scsi_device_put()
827 struct list_head *list = (prev ? &prev->siblings : &shost->__devices); in __scsi_iterate_devices()
831 spin_lock_irqsave(shost->host_lock, flags); in __scsi_iterate_devices()
832 while (list->next != &shost->__devices) { in __scsi_iterate_devices()
833 next = list_entry(list->next, struct scsi_device, siblings); in __scsi_iterate_devices()
841 list = list->next; in __scsi_iterate_devices()
843 spin_unlock_irqrestore(shost->host_lock, flags); in __scsi_iterate_devices()
852 * starget_for_each_device - helper to walk all devices of a target
864 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in starget_for_each_device()
868 if ((sdev->channel == starget->channel) && in starget_for_each_device()
869 (sdev->id == starget->id)) in starget_for_each_device()
876 * __starget_for_each_device - helper to walk all devices of a target (UNLOCKED)
883 * protected by shost->host_lock.
892 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in __starget_for_each_device()
896 if ((sdev->channel == starget->channel) && in __starget_for_each_device()
897 (sdev->id == starget->id)) in __starget_for_each_device()
904 * __scsi_device_lookup_by_target - find a device given the target (UNLOCKED)
923 list_for_each_entry(sdev, &starget->devices, same_target_siblings) { in __scsi_device_lookup_by_target()
924 if (sdev->sdev_state == SDEV_DEL) in __scsi_device_lookup_by_target()
926 if (sdev->lun ==lun) in __scsi_device_lookup_by_target()
935 * scsi_device_lookup_by_target - find a device given the target
947 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); in scsi_device_lookup_by_target()
950 spin_lock_irqsave(shost->host_lock, flags); in scsi_device_lookup_by_target()
954 spin_unlock_irqrestore(shost->host_lock, flags); in scsi_device_lookup_by_target()
961 * __scsi_device_lookup - find a device given the host (UNLOCKED)
981 list_for_each_entry(sdev, &shost->__devices, siblings) { in __scsi_device_lookup()
982 if (sdev->sdev_state == SDEV_DEL) in __scsi_device_lookup()
984 if (sdev->channel == channel && sdev->id == id && in __scsi_device_lookup()
985 sdev->lun ==lun) in __scsi_device_lookup()
994 * scsi_device_lookup - find a device given the host
1010 spin_lock_irqsave(shost->host_lock, flags); in scsi_device_lookup()
1014 spin_unlock_irqrestore(shost->host_lock, flags); in scsi_device_lookup()
1062 -error); in init_scsi()