aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2006-02-10 07:09:37 -0500
committerJeff Garzik <jgarzik@pobox.com>2006-02-10 07:09:37 -0500
commitca7d5e42d783e54f0057317c9226262d68ab7717 (patch)
tree209751546842e1200bfbd2fd5144e1727ab18c86 /drivers/scsi
parenta0819750024a0056d760a936d72f76882a7e393f (diff)
parentcc9278ed5e992122a654a3f762561ee5e013810f (diff)
Merge branch 'upstream'
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/ahci.c57
-rw-r--r--drivers/scsi/ata_piix.c1
-rw-r--r--drivers/scsi/libata-core.c46
-rw-r--r--drivers/scsi/libata-scsi.c44
-rw-r--r--drivers/scsi/libata.h1
-rw-r--r--drivers/scsi/pdc_adma.c1
-rw-r--r--drivers/scsi/sata_mv.c10
-rw-r--r--drivers/scsi/sata_nv.c1
-rw-r--r--drivers/scsi/sata_promise.c10
-rw-r--r--drivers/scsi/sata_qstor.c1
-rw-r--r--drivers/scsi/sata_sil.c1
-rw-r--r--drivers/scsi/sata_sil24.c6
-rw-r--r--drivers/scsi/sata_sis.c1
-rw-r--r--drivers/scsi/sata_svw.c1
-rw-r--r--drivers/scsi/sata_sx4.c10
-rw-r--r--drivers/scsi/sata_uli.c1
-rw-r--r--drivers/scsi/sata_via.c1
-rw-r--r--drivers/scsi/sata_vsc.c1
18 files changed, 111 insertions, 83 deletions
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index c840d5ec12a7..98ce6bb62ff8 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -206,6 +206,7 @@ static struct scsi_host_template ahci_sht = {
206 .name = DRV_NAME, 206 .name = DRV_NAME,
207 .ioctl = ata_scsi_ioctl, 207 .ioctl = ata_scsi_ioctl,
208 .queuecommand = ata_scsi_queuecmd, 208 .queuecommand = ata_scsi_queuecmd,
209 .eh_timed_out = ata_scsi_timed_out,
209 .eh_strategy_handler = ata_scsi_error, 210 .eh_strategy_handler = ata_scsi_error,
210 .can_queue = ATA_DEF_QUEUE, 211 .can_queue = ATA_DEF_QUEUE,
211 .this_id = ATA_SHT_THIS_ID, 212 .this_id = ATA_SHT_THIS_ID,
@@ -506,6 +507,15 @@ static unsigned int ahci_dev_classify(struct ata_port *ap)
506 return ata_dev_classify(&tf); 507 return ata_dev_classify(&tf);
507} 508}
508 509
510static void ahci_fill_cmd_slot(struct ata_port *ap, u32 opts)
511{
512 struct ahci_port_priv *pp = ap->private_data;
513 pp->cmd_slot[0].opts = cpu_to_le32(opts);
514 pp->cmd_slot[0].status = 0;
515 pp->cmd_slot[0].tbl_addr = cpu_to_le32(pp->cmd_tbl_dma & 0xffffffff);
516 pp->cmd_slot[0].tbl_addr_hi = cpu_to_le32((pp->cmd_tbl_dma >> 16) >> 16);
517}
518
509static void ahci_phy_reset(struct ata_port *ap) 519static void ahci_phy_reset(struct ata_port *ap)
510{ 520{
511 void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr; 521 void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
@@ -584,42 +594,35 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
584{ 594{
585 struct ata_port *ap = qc->ap; 595 struct ata_port *ap = qc->ap;
586 struct ahci_port_priv *pp = ap->private_data; 596 struct ahci_port_priv *pp = ap->private_data;
597 int is_atapi = is_atapi_taskfile(&qc->tf);
587 u32 opts; 598 u32 opts;
588 const u32 cmd_fis_len = 5; /* five dwords */ 599 const u32 cmd_fis_len = 5; /* five dwords */
589 unsigned int n_elem; 600 unsigned int n_elem;
590 601
591 /* 602 /*
592 * Fill in command slot information (currently only one slot,
593 * slot 0, is currently since we don't do queueing)
594 */
595
596 opts = cmd_fis_len;
597 if (qc->tf.flags & ATA_TFLAG_WRITE)
598 opts |= AHCI_CMD_WRITE;
599 if (is_atapi_taskfile(&qc->tf))
600 opts |= AHCI_CMD_ATAPI;
601
602 pp->cmd_slot[0].opts = cpu_to_le32(opts);
603 pp->cmd_slot[0].status = 0;
604 pp->cmd_slot[0].tbl_addr = cpu_to_le32(pp->cmd_tbl_dma & 0xffffffff);
605 pp->cmd_slot[0].tbl_addr_hi = cpu_to_le32((pp->cmd_tbl_dma >> 16) >> 16);
606
607 /*
608 * Fill in command table information. First, the header, 603 * Fill in command table information. First, the header,
609 * a SATA Register - Host to Device command FIS. 604 * a SATA Register - Host to Device command FIS.
610 */ 605 */
611 ata_tf_to_fis(&qc->tf, pp->cmd_tbl, 0); 606 ata_tf_to_fis(&qc->tf, pp->cmd_tbl, 0);
612 if (opts & AHCI_CMD_ATAPI) { 607 if (is_atapi) {
613 memset(pp->cmd_tbl + AHCI_CMD_TBL_CDB, 0, 32); 608 memset(pp->cmd_tbl + AHCI_CMD_TBL_CDB, 0, 32);
614 memcpy(pp->cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, ap->cdb_len); 609 memcpy(pp->cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, ap->cdb_len);
615 } 610 }
616 611
617 if (!(qc->flags & ATA_QCFLAG_DMAMAP)) 612 n_elem = 0;
618 return; 613 if (qc->flags & ATA_QCFLAG_DMAMAP)
614 n_elem = ahci_fill_sg(qc);
619 615
620 n_elem = ahci_fill_sg(qc); 616 /*
617 * Fill in command slot information.
618 */
619 opts = cmd_fis_len | n_elem << 16;
620 if (qc->tf.flags & ATA_TFLAG_WRITE)
621 opts |= AHCI_CMD_WRITE;
622 if (is_atapi)
623 opts |= AHCI_CMD_ATAPI;
621 624
622 pp->cmd_slot[0].opts |= cpu_to_le32(n_elem << 16); 625 ahci_fill_cmd_slot(ap, opts);
623} 626}
624 627
625static void ahci_restart_port(struct ata_port *ap, u32 irq_stat) 628static void ahci_restart_port(struct ata_port *ap, u32 irq_stat)
@@ -676,19 +679,13 @@ static void ahci_eng_timeout(struct ata_port *ap)
676 679
677 spin_lock_irqsave(&host_set->lock, flags); 680 spin_lock_irqsave(&host_set->lock, flags);
678 681
682 ahci_restart_port(ap, readl(port_mmio + PORT_IRQ_STAT));
679 qc = ata_qc_from_tag(ap, ap->active_tag); 683 qc = ata_qc_from_tag(ap, ap->active_tag);
680 if (!qc) { 684 qc->err_mask |= AC_ERR_TIMEOUT;
681 printk(KERN_ERR "ata%u: BUG: timeout without command\n",
682 ap->id);
683 } else {
684 ahci_restart_port(ap, readl(port_mmio + PORT_IRQ_STAT));
685 qc->err_mask |= AC_ERR_TIMEOUT;
686 }
687 685
688 spin_unlock_irqrestore(&host_set->lock, flags); 686 spin_unlock_irqrestore(&host_set->lock, flags);
689 687
690 if (qc) 688 ata_eh_qc_complete(qc);
691 ata_eh_qc_complete(qc);
692} 689}
693 690
694static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) 691static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index 49cc4209fe16..4933ba284885 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -180,6 +180,7 @@ static struct scsi_host_template piix_sht = {
180 .name = DRV_NAME, 180 .name = DRV_NAME,
181 .ioctl = ata_scsi_ioctl, 181 .ioctl = ata_scsi_ioctl,
182 .queuecommand = ata_scsi_queuecmd, 182 .queuecommand = ata_scsi_queuecmd,
183 .eh_timed_out = ata_scsi_timed_out,
183 .eh_strategy_handler = ata_scsi_error, 184 .eh_strategy_handler = ata_scsi_error,
184 .can_queue = ATA_DEF_QUEUE, 185 .can_queue = ATA_DEF_QUEUE,
185 .this_id = ATA_SHT_THIS_ID, 186 .this_id = ATA_SHT_THIS_ID,
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 8e31d4b0a5b7..592d3a86c840 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -3702,20 +3702,10 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
3702 3702
3703void ata_eng_timeout(struct ata_port *ap) 3703void ata_eng_timeout(struct ata_port *ap)
3704{ 3704{
3705 struct ata_queued_cmd *qc;
3706
3707 DPRINTK("ENTER\n"); 3705 DPRINTK("ENTER\n");
3708 3706
3709 qc = ata_qc_from_tag(ap, ap->active_tag); 3707 ata_qc_timeout(ata_qc_from_tag(ap, ap->active_tag));
3710 if (qc)
3711 ata_qc_timeout(qc);
3712 else {
3713 printk(KERN_ERR "ata%u: BUG: timeout without command\n",
3714 ap->id);
3715 goto out;
3716 }
3717 3708
3718out:
3719 DPRINTK("EXIT\n"); 3709 DPRINTK("EXIT\n");
3720} 3710}
3721 3711
@@ -3798,19 +3788,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
3798 } 3788 }
3799} 3789}
3800 3790
3801/** 3791inline void __ata_qc_complete(struct ata_queued_cmd *qc)
3802 * ata_qc_complete - Complete an active ATA command
3803 * @qc: Command to complete
3804 * @err_mask: ATA Status register contents
3805 *
3806 * Indicate to the mid and upper layers that an ATA
3807 * command has completed, with either an ok or not-ok status.
3808 *
3809 * LOCKING:
3810 * spin_lock_irqsave(host_set lock)
3811 */
3812
3813void ata_qc_complete(struct ata_queued_cmd *qc)
3814{ 3792{
3815 assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ 3793 assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */
3816 assert(qc->flags & ATA_QCFLAG_ACTIVE); 3794 assert(qc->flags & ATA_QCFLAG_ACTIVE);
@@ -3828,6 +3806,25 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
3828 qc->complete_fn(qc); 3806 qc->complete_fn(qc);
3829} 3807}
3830 3808
3809/**
3810 * ata_qc_complete - Complete an active ATA command
3811 * @qc: Command to complete
3812 * @err_mask: ATA Status register contents
3813 *
3814 * Indicate to the mid and upper layers that an ATA
3815 * command has completed, with either an ok or not-ok status.
3816 *
3817 * LOCKING:
3818 * spin_lock_irqsave(host_set lock)
3819 */
3820void ata_qc_complete(struct ata_queued_cmd *qc)
3821{
3822 if (unlikely(qc->flags & ATA_QCFLAG_EH_SCHEDULED))
3823 return;
3824
3825 __ata_qc_complete(qc);
3826}
3827
3831static inline int ata_should_dma_map(struct ata_queued_cmd *qc) 3828static inline int ata_should_dma_map(struct ata_queued_cmd *qc)
3832{ 3829{
3833 struct ata_port *ap = qc->ap; 3830 struct ata_port *ap = qc->ap;
@@ -5183,6 +5180,7 @@ EXPORT_SYMBOL_GPL(ata_ratelimit);
5183EXPORT_SYMBOL_GPL(ata_busy_sleep); 5180EXPORT_SYMBOL_GPL(ata_busy_sleep);
5184EXPORT_SYMBOL_GPL(ata_scsi_ioctl); 5181EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
5185EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); 5182EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);
5183EXPORT_SYMBOL_GPL(ata_scsi_timed_out);
5186EXPORT_SYMBOL_GPL(ata_scsi_error); 5184EXPORT_SYMBOL_GPL(ata_scsi_error);
5187EXPORT_SYMBOL_GPL(ata_scsi_slave_config); 5185EXPORT_SYMBOL_GPL(ata_scsi_slave_config);
5188EXPORT_SYMBOL_GPL(ata_scsi_release); 5186EXPORT_SYMBOL_GPL(ata_scsi_release);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index b007bb409382..9d67c6768335 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -717,6 +717,47 @@ int ata_scsi_slave_config(struct scsi_device *sdev)
717} 717}
718 718
719/** 719/**
720 * ata_scsi_timed_out - SCSI layer time out callback
721 * @cmd: timed out SCSI command
722 *
723 * Handles SCSI layer timeout. We race with normal completion of
724 * the qc for @cmd. If the qc is already gone, we lose and let
725 * the scsi command finish (EH_HANDLED). Otherwise, the qc has
726 * timed out and EH should be invoked. Prevent ata_qc_complete()
727 * from finishing it by setting EH_SCHEDULED and return
728 * EH_NOT_HANDLED.
729 *
730 * LOCKING:
731 * Called from timer context
732 *
733 * RETURNS:
734 * EH_HANDLED or EH_NOT_HANDLED
735 */
736enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd)
737{
738 struct Scsi_Host *host = cmd->device->host;
739 struct ata_port *ap = (struct ata_port *) &host->hostdata[0];
740 unsigned long flags;
741 struct ata_queued_cmd *qc;
742 enum scsi_eh_timer_return ret = EH_HANDLED;
743
744 DPRINTK("ENTER\n");
745
746 spin_lock_irqsave(&ap->host_set->lock, flags);
747 qc = ata_qc_from_tag(ap, ap->active_tag);
748 if (qc) {
749 assert(qc->scsicmd == cmd);
750 qc->flags |= ATA_QCFLAG_EH_SCHEDULED;
751 qc->err_mask |= AC_ERR_TIMEOUT;
752 ret = EH_NOT_HANDLED;
753 }
754 spin_unlock_irqrestore(&ap->host_set->lock, flags);
755
756 DPRINTK("EXIT, ret=%d\n", ret);
757 return ret;
758}
759
760/**
720 * ata_scsi_error - SCSI layer error handler callback 761 * ata_scsi_error - SCSI layer error handler callback
721 * @host: SCSI host on which error occurred 762 * @host: SCSI host on which error occurred
722 * 763 *
@@ -741,6 +782,7 @@ int ata_scsi_error(struct Scsi_Host *host)
741 spin_lock_irqsave(&ap->host_set->lock, flags); 782 spin_lock_irqsave(&ap->host_set->lock, flags);
742 assert(!(ap->flags & ATA_FLAG_IN_EH)); 783 assert(!(ap->flags & ATA_FLAG_IN_EH));
743 ap->flags |= ATA_FLAG_IN_EH; 784 ap->flags |= ATA_FLAG_IN_EH;
785 assert(ata_qc_from_tag(ap, ap->active_tag) != NULL);
744 spin_unlock_irqrestore(&ap->host_set->lock, flags); 786 spin_unlock_irqrestore(&ap->host_set->lock, flags);
745 787
746 ap->ops->eng_timeout(ap); 788 ap->ops->eng_timeout(ap);
@@ -770,7 +812,7 @@ static void __ata_eh_qc_complete(struct ata_queued_cmd *qc)
770 812
771 spin_lock_irqsave(&ap->host_set->lock, flags); 813 spin_lock_irqsave(&ap->host_set->lock, flags);
772 qc->scsidone = ata_eh_scsidone; 814 qc->scsidone = ata_eh_scsidone;
773 ata_qc_complete(qc); 815 __ata_qc_complete(qc);
774 assert(!ata_tag_valid(qc->tag)); 816 assert(!ata_tag_valid(qc->tag));
775 spin_unlock_irqrestore(&ap->host_set->lock, flags); 817 spin_unlock_irqrestore(&ap->host_set->lock, flags);
776 818
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index 9d76923a2253..1cd071a32e93 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -46,6 +46,7 @@ extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
46extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc); 46extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc);
47extern void ata_qc_free(struct ata_queued_cmd *qc); 47extern void ata_qc_free(struct ata_queued_cmd *qc);
48extern unsigned int ata_qc_issue(struct ata_queued_cmd *qc); 48extern unsigned int ata_qc_issue(struct ata_queued_cmd *qc);
49extern void __ata_qc_complete(struct ata_queued_cmd *qc);
49extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); 50extern int ata_check_atapi_dma(struct ata_queued_cmd *qc);
50extern void ata_dev_select(struct ata_port *ap, unsigned int device, 51extern void ata_dev_select(struct ata_port *ap, unsigned int device,
51 unsigned int wait, unsigned int can_sleep); 52 unsigned int wait, unsigned int can_sleep);
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index 2dca6c53868a..0f7e45a39fd9 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -143,6 +143,7 @@ static struct scsi_host_template adma_ata_sht = {
143 .name = DRV_NAME, 143 .name = DRV_NAME,
144 .ioctl = ata_scsi_ioctl, 144 .ioctl = ata_scsi_ioctl,
145 .queuecommand = ata_scsi_queuecmd, 145 .queuecommand = ata_scsi_queuecmd,
146 .eh_timed_out = ata_scsi_timed_out,
146 .eh_strategy_handler = ata_scsi_error, 147 .eh_strategy_handler = ata_scsi_error,
147 .can_queue = ATA_DEF_QUEUE, 148 .can_queue = ATA_DEF_QUEUE,
148 .this_id = ATA_SHT_THIS_ID, 149 .this_id = ATA_SHT_THIS_ID,
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index 5b36a23455de..cda4c495c10f 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -378,6 +378,7 @@ static struct scsi_host_template mv_sht = {
378 .name = DRV_NAME, 378 .name = DRV_NAME,
379 .ioctl = ata_scsi_ioctl, 379 .ioctl = ata_scsi_ioctl,
380 .queuecommand = ata_scsi_queuecmd, 380 .queuecommand = ata_scsi_queuecmd,
381 .eh_timed_out = ata_scsi_timed_out,
381 .eh_strategy_handler = ata_scsi_error, 382 .eh_strategy_handler = ata_scsi_error,
382 .can_queue = MV_USE_Q_DEPTH, 383 .can_queue = MV_USE_Q_DEPTH,
383 .this_id = ATA_SHT_THIS_ID, 384 .this_id = ATA_SHT_THIS_ID,
@@ -2025,13 +2026,8 @@ static void mv_eng_timeout(struct ata_port *ap)
2025 mv_err_intr(ap); 2026 mv_err_intr(ap);
2026 mv_stop_and_reset(ap); 2027 mv_stop_and_reset(ap);
2027 2028
2028 if (!qc) { 2029 qc->err_mask |= AC_ERR_TIMEOUT;
2029 printk(KERN_ERR "ata%u: BUG: timeout without command\n", 2030 ata_eh_qc_complete(qc);
2030 ap->id);
2031 } else {
2032 qc->err_mask |= AC_ERR_TIMEOUT;
2033 ata_eh_qc_complete(qc);
2034 }
2035} 2031}
2036 2032
2037/** 2033/**
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index 945194b76998..94dc2e1a8f30 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -229,6 +229,7 @@ static struct scsi_host_template nv_sht = {
229 .name = DRV_NAME, 229 .name = DRV_NAME,
230 .ioctl = ata_scsi_ioctl, 230 .ioctl = ata_scsi_ioctl,
231 .queuecommand = ata_scsi_queuecmd, 231 .queuecommand = ata_scsi_queuecmd,
232 .eh_timed_out = ata_scsi_timed_out,
232 .eh_strategy_handler = ata_scsi_error, 233 .eh_strategy_handler = ata_scsi_error,
233 .can_queue = ATA_DEF_QUEUE, 234 .can_queue = ATA_DEF_QUEUE,
234 .this_id = ATA_SHT_THIS_ID, 235 .this_id = ATA_SHT_THIS_ID,
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index dcd1667f4144..a88b563ebcc4 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -112,6 +112,7 @@ static struct scsi_host_template pdc_ata_sht = {
112 .name = DRV_NAME, 112 .name = DRV_NAME,
113 .ioctl = ata_scsi_ioctl, 113 .ioctl = ata_scsi_ioctl,
114 .queuecommand = ata_scsi_queuecmd, 114 .queuecommand = ata_scsi_queuecmd,
115 .eh_timed_out = ata_scsi_timed_out,
115 .eh_strategy_handler = ata_scsi_error, 116 .eh_strategy_handler = ata_scsi_error,
116 .can_queue = ATA_DEF_QUEUE, 117 .can_queue = ATA_DEF_QUEUE,
117 .this_id = ATA_SHT_THIS_ID, 118 .this_id = ATA_SHT_THIS_ID,
@@ -432,11 +433,6 @@ static void pdc_eng_timeout(struct ata_port *ap)
432 spin_lock_irqsave(&host_set->lock, flags); 433 spin_lock_irqsave(&host_set->lock, flags);
433 434
434 qc = ata_qc_from_tag(ap, ap->active_tag); 435 qc = ata_qc_from_tag(ap, ap->active_tag);
435 if (!qc) {
436 printk(KERN_ERR "ata%u: BUG: timeout without command\n",
437 ap->id);
438 goto out;
439 }
440 436
441 switch (qc->tf.protocol) { 437 switch (qc->tf.protocol) {
442 case ATA_PROT_DMA: 438 case ATA_PROT_DMA:
@@ -456,10 +452,8 @@ static void pdc_eng_timeout(struct ata_port *ap)
456 break; 452 break;
457 } 453 }
458 454
459out:
460 spin_unlock_irqrestore(&host_set->lock, flags); 455 spin_unlock_irqrestore(&host_set->lock, flags);
461 if (qc) 456 ata_eh_qc_complete(qc);
462 ata_eh_qc_complete(qc);
463 DPRINTK("EXIT\n"); 457 DPRINTK("EXIT\n");
464} 458}
465 459
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c
index b2f87da75735..d5c912763d0c 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/scsi/sata_qstor.c
@@ -132,6 +132,7 @@ static struct scsi_host_template qs_ata_sht = {
132 .name = DRV_NAME, 132 .name = DRV_NAME,
133 .ioctl = ata_scsi_ioctl, 133 .ioctl = ata_scsi_ioctl,
134 .queuecommand = ata_scsi_queuecmd, 134 .queuecommand = ata_scsi_queuecmd,
135 .eh_timed_out = ata_scsi_timed_out,
135 .eh_strategy_handler = ata_scsi_error, 136 .eh_strategy_handler = ata_scsi_error,
136 .can_queue = ATA_DEF_QUEUE, 137 .can_queue = ATA_DEF_QUEUE,
137 .this_id = ATA_SHT_THIS_ID, 138 .this_id = ATA_SHT_THIS_ID,
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index 17f74d3c10e7..f40f25edbb11 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/scsi/sata_sil.c
@@ -135,6 +135,7 @@ static struct scsi_host_template sil_sht = {
135 .name = DRV_NAME, 135 .name = DRV_NAME,
136 .ioctl = ata_scsi_ioctl, 136 .ioctl = ata_scsi_ioctl,
137 .queuecommand = ata_scsi_queuecmd, 137 .queuecommand = ata_scsi_queuecmd,
138 .eh_timed_out = ata_scsi_timed_out,
138 .eh_strategy_handler = ata_scsi_error, 139 .eh_strategy_handler = ata_scsi_error,
139 .can_queue = ATA_DEF_QUEUE, 140 .can_queue = ATA_DEF_QUEUE,
140 .this_id = ATA_SHT_THIS_ID, 141 .this_id = ATA_SHT_THIS_ID,
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c
index 7222fc7ff3fc..962396b36f61 100644
--- a/drivers/scsi/sata_sil24.c
+++ b/drivers/scsi/sata_sil24.c
@@ -280,6 +280,7 @@ static struct scsi_host_template sil24_sht = {
280 .name = DRV_NAME, 280 .name = DRV_NAME,
281 .ioctl = ata_scsi_ioctl, 281 .ioctl = ata_scsi_ioctl,
282 .queuecommand = ata_scsi_queuecmd, 282 .queuecommand = ata_scsi_queuecmd,
283 .eh_timed_out = ata_scsi_timed_out,
283 .eh_strategy_handler = ata_scsi_error, 284 .eh_strategy_handler = ata_scsi_error,
284 .can_queue = ATA_DEF_QUEUE, 285 .can_queue = ATA_DEF_QUEUE,
285 .this_id = ATA_SHT_THIS_ID, 286 .this_id = ATA_SHT_THIS_ID,
@@ -638,11 +639,6 @@ static void sil24_eng_timeout(struct ata_port *ap)
638 struct ata_queued_cmd *qc; 639 struct ata_queued_cmd *qc;
639 640
640 qc = ata_qc_from_tag(ap, ap->active_tag); 641 qc = ata_qc_from_tag(ap, ap->active_tag);
641 if (!qc) {
642 printk(KERN_ERR "ata%u: BUG: timeout without command\n",
643 ap->id);
644 return;
645 }
646 642
647 printk(KERN_ERR "ata%u: command timeout\n", ap->id); 643 printk(KERN_ERR "ata%u: command timeout\n", ap->id);
648 qc->err_mask |= AC_ERR_TIMEOUT; 644 qc->err_mask |= AC_ERR_TIMEOUT;
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c
index 2df8c5632ac3..2f1815715705 100644
--- a/drivers/scsi/sata_sis.c
+++ b/drivers/scsi/sata_sis.c
@@ -87,6 +87,7 @@ static struct scsi_host_template sis_sht = {
87 .name = DRV_NAME, 87 .name = DRV_NAME,
88 .ioctl = ata_scsi_ioctl, 88 .ioctl = ata_scsi_ioctl,
89 .queuecommand = ata_scsi_queuecmd, 89 .queuecommand = ata_scsi_queuecmd,
90 .eh_timed_out = ata_scsi_timed_out,
90 .eh_strategy_handler = ata_scsi_error, 91 .eh_strategy_handler = ata_scsi_error,
91 .can_queue = ATA_DEF_QUEUE, 92 .can_queue = ATA_DEF_QUEUE,
92 .this_id = ATA_SHT_THIS_ID, 93 .this_id = ATA_SHT_THIS_ID,
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index d8472563fde8..f369c3003adf 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -288,6 +288,7 @@ static struct scsi_host_template k2_sata_sht = {
288 .name = DRV_NAME, 288 .name = DRV_NAME,
289 .ioctl = ata_scsi_ioctl, 289 .ioctl = ata_scsi_ioctl,
290 .queuecommand = ata_scsi_queuecmd, 290 .queuecommand = ata_scsi_queuecmd,
291 .eh_timed_out = ata_scsi_timed_out,
291 .eh_strategy_handler = ata_scsi_error, 292 .eh_strategy_handler = ata_scsi_error,
292 .can_queue = ATA_DEF_QUEUE, 293 .can_queue = ATA_DEF_QUEUE,
293 .this_id = ATA_SHT_THIS_ID, 294 .this_id = ATA_SHT_THIS_ID,
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
index c3975fada63f..b7cf279deeb2 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/scsi/sata_sx4.c
@@ -182,6 +182,7 @@ static struct scsi_host_template pdc_sata_sht = {
182 .name = DRV_NAME, 182 .name = DRV_NAME,
183 .ioctl = ata_scsi_ioctl, 183 .ioctl = ata_scsi_ioctl,
184 .queuecommand = ata_scsi_queuecmd, 184 .queuecommand = ata_scsi_queuecmd,
185 .eh_timed_out = ata_scsi_timed_out,
185 .eh_strategy_handler = ata_scsi_error, 186 .eh_strategy_handler = ata_scsi_error,
186 .can_queue = ATA_DEF_QUEUE, 187 .can_queue = ATA_DEF_QUEUE,
187 .this_id = ATA_SHT_THIS_ID, 188 .this_id = ATA_SHT_THIS_ID,
@@ -866,11 +867,6 @@ static void pdc_eng_timeout(struct ata_port *ap)
866 spin_lock_irqsave(&host_set->lock, flags); 867 spin_lock_irqsave(&host_set->lock, flags);
867 868
868 qc = ata_qc_from_tag(ap, ap->active_tag); 869 qc = ata_qc_from_tag(ap, ap->active_tag);
869 if (!qc) {
870 printk(KERN_ERR "ata%u: BUG: timeout without command\n",
871 ap->id);
872 goto out;
873 }
874 870
875 switch (qc->tf.protocol) { 871 switch (qc->tf.protocol) {
876 case ATA_PROT_DMA: 872 case ATA_PROT_DMA:
@@ -889,10 +885,8 @@ static void pdc_eng_timeout(struct ata_port *ap)
889 break; 885 break;
890 } 886 }
891 887
892out:
893 spin_unlock_irqrestore(&host_set->lock, flags); 888 spin_unlock_irqrestore(&host_set->lock, flags);
894 if (qc) 889 ata_eh_qc_complete(qc);
895 ata_eh_qc_complete(qc);
896 DPRINTK("EXIT\n"); 890 DPRINTK("EXIT\n");
897} 891}
898 892
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
index 9635ca700977..c500f2490902 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/scsi/sata_uli.c
@@ -75,6 +75,7 @@ static struct scsi_host_template uli_sht = {
75 .name = DRV_NAME, 75 .name = DRV_NAME,
76 .ioctl = ata_scsi_ioctl, 76 .ioctl = ata_scsi_ioctl,
77 .queuecommand = ata_scsi_queuecmd, 77 .queuecommand = ata_scsi_queuecmd,
78 .eh_timed_out = ata_scsi_timed_out,
78 .eh_strategy_handler = ata_scsi_error, 79 .eh_strategy_handler = ata_scsi_error,
79 .can_queue = ATA_DEF_QUEUE, 80 .can_queue = ATA_DEF_QUEUE,
80 .this_id = ATA_SHT_THIS_ID, 81 .this_id = ATA_SHT_THIS_ID,
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c
index 6d5b0a794cfd..2e20887dc88f 100644
--- a/drivers/scsi/sata_via.c
+++ b/drivers/scsi/sata_via.c
@@ -94,6 +94,7 @@ static struct scsi_host_template svia_sht = {
94 .name = DRV_NAME, 94 .name = DRV_NAME,
95 .ioctl = ata_scsi_ioctl, 95 .ioctl = ata_scsi_ioctl,
96 .queuecommand = ata_scsi_queuecmd, 96 .queuecommand = ata_scsi_queuecmd,
97 .eh_timed_out = ata_scsi_timed_out,
97 .eh_strategy_handler = ata_scsi_error, 98 .eh_strategy_handler = ata_scsi_error,
98 .can_queue = ATA_DEF_QUEUE, 99 .can_queue = ATA_DEF_QUEUE,
99 .this_id = ATA_SHT_THIS_ID, 100 .this_id = ATA_SHT_THIS_ID,
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index 3e34fedd2104..4cfc03018ca3 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -223,6 +223,7 @@ static struct scsi_host_template vsc_sata_sht = {
223 .name = DRV_NAME, 223 .name = DRV_NAME,
224 .ioctl = ata_scsi_ioctl, 224 .ioctl = ata_scsi_ioctl,
225 .queuecommand = ata_scsi_queuecmd, 225 .queuecommand = ata_scsi_queuecmd,
226 .eh_timed_out = ata_scsi_timed_out,
226 .eh_strategy_handler = ata_scsi_error, 227 .eh_strategy_handler = ata_scsi_error,
227 .can_queue = ATA_DEF_QUEUE, 228 .can_queue = ATA_DEF_QUEUE,
228 .this_id = ATA_SHT_THIS_ID, 229 .this_id = ATA_SHT_THIS_ID,