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()
973 list_add_tail(&ent->list, &esp->queued_cmds); in esp_queuecommand_lck()
1051 struct esp_cmd_entry *ent; in esp_reconnect_with_tag() local
1128 ent = lp->tagged_cmds[esp->command_block[1]]; in esp_reconnect_with_tag()
1129 if (!ent) { in esp_reconnect_with_tag()
1136 return ent; in esp_reconnect_with_tag()
1141 struct esp_cmd_entry *ent; in esp_reconnect() local
1205 ent = lp->non_tagged_cmd; in esp_reconnect()
1206 if (!ent) { in esp_reconnect()
1207 ent = esp_reconnect_with_tag(esp, lp); in esp_reconnect()
1208 if (!ent) in esp_reconnect()
1212 esp->active_cmd = ent; in esp_reconnect()
1215 esp_restore_pointers(esp, ent); in esp_reconnect()
1226 struct esp_cmd_entry *ent; in esp_finish_select() local
1233 ent = esp->active_cmd; in esp_finish_select()
1234 cmd = ent->cmd; in esp_finish_select()
1241 esp_cmd_is_done(esp, ent, cmd, DID_ERROR); in esp_finish_select()
1254 if (!(ent->flags & ESP_CMD_FLAG_AUTOSENSE)) { in esp_finish_select()
1256 esp_free_lun_tag(ent, cmd->device->hostdata); in esp_finish_select()
1261 esp_unmap_sense(esp, ent); in esp_finish_select()
1267 list_move(&ent->list, &esp->queued_cmds); in esp_finish_select()
1286 esp_cmd_is_done(esp, ent, cmd, DID_BAD_TARGET); in esp_finish_select()
1318 static int esp_data_bytes_sent(struct esp *esp, struct esp_cmd_entry *ent, in esp_data_bytes_sent() argument
1349 if (fifo_cnt == 1 && ent->flags & ESP_CMD_FLAG_RESIDUAL) { in esp_data_bytes_sent()
1354 if (ent->flags & ESP_CMD_FLAG_AUTOSENSE) in esp_data_bytes_sent()
1355 ent->sense_ptr[bytes_sent] = bval; in esp_data_bytes_sent()
1368 ent->flags &= ~ESP_CMD_FLAG_RESIDUAL; in esp_data_bytes_sent()
1370 if (!(ent->flags & ESP_CMD_FLAG_WRITE)) in esp_data_bytes_sent()
1402 if (!(ent->flags & ESP_CMD_FLAG_WRITE)) in esp_data_bytes_sent()
1453 struct esp_cmd_entry *ent = esp->active_cmd; in esp_msgin_reject() local
1454 struct scsi_cmnd *cmd = ent->cmd; in esp_msgin_reject()
1593 struct esp_cmd_entry *ent = esp->active_cmd; in esp_msgin_extended() local
1594 struct scsi_cmnd *cmd = ent->cmd; in esp_msgin_extended()
1641 struct esp_cmd_entry *ent; in esp_msgin_process() local
1649 ent = esp->active_cmd; in esp_msgin_process()
1650 spriv = ESP_CMD_PRIV(ent->cmd); in esp_msgin_process()
1671 struct esp_cmd_entry *ent = esp->active_cmd; in esp_msgin_process() local
1673 ent->message = msg0; in esp_msgin_process()
1741 struct esp_cmd_entry *ent = esp->active_cmd; in esp_process_event() local
1742 struct scsi_cmnd *cmd = ent->cmd; in esp_process_event()
1743 dma_addr_t dma_addr = esp_cur_dma_addr(ent, cmd); in esp_process_event()
1744 unsigned int dma_len = esp_cur_dma_len(ent, cmd); in esp_process_event()
1750 ent->flags |= ESP_CMD_FLAG_WRITE; in esp_process_event()
1752 ent->flags &= ~ESP_CMD_FLAG_WRITE; in esp_process_event()
1767 (unsigned long long)esp_cur_dma_addr(ent, cmd), in esp_process_event()
1768 esp_cur_dma_len(ent, cmd)); in esp_process_event()
1782 struct esp_cmd_entry *ent = esp->active_cmd; in esp_process_event() local
1783 struct scsi_cmnd *cmd = ent->cmd; in esp_process_event()
1793 if (ent->flags & ESP_CMD_FLAG_WRITE) { in esp_process_event()
1810 bytes_sent = esp_data_bytes_sent(esp, ent, cmd); in esp_process_event()
1813 ent->flags, bytes_sent); in esp_process_event()
1821 esp_advance_dma(esp, ent, cmd, bytes_sent); in esp_process_event()
1827 struct esp_cmd_entry *ent = esp->active_cmd; in esp_process_event() local
1830 ent->status = esp_read8(ESP_FDATA); in esp_process_event()
1831 ent->message = esp_read8(ESP_FDATA); in esp_process_event()
1834 ent->status = esp_read8(ESP_FDATA); in esp_process_event()
1835 ent->message = 0xff; in esp_process_event()
1840 if (ent->message != COMMAND_COMPLETE) { in esp_process_event()
1843 ent->message); in esp_process_event()
1853 struct esp_cmd_entry *ent = esp->active_cmd; in esp_process_event() local
1854 struct scsi_cmnd *cmd = ent->cmd; in esp_process_event()
1856 if (ent->message == COMMAND_COMPLETE || in esp_process_event()
1857 ent->message == DISCONNECT) in esp_process_event()
1860 if (ent->message == COMMAND_COMPLETE) { in esp_process_event()
1862 ent->status, ent->message); in esp_process_event()
1863 if (ent->status == SAM_STAT_TASK_SET_FULL) in esp_process_event()
1864 esp_event_queue_full(esp, ent); in esp_process_event()
1866 if (ent->status == SAM_STAT_CHECK_CONDITION && in esp_process_event()
1867 !(ent->flags & ESP_CMD_FLAG_AUTOSENSE)) { in esp_process_event()
1868 ent->flags |= ESP_CMD_FLAG_AUTOSENSE; in esp_process_event()
1869 esp_autosense(esp, ent); in esp_process_event()
1871 esp_cmd_is_done(esp, ent, cmd, DID_OK); in esp_process_event()
1873 } else if (ent->message == DISCONNECT) { in esp_process_event()
1876 ent->tag[0], ent->tag[1]); in esp_process_event()
1883 ent->message); in esp_process_event()
2030 static void esp_reset_cleanup_one(struct esp *esp, struct esp_cmd_entry *ent) in esp_reset_cleanup_one() argument
2032 struct scsi_cmnd *cmd = ent->cmd; in esp_reset_cleanup_one()
2035 esp_free_lun_tag(ent, cmd->device->hostdata); in esp_reset_cleanup_one()
2038 if (ent->flags & ESP_CMD_FLAG_AUTOSENSE) in esp_reset_cleanup_one()
2039 esp_unmap_sense(esp, ent); in esp_reset_cleanup_one()
2042 list_del(&ent->list); in esp_reset_cleanup_one()
2043 esp_put_ent(esp, ent); in esp_reset_cleanup_one()
2056 struct esp_cmd_entry *ent, *tmp; in esp_reset_cleanup() local
2059 list_for_each_entry_safe(ent, tmp, &esp->queued_cmds, list) { in esp_reset_cleanup()
2060 struct scsi_cmnd *cmd = ent->cmd; in esp_reset_cleanup()
2062 list_del(&ent->list); in esp_reset_cleanup()
2065 esp_put_ent(esp, ent); in esp_reset_cleanup()
2068 list_for_each_entry_safe(ent, tmp, &esp->active_cmds, list) { in esp_reset_cleanup()
2069 if (ent == esp->active_cmd) in esp_reset_cleanup()
2071 esp_reset_cleanup_one(esp, ent); in esp_reset_cleanup()
2495 struct esp_cmd_entry *ent, *tmp; in esp_eh_abort_handler() local
2505 ent = esp->active_cmd; in esp_eh_abort_handler()
2506 if (ent) in esp_eh_abort_handler()
2509 ent->cmd, ent->cmd->cmnd[0]); in esp_eh_abort_handler()
2510 list_for_each_entry(ent, &esp->queued_cmds, list) { in esp_eh_abort_handler()
2512 ent->cmd, ent->cmd->cmnd[0]); in esp_eh_abort_handler()
2514 list_for_each_entry(ent, &esp->active_cmds, list) { in esp_eh_abort_handler()
2516 ent->cmd, ent->cmd->cmnd[0]); in esp_eh_abort_handler()
2523 ent = NULL; in esp_eh_abort_handler()
2526 ent = tmp; in esp_eh_abort_handler()
2531 if (ent) { in esp_eh_abort_handler()
2535 list_del(&ent->list); in esp_eh_abort_handler()
2540 esp_put_ent(esp, ent); in esp_eh_abort_handler()
2547 ent = esp->active_cmd; in esp_eh_abort_handler()
2548 if (ent && ent->cmd == cmd) { in esp_eh_abort_handler()
2561 ent->eh_done = &eh_done; in esp_eh_abort_handler()
2588 ent->eh_done = NULL; in esp_eh_abort_handler()