diff options
author | Tejun Heo <htejun@gmail.com> | 2006-04-02 05:51:53 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-04-02 10:09:21 -0400 |
commit | ece1d63619df010b8c4f08e43755e2a03f3b6eed (patch) | |
tree | c6474fe7541d479bf19c36c79700dfa9f6093a8d /drivers/scsi/libata-scsi.c | |
parent | 35e86b53b1a38e78ff0d70dae4aeb25f4572e433 (diff) |
[PATCH] libata: separate out libata-eh.c
A lot of EH codes are about to be added to libata. Separate out
libata-eh.c. ata_scsi_timed_out(), ata_scsi_error(),
ata_qc_timeout(), ata_eng_timeout(), ata_eh_qc_complete() and
ata_eh_qc_retry() are moved. No code is changed by this patch.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/scsi/libata-scsi.c')
-rw-r--r-- | drivers/scsi/libata-scsi.c | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 44008150d310..745fc263feeb 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -53,7 +53,6 @@ | |||
53 | typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd); | 53 | typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd); |
54 | static struct ata_device * | 54 | static struct ata_device * |
55 | ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev); | 55 | ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev); |
56 | enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); | ||
57 | 56 | ||
58 | #define RW_RECOVERY_MPAGE 0x1 | 57 | #define RW_RECOVERY_MPAGE 0x1 |
59 | #define RW_RECOVERY_MPAGE_LEN 12 | 58 | #define RW_RECOVERY_MPAGE_LEN 12 |
@@ -714,135 +713,6 @@ int ata_scsi_slave_config(struct scsi_device *sdev) | |||
714 | } | 713 | } |
715 | 714 | ||
716 | /** | 715 | /** |
717 | * ata_scsi_timed_out - SCSI layer time out callback | ||
718 | * @cmd: timed out SCSI command | ||
719 | * | ||
720 | * Handles SCSI layer timeout. We race with normal completion of | ||
721 | * the qc for @cmd. If the qc is already gone, we lose and let | ||
722 | * the scsi command finish (EH_HANDLED). Otherwise, the qc has | ||
723 | * timed out and EH should be invoked. Prevent ata_qc_complete() | ||
724 | * from finishing it by setting EH_SCHEDULED and return | ||
725 | * EH_NOT_HANDLED. | ||
726 | * | ||
727 | * LOCKING: | ||
728 | * Called from timer context | ||
729 | * | ||
730 | * RETURNS: | ||
731 | * EH_HANDLED or EH_NOT_HANDLED | ||
732 | */ | ||
733 | enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd) | ||
734 | { | ||
735 | struct Scsi_Host *host = cmd->device->host; | ||
736 | struct ata_port *ap = (struct ata_port *) &host->hostdata[0]; | ||
737 | unsigned long flags; | ||
738 | struct ata_queued_cmd *qc; | ||
739 | enum scsi_eh_timer_return ret = EH_HANDLED; | ||
740 | |||
741 | DPRINTK("ENTER\n"); | ||
742 | |||
743 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
744 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
745 | if (qc) { | ||
746 | WARN_ON(qc->scsicmd != cmd); | ||
747 | qc->flags |= ATA_QCFLAG_EH_SCHEDULED; | ||
748 | qc->err_mask |= AC_ERR_TIMEOUT; | ||
749 | ret = EH_NOT_HANDLED; | ||
750 | } | ||
751 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
752 | |||
753 | DPRINTK("EXIT, ret=%d\n", ret); | ||
754 | return ret; | ||
755 | } | ||
756 | |||
757 | /** | ||
758 | * ata_scsi_error - SCSI layer error handler callback | ||
759 | * @host: SCSI host on which error occurred | ||
760 | * | ||
761 | * Handles SCSI-layer-thrown error events. | ||
762 | * | ||
763 | * LOCKING: | ||
764 | * Inherited from SCSI layer (none, can sleep) | ||
765 | * | ||
766 | * RETURNS: | ||
767 | * Zero. | ||
768 | */ | ||
769 | |||
770 | int ata_scsi_error(struct Scsi_Host *host) | ||
771 | { | ||
772 | struct ata_port *ap = (struct ata_port *)&host->hostdata[0]; | ||
773 | |||
774 | DPRINTK("ENTER\n"); | ||
775 | |||
776 | /* synchronize with IRQ handler and port task */ | ||
777 | spin_unlock_wait(&ap->host_set->lock); | ||
778 | ata_port_flush_task(ap); | ||
779 | |||
780 | WARN_ON(ata_qc_from_tag(ap, ap->active_tag) == NULL); | ||
781 | |||
782 | ap->ops->eng_timeout(ap); | ||
783 | |||
784 | WARN_ON(host->host_failed || !list_empty(&host->eh_cmd_q)); | ||
785 | |||
786 | scsi_eh_flush_done_q(&ap->eh_done_q); | ||
787 | |||
788 | DPRINTK("EXIT\n"); | ||
789 | return 0; | ||
790 | } | ||
791 | |||
792 | static void ata_eh_scsidone(struct scsi_cmnd *scmd) | ||
793 | { | ||
794 | /* nada */ | ||
795 | } | ||
796 | |||
797 | static void __ata_eh_qc_complete(struct ata_queued_cmd *qc) | ||
798 | { | ||
799 | struct ata_port *ap = qc->ap; | ||
800 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
801 | unsigned long flags; | ||
802 | |||
803 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
804 | qc->scsidone = ata_eh_scsidone; | ||
805 | __ata_qc_complete(qc); | ||
806 | WARN_ON(ata_tag_valid(qc->tag)); | ||
807 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
808 | |||
809 | scsi_eh_finish_cmd(scmd, &ap->eh_done_q); | ||
810 | } | ||
811 | |||
812 | /** | ||
813 | * ata_eh_qc_complete - Complete an active ATA command from EH | ||
814 | * @qc: Command to complete | ||
815 | * | ||
816 | * Indicate to the mid and upper layers that an ATA command has | ||
817 | * completed. To be used from EH. | ||
818 | */ | ||
819 | void ata_eh_qc_complete(struct ata_queued_cmd *qc) | ||
820 | { | ||
821 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
822 | scmd->retries = scmd->allowed; | ||
823 | __ata_eh_qc_complete(qc); | ||
824 | } | ||
825 | |||
826 | /** | ||
827 | * ata_eh_qc_retry - Tell midlayer to retry an ATA command after EH | ||
828 | * @qc: Command to retry | ||
829 | * | ||
830 | * Indicate to the mid and upper layers that an ATA command | ||
831 | * should be retried. To be used from EH. | ||
832 | * | ||
833 | * SCSI midlayer limits the number of retries to scmd->allowed. | ||
834 | * scmd->retries is decremented for commands which get retried | ||
835 | * due to unrelated failures (qc->err_mask is zero). | ||
836 | */ | ||
837 | void ata_eh_qc_retry(struct ata_queued_cmd *qc) | ||
838 | { | ||
839 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
840 | if (!qc->err_mask && scmd->retries) | ||
841 | scmd->retries--; | ||
842 | __ata_eh_qc_complete(qc); | ||
843 | } | ||
844 | |||
845 | /** | ||
846 | * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command | 716 | * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command |
847 | * @qc: Storage for translated ATA taskfile | 717 | * @qc: Storage for translated ATA taskfile |
848 | * @scsicmd: SCSI command to translate | 718 | * @scsicmd: SCSI command to translate |