Lines Matching refs:ent

404 static dma_addr_t esp_cur_dma_addr(struct esp_cmd_entry *ent,  in esp_cur_dma_addr()  argument
409 if (ent->flags & ESP_CMD_FLAG_AUTOSENSE) { in esp_cur_dma_addr()
410 return ent->sense_dma + in esp_cur_dma_addr()
411 (ent->sense_ptr - cmd->sense_buffer); in esp_cur_dma_addr()
419 static unsigned int esp_cur_dma_len(struct esp_cmd_entry *ent, in esp_cur_dma_len() argument
424 if (ent->flags & ESP_CMD_FLAG_AUTOSENSE) { in esp_cur_dma_len()
426 (ent->sense_ptr - cmd->sense_buffer); in esp_cur_dma_len()
431 static void esp_advance_dma(struct esp *esp, struct esp_cmd_entry *ent, in esp_advance_dma() argument
436 if (ent->flags & ESP_CMD_FLAG_AUTOSENSE) { in esp_advance_dma()
437 ent->sense_ptr += len; in esp_advance_dma()
465 static void esp_save_pointers(struct esp *esp, struct esp_cmd_entry *ent) in esp_save_pointers() argument
467 struct scsi_cmnd *cmd = ent->cmd; in esp_save_pointers()
470 if (ent->flags & ESP_CMD_FLAG_AUTOSENSE) { in esp_save_pointers()
471 ent->saved_sense_ptr = ent->sense_ptr; in esp_save_pointers()
474 ent->saved_cur_residue = spriv->cur_residue; in esp_save_pointers()
475 ent->saved_prv_sg = spriv->prv_sg; in esp_save_pointers()
476 ent->saved_cur_sg = spriv->cur_sg; in esp_save_pointers()
477 ent->saved_tot_residue = spriv->tot_residue; in esp_save_pointers()
480 static void esp_restore_pointers(struct esp *esp, struct esp_cmd_entry *ent) in esp_restore_pointers() argument
482 struct scsi_cmnd *cmd = ent->cmd; in esp_restore_pointers()
485 if (ent->flags & ESP_CMD_FLAG_AUTOSENSE) { in esp_restore_pointers()
486 ent->sense_ptr = ent->saved_sense_ptr; in esp_restore_pointers()
489 spriv->cur_residue = ent->saved_cur_residue; in esp_restore_pointers()
490 spriv->prv_sg = ent->saved_prv_sg; in esp_restore_pointers()
491 spriv->cur_sg = ent->saved_cur_sg; in esp_restore_pointers()
492 spriv->tot_residue = ent->saved_tot_residue; in esp_restore_pointers()
574 static int esp_alloc_lun_tag(struct esp_cmd_entry *ent, in esp_alloc_lun_tag() argument
577 if (!ent->orig_tag[0]) { in esp_alloc_lun_tag()
601 lp->non_tagged_cmd = ent; in esp_alloc_lun_tag()
609 BUG_ON(lp->tagged_cmds[ent->orig_tag[1]]); in esp_alloc_lun_tag()
611 lp->tagged_cmds[ent->orig_tag[1]] = ent; in esp_alloc_lun_tag()
617 static void esp_free_lun_tag(struct esp_cmd_entry *ent, in esp_free_lun_tag() argument
620 if (ent->orig_tag[0]) { in esp_free_lun_tag()
621 BUG_ON(lp->tagged_cmds[ent->orig_tag[1]] != ent); in esp_free_lun_tag()
622 lp->tagged_cmds[ent->orig_tag[1]] = NULL; in esp_free_lun_tag()
625 BUG_ON(lp->non_tagged_cmd != ent); in esp_free_lun_tag()
630 static void esp_map_sense(struct esp *esp, struct esp_cmd_entry *ent) in esp_map_sense() argument
632 ent->sense_ptr = ent->cmd->sense_buffer; in esp_map_sense()
634 ent->sense_dma = (uintptr_t)ent->sense_ptr; in esp_map_sense()
638 ent->sense_dma = dma_map_single(esp->dev, ent->sense_ptr, in esp_map_sense()
642 static void esp_unmap_sense(struct esp *esp, struct esp_cmd_entry *ent) in esp_unmap_sense() argument
645 dma_unmap_single(esp->dev, ent->sense_dma, in esp_unmap_sense()
647 ent->sense_ptr = NULL; in esp_unmap_sense()
657 static void esp_autosense(struct esp *esp, struct esp_cmd_entry *ent) in esp_autosense() argument
659 struct scsi_cmnd *cmd = ent->cmd; in esp_autosense()
668 if (!ent->sense_ptr) { in esp_autosense()
671 esp_map_sense(esp, ent); in esp_autosense()
673 ent->saved_sense_ptr = ent->sense_ptr; in esp_autosense()
675 esp->active_cmd = ent; in esp_autosense()
706 struct esp_cmd_entry *ent; in find_and_prep_issuable_command() local
708 list_for_each_entry(ent, &esp->queued_cmds, list) { in find_and_prep_issuable_command()
709 struct scsi_cmnd *cmd = ent->cmd; in find_and_prep_issuable_command()
713 if (ent->flags & ESP_CMD_FLAG_AUTOSENSE) { in find_and_prep_issuable_command()
714 ent->tag[0] = 0; in find_and_prep_issuable_command()
715 ent->tag[1] = 0; in find_and_prep_issuable_command()
716 return ent; in find_and_prep_issuable_command()
719 if (!spi_populate_tag_msg(&ent->tag[0], cmd)) { in find_and_prep_issuable_command()
720 ent->tag[0] = 0; in find_and_prep_issuable_command()
721 ent->tag[1] = 0; in find_and_prep_issuable_command()
723 ent->orig_tag[0] = ent->tag[0]; in find_and_prep_issuable_command()
724 ent->orig_tag[1] = ent->tag[1]; in find_and_prep_issuable_command()
726 if (esp_alloc_lun_tag(ent, lp) < 0) in find_and_prep_issuable_command()
729 return ent; in find_and_prep_issuable_command()
740 struct esp_cmd_entry *ent; in esp_maybe_execute_command() local
750 ent = find_and_prep_issuable_command(esp); in esp_maybe_execute_command()
751 if (!ent) in esp_maybe_execute_command()
754 if (ent->flags & ESP_CMD_FLAG_AUTOSENSE) { in esp_maybe_execute_command()
755 esp_autosense(esp, ent); in esp_maybe_execute_command()
759 cmd = ent->cmd; in esp_maybe_execute_command()
765 list_move(&ent->list, &esp->active_cmds); in esp_maybe_execute_command()
767 esp->active_cmd = ent; in esp_maybe_execute_command()
770 esp_save_pointers(esp, ent); in esp_maybe_execute_command()
822 if (ent->tag[0] && esp->rev == ESP100) { in esp_maybe_execute_command()
833 if (ent->tag[0]) { in esp_maybe_execute_command()
837 esp->msg_out[0] = ent->tag[0]; in esp_maybe_execute_command()
838 esp->msg_out[1] = ent->tag[1]; in esp_maybe_execute_command()
846 if (ent->tag[0]) { in esp_maybe_execute_command()
847 *p++ = ent->tag[0]; in esp_maybe_execute_command()
848 *p++ = ent->tag[1]; in esp_maybe_execute_command()
893 static void esp_put_ent(struct esp *esp, struct esp_cmd_entry *ent) in esp_put_ent() argument
895 list_add(&ent->list, &esp->esp_cmd_pool); in esp_put_ent()
898 static void esp_cmd_is_done(struct esp *esp, struct esp_cmd_entry *ent, in esp_cmd_is_done() argument
907 esp_free_lun_tag(ent, dev->hostdata); in esp_cmd_is_done()
911 set_status_byte(cmd, ent->status); in esp_cmd_is_done()
913 if (ent->eh_done) { in esp_cmd_is_done()
914 complete(ent->eh_done); in esp_cmd_is_done()
915 ent->eh_done = NULL; in esp_cmd_is_done()
918 if (ent->flags & ESP_CMD_FLAG_AUTOSENSE) { in esp_cmd_is_done()
919 esp_unmap_sense(esp, ent); in esp_cmd_is_done()
927 ent->flags &= ~ESP_CMD_FLAG_AUTOSENSE; in esp_cmd_is_done()
941 list_del(&ent->list); in esp_cmd_is_done()
942 esp_put_ent(esp, ent); in esp_cmd_is_done()
947 static void esp_event_queue_full(struct esp *esp, struct esp_cmd_entry *ent) in esp_event_queue_full() argument
949 struct scsi_device *dev = ent->cmd->device; in esp_event_queue_full()
960 struct esp_cmd_entry *ent; in esp_queuecommand_lck() local
962 ent = esp_get_ent(esp); in esp_queuecommand_lck()
963 if (!ent) in esp_queuecommand_lck()
966 ent->cmd = cmd; in esp_queuecommand_lck()
971 list_add_tail(&ent->list, &esp->queued_cmds); in esp_queuecommand_lck()
1049 struct esp_cmd_entry *ent; in esp_reconnect_with_tag() local
1126 ent = lp->tagged_cmds[esp->command_block[1]]; in esp_reconnect_with_tag()
1127 if (!ent) { in esp_reconnect_with_tag()
1134 return ent; in esp_reconnect_with_tag()
1139 struct esp_cmd_entry *ent; in esp_reconnect() local
1203 ent = lp->non_tagged_cmd; in esp_reconnect()
1204 if (!ent) { in esp_reconnect()
1205 ent = esp_reconnect_with_tag(esp, lp); in esp_reconnect()
1206 if (!ent) in esp_reconnect()
1210 esp->active_cmd = ent; in esp_reconnect()
1213 esp_restore_pointers(esp, ent); in esp_reconnect()
1224 struct esp_cmd_entry *ent; in esp_finish_select() local
1231 ent = esp->active_cmd; in esp_finish_select()
1232 cmd = ent->cmd; in esp_finish_select()
1239 esp_cmd_is_done(esp, ent, cmd, DID_ERROR); in esp_finish_select()
1252 if (!(ent->flags & ESP_CMD_FLAG_AUTOSENSE)) { in esp_finish_select()
1254 esp_free_lun_tag(ent, cmd->device->hostdata); in esp_finish_select()
1259 esp_unmap_sense(esp, ent); in esp_finish_select()
1265 list_move(&ent->list, &esp->queued_cmds); in esp_finish_select()
1284 esp_cmd_is_done(esp, ent, cmd, DID_BAD_TARGET); in esp_finish_select()
1316 static int esp_data_bytes_sent(struct esp *esp, struct esp_cmd_entry *ent, in esp_data_bytes_sent() argument
1347 if (fifo_cnt == 1 && ent->flags & ESP_CMD_FLAG_RESIDUAL) { in esp_data_bytes_sent()
1352 if (ent->flags & ESP_CMD_FLAG_AUTOSENSE) in esp_data_bytes_sent()
1353 ent->sense_ptr[bytes_sent] = bval; in esp_data_bytes_sent()
1366 ent->flags &= ~ESP_CMD_FLAG_RESIDUAL; in esp_data_bytes_sent()
1368 if (!(ent->flags & ESP_CMD_FLAG_WRITE)) in esp_data_bytes_sent()
1400 if (!(ent->flags & ESP_CMD_FLAG_WRITE)) in esp_data_bytes_sent()
1451 struct esp_cmd_entry *ent = esp->active_cmd; in esp_msgin_reject() local
1452 struct scsi_cmnd *cmd = ent->cmd; in esp_msgin_reject()
1591 struct esp_cmd_entry *ent = esp->active_cmd; in esp_msgin_extended() local
1592 struct scsi_cmnd *cmd = ent->cmd; in esp_msgin_extended()
1639 struct esp_cmd_entry *ent; in esp_msgin_process() local
1647 ent = esp->active_cmd; in esp_msgin_process()
1648 spriv = ESP_CMD_PRIV(ent->cmd); in esp_msgin_process()
1669 struct esp_cmd_entry *ent = esp->active_cmd; in esp_msgin_process() local
1671 ent->message = msg0; in esp_msgin_process()
1739 struct esp_cmd_entry *ent = esp->active_cmd; in esp_process_event() local
1740 struct scsi_cmnd *cmd = ent->cmd; in esp_process_event()
1741 dma_addr_t dma_addr = esp_cur_dma_addr(ent, cmd); in esp_process_event()
1742 unsigned int dma_len = esp_cur_dma_len(ent, cmd); in esp_process_event()
1748 ent->flags |= ESP_CMD_FLAG_WRITE; in esp_process_event()
1750 ent->flags &= ~ESP_CMD_FLAG_WRITE; in esp_process_event()
1765 (unsigned long long)esp_cur_dma_addr(ent, cmd), in esp_process_event()
1766 esp_cur_dma_len(ent, cmd)); in esp_process_event()
1780 struct esp_cmd_entry *ent = esp->active_cmd; in esp_process_event() local
1781 struct scsi_cmnd *cmd = ent->cmd; in esp_process_event()
1791 if (ent->flags & ESP_CMD_FLAG_WRITE) { in esp_process_event()
1808 bytes_sent = esp_data_bytes_sent(esp, ent, cmd); in esp_process_event()
1811 ent->flags, bytes_sent); in esp_process_event()
1819 esp_advance_dma(esp, ent, cmd, bytes_sent); in esp_process_event()
1825 struct esp_cmd_entry *ent = esp->active_cmd; in esp_process_event() local
1828 ent->status = esp_read8(ESP_FDATA); in esp_process_event()
1829 ent->message = esp_read8(ESP_FDATA); in esp_process_event()
1832 ent->status = esp_read8(ESP_FDATA); in esp_process_event()
1833 ent->message = 0xff; in esp_process_event()
1838 if (ent->message != COMMAND_COMPLETE) { in esp_process_event()
1841 ent->message); in esp_process_event()
1851 struct esp_cmd_entry *ent = esp->active_cmd; in esp_process_event() local
1852 struct scsi_cmnd *cmd = ent->cmd; in esp_process_event()
1854 if (ent->message == COMMAND_COMPLETE || in esp_process_event()
1855 ent->message == DISCONNECT) in esp_process_event()
1858 if (ent->message == COMMAND_COMPLETE) { in esp_process_event()
1860 ent->status, ent->message); in esp_process_event()
1861 if (ent->status == SAM_STAT_TASK_SET_FULL) in esp_process_event()
1862 esp_event_queue_full(esp, ent); in esp_process_event()
1864 if (ent->status == SAM_STAT_CHECK_CONDITION && in esp_process_event()
1865 !(ent->flags & ESP_CMD_FLAG_AUTOSENSE)) { in esp_process_event()
1866 ent->flags |= ESP_CMD_FLAG_AUTOSENSE; in esp_process_event()
1867 esp_autosense(esp, ent); in esp_process_event()
1869 esp_cmd_is_done(esp, ent, cmd, DID_OK); in esp_process_event()
1871 } else if (ent->message == DISCONNECT) { in esp_process_event()
1874 ent->tag[0], ent->tag[1]); in esp_process_event()
1881 ent->message); in esp_process_event()
2028 static void esp_reset_cleanup_one(struct esp *esp, struct esp_cmd_entry *ent) in esp_reset_cleanup_one() argument
2030 struct scsi_cmnd *cmd = ent->cmd; in esp_reset_cleanup_one()
2033 esp_free_lun_tag(ent, cmd->device->hostdata); in esp_reset_cleanup_one()
2036 if (ent->flags & ESP_CMD_FLAG_AUTOSENSE) in esp_reset_cleanup_one()
2037 esp_unmap_sense(esp, ent); in esp_reset_cleanup_one()
2040 list_del(&ent->list); in esp_reset_cleanup_one()
2041 esp_put_ent(esp, ent); in esp_reset_cleanup_one()
2054 struct esp_cmd_entry *ent, *tmp; in esp_reset_cleanup() local
2057 list_for_each_entry_safe(ent, tmp, &esp->queued_cmds, list) { in esp_reset_cleanup()
2058 struct scsi_cmnd *cmd = ent->cmd; in esp_reset_cleanup()
2060 list_del(&ent->list); in esp_reset_cleanup()
2063 esp_put_ent(esp, ent); in esp_reset_cleanup()
2066 list_for_each_entry_safe(ent, tmp, &esp->active_cmds, list) { in esp_reset_cleanup()
2067 if (ent == esp->active_cmd) in esp_reset_cleanup()
2069 esp_reset_cleanup_one(esp, ent); in esp_reset_cleanup()
2493 struct esp_cmd_entry *ent, *tmp; in esp_eh_abort_handler() local
2503 ent = esp->active_cmd; in esp_eh_abort_handler()
2504 if (ent) in esp_eh_abort_handler()
2507 ent->cmd, ent->cmd->cmnd[0]); in esp_eh_abort_handler()
2508 list_for_each_entry(ent, &esp->queued_cmds, list) { in esp_eh_abort_handler()
2510 ent->cmd, ent->cmd->cmnd[0]); in esp_eh_abort_handler()
2512 list_for_each_entry(ent, &esp->active_cmds, list) { in esp_eh_abort_handler()
2514 ent->cmd, ent->cmd->cmnd[0]); in esp_eh_abort_handler()
2521 ent = NULL; in esp_eh_abort_handler()
2524 ent = tmp; in esp_eh_abort_handler()
2529 if (ent) { in esp_eh_abort_handler()
2533 list_del(&ent->list); in esp_eh_abort_handler()
2538 esp_put_ent(esp, ent); in esp_eh_abort_handler()
2545 ent = esp->active_cmd; in esp_eh_abort_handler()
2546 if (ent && ent->cmd == cmd) { in esp_eh_abort_handler()
2559 ent->eh_done = &eh_done; in esp_eh_abort_handler()
2586 ent->eh_done = NULL; in esp_eh_abort_handler()