• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/src/linux/linux-2.6/drivers/scsi/

Lines Matching refs:scmd

63  * Schedule SCSI EH without scmd.
83 * @scmd: scmd to run eh on.
89 int scsi_eh_scmd_add(struct scsi_cmnd *scmd, int eh_flag)
91 struct Scsi_Host *shost = scmd->device->host;
104 scmd->eh_eflags |= eh_flag;
105 list_add_tail(&scmd->eh_entry, &shost->eh_cmd_q);
115 * @scmd: scsi command that is about to start running.
124 void scsi_add_timer(struct scsi_cmnd *scmd, int timeout,
133 if (scmd->eh_timeout.function)
134 del_timer(&scmd->eh_timeout);
136 scmd->eh_timeout.data = (unsigned long)scmd;
137 scmd->eh_timeout.expires = jiffies + timeout;
138 scmd->eh_timeout.function = (void (*)(unsigned long)) complete;
140 SCSI_LOG_ERROR_RECOVERY(5, printk("%s: scmd: %p, time:"
142 scmd, timeout, complete));
144 add_timer(&scmd->eh_timeout);
149 * @scmd: Cmd that we are canceling timer for
158 int scsi_delete_timer(struct scsi_cmnd *scmd)
162 rtn = del_timer(&scmd->eh_timeout);
164 SCSI_LOG_ERROR_RECOVERY(5, printk("%s: scmd: %p,"
166 scmd, rtn));
168 scmd->eh_timeout.data = (unsigned long)NULL;
169 scmd->eh_timeout.function = NULL;
176 * @scmd: Cmd that is timing out.
184 void scsi_times_out(struct scsi_cmnd *scmd)
188 scsi_log_completion(scmd, TIMEOUT_ERROR);
190 if (scmd->device->host->transportt->eh_timed_out)
191 eh_timed_out = scmd->device->host->transportt->eh_timed_out;
192 else if (scmd->device->host->hostt->eh_timed_out)
193 eh_timed_out = scmd->device->host->hostt->eh_timed_out;
198 switch (eh_timed_out(scmd)) {
200 __scsi_done(scmd);
203 scsi_add_timer(scmd, scmd->timeout_per_command,
210 if (unlikely(!scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))) {
211 scmd->result |= DID_TIME_OUT << 16;
212 __scsi_done(scmd);
251 struct scsi_cmnd *scmd;
259 list_for_each_entry(scmd, work_q, eh_entry) {
260 if (scmd->device == sdev) {
262 if (scmd->eh_eflags & SCSI_EH_CANCEL_CMD)
289 * @scmd: Cmd to have sense checked.
298 static int scsi_check_sense(struct scsi_cmnd *scmd)
302 if (! scsi_command_normalize_sense(scmd, &sshdr))
314 if (scmd->sense_buffer[2] & 0xe0)
323 (scmd->sense_buffer[8] == 0x4) &&
324 (scmd->sense_buffer[11] & 0xe0))
344 if (scmd->device->expecting_cc_ua) {
345 scmd->device->expecting_cc_ua = 0;
358 if (scmd->device->allow_restart &&
378 if (scmd->device->retry_hwerror)
393 * @scmd: SCSI cmd to examine.
401 static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
407 if (host_byte(scmd->result) == DID_RESET) {
414 return scsi_check_sense(scmd);
416 if (host_byte(scmd->result) != DID_OK)
422 if (msg_byte(scmd->result) != COMMAND_COMPLETE)
429 switch (status_byte(scmd->result)) {
434 return scsi_check_sense(scmd);
450 * @scmd: Cmd that is done.
452 static void scsi_eh_done(struct scsi_cmnd *scmd)
457 printk("%s scmd: %p result: %x\n",
458 __FUNCTION__, scmd, scmd->result));
460 eh_action = scmd->device->host->eh_action;
467 * @scmd: SCSI cmd to send hsot reset.
469 static int scsi_try_host_reset(struct scsi_cmnd *scmd)
477 if (!scmd->device->host->hostt->eh_host_reset_handler)
480 rtn = scmd->device->host->hostt->eh_host_reset_handler(scmd);
483 if (!scmd->device->host->hostt->skip_settle_delay)
485 spin_lock_irqsave(scmd->device->host->host_lock, flags);
486 scsi_report_bus_reset(scmd->device->host,
487 scmd_channel(scmd));
488 spin_unlock_irqrestore(scmd->device->host->host_lock, flags);
496 * @scmd: SCSI cmd to send bus reset.
498 static int scsi_try_bus_reset(struct scsi_cmnd *scmd)
506 if (!scmd->device->host->hostt->eh_bus_reset_handler)
509 rtn = scmd->device->host->hostt->eh_bus_reset_handler(scmd);
512 if (!scmd->device->host->hostt->skip_settle_delay)
514 spin_lock_irqsave(scmd->device->host->host_lock, flags);
515 scsi_report_bus_reset(scmd->device->host,
516 scmd_channel(scmd));
517 spin_unlock_irqrestore(scmd->device->host->host_lock, flags);
525 * @scmd: SCSI cmd used to send BDR
533 static int scsi_try_bus_device_reset(struct scsi_cmnd *scmd)
537 if (!scmd->device->host->hostt->eh_device_reset_handler)
540 rtn = scmd->device->host->hostt->eh_device_reset_handler(scmd);
542 scmd->device->was_reset = 1;
543 scmd->device->expecting_cc_ua = 1;
549 static int __scsi_try_to_abort_cmd(struct scsi_cmnd *scmd)
551 if (!scmd->device->host->hostt->eh_abort_handler)
554 return scmd->device->host->hostt->eh_abort_handler(scmd);
559 * @scmd: SCSI cmd to abort from Lower Level.
568 static int scsi_try_to_abort_cmd(struct scsi_cmnd *scmd)
574 if (scmd->serial_number == 0)
576 return __scsi_try_to_abort_cmd(scmd);
579 static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd)
581 if (__scsi_try_to_abort_cmd(scmd) != SUCCESS)
582 if (scsi_try_bus_device_reset(scmd) != SUCCESS)
583 if (scsi_try_bus_reset(scmd) != SUCCESS)
584 scsi_try_host_reset(scmd);
589 * @scmd: SCSI command structure to hijack
599 * sense buffer it got into @scmd->sense_buffer.
604 static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
607 struct scsi_device *sdev = scmd->device;
609 int old_result = scmd->result;
629 old_buffer = scmd->request_buffer;
630 old_bufflen = scmd->request_bufflen;
631 memcpy(old_cmnd, scmd->cmnd, sizeof(scmd->cmnd));
632 old_data_direction = scmd->sc_data_direction;
633 old_cmd_len = scmd->cmd_len;
634 old_use_sg = scmd->use_sg;
636 memset(scmd->cmnd, 0, sizeof(scmd->cmnd));
637 memcpy(scmd->cmnd, cmnd, cmnd_size);
651 scmd->sc_data_direction = DMA_FROM_DEVICE;
652 scmd->request_bufflen = sgl.length;
653 scmd->request_buffer = &sgl;
654 scmd->use_sg = 1;
656 scmd->request_buffer = NULL;
657 scmd->request_bufflen = 0;
658 scmd->sc_data_direction = DMA_NONE;
659 scmd->use_sg = 0;
662 scmd->underflow = 0;
663 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);
666 scmd->cmnd[1] = (scmd->cmnd[1] & 0x1f) |
673 memset(scmd->sense_buffer, 0, sizeof(scmd->sense_buffer));
678 scsi_log_send(scmd);
679 shost->hostt->queuecommand(scmd, scsi_eh_done);
686 scsi_log_completion(scmd, SUCCESS);
689 printk("%s: scmd: %p, timeleft: %ld\n",
690 __FUNCTION__, scmd, timeleft));
699 rtn = scsi_eh_completed_normally(scmd);
714 scsi_abort_eh_cmnd(scmd);
723 if (!SCSI_SENSE_VALID(scmd)) {
724 memcpy(scmd->sense_buffer, page_address(sgl.page),
725 sizeof(scmd->sense_buffer));
734 scmd->request_buffer = old_buffer;
735 scmd->request_bufflen = old_bufflen;
736 memcpy(scmd->cmnd, old_cmnd, sizeof(scmd->cmnd));
737 scmd->sc_data_direction = old_data_direction;
738 scmd->cmd_len = old_cmd_len;
739 scmd->use_sg = old_use_sg;
740 scmd->result = old_result;
746 * @scmd: SCSI cmd for request sense.
753 static int scsi_request_sense(struct scsi_cmnd *scmd)
758 return scsi_send_eh_cmnd(scmd, generic_sense, 6, SENSE_TIMEOUT, 1);
763 * @scmd: Original SCSI cmd that eh has finished.
773 void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q)
775 scmd->device->host->host_failed--;
776 scmd->eh_eflags = 0;
777 list_move_tail(&scmd->eh_entry, done_q);
784 struct scsi_cmnd *scmd, *next;
787 list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
788 if ((scmd->eh_eflags & SCSI_EH_CANCEL_CMD) ||
789 SCSI_SENSE_VALID(scmd))
792 SCSI_LOG_ERROR_RECOVERY(2, scmd_printk(KERN_INFO, scmd,
795 rtn = scsi_request_sense(scmd);
800 " result %x\n", scmd,
801 scmd->result));
802 SCSI_LOG_ERROR_RECOVERY(3, scsi_print_sense("bh", scmd));
804 rtn = scsi_decide_disposition(scmd);
815 scmd->retries = scmd->allowed;
819 scsi_eh_finish_cmd(scmd, done_q);
828 * @scmd: Scsi cmd to send TUR
833 static int scsi_eh_tur(struct scsi_cmnd *scmd)
839 rtn = scsi_send_eh_cmnd(scmd, tur_command, 6, SENSE_TIMEOUT, 0);
841 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd %p rtn %x\n",
842 __FUNCTION__, scmd, rtn));
871 struct scsi_cmnd *scmd, *next;
874 list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
875 if (!(scmd->eh_eflags & SCSI_EH_CANCEL_CMD))
879 scmd));
880 rtn = scsi_try_to_abort_cmd(scmd);
882 scmd->eh_eflags &= ~SCSI_EH_CANCEL_CMD;
883 if (!scsi_device_online(scmd->device) ||
884 !scsi_eh_tur(scmd)) {
885 scsi_eh_finish_cmd(scmd, done_q);
893 scmd));
901 * @scmd: Scsi cmd to send START_UNIT
906 static int scsi_eh_try_stu(struct scsi_cmnd *scmd)
910 if (scmd->device->allow_restart) {
914 rtn = scsi_send_eh_cmnd(scmd, stu_command, 6,
915 scmd->device->timeout, 0);
937 struct scsi_cmnd *scmd, *stu_scmd, *next;
942 list_for_each_entry(scmd, work_q, eh_entry)
943 if (scmd->device == sdev && SCSI_SENSE_VALID(scmd) &&
944 scsi_check_sense(scmd) == FAILED ) {
945 stu_scmd = scmd;
958 list_for_each_entry_safe(scmd, next,
960 if (scmd->device == sdev)
961 scsi_eh_finish_cmd(scmd, done_q);
990 struct scsi_cmnd *scmd, *bdr_scmd, *next;
996 list_for_each_entry(scmd, work_q, eh_entry)
997 if (scmd->device == sdev) {
998 bdr_scmd = scmd;
1012 list_for_each_entry_safe(scmd, next,
1014 if (scmd->device == sdev)
1015 scsi_eh_finish_cmd(scmd,
1040 struct scsi_cmnd *scmd, *chan_scmd, *next;
1053 list_for_each_entry(scmd, work_q, eh_entry) {
1054 if (channel == scmd_channel(scmd)) {
1055 chan_scmd = scmd;
1067 list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
1068 if (channel == scmd_channel(scmd))
1069 if (!scsi_device_online(scmd->device) ||
1070 !scsi_eh_tur(scmd))
1071 scsi_eh_finish_cmd(scmd,
1092 struct scsi_cmnd *scmd, *next;
1096 scmd = list_entry(work_q->next,
1102 rtn = scsi_try_host_reset(scmd);
1104 list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
1105 if (!scsi_device_online(scmd->device) ||
1106 (!scsi_eh_try_stu(scmd) && !scsi_eh_tur(scmd)) ||
1107 !scsi_eh_tur(scmd))
1108 scsi_eh_finish_cmd(scmd, done_q);
1128 struct scsi_cmnd *scmd, *next;
1130 list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
1131 sdev_printk(KERN_INFO, scmd->device,
1134 scsi_device_set_state(scmd->device, SDEV_OFFLINE);
1135 if (scmd->eh_eflags & SCSI_EH_CANCEL_CMD) {
1137 scsi_eh_finish_cmd(scmd, done_q);
1144 * @scmd: SCSI cmd to examine.
1156 int scsi_decide_disposition(struct scsi_cmnd *scmd)
1164 if (!scsi_device_online(scmd->device)) {
1175 switch (host_byte(scmd->result)) {
1182 scmd->result &= 0xff00ffff;
1216 if (msg_byte(scmd->result) == COMMAND_COMPLETE &&
1217 status_byte(scmd->result) == RESERVATION_CONFLICT)
1234 if ((scmd->cmnd[0] == TEST_UNIT_READY ||
1235 scmd->cmnd[0] == INQUIRY)) {
1249 if (msg_byte(scmd->result) != COMMAND_COMPLETE)
1255 switch (status_byte(scmd->result)) {
1274 rtn = scsi_check_sense(scmd);
1289 sdev_printk(KERN_INFO, scmd->device,
1303 if ((++scmd->retries) <= scmd->allowed
1304 && !blk_noretry_request(scmd->request)) {
1423 struct scsi_cmnd *scmd, *next;
1425 list_for_each_entry_safe(scmd, next, done_q, eh_entry) {
1426 list_del_init(&scmd->eh_entry);
1427 if (scsi_device_online(scmd->device) &&
1428 !blk_noretry_request(scmd->request) &&
1429 (++scmd->retries <= scmd->allowed)) {
1433 scmd));
1434 scsi_queue_insert(scmd, SCSI_MLQUEUE_EH_RETRY);
1438 * scsi_eh_get_sense), scmd->result is already
1441 if (!scmd->result)
1442 scmd->result |= (DRIVER_TIMEOUT << 24);
1445 current->comm, scmd));
1446 scsi_finish_command(scmd);
1630 scsi_reset_provider_done_command(struct scsi_cmnd *scmd)
1650 struct scsi_cmnd *scmd = scsi_get_command(dev, GFP_KERNEL);
1656 scmd->request = &req;
1657 memset(&scmd->eh_timeout, 0, sizeof(scmd->eh_timeout));
1659 memset(&scmd->cmnd, '\0', sizeof(scmd->cmnd));
1661 scmd->scsi_done = scsi_reset_provider_done_command;
1662 scmd->done = NULL;
1663 scmd->request_buffer = NULL;
1664 scmd->request_bufflen = 0;
1666 scmd->cmd_len = 0;
1668 scmd->sc_data_direction = DMA_BIDIRECTIONAL;
1670 init_timer(&scmd->eh_timeout);
1676 scmd->pid = 0;
1684 rtn = scsi_try_bus_device_reset(scmd);
1689 rtn = scsi_try_bus_reset(scmd);
1694 rtn = scsi_try_host_reset(scmd);
1716 scsi_next_command(scmd);