diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-12-13 01:46:20 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-12-13 01:46:20 -0500 |
commit | 80c7af4074cbb4cb6be5d35c443ea6d5e8838a84 (patch) | |
tree | e900ad4c0beb4f44f0912b847c3319f11ef57d73 /drivers/scsi | |
parent | 451ec6ab310602515b361418debe93d00f67e273 (diff) | |
parent | d00d598ffbba974d9045ba8b95296655fe2162c5 (diff) |
Merge branch 'upstream'
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/ahci.c | 14 | ||||
-rw-r--r-- | drivers/scsi/ata_piix.c | 87 | ||||
-rw-r--r-- | drivers/scsi/libata-core.c | 346 | ||||
-rw-r--r-- | drivers/scsi/libata-scsi.c | 24 | ||||
-rw-r--r-- | drivers/scsi/libata.h | 1 | ||||
-rw-r--r-- | drivers/scsi/pdc_adma.c | 11 | ||||
-rw-r--r-- | drivers/scsi/sata_mv.c | 11 | ||||
-rw-r--r-- | drivers/scsi/sata_promise.c | 20 | ||||
-rw-r--r-- | drivers/scsi/sata_qstor.c | 9 | ||||
-rw-r--r-- | drivers/scsi/sata_sil.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sata_sil24.c | 15 | ||||
-rw-r--r-- | drivers/scsi/sata_sx4.c | 17 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 9 | ||||
-rw-r--r-- | drivers/scsi/scsi_scan.c | 3 |
14 files changed, 354 insertions, 215 deletions
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index 83467a05dc8e..887eaa2a3ebf 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c | |||
@@ -243,7 +243,7 @@ static const struct ata_port_operations ahci_ops = { | |||
243 | .port_stop = ahci_port_stop, | 243 | .port_stop = ahci_port_stop, |
244 | }; | 244 | }; |
245 | 245 | ||
246 | static struct ata_port_info ahci_port_info[] = { | 246 | static const struct ata_port_info ahci_port_info[] = { |
247 | /* board_ahci */ | 247 | /* board_ahci */ |
248 | { | 248 | { |
249 | .sht = &ahci_sht, | 249 | .sht = &ahci_sht, |
@@ -643,7 +643,8 @@ static void ahci_eng_timeout(struct ata_port *ap) | |||
643 | * not being called from the SCSI EH. | 643 | * not being called from the SCSI EH. |
644 | */ | 644 | */ |
645 | qc->scsidone = scsi_finish_command; | 645 | qc->scsidone = scsi_finish_command; |
646 | ata_qc_complete(qc, AC_ERR_OTHER); | 646 | qc->err_mask |= AC_ERR_OTHER; |
647 | ata_qc_complete(qc); | ||
647 | } | 648 | } |
648 | 649 | ||
649 | spin_unlock_irqrestore(&host_set->lock, flags); | 650 | spin_unlock_irqrestore(&host_set->lock, flags); |
@@ -664,7 +665,8 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
664 | ci = readl(port_mmio + PORT_CMD_ISSUE); | 665 | ci = readl(port_mmio + PORT_CMD_ISSUE); |
665 | if (likely((ci & 0x1) == 0)) { | 666 | if (likely((ci & 0x1) == 0)) { |
666 | if (qc) { | 667 | if (qc) { |
667 | ata_qc_complete(qc, 0); | 668 | assert(qc->err_mask == 0); |
669 | ata_qc_complete(qc); | ||
668 | qc = NULL; | 670 | qc = NULL; |
669 | } | 671 | } |
670 | } | 672 | } |
@@ -681,8 +683,10 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) | |||
681 | /* command processing has stopped due to error; restart */ | 683 | /* command processing has stopped due to error; restart */ |
682 | ahci_restart_port(ap, status); | 684 | ahci_restart_port(ap, status); |
683 | 685 | ||
684 | if (qc) | 686 | if (qc) { |
685 | ata_qc_complete(qc, err_mask); | 687 | qc->err_mask |= AC_ERR_OTHER; |
688 | ata_qc_complete(qc); | ||
689 | } | ||
686 | } | 690 | } |
687 | 691 | ||
688 | return 1; | 692 | return 1; |
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index 887b2b9ee4aa..0ea27873b9ff 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c | |||
@@ -37,6 +37,49 @@ | |||
37 | * | 37 | * |
38 | * Hardware documentation available at http://developer.intel.com/ | 38 | * Hardware documentation available at http://developer.intel.com/ |
39 | * | 39 | * |
40 | * Documentation | ||
41 | * Publically available from Intel web site. Errata documentation | ||
42 | * is also publically available. As an aide to anyone hacking on this | ||
43 | * driver the list of errata that are relevant is below.going back to | ||
44 | * PIIX4. Older device documentation is now a bit tricky to find. | ||
45 | * | ||
46 | * The chipsets all follow very much the same design. The orginal Triton | ||
47 | * series chipsets do _not_ support independant device timings, but this | ||
48 | * is fixed in Triton II. With the odd mobile exception the chips then | ||
49 | * change little except in gaining more modes until SATA arrives. This | ||
50 | * driver supports only the chips with independant timing (that is those | ||
51 | * with SITRE and the 0x44 timing register). See pata_oldpiix and pata_mpiix | ||
52 | * for the early chip drivers. | ||
53 | * | ||
54 | * Errata of note: | ||
55 | * | ||
56 | * Unfixable | ||
57 | * PIIX4 errata #9 - Only on ultra obscure hw | ||
58 | * ICH3 errata #13 - Not observed to affect real hw | ||
59 | * by Intel | ||
60 | * | ||
61 | * Things we must deal with | ||
62 | * PIIX4 errata #10 - BM IDE hang with non UDMA | ||
63 | * (must stop/start dma to recover) | ||
64 | * 440MX errata #15 - As PIIX4 errata #10 | ||
65 | * PIIX4 errata #15 - Must not read control registers | ||
66 | * during a PIO transfer | ||
67 | * 440MX errata #13 - As PIIX4 errata #15 | ||
68 | * ICH2 errata #21 - DMA mode 0 doesn't work right | ||
69 | * ICH0/1 errata #55 - As ICH2 errata #21 | ||
70 | * ICH2 spec c #9 - Extra operations needed to handle | ||
71 | * drive hotswap [NOT YET SUPPORTED] | ||
72 | * ICH2 spec c #20 - IDE PRD must not cross a 64K boundary | ||
73 | * and must be dword aligned | ||
74 | * ICH2 spec c #24 - UDMA mode 4,5 t85/86 should be 6ns not 3.3 | ||
75 | * | ||
76 | * Should have been BIOS fixed: | ||
77 | * 450NX: errata #19 - DMA hangs on old 450NX | ||
78 | * 450NX: errata #20 - DMA hangs on old 450NX | ||
79 | * 450NX: errata #25 - Corruption with DMA on old 450NX | ||
80 | * ICH3 errata #15 - IDE deadlock under high load | ||
81 | * (BIOS must set dev 31 fn 0 bit 23) | ||
82 | * ICH3 errata #18 - Don't use native mode | ||
40 | */ | 83 | */ |
41 | 84 | ||
42 | #include <linux/kernel.h> | 85 | #include <linux/kernel.h> |
@@ -577,6 +620,40 @@ static int piix_disable_ahci(struct pci_dev *pdev) | |||
577 | } | 620 | } |
578 | 621 | ||
579 | /** | 622 | /** |
623 | * piix_check_450nx_errata - Check for problem 450NX setup | ||
624 | * | ||
625 | * Check for the present of 450NX errata #19 and errata #25. If | ||
626 | * they are found return an error code so we can turn off DMA | ||
627 | */ | ||
628 | |||
629 | static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev) | ||
630 | { | ||
631 | struct pci_dev *pdev = NULL; | ||
632 | u16 cfg; | ||
633 | u8 rev; | ||
634 | int no_piix_dma = 0; | ||
635 | |||
636 | while((pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev)) != NULL) | ||
637 | { | ||
638 | /* Look for 450NX PXB. Check for problem configurations | ||
639 | A PCI quirk checks bit 6 already */ | ||
640 | pci_read_config_byte(pdev, PCI_REVISION_ID, &rev); | ||
641 | pci_read_config_word(pdev, 0x41, &cfg); | ||
642 | /* Only on the original revision: IDE DMA can hang */ | ||
643 | if(rev == 0x00) | ||
644 | no_piix_dma = 1; | ||
645 | /* On all revisions below 5 PXB bus lock must be disabled for IDE */ | ||
646 | else if(cfg & (1<<14) && rev < 5) | ||
647 | no_piix_dma = 2; | ||
648 | } | ||
649 | if(no_piix_dma) | ||
650 | dev_printk(KERN_WARNING, &ata_dev->dev, "450NX errata present, disabling IDE DMA.\n"); | ||
651 | if(no_piix_dma == 2) | ||
652 | dev_printk(KERN_WARNING, &ata_dev->dev, "A BIOS update may resolve this.\n"); | ||
653 | return no_piix_dma; | ||
654 | } | ||
655 | |||
656 | /** | ||
580 | * piix_init_one - Register PIIX ATA PCI device with kernel services | 657 | * piix_init_one - Register PIIX ATA PCI device with kernel services |
581 | * @pdev: PCI device to register | 658 | * @pdev: PCI device to register |
582 | * @ent: Entry in piix_pci_tbl matching with @pdev | 659 | * @ent: Entry in piix_pci_tbl matching with @pdev |
@@ -650,7 +727,15 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
650 | "combined mode detected (p=%u, s=%u)\n", | 727 | "combined mode detected (p=%u, s=%u)\n", |
651 | pata_chan, sata_chan); | 728 | pata_chan, sata_chan); |
652 | } | 729 | } |
653 | 730 | if (piix_check_450nx_errata(pdev)) { | |
731 | /* This writes into the master table but it does not | ||
732 | really matter for this errata as we will apply it to | ||
733 | all the PIIX devices on the board */ | ||
734 | port_info[0]->mwdma_mask = 0; | ||
735 | port_info[0]->udma_mask = 0; | ||
736 | port_info[1]->mwdma_mask = 0; | ||
737 | port_info[1]->udma_mask = 0; | ||
738 | } | ||
654 | return ata_pci_init_one(pdev, port_info, 2); | 739 | return ata_pci_init_one(pdev, port_info, 2); |
655 | } | 740 | } |
656 | 741 | ||
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 9f27e8d0e774..9ea102587914 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -605,7 +605,7 @@ void ata_rwcmd_protocol(struct ata_queued_cmd *qc) | |||
605 | tf->command = ata_rw_cmds[index + lba48 + write]; | 605 | tf->command = ata_rw_cmds[index + lba48 + write]; |
606 | } | 606 | } |
607 | 607 | ||
608 | static const char * xfer_mode_str[] = { | 608 | static const char * const xfer_mode_str[] = { |
609 | "UDMA/16", | 609 | "UDMA/16", |
610 | "UDMA/25", | 610 | "UDMA/25", |
611 | "UDMA/33", | 611 | "UDMA/33", |
@@ -1046,28 +1046,103 @@ static unsigned int ata_pio_modes(const struct ata_device *adev) | |||
1046 | return modes; | 1046 | return modes; |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | static int ata_qc_wait_err(struct ata_queued_cmd *qc, | 1049 | struct ata_exec_internal_arg { |
1050 | struct completion *wait) | 1050 | unsigned int err_mask; |
1051 | struct ata_taskfile *tf; | ||
1052 | struct completion *waiting; | ||
1053 | }; | ||
1054 | |||
1055 | int ata_qc_complete_internal(struct ata_queued_cmd *qc) | ||
1051 | { | 1056 | { |
1052 | int rc = 0; | 1057 | struct ata_exec_internal_arg *arg = qc->private_data; |
1058 | struct completion *waiting = arg->waiting; | ||
1053 | 1059 | ||
1054 | if (wait_for_completion_timeout(wait, 30 * HZ) < 1) { | 1060 | if (!(qc->err_mask & ~AC_ERR_DEV)) |
1055 | /* timeout handling */ | 1061 | qc->ap->ops->tf_read(qc->ap, arg->tf); |
1056 | unsigned int err_mask = ac_err_mask(ata_chk_status(qc->ap)); | 1062 | arg->err_mask = qc->err_mask; |
1063 | arg->waiting = NULL; | ||
1064 | complete(waiting); | ||
1057 | 1065 | ||
1058 | if (!err_mask) { | 1066 | return 0; |
1059 | printk(KERN_WARNING "ata%u: slow completion (cmd %x)\n", | 1067 | } |
1060 | qc->ap->id, qc->tf.command); | 1068 | |
1061 | } else { | 1069 | /** |
1062 | printk(KERN_WARNING "ata%u: qc timeout (cmd %x)\n", | 1070 | * ata_exec_internal - execute libata internal command |
1063 | qc->ap->id, qc->tf.command); | 1071 | * @ap: Port to which the command is sent |
1064 | rc = -EIO; | 1072 | * @dev: Device to which the command is sent |
1073 | * @tf: Taskfile registers for the command and the result | ||
1074 | * @dma_dir: Data tranfer direction of the command | ||
1075 | * @buf: Data buffer of the command | ||
1076 | * @buflen: Length of data buffer | ||
1077 | * | ||
1078 | * Executes libata internal command with timeout. @tf contains | ||
1079 | * command on entry and result on return. Timeout and error | ||
1080 | * conditions are reported via return value. No recovery action | ||
1081 | * is taken after a command times out. It's caller's duty to | ||
1082 | * clean up after timeout. | ||
1083 | * | ||
1084 | * LOCKING: | ||
1085 | * None. Should be called with kernel context, might sleep. | ||
1086 | */ | ||
1087 | |||
1088 | static unsigned | ||
1089 | ata_exec_internal(struct ata_port *ap, struct ata_device *dev, | ||
1090 | struct ata_taskfile *tf, | ||
1091 | int dma_dir, void *buf, unsigned int buflen) | ||
1092 | { | ||
1093 | u8 command = tf->command; | ||
1094 | struct ata_queued_cmd *qc; | ||
1095 | DECLARE_COMPLETION(wait); | ||
1096 | unsigned long flags; | ||
1097 | struct ata_exec_internal_arg arg; | ||
1098 | |||
1099 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
1100 | |||
1101 | qc = ata_qc_new_init(ap, dev); | ||
1102 | BUG_ON(qc == NULL); | ||
1103 | |||
1104 | qc->tf = *tf; | ||
1105 | qc->dma_dir = dma_dir; | ||
1106 | if (dma_dir != DMA_NONE) { | ||
1107 | ata_sg_init_one(qc, buf, buflen); | ||
1108 | qc->nsect = buflen / ATA_SECT_SIZE; | ||
1109 | } | ||
1110 | |||
1111 | arg.waiting = &wait; | ||
1112 | arg.tf = tf; | ||
1113 | qc->private_data = &arg; | ||
1114 | qc->complete_fn = ata_qc_complete_internal; | ||
1115 | |||
1116 | if (ata_qc_issue(qc)) | ||
1117 | goto issue_fail; | ||
1118 | |||
1119 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
1120 | |||
1121 | if (!wait_for_completion_timeout(&wait, ATA_TMOUT_INTERNAL)) { | ||
1122 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
1123 | |||
1124 | /* We're racing with irq here. If we lose, the | ||
1125 | * following test prevents us from completing the qc | ||
1126 | * again. If completion irq occurs after here but | ||
1127 | * before the caller cleans up, it will result in a | ||
1128 | * spurious interrupt. We can live with that. | ||
1129 | */ | ||
1130 | if (arg.waiting) { | ||
1131 | qc->err_mask = AC_ERR_OTHER; | ||
1132 | ata_qc_complete(qc); | ||
1133 | printk(KERN_WARNING "ata%u: qc timeout (cmd 0x%x)\n", | ||
1134 | ap->id, command); | ||
1065 | } | 1135 | } |
1066 | 1136 | ||
1067 | ata_qc_complete(qc, err_mask); | 1137 | spin_unlock_irqrestore(&ap->host_set->lock, flags); |
1068 | } | 1138 | } |
1069 | 1139 | ||
1070 | return rc; | 1140 | return arg.err_mask; |
1141 | |||
1142 | issue_fail: | ||
1143 | ata_qc_free(qc); | ||
1144 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
1145 | return AC_ERR_OTHER; | ||
1071 | } | 1146 | } |
1072 | 1147 | ||
1073 | /** | 1148 | /** |
@@ -1099,9 +1174,8 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) | |||
1099 | u16 tmp; | 1174 | u16 tmp; |
1100 | unsigned long xfer_modes; | 1175 | unsigned long xfer_modes; |
1101 | unsigned int using_edd; | 1176 | unsigned int using_edd; |
1102 | DECLARE_COMPLETION(wait); | 1177 | struct ata_taskfile tf; |
1103 | struct ata_queued_cmd *qc; | 1178 | unsigned int err_mask; |
1104 | unsigned long flags; | ||
1105 | int rc; | 1179 | int rc; |
1106 | 1180 | ||
1107 | if (!ata_dev_present(dev)) { | 1181 | if (!ata_dev_present(dev)) { |
@@ -1122,40 +1196,26 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) | |||
1122 | 1196 | ||
1123 | ata_dev_select(ap, device, 1, 1); /* select device 0/1 */ | 1197 | ata_dev_select(ap, device, 1, 1); /* select device 0/1 */ |
1124 | 1198 | ||
1125 | qc = ata_qc_new_init(ap, dev); | ||
1126 | BUG_ON(qc == NULL); | ||
1127 | |||
1128 | ata_sg_init_one(qc, dev->id, sizeof(dev->id)); | ||
1129 | qc->dma_dir = DMA_FROM_DEVICE; | ||
1130 | qc->tf.protocol = ATA_PROT_PIO; | ||
1131 | qc->nsect = 1; | ||
1132 | |||
1133 | retry: | 1199 | retry: |
1200 | ata_tf_init(ap, &tf, device); | ||
1201 | |||
1134 | if (dev->class == ATA_DEV_ATA) { | 1202 | if (dev->class == ATA_DEV_ATA) { |
1135 | qc->tf.command = ATA_CMD_ID_ATA; | 1203 | tf.command = ATA_CMD_ID_ATA; |
1136 | DPRINTK("do ATA identify\n"); | 1204 | DPRINTK("do ATA identify\n"); |
1137 | } else { | 1205 | } else { |
1138 | qc->tf.command = ATA_CMD_ID_ATAPI; | 1206 | tf.command = ATA_CMD_ID_ATAPI; |
1139 | DPRINTK("do ATAPI identify\n"); | 1207 | DPRINTK("do ATAPI identify\n"); |
1140 | } | 1208 | } |
1141 | 1209 | ||
1142 | qc->waiting = &wait; | 1210 | tf.protocol = ATA_PROT_PIO; |
1143 | qc->complete_fn = ata_qc_complete_noop; | ||
1144 | |||
1145 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
1146 | rc = ata_qc_issue(qc); | ||
1147 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
1148 | 1211 | ||
1149 | if (rc) | 1212 | err_mask = ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE, |
1150 | goto err_out; | 1213 | dev->id, sizeof(dev->id)); |
1151 | else | ||
1152 | ata_qc_wait_err(qc, &wait); | ||
1153 | 1214 | ||
1154 | spin_lock_irqsave(&ap->host_set->lock, flags); | 1215 | if (err_mask) { |
1155 | ap->ops->tf_read(ap, &qc->tf); | 1216 | if (err_mask & ~AC_ERR_DEV) |
1156 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | 1217 | goto err_out; |
1157 | 1218 | ||
1158 | if (qc->tf.command & ATA_ERR) { | ||
1159 | /* | 1219 | /* |
1160 | * arg! EDD works for all test cases, but seems to return | 1220 | * arg! EDD works for all test cases, but seems to return |
1161 | * the ATA signature for some ATAPI devices. Until the | 1221 | * the ATA signature for some ATAPI devices. Until the |
@@ -1168,13 +1228,9 @@ retry: | |||
1168 | * to have this problem. | 1228 | * to have this problem. |
1169 | */ | 1229 | */ |
1170 | if ((using_edd) && (dev->class == ATA_DEV_ATA)) { | 1230 | if ((using_edd) && (dev->class == ATA_DEV_ATA)) { |
1171 | u8 err = qc->tf.feature; | 1231 | u8 err = tf.feature; |
1172 | if (err & ATA_ABORTED) { | 1232 | if (err & ATA_ABORTED) { |
1173 | dev->class = ATA_DEV_ATAPI; | 1233 | dev->class = ATA_DEV_ATAPI; |
1174 | qc->cursg = 0; | ||
1175 | qc->cursg_ofs = 0; | ||
1176 | qc->cursect = 0; | ||
1177 | qc->nsect = 1; | ||
1178 | goto retry; | 1234 | goto retry; |
1179 | } | 1235 | } |
1180 | } | 1236 | } |
@@ -2083,7 +2139,7 @@ static void ata_pr_blacklisted(const struct ata_port *ap, | |||
2083 | ap->id, dev->devno); | 2139 | ap->id, dev->devno); |
2084 | } | 2140 | } |
2085 | 2141 | ||
2086 | static const char * ata_dma_blacklist [] = { | 2142 | static const char * const ata_dma_blacklist [] = { |
2087 | "WDC AC11000H", | 2143 | "WDC AC11000H", |
2088 | "WDC AC22100H", | 2144 | "WDC AC22100H", |
2089 | "WDC AC32500H", | 2145 | "WDC AC32500H", |
@@ -2278,34 +2334,23 @@ static int ata_choose_xfer_mode(const struct ata_port *ap, | |||
2278 | 2334 | ||
2279 | static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) | 2335 | static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) |
2280 | { | 2336 | { |
2281 | DECLARE_COMPLETION(wait); | 2337 | struct ata_taskfile tf; |
2282 | struct ata_queued_cmd *qc; | ||
2283 | int rc; | ||
2284 | unsigned long flags; | ||
2285 | 2338 | ||
2286 | /* set up set-features taskfile */ | 2339 | /* set up set-features taskfile */ |
2287 | DPRINTK("set features - xfer mode\n"); | 2340 | DPRINTK("set features - xfer mode\n"); |
2288 | 2341 | ||
2289 | qc = ata_qc_new_init(ap, dev); | 2342 | ata_tf_init(ap, &tf, dev->devno); |
2290 | BUG_ON(qc == NULL); | 2343 | tf.command = ATA_CMD_SET_FEATURES; |
2291 | 2344 | tf.feature = SETFEATURES_XFER; | |
2292 | qc->tf.command = ATA_CMD_SET_FEATURES; | 2345 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; |
2293 | qc->tf.feature = SETFEATURES_XFER; | 2346 | tf.protocol = ATA_PROT_NODATA; |
2294 | qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 2347 | tf.nsect = dev->xfer_mode; |
2295 | qc->tf.protocol = ATA_PROT_NODATA; | ||
2296 | qc->tf.nsect = dev->xfer_mode; | ||
2297 | |||
2298 | qc->waiting = &wait; | ||
2299 | qc->complete_fn = ata_qc_complete_noop; | ||
2300 | |||
2301 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
2302 | rc = ata_qc_issue(qc); | ||
2303 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
2304 | 2348 | ||
2305 | if (rc) | 2349 | if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) { |
2350 | printk(KERN_ERR "ata%u: failed to set xfermode, disabled\n", | ||
2351 | ap->id); | ||
2306 | ata_port_disable(ap); | 2352 | ata_port_disable(ap); |
2307 | else | 2353 | } |
2308 | ata_qc_wait_err(qc, &wait); | ||
2309 | 2354 | ||
2310 | DPRINTK("EXIT\n"); | 2355 | DPRINTK("EXIT\n"); |
2311 | } | 2356 | } |
@@ -2320,41 +2365,25 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) | |||
2320 | 2365 | ||
2321 | static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev) | 2366 | static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev) |
2322 | { | 2367 | { |
2323 | DECLARE_COMPLETION(wait); | 2368 | struct ata_taskfile tf; |
2324 | struct ata_queued_cmd *qc; | ||
2325 | unsigned long flags; | ||
2326 | int rc; | ||
2327 | |||
2328 | qc = ata_qc_new_init(ap, dev); | ||
2329 | BUG_ON(qc == NULL); | ||
2330 | 2369 | ||
2331 | ata_sg_init_one(qc, dev->id, sizeof(dev->id)); | 2370 | ata_tf_init(ap, &tf, dev->devno); |
2332 | qc->dma_dir = DMA_FROM_DEVICE; | ||
2333 | 2371 | ||
2334 | if (dev->class == ATA_DEV_ATA) { | 2372 | if (dev->class == ATA_DEV_ATA) { |
2335 | qc->tf.command = ATA_CMD_ID_ATA; | 2373 | tf.command = ATA_CMD_ID_ATA; |
2336 | DPRINTK("do ATA identify\n"); | 2374 | DPRINTK("do ATA identify\n"); |
2337 | } else { | 2375 | } else { |
2338 | qc->tf.command = ATA_CMD_ID_ATAPI; | 2376 | tf.command = ATA_CMD_ID_ATAPI; |
2339 | DPRINTK("do ATAPI identify\n"); | 2377 | DPRINTK("do ATAPI identify\n"); |
2340 | } | 2378 | } |
2341 | 2379 | ||
2342 | qc->tf.flags |= ATA_TFLAG_DEVICE; | 2380 | tf.flags |= ATA_TFLAG_DEVICE; |
2343 | qc->tf.protocol = ATA_PROT_PIO; | 2381 | tf.protocol = ATA_PROT_PIO; |
2344 | qc->nsect = 1; | ||
2345 | |||
2346 | qc->waiting = &wait; | ||
2347 | qc->complete_fn = ata_qc_complete_noop; | ||
2348 | |||
2349 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
2350 | rc = ata_qc_issue(qc); | ||
2351 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
2352 | 2382 | ||
2353 | if (rc) | 2383 | if (ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE, |
2384 | dev->id, sizeof(dev->id))) | ||
2354 | goto err_out; | 2385 | goto err_out; |
2355 | 2386 | ||
2356 | ata_qc_wait_err(qc, &wait); | ||
2357 | |||
2358 | swap_buf_le16(dev->id, ATA_ID_WORDS); | 2387 | swap_buf_le16(dev->id, ATA_ID_WORDS); |
2359 | 2388 | ||
2360 | ata_dump_id(dev); | 2389 | ata_dump_id(dev); |
@@ -2363,6 +2392,7 @@ static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev) | |||
2363 | 2392 | ||
2364 | return; | 2393 | return; |
2365 | err_out: | 2394 | err_out: |
2395 | printk(KERN_ERR "ata%u: failed to reread ID, disabled\n", ap->id); | ||
2366 | ata_port_disable(ap); | 2396 | ata_port_disable(ap); |
2367 | } | 2397 | } |
2368 | 2398 | ||
@@ -2376,10 +2406,7 @@ err_out: | |||
2376 | 2406 | ||
2377 | static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev) | 2407 | static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev) |
2378 | { | 2408 | { |
2379 | DECLARE_COMPLETION(wait); | 2409 | struct ata_taskfile tf; |
2380 | struct ata_queued_cmd *qc; | ||
2381 | int rc; | ||
2382 | unsigned long flags; | ||
2383 | u16 sectors = dev->id[6]; | 2410 | u16 sectors = dev->id[6]; |
2384 | u16 heads = dev->id[3]; | 2411 | u16 heads = dev->id[3]; |
2385 | 2412 | ||
@@ -2390,26 +2417,18 @@ static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev) | |||
2390 | /* set up init dev params taskfile */ | 2417 | /* set up init dev params taskfile */ |
2391 | DPRINTK("init dev params \n"); | 2418 | DPRINTK("init dev params \n"); |
2392 | 2419 | ||
2393 | qc = ata_qc_new_init(ap, dev); | 2420 | ata_tf_init(ap, &tf, dev->devno); |
2394 | BUG_ON(qc == NULL); | 2421 | tf.command = ATA_CMD_INIT_DEV_PARAMS; |
2395 | 2422 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | |
2396 | qc->tf.command = ATA_CMD_INIT_DEV_PARAMS; | 2423 | tf.protocol = ATA_PROT_NODATA; |
2397 | qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 2424 | tf.nsect = sectors; |
2398 | qc->tf.protocol = ATA_PROT_NODATA; | 2425 | tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ |
2399 | qc->tf.nsect = sectors; | ||
2400 | qc->tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ | ||
2401 | |||
2402 | qc->waiting = &wait; | ||
2403 | qc->complete_fn = ata_qc_complete_noop; | ||
2404 | |||
2405 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
2406 | rc = ata_qc_issue(qc); | ||
2407 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
2408 | 2426 | ||
2409 | if (rc) | 2427 | if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) { |
2428 | printk(KERN_ERR "ata%u: failed to init parameters, disabled\n", | ||
2429 | ap->id); | ||
2410 | ata_port_disable(ap); | 2430 | ata_port_disable(ap); |
2411 | else | 2431 | } |
2412 | ata_qc_wait_err(qc, &wait); | ||
2413 | 2432 | ||
2414 | DPRINTK("EXIT\n"); | 2433 | DPRINTK("EXIT\n"); |
2415 | } | 2434 | } |
@@ -2455,7 +2474,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc) | |||
2455 | struct scatterlist *psg = &qc->pad_sgent; | 2474 | struct scatterlist *psg = &qc->pad_sgent; |
2456 | void *addr = kmap_atomic(psg->page, KM_IRQ0); | 2475 | void *addr = kmap_atomic(psg->page, KM_IRQ0); |
2457 | memcpy(addr + psg->offset, pad_buf, qc->pad_len); | 2476 | memcpy(addr + psg->offset, pad_buf, qc->pad_len); |
2458 | kunmap_atomic(psg->page, KM_IRQ0); | 2477 | kunmap_atomic(addr, KM_IRQ0); |
2459 | } | 2478 | } |
2460 | } else { | 2479 | } else { |
2461 | if (sg_dma_len(&sg[0]) > 0) | 2480 | if (sg_dma_len(&sg[0]) > 0) |
@@ -2729,7 +2748,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
2729 | if (qc->tf.flags & ATA_TFLAG_WRITE) { | 2748 | if (qc->tf.flags & ATA_TFLAG_WRITE) { |
2730 | void *addr = kmap_atomic(psg->page, KM_IRQ0); | 2749 | void *addr = kmap_atomic(psg->page, KM_IRQ0); |
2731 | memcpy(pad_buf, addr + psg->offset, qc->pad_len); | 2750 | memcpy(pad_buf, addr + psg->offset, qc->pad_len); |
2732 | kunmap_atomic(psg->page, KM_IRQ0); | 2751 | kunmap_atomic(addr, KM_IRQ0); |
2733 | } | 2752 | } |
2734 | 2753 | ||
2735 | sg_dma_address(psg) = ap->pad_dma + (qc->tag * ATA_DMA_PAD_SZ); | 2754 | sg_dma_address(psg) = ap->pad_dma + (qc->tag * ATA_DMA_PAD_SZ); |
@@ -2777,7 +2796,7 @@ skip_map: | |||
2777 | * None. (grabs host lock) | 2796 | * None. (grabs host lock) |
2778 | */ | 2797 | */ |
2779 | 2798 | ||
2780 | void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) | 2799 | void ata_poll_qc_complete(struct ata_queued_cmd *qc) |
2781 | { | 2800 | { |
2782 | struct ata_port *ap = qc->ap; | 2801 | struct ata_port *ap = qc->ap; |
2783 | unsigned long flags; | 2802 | unsigned long flags; |
@@ -2785,7 +2804,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) | |||
2785 | spin_lock_irqsave(&ap->host_set->lock, flags); | 2804 | spin_lock_irqsave(&ap->host_set->lock, flags); |
2786 | ap->flags &= ~ATA_FLAG_NOINTR; | 2805 | ap->flags &= ~ATA_FLAG_NOINTR; |
2787 | ata_irq_on(ap); | 2806 | ata_irq_on(ap); |
2788 | ata_qc_complete(qc, err_mask); | 2807 | ata_qc_complete(qc); |
2789 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | 2808 | spin_unlock_irqrestore(&ap->host_set->lock, flags); |
2790 | } | 2809 | } |
2791 | 2810 | ||
@@ -2802,10 +2821,14 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) | |||
2802 | 2821 | ||
2803 | static unsigned long ata_pio_poll(struct ata_port *ap) | 2822 | static unsigned long ata_pio_poll(struct ata_port *ap) |
2804 | { | 2823 | { |
2824 | struct ata_queued_cmd *qc; | ||
2805 | u8 status; | 2825 | u8 status; |
2806 | unsigned int poll_state = HSM_ST_UNKNOWN; | 2826 | unsigned int poll_state = HSM_ST_UNKNOWN; |
2807 | unsigned int reg_state = HSM_ST_UNKNOWN; | 2827 | unsigned int reg_state = HSM_ST_UNKNOWN; |
2808 | 2828 | ||
2829 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
2830 | assert(qc != NULL); | ||
2831 | |||
2809 | switch (ap->hsm_task_state) { | 2832 | switch (ap->hsm_task_state) { |
2810 | case HSM_ST: | 2833 | case HSM_ST: |
2811 | case HSM_ST_POLL: | 2834 | case HSM_ST_POLL: |
@@ -2825,6 +2848,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap) | |||
2825 | status = ata_chk_status(ap); | 2848 | status = ata_chk_status(ap); |
2826 | if (status & ATA_BUSY) { | 2849 | if (status & ATA_BUSY) { |
2827 | if (time_after(jiffies, ap->pio_task_timeout)) { | 2850 | if (time_after(jiffies, ap->pio_task_timeout)) { |
2851 | qc->err_mask |= AC_ERR_ATA_BUS; | ||
2828 | ap->hsm_task_state = HSM_ST_TMOUT; | 2852 | ap->hsm_task_state = HSM_ST_TMOUT; |
2829 | return 0; | 2853 | return 0; |
2830 | } | 2854 | } |
@@ -2859,29 +2883,31 @@ static int ata_pio_complete (struct ata_port *ap) | |||
2859 | * msecs, then chk-status again. If still busy, fall back to | 2883 | * msecs, then chk-status again. If still busy, fall back to |
2860 | * HSM_ST_POLL state. | 2884 | * HSM_ST_POLL state. |
2861 | */ | 2885 | */ |
2862 | drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10); | 2886 | drv_stat = ata_busy_wait(ap, ATA_BUSY, 10); |
2863 | if (drv_stat & (ATA_BUSY | ATA_DRQ)) { | 2887 | if (drv_stat & ATA_BUSY) { |
2864 | msleep(2); | 2888 | msleep(2); |
2865 | drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10); | 2889 | drv_stat = ata_busy_wait(ap, ATA_BUSY, 10); |
2866 | if (drv_stat & (ATA_BUSY | ATA_DRQ)) { | 2890 | if (drv_stat & ATA_BUSY) { |
2867 | ap->hsm_task_state = HSM_ST_LAST_POLL; | 2891 | ap->hsm_task_state = HSM_ST_LAST_POLL; |
2868 | ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO; | 2892 | ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO; |
2869 | return 0; | 2893 | return 0; |
2870 | } | 2894 | } |
2871 | } | 2895 | } |
2872 | 2896 | ||
2897 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
2898 | assert(qc != NULL); | ||
2899 | |||
2873 | drv_stat = ata_wait_idle(ap); | 2900 | drv_stat = ata_wait_idle(ap); |
2874 | if (!ata_ok(drv_stat)) { | 2901 | if (!ata_ok(drv_stat)) { |
2902 | qc->err_mask |= __ac_err_mask(drv_stat); | ||
2875 | ap->hsm_task_state = HSM_ST_ERR; | 2903 | ap->hsm_task_state = HSM_ST_ERR; |
2876 | return 0; | 2904 | return 0; |
2877 | } | 2905 | } |
2878 | 2906 | ||
2879 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
2880 | assert(qc != NULL); | ||
2881 | |||
2882 | ap->hsm_task_state = HSM_ST_IDLE; | 2907 | ap->hsm_task_state = HSM_ST_IDLE; |
2883 | 2908 | ||
2884 | ata_poll_qc_complete(qc, 0); | 2909 | assert(qc->err_mask == 0); |
2910 | ata_poll_qc_complete(qc); | ||
2885 | 2911 | ||
2886 | /* another command may start at this point */ | 2912 | /* another command may start at this point */ |
2887 | 2913 | ||
@@ -3189,6 +3215,7 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc) | |||
3189 | err_out: | 3215 | err_out: |
3190 | printk(KERN_INFO "ata%u: dev %u: ATAPI check failed\n", | 3216 | printk(KERN_INFO "ata%u: dev %u: ATAPI check failed\n", |
3191 | ap->id, dev->devno); | 3217 | ap->id, dev->devno); |
3218 | qc->err_mask |= AC_ERR_ATA_BUS; | ||
3192 | ap->hsm_task_state = HSM_ST_ERR; | 3219 | ap->hsm_task_state = HSM_ST_ERR; |
3193 | } | 3220 | } |
3194 | 3221 | ||
@@ -3227,8 +3254,16 @@ static void ata_pio_block(struct ata_port *ap) | |||
3227 | qc = ata_qc_from_tag(ap, ap->active_tag); | 3254 | qc = ata_qc_from_tag(ap, ap->active_tag); |
3228 | assert(qc != NULL); | 3255 | assert(qc != NULL); |
3229 | 3256 | ||
3257 | /* check error */ | ||
3258 | if (status & (ATA_ERR | ATA_DF)) { | ||
3259 | qc->err_mask |= AC_ERR_DEV; | ||
3260 | ap->hsm_task_state = HSM_ST_ERR; | ||
3261 | return; | ||
3262 | } | ||
3263 | |||
3264 | /* transfer data if any */ | ||
3230 | if (is_atapi_taskfile(&qc->tf)) { | 3265 | if (is_atapi_taskfile(&qc->tf)) { |
3231 | /* no more data to transfer or unsupported ATAPI command */ | 3266 | /* DRQ=0 means no more data to transfer */ |
3232 | if ((status & ATA_DRQ) == 0) { | 3267 | if ((status & ATA_DRQ) == 0) { |
3233 | ap->hsm_task_state = HSM_ST_LAST; | 3268 | ap->hsm_task_state = HSM_ST_LAST; |
3234 | return; | 3269 | return; |
@@ -3238,6 +3273,7 @@ static void ata_pio_block(struct ata_port *ap) | |||
3238 | } else { | 3273 | } else { |
3239 | /* handle BSY=0, DRQ=0 as error */ | 3274 | /* handle BSY=0, DRQ=0 as error */ |
3240 | if ((status & ATA_DRQ) == 0) { | 3275 | if ((status & ATA_DRQ) == 0) { |
3276 | qc->err_mask |= AC_ERR_ATA_BUS; | ||
3241 | ap->hsm_task_state = HSM_ST_ERR; | 3277 | ap->hsm_task_state = HSM_ST_ERR; |
3242 | return; | 3278 | return; |
3243 | } | 3279 | } |
@@ -3255,9 +3291,14 @@ static void ata_pio_error(struct ata_port *ap) | |||
3255 | qc = ata_qc_from_tag(ap, ap->active_tag); | 3291 | qc = ata_qc_from_tag(ap, ap->active_tag); |
3256 | assert(qc != NULL); | 3292 | assert(qc != NULL); |
3257 | 3293 | ||
3294 | /* make sure qc->err_mask is available to | ||
3295 | * know what's wrong and recover | ||
3296 | */ | ||
3297 | assert(qc->err_mask); | ||
3298 | |||
3258 | ap->hsm_task_state = HSM_ST_IDLE; | 3299 | ap->hsm_task_state = HSM_ST_IDLE; |
3259 | 3300 | ||
3260 | ata_poll_qc_complete(qc, AC_ERR_ATA_BUS); | 3301 | ata_poll_qc_complete(qc); |
3261 | } | 3302 | } |
3262 | 3303 | ||
3263 | static void ata_pio_task(void *_data) | 3304 | static void ata_pio_task(void *_data) |
@@ -3359,7 +3400,8 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc) | |||
3359 | ap->id, qc->tf.command, drv_stat, host_stat); | 3400 | ap->id, qc->tf.command, drv_stat, host_stat); |
3360 | 3401 | ||
3361 | /* complete taskfile transaction */ | 3402 | /* complete taskfile transaction */ |
3362 | ata_qc_complete(qc, ac_err_mask(drv_stat)); | 3403 | qc->err_mask |= ac_err_mask(drv_stat); |
3404 | ata_qc_complete(qc); | ||
3363 | break; | 3405 | break; |
3364 | } | 3406 | } |
3365 | 3407 | ||
@@ -3458,15 +3500,10 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, | |||
3458 | return qc; | 3500 | return qc; |
3459 | } | 3501 | } |
3460 | 3502 | ||
3461 | int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask) | ||
3462 | { | ||
3463 | return 0; | ||
3464 | } | ||
3465 | |||
3466 | static void __ata_qc_complete(struct ata_queued_cmd *qc) | 3503 | static void __ata_qc_complete(struct ata_queued_cmd *qc) |
3467 | { | 3504 | { |
3468 | struct ata_port *ap = qc->ap; | 3505 | struct ata_port *ap = qc->ap; |
3469 | unsigned int tag, do_clear = 0; | 3506 | unsigned int tag; |
3470 | 3507 | ||
3471 | qc->flags = 0; | 3508 | qc->flags = 0; |
3472 | tag = qc->tag; | 3509 | tag = qc->tag; |
@@ -3474,17 +3511,8 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc) | |||
3474 | if (tag == ap->active_tag) | 3511 | if (tag == ap->active_tag) |
3475 | ap->active_tag = ATA_TAG_POISON; | 3512 | ap->active_tag = ATA_TAG_POISON; |
3476 | qc->tag = ATA_TAG_POISON; | 3513 | qc->tag = ATA_TAG_POISON; |
3477 | do_clear = 1; | ||
3478 | } | ||
3479 | |||
3480 | if (qc->waiting) { | ||
3481 | struct completion *waiting = qc->waiting; | ||
3482 | qc->waiting = NULL; | ||
3483 | complete(waiting); | ||
3484 | } | ||
3485 | |||
3486 | if (likely(do_clear)) | ||
3487 | clear_bit(tag, &ap->qactive); | 3514 | clear_bit(tag, &ap->qactive); |
3515 | } | ||
3488 | } | 3516 | } |
3489 | 3517 | ||
3490 | /** | 3518 | /** |
@@ -3500,7 +3528,6 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc) | |||
3500 | void ata_qc_free(struct ata_queued_cmd *qc) | 3528 | void ata_qc_free(struct ata_queued_cmd *qc) |
3501 | { | 3529 | { |
3502 | assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ | 3530 | assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ |
3503 | assert(qc->waiting == NULL); /* nothing should be waiting */ | ||
3504 | 3531 | ||
3505 | __ata_qc_complete(qc); | 3532 | __ata_qc_complete(qc); |
3506 | } | 3533 | } |
@@ -3517,7 +3544,7 @@ void ata_qc_free(struct ata_queued_cmd *qc) | |||
3517 | * spin_lock_irqsave(host_set lock) | 3544 | * spin_lock_irqsave(host_set lock) |
3518 | */ | 3545 | */ |
3519 | 3546 | ||
3520 | void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) | 3547 | void ata_qc_complete(struct ata_queued_cmd *qc) |
3521 | { | 3548 | { |
3522 | int rc; | 3549 | int rc; |
3523 | 3550 | ||
@@ -3534,7 +3561,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) | |||
3534 | qc->flags &= ~ATA_QCFLAG_ACTIVE; | 3561 | qc->flags &= ~ATA_QCFLAG_ACTIVE; |
3535 | 3562 | ||
3536 | /* call completion callback */ | 3563 | /* call completion callback */ |
3537 | rc = qc->complete_fn(qc, err_mask); | 3564 | rc = qc->complete_fn(qc); |
3538 | 3565 | ||
3539 | /* if callback indicates not to complete command (non-zero), | 3566 | /* if callback indicates not to complete command (non-zero), |
3540 | * return immediately | 3567 | * return immediately |
@@ -3972,7 +3999,8 @@ inline unsigned int ata_host_intr (struct ata_port *ap, | |||
3972 | ap->ops->irq_clear(ap); | 3999 | ap->ops->irq_clear(ap); |
3973 | 4000 | ||
3974 | /* complete taskfile transaction */ | 4001 | /* complete taskfile transaction */ |
3975 | ata_qc_complete(qc, ac_err_mask(status)); | 4002 | qc->err_mask |= ac_err_mask(status); |
4003 | ata_qc_complete(qc); | ||
3976 | break; | 4004 | break; |
3977 | 4005 | ||
3978 | default: | 4006 | default: |
@@ -4066,13 +4094,17 @@ static void atapi_packet_task(void *_data) | |||
4066 | 4094 | ||
4067 | /* sleep-wait for BSY to clear */ | 4095 | /* sleep-wait for BSY to clear */ |
4068 | DPRINTK("busy wait\n"); | 4096 | DPRINTK("busy wait\n"); |
4069 | if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) | 4097 | if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) { |
4070 | goto err_out_status; | 4098 | qc->err_mask |= AC_ERR_ATA_BUS; |
4099 | goto err_out; | ||
4100 | } | ||
4071 | 4101 | ||
4072 | /* make sure DRQ is set */ | 4102 | /* make sure DRQ is set */ |
4073 | status = ata_chk_status(ap); | 4103 | status = ata_chk_status(ap); |
4074 | if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) | 4104 | if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) { |
4105 | qc->err_mask |= AC_ERR_ATA_BUS; | ||
4075 | goto err_out; | 4106 | goto err_out; |
4107 | } | ||
4076 | 4108 | ||
4077 | /* send SCSI cdb */ | 4109 | /* send SCSI cdb */ |
4078 | DPRINTK("send cdb\n"); | 4110 | DPRINTK("send cdb\n"); |
@@ -4104,10 +4136,8 @@ static void atapi_packet_task(void *_data) | |||
4104 | 4136 | ||
4105 | return; | 4137 | return; |
4106 | 4138 | ||
4107 | err_out_status: | ||
4108 | status = ata_chk_status(ap); | ||
4109 | err_out: | 4139 | err_out: |
4110 | ata_poll_qc_complete(qc, __ac_err_mask(status)); | 4140 | ata_poll_qc_complete(qc); |
4111 | } | 4141 | } |
4112 | 4142 | ||
4113 | 4143 | ||
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 7445d8b524d5..e2f298b2ade6 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -418,7 +418,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, | |||
418 | int i; | 418 | int i; |
419 | 419 | ||
420 | /* Based on the 3ware driver translation table */ | 420 | /* Based on the 3ware driver translation table */ |
421 | static unsigned char sense_table[][4] = { | 421 | static const unsigned char sense_table[][4] = { |
422 | /* BBD|ECC|ID|MAR */ | 422 | /* BBD|ECC|ID|MAR */ |
423 | {0xd1, ABORTED_COMMAND, 0x00, 0x00}, // Device busy Aborted command | 423 | {0xd1, ABORTED_COMMAND, 0x00, 0x00}, // Device busy Aborted command |
424 | /* BBD|ECC|ID */ | 424 | /* BBD|ECC|ID */ |
@@ -449,7 +449,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, | |||
449 | {0x80, MEDIUM_ERROR, 0x11, 0x04}, // Block marked bad Medium error, unrecovered read error | 449 | {0x80, MEDIUM_ERROR, 0x11, 0x04}, // Block marked bad Medium error, unrecovered read error |
450 | {0xFF, 0xFF, 0xFF, 0xFF}, // END mark | 450 | {0xFF, 0xFF, 0xFF, 0xFF}, // END mark |
451 | }; | 451 | }; |
452 | static unsigned char stat_table[][4] = { | 452 | static const unsigned char stat_table[][4] = { |
453 | /* Must be first because BUSY means no other bits valid */ | 453 | /* Must be first because BUSY means no other bits valid */ |
454 | {0x80, ABORTED_COMMAND, 0x47, 0x00}, // Busy, fake parity for now | 454 | {0x80, ABORTED_COMMAND, 0x47, 0x00}, // Busy, fake parity for now |
455 | {0x20, HARDWARE_ERROR, 0x00, 0x00}, // Device fault | 455 | {0x20, HARDWARE_ERROR, 0x00, 0x00}, // Device fault |
@@ -1197,12 +1197,11 @@ nothing_to_do: | |||
1197 | return 1; | 1197 | return 1; |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, | 1200 | static int ata_scsi_qc_complete(struct ata_queued_cmd *qc) |
1201 | unsigned int err_mask) | ||
1202 | { | 1201 | { |
1203 | struct scsi_cmnd *cmd = qc->scsicmd; | 1202 | struct scsi_cmnd *cmd = qc->scsicmd; |
1204 | u8 *cdb = cmd->cmnd; | 1203 | u8 *cdb = cmd->cmnd; |
1205 | int need_sense = (err_mask != 0); | 1204 | int need_sense = (qc->err_mask != 0); |
1206 | 1205 | ||
1207 | /* For ATA pass thru (SAT) commands, generate a sense block if | 1206 | /* For ATA pass thru (SAT) commands, generate a sense block if |
1208 | * user mandated it or if there's an error. Note that if we | 1207 | * user mandated it or if there's an error. Note that if we |
@@ -1526,7 +1525,7 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf, | |||
1526 | return 0; | 1525 | return 0; |
1527 | } | 1526 | } |
1528 | 1527 | ||
1529 | static const char *inq_83_str = "Linux ATA-SCSI simulator"; | 1528 | static const char * const inq_83_str = "Linux ATA-SCSI simulator"; |
1530 | 1529 | ||
1531 | /** | 1530 | /** |
1532 | * ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity | 1531 | * ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity |
@@ -1949,9 +1948,9 @@ void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8 | |||
1949 | done(cmd); | 1948 | done(cmd); |
1950 | } | 1949 | } |
1951 | 1950 | ||
1952 | static int atapi_sense_complete(struct ata_queued_cmd *qc,unsigned int err_mask) | 1951 | static int atapi_sense_complete(struct ata_queued_cmd *qc) |
1953 | { | 1952 | { |
1954 | if (err_mask && ((err_mask & AC_ERR_DEV) == 0)) | 1953 | if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) |
1955 | /* FIXME: not quite right; we don't want the | 1954 | /* FIXME: not quite right; we don't want the |
1956 | * translation of taskfile registers into | 1955 | * translation of taskfile registers into |
1957 | * a sense descriptors, since that's only | 1956 | * a sense descriptors, since that's only |
@@ -2009,15 +2008,18 @@ static void atapi_request_sense(struct ata_queued_cmd *qc) | |||
2009 | 2008 | ||
2010 | qc->complete_fn = atapi_sense_complete; | 2009 | qc->complete_fn = atapi_sense_complete; |
2011 | 2010 | ||
2012 | if (ata_qc_issue(qc)) | 2011 | if (ata_qc_issue(qc)) { |
2013 | ata_qc_complete(qc, AC_ERR_OTHER); | 2012 | qc->err_mask |= AC_ERR_OTHER; |
2013 | ata_qc_complete(qc); | ||
2014 | } | ||
2014 | 2015 | ||
2015 | DPRINTK("EXIT\n"); | 2016 | DPRINTK("EXIT\n"); |
2016 | } | 2017 | } |
2017 | 2018 | ||
2018 | static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) | 2019 | static int atapi_qc_complete(struct ata_queued_cmd *qc) |
2019 | { | 2020 | { |
2020 | struct scsi_cmnd *cmd = qc->scsicmd; | 2021 | struct scsi_cmnd *cmd = qc->scsicmd; |
2022 | unsigned int err_mask = qc->err_mask; | ||
2021 | 2023 | ||
2022 | VPRINTK("ENTER, err_mask 0x%X\n", err_mask); | 2024 | VPRINTK("ENTER, err_mask 0x%X\n", err_mask); |
2023 | 2025 | ||
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index 8ebaa694d18e..251e53bdc6e0 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h | |||
@@ -39,7 +39,6 @@ struct ata_scsi_args { | |||
39 | 39 | ||
40 | /* libata-core.c */ | 40 | /* libata-core.c */ |
41 | extern int atapi_enabled; | 41 | extern int atapi_enabled; |
42 | extern int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask); | ||
43 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, | 42 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, |
44 | struct ata_device *dev); | 43 | struct ata_device *dev); |
45 | extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); | 44 | extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); |
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c index f557f17ca00c..e8df0c9ec1e6 100644 --- a/drivers/scsi/pdc_adma.c +++ b/drivers/scsi/pdc_adma.c | |||
@@ -464,14 +464,12 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set) | |||
464 | continue; | 464 | continue; |
465 | qc = ata_qc_from_tag(ap, ap->active_tag); | 465 | qc = ata_qc_from_tag(ap, ap->active_tag); |
466 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) { | 466 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) { |
467 | unsigned int err_mask = 0; | ||
468 | |||
469 | if ((status & (aPERR | aPSD | aUIRQ))) | 467 | if ((status & (aPERR | aPSD | aUIRQ))) |
470 | err_mask = AC_ERR_OTHER; | 468 | qc->err_mask |= AC_ERR_OTHER; |
471 | else if (pp->pkt[0] != cDONE) | 469 | else if (pp->pkt[0] != cDONE) |
472 | err_mask = AC_ERR_OTHER; | 470 | qc->err_mask |= AC_ERR_OTHER; |
473 | 471 | ||
474 | ata_qc_complete(qc, err_mask); | 472 | ata_qc_complete(qc); |
475 | } | 473 | } |
476 | } | 474 | } |
477 | return handled; | 475 | return handled; |
@@ -501,7 +499,8 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set) | |||
501 | 499 | ||
502 | /* complete taskfile transaction */ | 500 | /* complete taskfile transaction */ |
503 | pp->state = adma_state_idle; | 501 | pp->state = adma_state_idle; |
504 | ata_qc_complete(qc, ac_err_mask(status)); | 502 | qc->err_mask |= ac_err_mask(status); |
503 | ata_qc_complete(qc); | ||
505 | handled = 1; | 504 | handled = 1; |
506 | } | 505 | } |
507 | } | 506 | } |
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c index ab7432a5778e..3e7866b51ac6 100644 --- a/drivers/scsi/sata_mv.c +++ b/drivers/scsi/sata_mv.c | |||
@@ -430,7 +430,7 @@ static const struct ata_port_operations mv6_ops = { | |||
430 | .host_stop = mv_host_stop, | 430 | .host_stop = mv_host_stop, |
431 | }; | 431 | }; |
432 | 432 | ||
433 | static struct ata_port_info mv_port_info[] = { | 433 | static const struct ata_port_info mv_port_info[] = { |
434 | { /* chip_504x */ | 434 | { /* chip_504x */ |
435 | .sht = &mv_sht, | 435 | .sht = &mv_sht, |
436 | .host_flags = MV_COMMON_FLAGS, | 436 | .host_flags = MV_COMMON_FLAGS, |
@@ -1242,8 +1242,10 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, | |||
1242 | VPRINTK("port %u IRQ found for qc, " | 1242 | VPRINTK("port %u IRQ found for qc, " |
1243 | "ata_status 0x%x\n", port,ata_status); | 1243 | "ata_status 0x%x\n", port,ata_status); |
1244 | /* mark qc status appropriately */ | 1244 | /* mark qc status appropriately */ |
1245 | if (!(qc->tf.ctl & ATA_NIEN)) | 1245 | if (!(qc->tf.ctl & ATA_NIEN)) { |
1246 | ata_qc_complete(qc, err_mask); | 1246 | qc->err_mask |= err_mask; |
1247 | ata_qc_complete(qc); | ||
1248 | } | ||
1247 | } | 1249 | } |
1248 | } | 1250 | } |
1249 | } | 1251 | } |
@@ -1864,7 +1866,8 @@ static void mv_eng_timeout(struct ata_port *ap) | |||
1864 | */ | 1866 | */ |
1865 | spin_lock_irqsave(&ap->host_set->lock, flags); | 1867 | spin_lock_irqsave(&ap->host_set->lock, flags); |
1866 | qc->scsidone = scsi_finish_command; | 1868 | qc->scsidone = scsi_finish_command; |
1867 | ata_qc_complete(qc, AC_ERR_OTHER); | 1869 | qc->err_mask |= AC_ERR_OTHER; |
1870 | ata_qc_complete(qc); | ||
1868 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | 1871 | spin_unlock_irqrestore(&ap->host_set->lock, flags); |
1869 | } | 1872 | } |
1870 | } | 1873 | } |
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index 8a8e3e3ef0ed..e2e146a14f97 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c | |||
@@ -158,7 +158,7 @@ static const struct ata_port_operations pdc_pata_ops = { | |||
158 | .host_stop = ata_pci_host_stop, | 158 | .host_stop = ata_pci_host_stop, |
159 | }; | 159 | }; |
160 | 160 | ||
161 | static struct ata_port_info pdc_port_info[] = { | 161 | static const struct ata_port_info pdc_port_info[] = { |
162 | /* board_2037x */ | 162 | /* board_2037x */ |
163 | { | 163 | { |
164 | .sht = &pdc_ata_sht, | 164 | .sht = &pdc_ata_sht, |
@@ -401,7 +401,8 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
401 | case ATA_PROT_NODATA: | 401 | case ATA_PROT_NODATA: |
402 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); | 402 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); |
403 | drv_stat = ata_wait_idle(ap); | 403 | drv_stat = ata_wait_idle(ap); |
404 | ata_qc_complete(qc, __ac_err_mask(drv_stat)); | 404 | qc->err_mask |= __ac_err_mask(drv_stat); |
405 | ata_qc_complete(qc); | ||
405 | break; | 406 | break; |
406 | 407 | ||
407 | default: | 408 | default: |
@@ -410,7 +411,8 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
410 | printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", | 411 | printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", |
411 | ap->id, qc->tf.command, drv_stat); | 412 | ap->id, qc->tf.command, drv_stat); |
412 | 413 | ||
413 | ata_qc_complete(qc, ac_err_mask(drv_stat)); | 414 | qc->err_mask |= ac_err_mask(drv_stat); |
415 | ata_qc_complete(qc); | ||
414 | break; | 416 | break; |
415 | } | 417 | } |
416 | 418 | ||
@@ -422,21 +424,21 @@ out: | |||
422 | static inline unsigned int pdc_host_intr( struct ata_port *ap, | 424 | static inline unsigned int pdc_host_intr( struct ata_port *ap, |
423 | struct ata_queued_cmd *qc) | 425 | struct ata_queued_cmd *qc) |
424 | { | 426 | { |
425 | unsigned int handled = 0, err_mask = 0; | 427 | unsigned int handled = 0; |
426 | u32 tmp; | 428 | u32 tmp; |
427 | void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; | 429 | void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; |
428 | 430 | ||
429 | tmp = readl(mmio); | 431 | tmp = readl(mmio); |
430 | if (tmp & PDC_ERR_MASK) { | 432 | if (tmp & PDC_ERR_MASK) { |
431 | err_mask = AC_ERR_DEV; | 433 | qc->err_mask |= AC_ERR_DEV; |
432 | pdc_reset_port(ap); | 434 | pdc_reset_port(ap); |
433 | } | 435 | } |
434 | 436 | ||
435 | switch (qc->tf.protocol) { | 437 | switch (qc->tf.protocol) { |
436 | case ATA_PROT_DMA: | 438 | case ATA_PROT_DMA: |
437 | case ATA_PROT_NODATA: | 439 | case ATA_PROT_NODATA: |
438 | err_mask |= ac_err_mask(ata_wait_idle(ap)); | 440 | qc->err_mask |= ac_err_mask(ata_wait_idle(ap)); |
439 | ata_qc_complete(qc, err_mask); | 441 | ata_qc_complete(qc); |
440 | handled = 1; | 442 | handled = 1; |
441 | break; | 443 | break; |
442 | 444 | ||
@@ -703,7 +705,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
703 | probe_ent->port[3].scr_addr = base + 0x700; | 705 | probe_ent->port[3].scr_addr = base + 0x700; |
704 | break; | 706 | break; |
705 | case board_2037x: | 707 | case board_2037x: |
706 | probe_ent->n_ports = 2; | 708 | probe_ent->n_ports = 2; |
707 | break; | 709 | break; |
708 | case board_20619: | 710 | case board_20619: |
709 | probe_ent->n_ports = 4; | 711 | probe_ent->n_ports = 4; |
@@ -713,7 +715,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
713 | 715 | ||
714 | probe_ent->port[2].scr_addr = base + 0x600; | 716 | probe_ent->port[2].scr_addr = base + 0x600; |
715 | probe_ent->port[3].scr_addr = base + 0x700; | 717 | probe_ent->port[3].scr_addr = base + 0x700; |
716 | break; | 718 | break; |
717 | default: | 719 | default: |
718 | BUG(); | 720 | BUG(); |
719 | break; | 721 | break; |
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c index a8987f5ff5cc..de05e2883f9c 100644 --- a/drivers/scsi/sata_qstor.c +++ b/drivers/scsi/sata_qstor.c | |||
@@ -170,7 +170,7 @@ static const struct ata_port_operations qs_ata_ops = { | |||
170 | .bmdma_status = qs_bmdma_status, | 170 | .bmdma_status = qs_bmdma_status, |
171 | }; | 171 | }; |
172 | 172 | ||
173 | static struct ata_port_info qs_port_info[] = { | 173 | static const struct ata_port_info qs_port_info[] = { |
174 | /* board_2068_idx */ | 174 | /* board_2068_idx */ |
175 | { | 175 | { |
176 | .sht = &qs_ata_sht, | 176 | .sht = &qs_ata_sht, |
@@ -409,8 +409,8 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set) | |||
409 | case 3: /* device error */ | 409 | case 3: /* device error */ |
410 | pp->state = qs_state_idle; | 410 | pp->state = qs_state_idle; |
411 | qs_enter_reg_mode(qc->ap); | 411 | qs_enter_reg_mode(qc->ap); |
412 | ata_qc_complete(qc, | 412 | qc->err_mask |= ac_err_mask(sDST); |
413 | ac_err_mask(sDST)); | 413 | ata_qc_complete(qc); |
414 | break; | 414 | break; |
415 | default: | 415 | default: |
416 | break; | 416 | break; |
@@ -447,7 +447,8 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set) | |||
447 | 447 | ||
448 | /* complete taskfile transaction */ | 448 | /* complete taskfile transaction */ |
449 | pp->state = qs_state_idle; | 449 | pp->state = qs_state_idle; |
450 | ata_qc_complete(qc, ac_err_mask(status)); | 450 | qc->err_mask |= ac_err_mask(status); |
451 | ata_qc_complete(qc); | ||
451 | handled = 1; | 452 | handled = 1; |
452 | } | 453 | } |
453 | } | 454 | } |
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c index 36091868560d..d2053487c73b 100644 --- a/drivers/scsi/sata_sil.c +++ b/drivers/scsi/sata_sil.c | |||
@@ -176,7 +176,7 @@ static const struct ata_port_operations sil_ops = { | |||
176 | .host_stop = ata_pci_host_stop, | 176 | .host_stop = ata_pci_host_stop, |
177 | }; | 177 | }; |
178 | 178 | ||
179 | static struct ata_port_info sil_port_info[] = { | 179 | static const struct ata_port_info sil_port_info[] = { |
180 | /* sil_3112 */ | 180 | /* sil_3112 */ |
181 | { | 181 | { |
182 | .sht = &sil_sht, | 182 | .sht = &sil_sht, |
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c index e0d6f194f54f..a0ad3ed2200a 100644 --- a/drivers/scsi/sata_sil24.c +++ b/drivers/scsi/sata_sil24.c | |||
@@ -654,7 +654,8 @@ static void sil24_eng_timeout(struct ata_port *ap) | |||
654 | */ | 654 | */ |
655 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); | 655 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); |
656 | qc->scsidone = scsi_finish_command; | 656 | qc->scsidone = scsi_finish_command; |
657 | ata_qc_complete(qc, AC_ERR_OTHER); | 657 | qc->err_mask |= AC_ERR_OTHER; |
658 | ata_qc_complete(qc); | ||
658 | 659 | ||
659 | sil24_reset_controller(ap); | 660 | sil24_reset_controller(ap); |
660 | } | 661 | } |
@@ -711,8 +712,10 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat) | |||
711 | sil24_reset_controller(ap); | 712 | sil24_reset_controller(ap); |
712 | } | 713 | } |
713 | 714 | ||
714 | if (qc) | 715 | if (qc) { |
715 | ata_qc_complete(qc, err_mask); | 716 | qc->err_mask |= err_mask; |
717 | ata_qc_complete(qc); | ||
718 | } | ||
716 | } | 719 | } |
717 | 720 | ||
718 | static inline void sil24_host_intr(struct ata_port *ap) | 721 | static inline void sil24_host_intr(struct ata_port *ap) |
@@ -734,8 +737,10 @@ static inline void sil24_host_intr(struct ata_port *ap) | |||
734 | */ | 737 | */ |
735 | sil24_update_tf(ap); | 738 | sil24_update_tf(ap); |
736 | 739 | ||
737 | if (qc) | 740 | if (qc) { |
738 | ata_qc_complete(qc, ac_err_mask(pp->tf.command)); | 741 | qc->err_mask |= ac_err_mask(pp->tf.command); |
742 | ata_qc_complete(qc); | ||
743 | } | ||
739 | } else | 744 | } else |
740 | sil24_error_intr(ap, slot_stat); | 745 | sil24_error_intr(ap, slot_stat); |
741 | } | 746 | } |
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c index dcc3ad9a9d6e..58da854a7c68 100644 --- a/drivers/scsi/sata_sx4.c +++ b/drivers/scsi/sata_sx4.c | |||
@@ -215,7 +215,7 @@ static const struct ata_port_operations pdc_20621_ops = { | |||
215 | .host_stop = pdc20621_host_stop, | 215 | .host_stop = pdc20621_host_stop, |
216 | }; | 216 | }; |
217 | 217 | ||
218 | static struct ata_port_info pdc_port_info[] = { | 218 | static const struct ata_port_info pdc_port_info[] = { |
219 | /* board_20621 */ | 219 | /* board_20621 */ |
220 | { | 220 | { |
221 | .sht = &pdc_sata_sht, | 221 | .sht = &pdc_sata_sht, |
@@ -718,7 +718,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
718 | VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id, | 718 | VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id, |
719 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); | 719 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); |
720 | /* get drive status; clear intr; complete txn */ | 720 | /* get drive status; clear intr; complete txn */ |
721 | ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap))); | 721 | qc->err_mask |= ac_err_mask(ata_wait_idle(ap)); |
722 | ata_qc_complete(qc); | ||
722 | pdc20621_pop_hdma(qc); | 723 | pdc20621_pop_hdma(qc); |
723 | } | 724 | } |
724 | 725 | ||
@@ -756,7 +757,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
756 | VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id, | 757 | VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id, |
757 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); | 758 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); |
758 | /* get drive status; clear intr; complete txn */ | 759 | /* get drive status; clear intr; complete txn */ |
759 | ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap))); | 760 | qc->err_mask |= ac_err_mask(ata_wait_idle(ap)); |
761 | ata_qc_complete(qc); | ||
760 | pdc20621_pop_hdma(qc); | 762 | pdc20621_pop_hdma(qc); |
761 | } | 763 | } |
762 | handled = 1; | 764 | handled = 1; |
@@ -766,7 +768,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
766 | 768 | ||
767 | status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); | 769 | status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); |
768 | DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status); | 770 | DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status); |
769 | ata_qc_complete(qc, ac_err_mask(status)); | 771 | qc->err_mask |= ac_err_mask(status); |
772 | ata_qc_complete(qc); | ||
770 | handled = 1; | 773 | handled = 1; |
771 | 774 | ||
772 | } else { | 775 | } else { |
@@ -881,7 +884,8 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
881 | case ATA_PROT_DMA: | 884 | case ATA_PROT_DMA: |
882 | case ATA_PROT_NODATA: | 885 | case ATA_PROT_NODATA: |
883 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); | 886 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); |
884 | ata_qc_complete(qc, __ac_err_mask(ata_wait_idle(ap))); | 887 | qc->err_mask |= __ac_err_mask(ata_wait_idle(ap)); |
888 | ata_qc_complete(qc); | ||
885 | break; | 889 | break; |
886 | 890 | ||
887 | default: | 891 | default: |
@@ -890,7 +894,8 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
890 | printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", | 894 | printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", |
891 | ap->id, qc->tf.command, drv_stat); | 895 | ap->id, qc->tf.command, drv_stat); |
892 | 896 | ||
893 | ata_qc_complete(qc, ac_err_mask(drv_stat)); | 897 | qc->err_mask |= ac_err_mask(drv_stat); |
898 | ata_qc_complete(qc); | ||
894 | break; | 899 | break; |
895 | } | 900 | } |
896 | 901 | ||
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 4afef5cdcb17..ce9d73a292e2 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -542,10 +542,17 @@ static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd) | |||
542 | 542 | ||
543 | void scsi_next_command(struct scsi_cmnd *cmd) | 543 | void scsi_next_command(struct scsi_cmnd *cmd) |
544 | { | 544 | { |
545 | struct request_queue *q = cmd->device->request_queue; | 545 | struct scsi_device *sdev = cmd->device; |
546 | struct request_queue *q = sdev->request_queue; | ||
547 | |||
548 | /* need to hold a reference on the device before we let go of the cmd */ | ||
549 | get_device(&sdev->sdev_gendev); | ||
546 | 550 | ||
547 | scsi_put_command(cmd); | 551 | scsi_put_command(cmd); |
548 | scsi_run_queue(q); | 552 | scsi_run_queue(q); |
553 | |||
554 | /* ok to remove device now */ | ||
555 | put_device(&sdev->sdev_gendev); | ||
549 | } | 556 | } |
550 | 557 | ||
551 | void scsi_run_host_queues(struct Scsi_Host *shost) | 558 | void scsi_run_host_queues(struct Scsi_Host *shost) |
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 374853df9cca..94e5167f260d 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -266,8 +266,6 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget, | |||
266 | /* | 266 | /* |
267 | * if LLDD reports slave not present, don't clutter | 267 | * if LLDD reports slave not present, don't clutter |
268 | * console with alloc failure messages | 268 | * console with alloc failure messages |
269 | |||
270 | |||
271 | */ | 269 | */ |
272 | if (ret == -ENXIO) | 270 | if (ret == -ENXIO) |
273 | display_failure_msg = 0; | 271 | display_failure_msg = 0; |
@@ -279,7 +277,6 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget, | |||
279 | 277 | ||
280 | out_device_destroy: | 278 | out_device_destroy: |
281 | transport_destroy_device(&sdev->sdev_gendev); | 279 | transport_destroy_device(&sdev->sdev_gendev); |
282 | scsi_free_queue(sdev->request_queue); | ||
283 | put_device(&sdev->sdev_gendev); | 280 | put_device(&sdev->sdev_gendev); |
284 | out: | 281 | out: |
285 | if (display_failure_msg) | 282 | if (display_failure_msg) |