aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/ahci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/ahci.c')
-rw-r--r--drivers/ata/ahci.c255
1 files changed, 149 insertions, 106 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 11e4eb9f304e..06f212ff2b4f 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -99,6 +99,7 @@ enum {
99 HOST_CAP_SSC = (1 << 14), /* Slumber capable */ 99 HOST_CAP_SSC = (1 << 14), /* Slumber capable */
100 HOST_CAP_CLO = (1 << 24), /* Command List Override support */ 100 HOST_CAP_CLO = (1 << 24), /* Command List Override support */
101 HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */ 101 HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */
102 HOST_CAP_SNTF = (1 << 29), /* SNotification register */
102 HOST_CAP_NCQ = (1 << 30), /* Native Command Queueing */ 103 HOST_CAP_NCQ = (1 << 30), /* Native Command Queueing */
103 HOST_CAP_64 = (1 << 31), /* PCI DAC (64-bit DMA) support */ 104 HOST_CAP_64 = (1 << 31), /* PCI DAC (64-bit DMA) support */
104 105
@@ -113,11 +114,11 @@ enum {
113 PORT_TFDATA = 0x20, /* taskfile data */ 114 PORT_TFDATA = 0x20, /* taskfile data */
114 PORT_SIG = 0x24, /* device TF signature */ 115 PORT_SIG = 0x24, /* device TF signature */
115 PORT_CMD_ISSUE = 0x38, /* command issue */ 116 PORT_CMD_ISSUE = 0x38, /* command issue */
116 PORT_SCR = 0x28, /* SATA phy register block */
117 PORT_SCR_STAT = 0x28, /* SATA phy register: SStatus */ 117 PORT_SCR_STAT = 0x28, /* SATA phy register: SStatus */
118 PORT_SCR_CTL = 0x2c, /* SATA phy register: SControl */ 118 PORT_SCR_CTL = 0x2c, /* SATA phy register: SControl */
119 PORT_SCR_ERR = 0x30, /* SATA phy register: SError */ 119 PORT_SCR_ERR = 0x30, /* SATA phy register: SError */
120 PORT_SCR_ACT = 0x34, /* SATA phy register: SActive */ 120 PORT_SCR_ACT = 0x34, /* SATA phy register: SActive */
121 PORT_SCR_NTF = 0x3c, /* SATA phy register: SNotification */
121 122
122 /* PORT_IRQ_{STAT,MASK} bits */ 123 /* PORT_IRQ_{STAT,MASK} bits */
123 PORT_IRQ_COLD_PRES = (1 << 31), /* cold presence detect */ 124 PORT_IRQ_COLD_PRES = (1 << 31), /* cold presence detect */
@@ -216,8 +217,8 @@ struct ahci_port_priv {
216 unsigned int ncq_saw_sdb:1; 217 unsigned int ncq_saw_sdb:1;
217}; 218};
218 219
219static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg); 220static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val);
220static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); 221static int ahci_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val);
221static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 222static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
222static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc); 223static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc);
223static void ahci_irq_clear(struct ata_port *ap); 224static void ahci_irq_clear(struct ata_port *ap);
@@ -417,7 +418,10 @@ static const struct pci_device_id ahci_pci_tbl[] = {
417 418
418 /* ATI */ 419 /* ATI */
419 { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */ 420 { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */
420 { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb600 }, /* ATI SB700 */ 421 { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb600 }, /* ATI SB700 IDE */
422 { PCI_VDEVICE(ATI, 0x4391), board_ahci_sb600 }, /* ATI SB700 AHCI */
423 { PCI_VDEVICE(ATI, 0x4392), board_ahci_sb600 }, /* ATI SB700 nraid5 */
424 { PCI_VDEVICE(ATI, 0x4393), board_ahci_sb600 }, /* ATI SB700 raid5 */
421 425
422 /* VIA */ 426 /* VIA */
423 { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */ 427 { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */
@@ -545,13 +549,19 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
545 hpriv->saved_cap = cap = readl(mmio + HOST_CAP); 549 hpriv->saved_cap = cap = readl(mmio + HOST_CAP);
546 hpriv->saved_port_map = port_map = readl(mmio + HOST_PORTS_IMPL); 550 hpriv->saved_port_map = port_map = readl(mmio + HOST_PORTS_IMPL);
547 551
548 /* some chips lie about 64bit support */ 552 /* some chips have errata preventing 64bit use */
549 if ((cap & HOST_CAP_64) && (pi->flags & AHCI_FLAG_32BIT_ONLY)) { 553 if ((cap & HOST_CAP_64) && (pi->flags & AHCI_FLAG_32BIT_ONLY)) {
550 dev_printk(KERN_INFO, &pdev->dev, 554 dev_printk(KERN_INFO, &pdev->dev,
551 "controller can't do 64bit DMA, forcing 32bit\n"); 555 "controller can't do 64bit DMA, forcing 32bit\n");
552 cap &= ~HOST_CAP_64; 556 cap &= ~HOST_CAP_64;
553 } 557 }
554 558
559 if ((cap & HOST_CAP_NCQ) && (pi->flags & AHCI_FLAG_NO_NCQ)) {
560 dev_printk(KERN_INFO, &pdev->dev,
561 "controller can't do NCQ, turning off CAP_NCQ\n");
562 cap &= ~HOST_CAP_NCQ;
563 }
564
555 /* fixup zero port_map */ 565 /* fixup zero port_map */
556 if (!port_map) { 566 if (!port_map) {
557 port_map = (1 << ahci_nr_ports(cap)) - 1; 567 port_map = (1 << ahci_nr_ports(cap)) - 1;
@@ -625,38 +635,45 @@ static void ahci_restore_initial_config(struct ata_host *host)
625 (void) readl(mmio + HOST_PORTS_IMPL); /* flush */ 635 (void) readl(mmio + HOST_PORTS_IMPL); /* flush */
626} 636}
627 637
628static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in) 638static unsigned ahci_scr_offset(struct ata_port *ap, unsigned int sc_reg)
629{ 639{
630 unsigned int sc_reg; 640 static const int offset[] = {
631 641 [SCR_STATUS] = PORT_SCR_STAT,
632 switch (sc_reg_in) { 642 [SCR_CONTROL] = PORT_SCR_CTL,
633 case SCR_STATUS: sc_reg = 0; break; 643 [SCR_ERROR] = PORT_SCR_ERR,
634 case SCR_CONTROL: sc_reg = 1; break; 644 [SCR_ACTIVE] = PORT_SCR_ACT,
635 case SCR_ERROR: sc_reg = 2; break; 645 [SCR_NOTIFICATION] = PORT_SCR_NTF,
636 case SCR_ACTIVE: sc_reg = 3; break; 646 };
637 default: 647 struct ahci_host_priv *hpriv = ap->host->private_data;
638 return 0xffffffffU;
639 }
640 648
641 return readl(ap->ioaddr.scr_addr + (sc_reg * 4)); 649 if (sc_reg < ARRAY_SIZE(offset) &&
650 (sc_reg != SCR_NOTIFICATION || (hpriv->cap & HOST_CAP_SNTF)))
651 return offset[sc_reg];
652 return 0;
642} 653}
643 654
644 655static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
645static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in,
646 u32 val)
647{ 656{
648 unsigned int sc_reg; 657 void __iomem *port_mmio = ahci_port_base(ap);
649 658 int offset = ahci_scr_offset(ap, sc_reg);
650 switch (sc_reg_in) { 659
651 case SCR_STATUS: sc_reg = 0; break; 660 if (offset) {
652 case SCR_CONTROL: sc_reg = 1; break; 661 *val = readl(port_mmio + offset);
653 case SCR_ERROR: sc_reg = 2; break; 662 return 0;
654 case SCR_ACTIVE: sc_reg = 3; break;
655 default:
656 return;
657 } 663 }
664 return -EINVAL;
665}
658 666
659 writel(val, ap->ioaddr.scr_addr + (sc_reg * 4)); 667static int ahci_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val)
668{
669 void __iomem *port_mmio = ahci_port_base(ap);
670 int offset = ahci_scr_offset(ap, sc_reg);
671
672 if (offset) {
673 writel(val, port_mmio + offset);
674 return 0;
675 }
676 return -EINVAL;
660} 677}
661 678
662static void ahci_start_engine(struct ata_port *ap) 679static void ahci_start_engine(struct ata_port *ap)
@@ -948,37 +965,87 @@ static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
948 pp->cmd_slot[tag].tbl_addr_hi = cpu_to_le32((cmd_tbl_dma >> 16) >> 16); 965 pp->cmd_slot[tag].tbl_addr_hi = cpu_to_le32((cmd_tbl_dma >> 16) >> 16);
949} 966}
950 967
951static int ahci_clo(struct ata_port *ap) 968static int ahci_kick_engine(struct ata_port *ap, int force_restart)
952{ 969{
953 void __iomem *port_mmio = ap->ioaddr.cmd_addr; 970 void __iomem *port_mmio = ap->ioaddr.cmd_addr;
954 struct ahci_host_priv *hpriv = ap->host->private_data; 971 struct ahci_host_priv *hpriv = ap->host->private_data;
955 u32 tmp; 972 u32 tmp;
973 int busy, rc;
974
975 /* do we need to kick the port? */
976 busy = ahci_check_status(ap) & (ATA_BUSY | ATA_DRQ);
977 if (!busy && !force_restart)
978 return 0;
979
980 /* stop engine */
981 rc = ahci_stop_engine(ap);
982 if (rc)
983 goto out_restart;
956 984
957 if (!(hpriv->cap & HOST_CAP_CLO)) 985 /* need to do CLO? */
958 return -EOPNOTSUPP; 986 if (!busy) {
987 rc = 0;
988 goto out_restart;
989 }
959 990
991 if (!(hpriv->cap & HOST_CAP_CLO)) {
992 rc = -EOPNOTSUPP;
993 goto out_restart;
994 }
995
996 /* perform CLO */
960 tmp = readl(port_mmio + PORT_CMD); 997 tmp = readl(port_mmio + PORT_CMD);
961 tmp |= PORT_CMD_CLO; 998 tmp |= PORT_CMD_CLO;
962 writel(tmp, port_mmio + PORT_CMD); 999 writel(tmp, port_mmio + PORT_CMD);
963 1000
1001 rc = 0;
964 tmp = ata_wait_register(port_mmio + PORT_CMD, 1002 tmp = ata_wait_register(port_mmio + PORT_CMD,
965 PORT_CMD_CLO, PORT_CMD_CLO, 1, 500); 1003 PORT_CMD_CLO, PORT_CMD_CLO, 1, 500);
966 if (tmp & PORT_CMD_CLO) 1004 if (tmp & PORT_CMD_CLO)
967 return -EIO; 1005 rc = -EIO;
968 1006
969 return 0; 1007 /* restart engine */
1008 out_restart:
1009 ahci_start_engine(ap);
1010 return rc;
970} 1011}
971 1012
972static int ahci_softreset(struct ata_port *ap, unsigned int *class, 1013static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
973 unsigned long deadline) 1014 struct ata_taskfile *tf, int is_cmd, u16 flags,
1015 unsigned long timeout_msec)
974{ 1016{
1017 const u32 cmd_fis_len = 5; /* five dwords */
975 struct ahci_port_priv *pp = ap->private_data; 1018 struct ahci_port_priv *pp = ap->private_data;
976 void __iomem *port_mmio = ahci_port_base(ap); 1019 void __iomem *port_mmio = ahci_port_base(ap);
977 const u32 cmd_fis_len = 5; /* five dwords */ 1020 u8 *fis = pp->cmd_tbl;
1021 u32 tmp;
1022
1023 /* prep the command */
1024 ata_tf_to_fis(tf, pmp, is_cmd, fis);
1025 ahci_fill_cmd_slot(pp, 0, cmd_fis_len | flags | (pmp << 12));
1026
1027 /* issue & wait */
1028 writel(1, port_mmio + PORT_CMD_ISSUE);
1029
1030 if (timeout_msec) {
1031 tmp = ata_wait_register(port_mmio + PORT_CMD_ISSUE, 0x1, 0x1,
1032 1, timeout_msec);
1033 if (tmp & 0x1) {
1034 ahci_kick_engine(ap, 1);
1035 return -EBUSY;
1036 }
1037 } else
1038 readl(port_mmio + PORT_CMD_ISSUE); /* flush */
1039
1040 return 0;
1041}
1042
1043static int ahci_do_softreset(struct ata_port *ap, unsigned int *class,
1044 int pmp, unsigned long deadline)
1045{
978 const char *reason = NULL; 1046 const char *reason = NULL;
1047 unsigned long now, msecs;
979 struct ata_taskfile tf; 1048 struct ata_taskfile tf;
980 u32 tmp;
981 u8 *fis;
982 int rc; 1049 int rc;
983 1050
984 DPRINTK("ENTER\n"); 1051 DPRINTK("ENTER\n");
@@ -990,43 +1057,22 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class,
990 } 1057 }
991 1058
992 /* prepare for SRST (AHCI-1.1 10.4.1) */ 1059 /* prepare for SRST (AHCI-1.1 10.4.1) */
993 rc = ahci_stop_engine(ap); 1060 rc = ahci_kick_engine(ap, 1);
994 if (rc) { 1061 if (rc)
995 reason = "failed to stop engine"; 1062 ata_port_printk(ap, KERN_WARNING,
996 goto fail_restart; 1063 "failed to reset engine (errno=%d)", rc);
997 }
998
999 /* check BUSY/DRQ, perform Command List Override if necessary */
1000 if (ahci_check_status(ap) & (ATA_BUSY | ATA_DRQ)) {
1001 rc = ahci_clo(ap);
1002
1003 if (rc == -EOPNOTSUPP) {
1004 reason = "port busy but CLO unavailable";
1005 goto fail_restart;
1006 } else if (rc) {
1007 reason = "port busy but CLO failed";
1008 goto fail_restart;
1009 }
1010 }
1011
1012 /* restart engine */
1013 ahci_start_engine(ap);
1014 1064
1015 ata_tf_init(ap->device, &tf); 1065 ata_tf_init(ap->device, &tf);
1016 fis = pp->cmd_tbl;
1017 1066
1018 /* issue the first D2H Register FIS */ 1067 /* issue the first D2H Register FIS */
1019 ahci_fill_cmd_slot(pp, 0, 1068 msecs = 0;
1020 cmd_fis_len | AHCI_CMD_RESET | AHCI_CMD_CLR_BUSY); 1069 now = jiffies;
1070 if (time_after(now, deadline))
1071 msecs = jiffies_to_msecs(deadline - now);
1021 1072
1022 tf.ctl |= ATA_SRST; 1073 tf.ctl |= ATA_SRST;
1023 ata_tf_to_fis(&tf, fis, 0); 1074 if (ahci_exec_polled_cmd(ap, pmp, &tf, 0,
1024 fis[1] &= ~(1 << 7); /* turn off Command FIS bit */ 1075 AHCI_CMD_RESET | AHCI_CMD_CLR_BUSY, msecs)) {
1025
1026 writel(1, port_mmio + PORT_CMD_ISSUE);
1027
1028 tmp = ata_wait_register(port_mmio + PORT_CMD_ISSUE, 0x1, 0x1, 1, 500);
1029 if (tmp & 0x1) {
1030 rc = -EIO; 1076 rc = -EIO;
1031 reason = "1st FIS failed"; 1077 reason = "1st FIS failed";
1032 goto fail; 1078 goto fail;
@@ -1036,14 +1082,8 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class,
1036 msleep(1); 1082 msleep(1);
1037 1083
1038 /* issue the second D2H Register FIS */ 1084 /* issue the second D2H Register FIS */
1039 ahci_fill_cmd_slot(pp, 0, cmd_fis_len);
1040
1041 tf.ctl &= ~ATA_SRST; 1085 tf.ctl &= ~ATA_SRST;
1042 ata_tf_to_fis(&tf, fis, 0); 1086 ahci_exec_polled_cmd(ap, pmp, &tf, 0, 0, 0);
1043 fis[1] &= ~(1 << 7); /* turn off Command FIS bit */
1044
1045 writel(1, port_mmio + PORT_CMD_ISSUE);
1046 readl(port_mmio + PORT_CMD_ISSUE); /* flush */
1047 1087
1048 /* spec mandates ">= 2ms" before checking status. 1088 /* spec mandates ">= 2ms" before checking status.
1049 * We wait 150ms, because that was the magic delay used for 1089 * We wait 150ms, because that was the magic delay used for
@@ -1066,13 +1106,17 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class,
1066 DPRINTK("EXIT, class=%u\n", *class); 1106 DPRINTK("EXIT, class=%u\n", *class);
1067 return 0; 1107 return 0;
1068 1108
1069 fail_restart:
1070 ahci_start_engine(ap);
1071 fail: 1109 fail:
1072 ata_port_printk(ap, KERN_ERR, "softreset failed (%s)\n", reason); 1110 ata_port_printk(ap, KERN_ERR, "softreset failed (%s)\n", reason);
1073 return rc; 1111 return rc;
1074} 1112}
1075 1113
1114static int ahci_softreset(struct ata_port *ap, unsigned int *class,
1115 unsigned long deadline)
1116{
1117 return ahci_do_softreset(ap, class, 0, deadline);
1118}
1119
1076static int ahci_hardreset(struct ata_port *ap, unsigned int *class, 1120static int ahci_hardreset(struct ata_port *ap, unsigned int *class,
1077 unsigned long deadline) 1121 unsigned long deadline)
1078{ 1122{
@@ -1088,7 +1132,7 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class,
1088 /* clear D2H reception area to properly wait for D2H FIS */ 1132 /* clear D2H reception area to properly wait for D2H FIS */
1089 ata_tf_init(ap->device, &tf); 1133 ata_tf_init(ap->device, &tf);
1090 tf.command = 0x80; 1134 tf.command = 0x80;
1091 ata_tf_to_fis(&tf, d2h_fis, 0); 1135 ata_tf_to_fis(&tf, 0, 0, d2h_fis);
1092 1136
1093 rc = sata_std_hardreset(ap, class, deadline); 1137 rc = sata_std_hardreset(ap, class, deadline);
1094 1138
@@ -1106,6 +1150,7 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class,
1106static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class, 1150static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class,
1107 unsigned long deadline) 1151 unsigned long deadline)
1108{ 1152{
1153 u32 serror;
1109 int rc; 1154 int rc;
1110 1155
1111 DPRINTK("ENTER\n"); 1156 DPRINTK("ENTER\n");
@@ -1116,7 +1161,8 @@ static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class,
1116 deadline); 1161 deadline);
1117 1162
1118 /* vt8251 needs SError cleared for the port to operate */ 1163 /* vt8251 needs SError cleared for the port to operate */
1119 ahci_scr_write(ap, SCR_ERROR, ahci_scr_read(ap, SCR_ERROR)); 1164 ahci_scr_read(ap, SCR_ERROR, &serror);
1165 ahci_scr_write(ap, SCR_ERROR, serror);
1120 1166
1121 ahci_start_engine(ap); 1167 ahci_start_engine(ap);
1122 1168
@@ -1205,7 +1251,7 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
1205 */ 1251 */
1206 cmd_tbl = pp->cmd_tbl + qc->tag * AHCI_CMD_TBL_SZ; 1252 cmd_tbl = pp->cmd_tbl + qc->tag * AHCI_CMD_TBL_SZ;
1207 1253
1208 ata_tf_to_fis(&qc->tf, cmd_tbl, 0); 1254 ata_tf_to_fis(&qc->tf, 0, 1, cmd_tbl);
1209 if (is_atapi) { 1255 if (is_atapi) {
1210 memset(cmd_tbl + AHCI_CMD_TBL_CDB, 0, 32); 1256 memset(cmd_tbl + AHCI_CMD_TBL_CDB, 0, 32);
1211 memcpy(cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, qc->dev->cdb_len); 1257 memcpy(cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, qc->dev->cdb_len);
@@ -1238,7 +1284,7 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
1238 ata_ehi_clear_desc(ehi); 1284 ata_ehi_clear_desc(ehi);
1239 1285
1240 /* AHCI needs SError cleared; otherwise, it might lock up */ 1286 /* AHCI needs SError cleared; otherwise, it might lock up */
1241 serror = ahci_scr_read(ap, SCR_ERROR); 1287 ahci_scr_read(ap, SCR_ERROR, &serror);
1242 ahci_scr_write(ap, SCR_ERROR, serror); 1288 ahci_scr_write(ap, SCR_ERROR, serror);
1243 1289
1244 /* analyze @irq_stat */ 1290 /* analyze @irq_stat */
@@ -1262,12 +1308,12 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
1262 if (irq_stat & PORT_IRQ_IF_ERR) { 1308 if (irq_stat & PORT_IRQ_IF_ERR) {
1263 err_mask |= AC_ERR_ATA_BUS; 1309 err_mask |= AC_ERR_ATA_BUS;
1264 action |= ATA_EH_SOFTRESET; 1310 action |= ATA_EH_SOFTRESET;
1265 ata_ehi_push_desc(ehi, ", interface fatal error"); 1311 ata_ehi_push_desc(ehi, "interface fatal error");
1266 } 1312 }
1267 1313
1268 if (irq_stat & (PORT_IRQ_CONNECT | PORT_IRQ_PHYRDY)) { 1314 if (irq_stat & (PORT_IRQ_CONNECT | PORT_IRQ_PHYRDY)) {
1269 ata_ehi_hotplugged(ehi); 1315 ata_ehi_hotplugged(ehi);
1270 ata_ehi_push_desc(ehi, ", %s", irq_stat & PORT_IRQ_CONNECT ? 1316 ata_ehi_push_desc(ehi, "%s", irq_stat & PORT_IRQ_CONNECT ?
1271 "connection status changed" : "PHY RDY changed"); 1317 "connection status changed" : "PHY RDY changed");
1272 } 1318 }
1273 1319
@@ -1276,7 +1322,7 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
1276 1322
1277 err_mask |= AC_ERR_HSM; 1323 err_mask |= AC_ERR_HSM;
1278 action |= ATA_EH_SOFTRESET; 1324 action |= ATA_EH_SOFTRESET;
1279 ata_ehi_push_desc(ehi, ", unknown FIS %08x %08x %08x %08x", 1325 ata_ehi_push_desc(ehi, "unknown FIS %08x %08x %08x %08x",
1280 unk[0], unk[1], unk[2], unk[3]); 1326 unk[0], unk[1], unk[2], unk[3]);
1281 } 1327 }
1282 1328
@@ -1512,11 +1558,17 @@ static void ahci_post_internal_cmd(struct ata_queued_cmd *qc)
1512{ 1558{
1513 struct ata_port *ap = qc->ap; 1559 struct ata_port *ap = qc->ap;
1514 1560
1515 if (qc->flags & ATA_QCFLAG_FAILED) { 1561 /* make DMA engine forget about the failed command */
1516 /* make DMA engine forget about the failed command */ 1562 if (qc->flags & ATA_QCFLAG_FAILED)
1517 ahci_stop_engine(ap); 1563 ahci_kick_engine(ap, 1);
1518 ahci_start_engine(ap); 1564}
1519 } 1565
1566static int ahci_port_resume(struct ata_port *ap)
1567{
1568 ahci_power_up(ap);
1569 ahci_start_port(ap);
1570
1571 return 0;
1520} 1572}
1521 1573
1522#ifdef CONFIG_PM 1574#ifdef CONFIG_PM
@@ -1536,14 +1588,6 @@ static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg)
1536 return rc; 1588 return rc;
1537} 1589}
1538 1590
1539static int ahci_port_resume(struct ata_port *ap)
1540{
1541 ahci_power_up(ap);
1542 ahci_start_port(ap);
1543
1544 return 0;
1545}
1546
1547static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) 1591static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
1548{ 1592{
1549 struct ata_host *host = dev_get_drvdata(&pdev->dev); 1593 struct ata_host *host = dev_get_drvdata(&pdev->dev);
@@ -1734,12 +1778,13 @@ static void ahci_print_info(struct ata_host *host)
1734 1778
1735 dev_printk(KERN_INFO, &pdev->dev, 1779 dev_printk(KERN_INFO, &pdev->dev,
1736 "flags: " 1780 "flags: "
1737 "%s%s%s%s%s%s" 1781 "%s%s%s%s%s%s%s"
1738 "%s%s%s%s%s%s%s\n" 1782 "%s%s%s%s%s%s%s\n"
1739 , 1783 ,
1740 1784
1741 cap & (1 << 31) ? "64bit " : "", 1785 cap & (1 << 31) ? "64bit " : "",
1742 cap & (1 << 30) ? "ncq " : "", 1786 cap & (1 << 30) ? "ncq " : "",
1787 cap & (1 << 29) ? "sntf " : "",
1743 cap & (1 << 28) ? "ilck " : "", 1788 cap & (1 << 28) ? "ilck " : "",
1744 cap & (1 << 27) ? "stag " : "", 1789 cap & (1 << 27) ? "stag " : "",
1745 cap & (1 << 26) ? "pm " : "", 1790 cap & (1 << 26) ? "pm " : "",
@@ -1794,7 +1839,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1794 ahci_save_initial_config(pdev, &pi, hpriv); 1839 ahci_save_initial_config(pdev, &pi, hpriv);
1795 1840
1796 /* prepare host */ 1841 /* prepare host */
1797 if (!(pi.flags & AHCI_FLAG_NO_NCQ) && (hpriv->cap & HOST_CAP_NCQ)) 1842 if (hpriv->cap & HOST_CAP_NCQ)
1798 pi.flags |= ATA_FLAG_NCQ; 1843 pi.flags |= ATA_FLAG_NCQ;
1799 1844
1800 host = ata_host_alloc_pinfo(&pdev->dev, ppi, fls(hpriv->port_map)); 1845 host = ata_host_alloc_pinfo(&pdev->dev, ppi, fls(hpriv->port_map));
@@ -1808,10 +1853,8 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1808 void __iomem *port_mmio = ahci_port_base(ap); 1853 void __iomem *port_mmio = ahci_port_base(ap);
1809 1854
1810 /* standard SATA port setup */ 1855 /* standard SATA port setup */
1811 if (hpriv->port_map & (1 << i)) { 1856 if (hpriv->port_map & (1 << i))
1812 ap->ioaddr.cmd_addr = port_mmio; 1857 ap->ioaddr.cmd_addr = port_mmio;
1813 ap->ioaddr.scr_addr = port_mmio + PORT_SCR;
1814 }
1815 1858
1816 /* disabled/not-implemented port */ 1859 /* disabled/not-implemented port */
1817 else 1860 else