diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-04 19:32:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-04 19:32:33 -0500 |
commit | 1cb9e8e01d2c73184e2074f37cd155b3c4fdaae6 (patch) | |
tree | 3c8d1716cd53ed77a935036090323a1ae9a7963b /drivers | |
parent | d779188d2baf436e67fe8816fca2ef53d246900f (diff) | |
parent | a18ceba7b40e24a9da87249bd74f16ea5abd6894 (diff) |
Merge branch 'upstream' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pci/quirks.c | 30 | ||||
-rw-r--r-- | drivers/scsi/ahci.c | 14 | ||||
-rw-r--r-- | drivers/scsi/ata_piix.c | 127 | ||||
-rw-r--r-- | drivers/scsi/libata-core.c | 362 | ||||
-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 |
13 files changed, 397 insertions, 246 deletions
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 3a4f49f4effb..f28ebdd3958a 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -1098,6 +1098,23 @@ static void __init quirk_alder_ioapic(struct pci_dev *pdev) | |||
1098 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EESSC, quirk_alder_ioapic ); | 1098 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EESSC, quirk_alder_ioapic ); |
1099 | #endif | 1099 | #endif |
1100 | 1100 | ||
1101 | enum ide_combined_type { COMBINED = 0, IDE = 1, LIBATA = 2 }; | ||
1102 | /* Defaults to combined */ | ||
1103 | static enum ide_combined_type combined_mode; | ||
1104 | |||
1105 | static int __init combined_setup(char *str) | ||
1106 | { | ||
1107 | if (!strncmp(str, "ide", 3)) | ||
1108 | combined_mode = IDE; | ||
1109 | else if (!strncmp(str, "libata", 6)) | ||
1110 | combined_mode = LIBATA; | ||
1111 | else /* "combined" or anything else defaults to old behavior */ | ||
1112 | combined_mode = COMBINED; | ||
1113 | |||
1114 | return 1; | ||
1115 | } | ||
1116 | __setup("combined_mode=", combined_setup); | ||
1117 | |||
1101 | #ifdef CONFIG_SCSI_SATA_INTEL_COMBINED | 1118 | #ifdef CONFIG_SCSI_SATA_INTEL_COMBINED |
1102 | static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev) | 1119 | static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev) |
1103 | { | 1120 | { |
@@ -1164,6 +1181,19 @@ static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev) | |||
1164 | if (prog & comb) | 1181 | if (prog & comb) |
1165 | return; | 1182 | return; |
1166 | 1183 | ||
1184 | /* Don't reserve any so the IDE driver can get them (but only if | ||
1185 | * combined_mode=ide). | ||
1186 | */ | ||
1187 | if (combined_mode == IDE) | ||
1188 | return; | ||
1189 | |||
1190 | /* Grab them both for libata if combined_mode=libata. */ | ||
1191 | if (combined_mode == LIBATA) { | ||
1192 | request_region(0x1f0, 8, "libata"); /* port 0 */ | ||
1193 | request_region(0x170, 8, "libata"); /* port 1 */ | ||
1194 | return; | ||
1195 | } | ||
1196 | |||
1167 | /* SATA port is in legacy mode. Reserve port so that | 1197 | /* SATA port is in legacy mode. Reserve port so that |
1168 | * IDE driver does not attempt to use it. If request_region | 1198 | * IDE driver does not attempt to use it. If request_region |
1169 | * fails, it will be obvious at boot time, so we don't bother | 1199 | * fails, it will be obvious at boot time, so we don't bother |
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 333d69dd84ef..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> |
@@ -78,9 +121,7 @@ enum { | |||
78 | ich5_sata = 1, | 121 | ich5_sata = 1, |
79 | piix4_pata = 2, | 122 | piix4_pata = 2, |
80 | ich6_sata = 3, | 123 | ich6_sata = 3, |
81 | ich6_sata_rm = 4, | 124 | ich6_sata_ahci = 4, |
82 | ich7_sata = 5, | ||
83 | esb2_sata = 6, | ||
84 | 125 | ||
85 | PIIX_AHCI_DEVICE = 6, | 126 | PIIX_AHCI_DEVICE = 6, |
86 | }; | 127 | }; |
@@ -111,11 +152,11 @@ static const struct pci_device_id piix_pci_tbl[] = { | |||
111 | { 0x8086, 0x25a3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, | 152 | { 0x8086, 0x25a3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, |
112 | { 0x8086, 0x25b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, | 153 | { 0x8086, 0x25b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, |
113 | { 0x8086, 0x2651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata }, | 154 | { 0x8086, 0x2651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata }, |
114 | { 0x8086, 0x2652, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_rm }, | 155 | { 0x8086, 0x2652, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, |
115 | { 0x8086, 0x2653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_rm }, | 156 | { 0x8086, 0x2653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, |
116 | { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich7_sata }, | 157 | { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, |
117 | { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich7_sata }, | 158 | { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, |
118 | { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, esb2_sata }, | 159 | { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, |
119 | 160 | ||
120 | { } /* terminate list */ | 161 | { } /* terminate list */ |
121 | }; | 162 | }; |
@@ -258,31 +299,7 @@ static struct ata_port_info piix_port_info[] = { | |||
258 | .port_ops = &piix_sata_ops, | 299 | .port_ops = &piix_sata_ops, |
259 | }, | 300 | }, |
260 | 301 | ||
261 | /* ich6_sata_rm */ | 302 | /* ich6_sata_ahci */ |
262 | { | ||
263 | .sht = &piix_sht, | ||
264 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | | ||
265 | PIIX_FLAG_COMBINED | PIIX_FLAG_CHECKINTR | | ||
266 | ATA_FLAG_SLAVE_POSS | PIIX_FLAG_AHCI, | ||
267 | .pio_mask = 0x1f, /* pio0-4 */ | ||
268 | .mwdma_mask = 0x07, /* mwdma0-2 */ | ||
269 | .udma_mask = 0x7f, /* udma0-6 */ | ||
270 | .port_ops = &piix_sata_ops, | ||
271 | }, | ||
272 | |||
273 | /* ich7_sata */ | ||
274 | { | ||
275 | .sht = &piix_sht, | ||
276 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | | ||
277 | PIIX_FLAG_COMBINED | PIIX_FLAG_CHECKINTR | | ||
278 | ATA_FLAG_SLAVE_POSS | PIIX_FLAG_AHCI, | ||
279 | .pio_mask = 0x1f, /* pio0-4 */ | ||
280 | .mwdma_mask = 0x07, /* mwdma0-2 */ | ||
281 | .udma_mask = 0x7f, /* udma0-6 */ | ||
282 | .port_ops = &piix_sata_ops, | ||
283 | }, | ||
284 | |||
285 | /* esb2_sata */ | ||
286 | { | 303 | { |
287 | .sht = &piix_sht, | 304 | .sht = &piix_sht, |
288 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | | 305 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | |
@@ -603,6 +620,40 @@ static int piix_disable_ahci(struct pci_dev *pdev) | |||
603 | } | 620 | } |
604 | 621 | ||
605 | /** | 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 | /** | ||
606 | * piix_init_one - Register PIIX ATA PCI device with kernel services | 657 | * piix_init_one - Register PIIX ATA PCI device with kernel services |
607 | * @pdev: PCI device to register | 658 | * @pdev: PCI device to register |
608 | * @ent: Entry in piix_pci_tbl matching with @pdev | 659 | * @ent: Entry in piix_pci_tbl matching with @pdev |
@@ -676,7 +727,15 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
676 | "combined mode detected (p=%u, s=%u)\n", | 727 | "combined mode detected (p=%u, s=%u)\n", |
677 | pata_chan, sata_chan); | 728 | pata_chan, sata_chan); |
678 | } | 729 | } |
679 | 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 | } | ||
680 | return ata_pci_init_one(pdev, port_info, 2); | 739 | return ata_pci_init_one(pdev, port_info, 2); |
681 | } | 740 | } |
682 | 741 | ||
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index d0a0fdbd0fc4..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 | 1211 | ||
1145 | spin_lock_irqsave(&ap->host_set->lock, flags); | 1212 | err_mask = ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE, |
1146 | rc = ata_qc_issue(qc); | 1213 | dev->id, sizeof(dev->id)); |
1147 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
1148 | |||
1149 | if (rc) | ||
1150 | goto err_out; | ||
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 | } |
@@ -1444,11 +1500,23 @@ void __sata_phy_reset(struct ata_port *ap) | |||
1444 | } while (time_before(jiffies, timeout)); | 1500 | } while (time_before(jiffies, timeout)); |
1445 | 1501 | ||
1446 | /* TODO: phy layer with polling, timeouts, etc. */ | 1502 | /* TODO: phy layer with polling, timeouts, etc. */ |
1447 | if (sata_dev_present(ap)) | 1503 | sstatus = scr_read(ap, SCR_STATUS); |
1504 | if (sata_dev_present(ap)) { | ||
1505 | const char *speed; | ||
1506 | u32 tmp; | ||
1507 | |||
1508 | tmp = (sstatus >> 4) & 0xf; | ||
1509 | if (tmp & (1 << 0)) | ||
1510 | speed = "1.5"; | ||
1511 | else if (tmp & (1 << 1)) | ||
1512 | speed = "3.0"; | ||
1513 | else | ||
1514 | speed = "<unknown>"; | ||
1515 | printk(KERN_INFO "ata%u: SATA link up %s Gbps (SStatus %X)\n", | ||
1516 | ap->id, speed, sstatus); | ||
1448 | ata_port_probe(ap); | 1517 | ata_port_probe(ap); |
1449 | else { | 1518 | } else { |
1450 | sstatus = scr_read(ap, SCR_STATUS); | 1519 | printk(KERN_INFO "ata%u: SATA link down (SStatus %X)\n", |
1451 | printk(KERN_INFO "ata%u: no device found (phy stat %08x)\n", | ||
1452 | ap->id, sstatus); | 1520 | ap->id, sstatus); |
1453 | ata_port_disable(ap); | 1521 | ata_port_disable(ap); |
1454 | } | 1522 | } |
@@ -2071,7 +2139,7 @@ static void ata_pr_blacklisted(const struct ata_port *ap, | |||
2071 | ap->id, dev->devno); | 2139 | ap->id, dev->devno); |
2072 | } | 2140 | } |
2073 | 2141 | ||
2074 | static const char * ata_dma_blacklist [] = { | 2142 | static const char * const ata_dma_blacklist [] = { |
2075 | "WDC AC11000H", | 2143 | "WDC AC11000H", |
2076 | "WDC AC22100H", | 2144 | "WDC AC22100H", |
2077 | "WDC AC32500H", | 2145 | "WDC AC32500H", |
@@ -2266,34 +2334,23 @@ static int ata_choose_xfer_mode(const struct ata_port *ap, | |||
2266 | 2334 | ||
2267 | 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) |
2268 | { | 2336 | { |
2269 | DECLARE_COMPLETION(wait); | 2337 | struct ata_taskfile tf; |
2270 | struct ata_queued_cmd *qc; | ||
2271 | int rc; | ||
2272 | unsigned long flags; | ||
2273 | 2338 | ||
2274 | /* set up set-features taskfile */ | 2339 | /* set up set-features taskfile */ |
2275 | DPRINTK("set features - xfer mode\n"); | 2340 | DPRINTK("set features - xfer mode\n"); |
2276 | 2341 | ||
2277 | qc = ata_qc_new_init(ap, dev); | 2342 | ata_tf_init(ap, &tf, dev->devno); |
2278 | BUG_ON(qc == NULL); | 2343 | tf.command = ATA_CMD_SET_FEATURES; |
2279 | 2344 | tf.feature = SETFEATURES_XFER; | |
2280 | qc->tf.command = ATA_CMD_SET_FEATURES; | 2345 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; |
2281 | qc->tf.feature = SETFEATURES_XFER; | 2346 | tf.protocol = ATA_PROT_NODATA; |
2282 | qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 2347 | tf.nsect = dev->xfer_mode; |
2283 | qc->tf.protocol = ATA_PROT_NODATA; | ||
2284 | qc->tf.nsect = dev->xfer_mode; | ||
2285 | |||
2286 | qc->waiting = &wait; | ||
2287 | qc->complete_fn = ata_qc_complete_noop; | ||
2288 | |||
2289 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
2290 | rc = ata_qc_issue(qc); | ||
2291 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
2292 | 2348 | ||
2293 | 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); | ||
2294 | ata_port_disable(ap); | 2352 | ata_port_disable(ap); |
2295 | else | 2353 | } |
2296 | ata_qc_wait_err(qc, &wait); | ||
2297 | 2354 | ||
2298 | DPRINTK("EXIT\n"); | 2355 | DPRINTK("EXIT\n"); |
2299 | } | 2356 | } |
@@ -2308,41 +2365,25 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) | |||
2308 | 2365 | ||
2309 | 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) |
2310 | { | 2367 | { |
2311 | DECLARE_COMPLETION(wait); | 2368 | struct ata_taskfile tf; |
2312 | struct ata_queued_cmd *qc; | ||
2313 | unsigned long flags; | ||
2314 | int rc; | ||
2315 | |||
2316 | qc = ata_qc_new_init(ap, dev); | ||
2317 | BUG_ON(qc == NULL); | ||
2318 | 2369 | ||
2319 | ata_sg_init_one(qc, dev->id, sizeof(dev->id)); | 2370 | ata_tf_init(ap, &tf, dev->devno); |
2320 | qc->dma_dir = DMA_FROM_DEVICE; | ||
2321 | 2371 | ||
2322 | if (dev->class == ATA_DEV_ATA) { | 2372 | if (dev->class == ATA_DEV_ATA) { |
2323 | qc->tf.command = ATA_CMD_ID_ATA; | 2373 | tf.command = ATA_CMD_ID_ATA; |
2324 | DPRINTK("do ATA identify\n"); | 2374 | DPRINTK("do ATA identify\n"); |
2325 | } else { | 2375 | } else { |
2326 | qc->tf.command = ATA_CMD_ID_ATAPI; | 2376 | tf.command = ATA_CMD_ID_ATAPI; |
2327 | DPRINTK("do ATAPI identify\n"); | 2377 | DPRINTK("do ATAPI identify\n"); |
2328 | } | 2378 | } |
2329 | 2379 | ||
2330 | qc->tf.flags |= ATA_TFLAG_DEVICE; | 2380 | tf.flags |= ATA_TFLAG_DEVICE; |
2331 | qc->tf.protocol = ATA_PROT_PIO; | 2381 | tf.protocol = ATA_PROT_PIO; |
2332 | qc->nsect = 1; | ||
2333 | |||
2334 | qc->waiting = &wait; | ||
2335 | qc->complete_fn = ata_qc_complete_noop; | ||
2336 | |||
2337 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
2338 | rc = ata_qc_issue(qc); | ||
2339 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
2340 | 2382 | ||
2341 | if (rc) | 2383 | if (ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE, |
2384 | dev->id, sizeof(dev->id))) | ||
2342 | goto err_out; | 2385 | goto err_out; |
2343 | 2386 | ||
2344 | ata_qc_wait_err(qc, &wait); | ||
2345 | |||
2346 | swap_buf_le16(dev->id, ATA_ID_WORDS); | 2387 | swap_buf_le16(dev->id, ATA_ID_WORDS); |
2347 | 2388 | ||
2348 | ata_dump_id(dev); | 2389 | ata_dump_id(dev); |
@@ -2351,6 +2392,7 @@ static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev) | |||
2351 | 2392 | ||
2352 | return; | 2393 | return; |
2353 | err_out: | 2394 | err_out: |
2395 | printk(KERN_ERR "ata%u: failed to reread ID, disabled\n", ap->id); | ||
2354 | ata_port_disable(ap); | 2396 | ata_port_disable(ap); |
2355 | } | 2397 | } |
2356 | 2398 | ||
@@ -2364,10 +2406,7 @@ err_out: | |||
2364 | 2406 | ||
2365 | 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) |
2366 | { | 2408 | { |
2367 | DECLARE_COMPLETION(wait); | 2409 | struct ata_taskfile tf; |
2368 | struct ata_queued_cmd *qc; | ||
2369 | int rc; | ||
2370 | unsigned long flags; | ||
2371 | u16 sectors = dev->id[6]; | 2410 | u16 sectors = dev->id[6]; |
2372 | u16 heads = dev->id[3]; | 2411 | u16 heads = dev->id[3]; |
2373 | 2412 | ||
@@ -2378,26 +2417,18 @@ static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev) | |||
2378 | /* set up init dev params taskfile */ | 2417 | /* set up init dev params taskfile */ |
2379 | DPRINTK("init dev params \n"); | 2418 | DPRINTK("init dev params \n"); |
2380 | 2419 | ||
2381 | qc = ata_qc_new_init(ap, dev); | 2420 | ata_tf_init(ap, &tf, dev->devno); |
2382 | BUG_ON(qc == NULL); | 2421 | tf.command = ATA_CMD_INIT_DEV_PARAMS; |
2383 | 2422 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | |
2384 | qc->tf.command = ATA_CMD_INIT_DEV_PARAMS; | 2423 | tf.protocol = ATA_PROT_NODATA; |
2385 | qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 2424 | tf.nsect = sectors; |
2386 | qc->tf.protocol = ATA_PROT_NODATA; | 2425 | tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ |
2387 | qc->tf.nsect = sectors; | ||
2388 | qc->tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ | ||
2389 | |||
2390 | qc->waiting = &wait; | ||
2391 | qc->complete_fn = ata_qc_complete_noop; | ||
2392 | |||
2393 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
2394 | rc = ata_qc_issue(qc); | ||
2395 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
2396 | 2426 | ||
2397 | 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); | ||
2398 | ata_port_disable(ap); | 2430 | ata_port_disable(ap); |
2399 | else | 2431 | } |
2400 | ata_qc_wait_err(qc, &wait); | ||
2401 | 2432 | ||
2402 | DPRINTK("EXIT\n"); | 2433 | DPRINTK("EXIT\n"); |
2403 | } | 2434 | } |
@@ -2765,7 +2796,7 @@ skip_map: | |||
2765 | * None. (grabs host lock) | 2796 | * None. (grabs host lock) |
2766 | */ | 2797 | */ |
2767 | 2798 | ||
2768 | 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) |
2769 | { | 2800 | { |
2770 | struct ata_port *ap = qc->ap; | 2801 | struct ata_port *ap = qc->ap; |
2771 | unsigned long flags; | 2802 | unsigned long flags; |
@@ -2773,7 +2804,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) | |||
2773 | spin_lock_irqsave(&ap->host_set->lock, flags); | 2804 | spin_lock_irqsave(&ap->host_set->lock, flags); |
2774 | ap->flags &= ~ATA_FLAG_NOINTR; | 2805 | ap->flags &= ~ATA_FLAG_NOINTR; |
2775 | ata_irq_on(ap); | 2806 | ata_irq_on(ap); |
2776 | ata_qc_complete(qc, err_mask); | 2807 | ata_qc_complete(qc); |
2777 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | 2808 | spin_unlock_irqrestore(&ap->host_set->lock, flags); |
2778 | } | 2809 | } |
2779 | 2810 | ||
@@ -2790,10 +2821,14 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) | |||
2790 | 2821 | ||
2791 | static unsigned long ata_pio_poll(struct ata_port *ap) | 2822 | static unsigned long ata_pio_poll(struct ata_port *ap) |
2792 | { | 2823 | { |
2824 | struct ata_queued_cmd *qc; | ||
2793 | u8 status; | 2825 | u8 status; |
2794 | unsigned int poll_state = HSM_ST_UNKNOWN; | 2826 | unsigned int poll_state = HSM_ST_UNKNOWN; |
2795 | unsigned int reg_state = HSM_ST_UNKNOWN; | 2827 | unsigned int reg_state = HSM_ST_UNKNOWN; |
2796 | 2828 | ||
2829 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
2830 | assert(qc != NULL); | ||
2831 | |||
2797 | switch (ap->hsm_task_state) { | 2832 | switch (ap->hsm_task_state) { |
2798 | case HSM_ST: | 2833 | case HSM_ST: |
2799 | case HSM_ST_POLL: | 2834 | case HSM_ST_POLL: |
@@ -2813,6 +2848,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap) | |||
2813 | status = ata_chk_status(ap); | 2848 | status = ata_chk_status(ap); |
2814 | if (status & ATA_BUSY) { | 2849 | if (status & ATA_BUSY) { |
2815 | 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; | ||
2816 | ap->hsm_task_state = HSM_ST_TMOUT; | 2852 | ap->hsm_task_state = HSM_ST_TMOUT; |
2817 | return 0; | 2853 | return 0; |
2818 | } | 2854 | } |
@@ -2847,29 +2883,31 @@ static int ata_pio_complete (struct ata_port *ap) | |||
2847 | * msecs, then chk-status again. If still busy, fall back to | 2883 | * msecs, then chk-status again. If still busy, fall back to |
2848 | * HSM_ST_POLL state. | 2884 | * HSM_ST_POLL state. |
2849 | */ | 2885 | */ |
2850 | drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10); | 2886 | drv_stat = ata_busy_wait(ap, ATA_BUSY, 10); |
2851 | if (drv_stat & (ATA_BUSY | ATA_DRQ)) { | 2887 | if (drv_stat & ATA_BUSY) { |
2852 | msleep(2); | 2888 | msleep(2); |
2853 | drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10); | 2889 | drv_stat = ata_busy_wait(ap, ATA_BUSY, 10); |
2854 | if (drv_stat & (ATA_BUSY | ATA_DRQ)) { | 2890 | if (drv_stat & ATA_BUSY) { |
2855 | ap->hsm_task_state = HSM_ST_LAST_POLL; | 2891 | ap->hsm_task_state = HSM_ST_LAST_POLL; |
2856 | ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO; | 2892 | ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO; |
2857 | return 0; | 2893 | return 0; |
2858 | } | 2894 | } |
2859 | } | 2895 | } |
2860 | 2896 | ||
2897 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
2898 | assert(qc != NULL); | ||
2899 | |||
2861 | drv_stat = ata_wait_idle(ap); | 2900 | drv_stat = ata_wait_idle(ap); |
2862 | if (!ata_ok(drv_stat)) { | 2901 | if (!ata_ok(drv_stat)) { |
2902 | qc->err_mask |= __ac_err_mask(drv_stat); | ||
2863 | ap->hsm_task_state = HSM_ST_ERR; | 2903 | ap->hsm_task_state = HSM_ST_ERR; |
2864 | return 0; | 2904 | return 0; |
2865 | } | 2905 | } |
2866 | 2906 | ||
2867 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
2868 | assert(qc != NULL); | ||
2869 | |||
2870 | ap->hsm_task_state = HSM_ST_IDLE; | 2907 | ap->hsm_task_state = HSM_ST_IDLE; |
2871 | 2908 | ||
2872 | ata_poll_qc_complete(qc, 0); | 2909 | assert(qc->err_mask == 0); |
2910 | ata_poll_qc_complete(qc); | ||
2873 | 2911 | ||
2874 | /* another command may start at this point */ | 2912 | /* another command may start at this point */ |
2875 | 2913 | ||
@@ -3177,6 +3215,7 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc) | |||
3177 | err_out: | 3215 | err_out: |
3178 | printk(KERN_INFO "ata%u: dev %u: ATAPI check failed\n", | 3216 | printk(KERN_INFO "ata%u: dev %u: ATAPI check failed\n", |
3179 | ap->id, dev->devno); | 3217 | ap->id, dev->devno); |
3218 | qc->err_mask |= AC_ERR_ATA_BUS; | ||
3180 | ap->hsm_task_state = HSM_ST_ERR; | 3219 | ap->hsm_task_state = HSM_ST_ERR; |
3181 | } | 3220 | } |
3182 | 3221 | ||
@@ -3215,8 +3254,16 @@ static void ata_pio_block(struct ata_port *ap) | |||
3215 | qc = ata_qc_from_tag(ap, ap->active_tag); | 3254 | qc = ata_qc_from_tag(ap, ap->active_tag); |
3216 | assert(qc != NULL); | 3255 | assert(qc != NULL); |
3217 | 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 */ | ||
3218 | if (is_atapi_taskfile(&qc->tf)) { | 3265 | if (is_atapi_taskfile(&qc->tf)) { |
3219 | /* no more data to transfer or unsupported ATAPI command */ | 3266 | /* DRQ=0 means no more data to transfer */ |
3220 | if ((status & ATA_DRQ) == 0) { | 3267 | if ((status & ATA_DRQ) == 0) { |
3221 | ap->hsm_task_state = HSM_ST_LAST; | 3268 | ap->hsm_task_state = HSM_ST_LAST; |
3222 | return; | 3269 | return; |
@@ -3226,6 +3273,7 @@ static void ata_pio_block(struct ata_port *ap) | |||
3226 | } else { | 3273 | } else { |
3227 | /* handle BSY=0, DRQ=0 as error */ | 3274 | /* handle BSY=0, DRQ=0 as error */ |
3228 | if ((status & ATA_DRQ) == 0) { | 3275 | if ((status & ATA_DRQ) == 0) { |
3276 | qc->err_mask |= AC_ERR_ATA_BUS; | ||
3229 | ap->hsm_task_state = HSM_ST_ERR; | 3277 | ap->hsm_task_state = HSM_ST_ERR; |
3230 | return; | 3278 | return; |
3231 | } | 3279 | } |
@@ -3243,9 +3291,14 @@ static void ata_pio_error(struct ata_port *ap) | |||
3243 | qc = ata_qc_from_tag(ap, ap->active_tag); | 3291 | qc = ata_qc_from_tag(ap, ap->active_tag); |
3244 | assert(qc != NULL); | 3292 | assert(qc != NULL); |
3245 | 3293 | ||
3294 | /* make sure qc->err_mask is available to | ||
3295 | * know what's wrong and recover | ||
3296 | */ | ||
3297 | assert(qc->err_mask); | ||
3298 | |||
3246 | ap->hsm_task_state = HSM_ST_IDLE; | 3299 | ap->hsm_task_state = HSM_ST_IDLE; |
3247 | 3300 | ||
3248 | ata_poll_qc_complete(qc, AC_ERR_ATA_BUS); | 3301 | ata_poll_qc_complete(qc); |
3249 | } | 3302 | } |
3250 | 3303 | ||
3251 | static void ata_pio_task(void *_data) | 3304 | static void ata_pio_task(void *_data) |
@@ -3347,7 +3400,8 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc) | |||
3347 | ap->id, qc->tf.command, drv_stat, host_stat); | 3400 | ap->id, qc->tf.command, drv_stat, host_stat); |
3348 | 3401 | ||
3349 | /* complete taskfile transaction */ | 3402 | /* complete taskfile transaction */ |
3350 | ata_qc_complete(qc, ac_err_mask(drv_stat)); | 3403 | qc->err_mask |= ac_err_mask(drv_stat); |
3404 | ata_qc_complete(qc); | ||
3351 | break; | 3405 | break; |
3352 | } | 3406 | } |
3353 | 3407 | ||
@@ -3446,15 +3500,10 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, | |||
3446 | return qc; | 3500 | return qc; |
3447 | } | 3501 | } |
3448 | 3502 | ||
3449 | int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask) | ||
3450 | { | ||
3451 | return 0; | ||
3452 | } | ||
3453 | |||
3454 | static void __ata_qc_complete(struct ata_queued_cmd *qc) | 3503 | static void __ata_qc_complete(struct ata_queued_cmd *qc) |
3455 | { | 3504 | { |
3456 | struct ata_port *ap = qc->ap; | 3505 | struct ata_port *ap = qc->ap; |
3457 | unsigned int tag, do_clear = 0; | 3506 | unsigned int tag; |
3458 | 3507 | ||
3459 | qc->flags = 0; | 3508 | qc->flags = 0; |
3460 | tag = qc->tag; | 3509 | tag = qc->tag; |
@@ -3462,17 +3511,8 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc) | |||
3462 | if (tag == ap->active_tag) | 3511 | if (tag == ap->active_tag) |
3463 | ap->active_tag = ATA_TAG_POISON; | 3512 | ap->active_tag = ATA_TAG_POISON; |
3464 | qc->tag = ATA_TAG_POISON; | 3513 | qc->tag = ATA_TAG_POISON; |
3465 | do_clear = 1; | ||
3466 | } | ||
3467 | |||
3468 | if (qc->waiting) { | ||
3469 | struct completion *waiting = qc->waiting; | ||
3470 | qc->waiting = NULL; | ||
3471 | complete(waiting); | ||
3472 | } | ||
3473 | |||
3474 | if (likely(do_clear)) | ||
3475 | clear_bit(tag, &ap->qactive); | 3514 | clear_bit(tag, &ap->qactive); |
3515 | } | ||
3476 | } | 3516 | } |
3477 | 3517 | ||
3478 | /** | 3518 | /** |
@@ -3488,7 +3528,6 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc) | |||
3488 | void ata_qc_free(struct ata_queued_cmd *qc) | 3528 | void ata_qc_free(struct ata_queued_cmd *qc) |
3489 | { | 3529 | { |
3490 | assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ | 3530 | assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ |
3491 | assert(qc->waiting == NULL); /* nothing should be waiting */ | ||
3492 | 3531 | ||
3493 | __ata_qc_complete(qc); | 3532 | __ata_qc_complete(qc); |
3494 | } | 3533 | } |
@@ -3505,7 +3544,7 @@ void ata_qc_free(struct ata_queued_cmd *qc) | |||
3505 | * spin_lock_irqsave(host_set lock) | 3544 | * spin_lock_irqsave(host_set lock) |
3506 | */ | 3545 | */ |
3507 | 3546 | ||
3508 | void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) | 3547 | void ata_qc_complete(struct ata_queued_cmd *qc) |
3509 | { | 3548 | { |
3510 | int rc; | 3549 | int rc; |
3511 | 3550 | ||
@@ -3522,7 +3561,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) | |||
3522 | qc->flags &= ~ATA_QCFLAG_ACTIVE; | 3561 | qc->flags &= ~ATA_QCFLAG_ACTIVE; |
3523 | 3562 | ||
3524 | /* call completion callback */ | 3563 | /* call completion callback */ |
3525 | rc = qc->complete_fn(qc, err_mask); | 3564 | rc = qc->complete_fn(qc); |
3526 | 3565 | ||
3527 | /* if callback indicates not to complete command (non-zero), | 3566 | /* if callback indicates not to complete command (non-zero), |
3528 | * return immediately | 3567 | * return immediately |
@@ -3960,7 +3999,8 @@ inline unsigned int ata_host_intr (struct ata_port *ap, | |||
3960 | ap->ops->irq_clear(ap); | 3999 | ap->ops->irq_clear(ap); |
3961 | 4000 | ||
3962 | /* complete taskfile transaction */ | 4001 | /* complete taskfile transaction */ |
3963 | ata_qc_complete(qc, ac_err_mask(status)); | 4002 | qc->err_mask |= ac_err_mask(status); |
4003 | ata_qc_complete(qc); | ||
3964 | break; | 4004 | break; |
3965 | 4005 | ||
3966 | default: | 4006 | default: |
@@ -4054,13 +4094,17 @@ static void atapi_packet_task(void *_data) | |||
4054 | 4094 | ||
4055 | /* sleep-wait for BSY to clear */ | 4095 | /* sleep-wait for BSY to clear */ |
4056 | DPRINTK("busy wait\n"); | 4096 | DPRINTK("busy wait\n"); |
4057 | 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)) { |
4058 | goto err_out_status; | 4098 | qc->err_mask |= AC_ERR_ATA_BUS; |
4099 | goto err_out; | ||
4100 | } | ||
4059 | 4101 | ||
4060 | /* make sure DRQ is set */ | 4102 | /* make sure DRQ is set */ |
4061 | status = ata_chk_status(ap); | 4103 | status = ata_chk_status(ap); |
4062 | 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; | ||
4063 | goto err_out; | 4106 | goto err_out; |
4107 | } | ||
4064 | 4108 | ||
4065 | /* send SCSI cdb */ | 4109 | /* send SCSI cdb */ |
4066 | DPRINTK("send cdb\n"); | 4110 | DPRINTK("send cdb\n"); |
@@ -4092,10 +4136,8 @@ static void atapi_packet_task(void *_data) | |||
4092 | 4136 | ||
4093 | return; | 4137 | return; |
4094 | 4138 | ||
4095 | err_out_status: | ||
4096 | status = ata_chk_status(ap); | ||
4097 | err_out: | 4139 | err_out: |
4098 | ata_poll_qc_complete(qc, __ac_err_mask(status)); | 4140 | ata_poll_qc_complete(qc); |
4099 | } | 4141 | } |
4100 | 4142 | ||
4101 | 4143 | ||
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 2282c04fee46..e0439be4b573 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 |
@@ -1203,12 +1203,11 @@ nothing_to_do: | |||
1203 | return 1; | 1203 | return 1; |
1204 | } | 1204 | } |
1205 | 1205 | ||
1206 | static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, | 1206 | static int ata_scsi_qc_complete(struct ata_queued_cmd *qc) |
1207 | unsigned int err_mask) | ||
1208 | { | 1207 | { |
1209 | struct scsi_cmnd *cmd = qc->scsicmd; | 1208 | struct scsi_cmnd *cmd = qc->scsicmd; |
1210 | u8 *cdb = cmd->cmnd; | 1209 | u8 *cdb = cmd->cmnd; |
1211 | int need_sense = (err_mask != 0); | 1210 | int need_sense = (qc->err_mask != 0); |
1212 | 1211 | ||
1213 | /* For ATA pass thru (SAT) commands, generate a sense block if | 1212 | /* For ATA pass thru (SAT) commands, generate a sense block if |
1214 | * user mandated it or if there's an error. Note that if we | 1213 | * user mandated it or if there's an error. Note that if we |
@@ -1532,7 +1531,7 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf, | |||
1532 | return 0; | 1531 | return 0; |
1533 | } | 1532 | } |
1534 | 1533 | ||
1535 | static const char *inq_83_str = "Linux ATA-SCSI simulator"; | 1534 | static const char * const inq_83_str = "Linux ATA-SCSI simulator"; |
1536 | 1535 | ||
1537 | /** | 1536 | /** |
1538 | * ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity | 1537 | * ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity |
@@ -1955,9 +1954,9 @@ void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8 | |||
1955 | done(cmd); | 1954 | done(cmd); |
1956 | } | 1955 | } |
1957 | 1956 | ||
1958 | static int atapi_sense_complete(struct ata_queued_cmd *qc,unsigned int err_mask) | 1957 | static int atapi_sense_complete(struct ata_queued_cmd *qc) |
1959 | { | 1958 | { |
1960 | if (err_mask && ((err_mask & AC_ERR_DEV) == 0)) | 1959 | if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) |
1961 | /* FIXME: not quite right; we don't want the | 1960 | /* FIXME: not quite right; we don't want the |
1962 | * translation of taskfile registers into | 1961 | * translation of taskfile registers into |
1963 | * a sense descriptors, since that's only | 1962 | * a sense descriptors, since that's only |
@@ -2015,15 +2014,18 @@ static void atapi_request_sense(struct ata_queued_cmd *qc) | |||
2015 | 2014 | ||
2016 | qc->complete_fn = atapi_sense_complete; | 2015 | qc->complete_fn = atapi_sense_complete; |
2017 | 2016 | ||
2018 | if (ata_qc_issue(qc)) | 2017 | if (ata_qc_issue(qc)) { |
2019 | ata_qc_complete(qc, AC_ERR_OTHER); | 2018 | qc->err_mask |= AC_ERR_OTHER; |
2019 | ata_qc_complete(qc); | ||
2020 | } | ||
2020 | 2021 | ||
2021 | DPRINTK("EXIT\n"); | 2022 | DPRINTK("EXIT\n"); |
2022 | } | 2023 | } |
2023 | 2024 | ||
2024 | static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) | 2025 | static int atapi_qc_complete(struct ata_queued_cmd *qc) |
2025 | { | 2026 | { |
2026 | struct scsi_cmnd *cmd = qc->scsicmd; | 2027 | struct scsi_cmnd *cmd = qc->scsicmd; |
2028 | unsigned int err_mask = qc->err_mask; | ||
2027 | 2029 | ||
2028 | VPRINTK("ENTER, err_mask 0x%X\n", err_mask); | 2030 | VPRINTK("ENTER, err_mask 0x%X\n", err_mask); |
2029 | 2031 | ||
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 9321cdf45680..b2bf16a9bf4b 100644 --- a/drivers/scsi/sata_mv.c +++ b/drivers/scsi/sata_mv.c | |||
@@ -431,7 +431,7 @@ static const struct ata_port_operations mv6_ops = { | |||
431 | .host_stop = mv_host_stop, | 431 | .host_stop = mv_host_stop, |
432 | }; | 432 | }; |
433 | 433 | ||
434 | static struct ata_port_info mv_port_info[] = { | 434 | static const struct ata_port_info mv_port_info[] = { |
435 | { /* chip_504x */ | 435 | { /* chip_504x */ |
436 | .sht = &mv_sht, | 436 | .sht = &mv_sht, |
437 | .host_flags = MV_COMMON_FLAGS, | 437 | .host_flags = MV_COMMON_FLAGS, |
@@ -1243,8 +1243,10 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, | |||
1243 | VPRINTK("port %u IRQ found for qc, " | 1243 | VPRINTK("port %u IRQ found for qc, " |
1244 | "ata_status 0x%x\n", port,ata_status); | 1244 | "ata_status 0x%x\n", port,ata_status); |
1245 | /* mark qc status appropriately */ | 1245 | /* mark qc status appropriately */ |
1246 | if (!(qc->tf.ctl & ATA_NIEN)) | 1246 | if (!(qc->tf.ctl & ATA_NIEN)) { |
1247 | ata_qc_complete(qc, err_mask); | 1247 | qc->err_mask |= err_mask; |
1248 | ata_qc_complete(qc); | ||
1249 | } | ||
1248 | } | 1250 | } |
1249 | } | 1251 | } |
1250 | } | 1252 | } |
@@ -1865,7 +1867,8 @@ static void mv_eng_timeout(struct ata_port *ap) | |||
1865 | */ | 1867 | */ |
1866 | spin_lock_irqsave(&ap->host_set->lock, flags); | 1868 | spin_lock_irqsave(&ap->host_set->lock, flags); |
1867 | qc->scsidone = scsi_finish_command; | 1869 | qc->scsidone = scsi_finish_command; |
1868 | ata_qc_complete(qc, AC_ERR_OTHER); | 1870 | qc->err_mask |= AC_ERR_OTHER; |
1871 | ata_qc_complete(qc); | ||
1869 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | 1872 | spin_unlock_irqrestore(&ap->host_set->lock, flags); |
1870 | } | 1873 | } |
1871 | } | 1874 | } |
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index 2691625f9bce..da7fa04b8a73 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c | |||
@@ -161,7 +161,7 @@ static const struct ata_port_operations pdc_pata_ops = { | |||
161 | .host_stop = ata_pci_host_stop, | 161 | .host_stop = ata_pci_host_stop, |
162 | }; | 162 | }; |
163 | 163 | ||
164 | static struct ata_port_info pdc_port_info[] = { | 164 | static const struct ata_port_info pdc_port_info[] = { |
165 | /* board_2037x */ | 165 | /* board_2037x */ |
166 | { | 166 | { |
167 | .sht = &pdc_ata_sht, | 167 | .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 ac7b0d819ebc..94b253b80da8 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, |
@@ -719,7 +719,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
719 | VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id, | 719 | VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id, |
720 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); | 720 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); |
721 | /* get drive status; clear intr; complete txn */ | 721 | /* get drive status; clear intr; complete txn */ |
722 | ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap))); | 722 | qc->err_mask |= ac_err_mask(ata_wait_idle(ap)); |
723 | ata_qc_complete(qc); | ||
723 | pdc20621_pop_hdma(qc); | 724 | pdc20621_pop_hdma(qc); |
724 | } | 725 | } |
725 | 726 | ||
@@ -757,7 +758,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
757 | VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id, | 758 | VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id, |
758 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); | 759 | readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); |
759 | /* get drive status; clear intr; complete txn */ | 760 | /* get drive status; clear intr; complete txn */ |
760 | ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap))); | 761 | qc->err_mask |= ac_err_mask(ata_wait_idle(ap)); |
762 | ata_qc_complete(qc); | ||
761 | pdc20621_pop_hdma(qc); | 763 | pdc20621_pop_hdma(qc); |
762 | } | 764 | } |
763 | handled = 1; | 765 | handled = 1; |
@@ -767,7 +769,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, | |||
767 | 769 | ||
768 | status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); | 770 | status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); |
769 | DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status); | 771 | DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status); |
770 | ata_qc_complete(qc, ac_err_mask(status)); | 772 | qc->err_mask |= ac_err_mask(status); |
773 | ata_qc_complete(qc); | ||
771 | handled = 1; | 774 | handled = 1; |
772 | 775 | ||
773 | } else { | 776 | } else { |
@@ -882,7 +885,8 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
882 | case ATA_PROT_DMA: | 885 | case ATA_PROT_DMA: |
883 | case ATA_PROT_NODATA: | 886 | case ATA_PROT_NODATA: |
884 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); | 887 | printk(KERN_ERR "ata%u: command timeout\n", ap->id); |
885 | ata_qc_complete(qc, __ac_err_mask(ata_wait_idle(ap))); | 888 | qc->err_mask |= __ac_err_mask(ata_wait_idle(ap)); |
889 | ata_qc_complete(qc); | ||
886 | break; | 890 | break; |
887 | 891 | ||
888 | default: | 892 | default: |
@@ -891,7 +895,8 @@ static void pdc_eng_timeout(struct ata_port *ap) | |||
891 | printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", | 895 | printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", |
892 | ap->id, qc->tf.command, drv_stat); | 896 | ap->id, qc->tf.command, drv_stat); |
893 | 897 | ||
894 | ata_qc_complete(qc, ac_err_mask(drv_stat)); | 898 | qc->err_mask |= ac_err_mask(drv_stat); |
899 | ata_qc_complete(qc); | ||
895 | break; | 900 | break; |
896 | } | 901 | } |
897 | 902 | ||