aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-02-10 15:04:59 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-02-10 15:04:59 -0500
commit4e54169986d5197cc51ee1069922364c9a92d1be (patch)
tree9a819b43351a2fd1bf1c9eb1bb028bfeb9b17141
parentfb0dc5f129bc2d4763bdc237b8df0e1708c03e1e (diff)
parent342decff2b846b46fa61eb5ee40986fab79a9a32 (diff)
Merge branch 'for-4.5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata fixes from Tejun Heo: - PORTS_IMPL workaround for very early ahci controllers is misbehaving on new systems. Disabled on recent ahci versions. - Old-style PIO state machine had a horrible locking problem. Don't know how we've been getting away this far. Fixed. - Other device specific updates. * 'for-4.5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: ahci: Intel DNV device IDs SATA libata: fix sff host state machine locking while polling libata-sff: use WARN instead of BUG on illegal host state machine state libata: disable forced PORTS_IMPL for >= AHCI 1.3 libata: blacklist a Viking flash model for MWDMA corruption drivers: ata: wake port before DMA stop for ALPM
-rw-r--r--drivers/ata/ahci.c20
-rw-r--r--drivers/ata/ahci.h1
-rw-r--r--drivers/ata/ahci_brcmstb.c1
-rw-r--r--drivers/ata/libahci.c27
-rw-r--r--drivers/ata/libata-core.c1
-rw-r--r--drivers/ata/libata-sff.c35
-rw-r--r--include/linux/libata.h1
7 files changed, 61 insertions, 25 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 594fcabd22cd..546a3692774f 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -264,6 +264,26 @@ static const struct pci_device_id ahci_pci_tbl[] = {
264 { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */ 264 { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */
265 { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH RAID */ 265 { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH RAID */
266 { PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */ 266 { PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */
267 { PCI_VDEVICE(INTEL, 0x19b0), board_ahci }, /* DNV AHCI */
268 { PCI_VDEVICE(INTEL, 0x19b1), board_ahci }, /* DNV AHCI */
269 { PCI_VDEVICE(INTEL, 0x19b2), board_ahci }, /* DNV AHCI */
270 { PCI_VDEVICE(INTEL, 0x19b3), board_ahci }, /* DNV AHCI */
271 { PCI_VDEVICE(INTEL, 0x19b4), board_ahci }, /* DNV AHCI */
272 { PCI_VDEVICE(INTEL, 0x19b5), board_ahci }, /* DNV AHCI */
273 { PCI_VDEVICE(INTEL, 0x19b6), board_ahci }, /* DNV AHCI */
274 { PCI_VDEVICE(INTEL, 0x19b7), board_ahci }, /* DNV AHCI */
275 { PCI_VDEVICE(INTEL, 0x19bE), board_ahci }, /* DNV AHCI */
276 { PCI_VDEVICE(INTEL, 0x19bF), board_ahci }, /* DNV AHCI */
277 { PCI_VDEVICE(INTEL, 0x19c0), board_ahci }, /* DNV AHCI */
278 { PCI_VDEVICE(INTEL, 0x19c1), board_ahci }, /* DNV AHCI */
279 { PCI_VDEVICE(INTEL, 0x19c2), board_ahci }, /* DNV AHCI */
280 { PCI_VDEVICE(INTEL, 0x19c3), board_ahci }, /* DNV AHCI */
281 { PCI_VDEVICE(INTEL, 0x19c4), board_ahci }, /* DNV AHCI */
282 { PCI_VDEVICE(INTEL, 0x19c5), board_ahci }, /* DNV AHCI */
283 { PCI_VDEVICE(INTEL, 0x19c6), board_ahci }, /* DNV AHCI */
284 { PCI_VDEVICE(INTEL, 0x19c7), board_ahci }, /* DNV AHCI */
285 { PCI_VDEVICE(INTEL, 0x19cE), board_ahci }, /* DNV AHCI */
286 { PCI_VDEVICE(INTEL, 0x19cF), board_ahci }, /* DNV AHCI */
267 { PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */ 287 { PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */
268 { PCI_VDEVICE(INTEL, 0x1c03), board_ahci }, /* CPT AHCI */ 288 { PCI_VDEVICE(INTEL, 0x1c03), board_ahci }, /* CPT AHCI */
269 { PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */ 289 { PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index a4faa438889c..a44c75d4c284 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -250,6 +250,7 @@ enum {
250 AHCI_HFLAG_MULTI_MSI = 0, 250 AHCI_HFLAG_MULTI_MSI = 0,
251 AHCI_HFLAG_MULTI_MSIX = 0, 251 AHCI_HFLAG_MULTI_MSIX = 0,
252#endif 252#endif
253 AHCI_HFLAG_WAKE_BEFORE_STOP = (1 << 22), /* wake before DMA stop */
253 254
254 /* ap->flags bits */ 255 /* ap->flags bits */
255 256
diff --git a/drivers/ata/ahci_brcmstb.c b/drivers/ata/ahci_brcmstb.c
index b36cae2fd04b..e87bcec0fd7c 100644
--- a/drivers/ata/ahci_brcmstb.c
+++ b/drivers/ata/ahci_brcmstb.c
@@ -317,6 +317,7 @@ static int brcm_ahci_probe(struct platform_device *pdev)
317 if (IS_ERR(hpriv)) 317 if (IS_ERR(hpriv))
318 return PTR_ERR(hpriv); 318 return PTR_ERR(hpriv);
319 hpriv->plat_data = priv; 319 hpriv->plat_data = priv;
320 hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP;
320 321
321 brcm_sata_alpm_init(hpriv); 322 brcm_sata_alpm_init(hpriv);
322 323
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index d61740e78d6d..402967902cbe 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -496,8 +496,8 @@ void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv)
496 } 496 }
497 } 497 }
498 498
499 /* fabricate port_map from cap.nr_ports */ 499 /* fabricate port_map from cap.nr_ports for < AHCI 1.3 */
500 if (!port_map) { 500 if (!port_map && vers < 0x10300) {
501 port_map = (1 << ahci_nr_ports(cap)) - 1; 501 port_map = (1 << ahci_nr_ports(cap)) - 1;
502 dev_warn(dev, "forcing PORTS_IMPL to 0x%x\n", port_map); 502 dev_warn(dev, "forcing PORTS_IMPL to 0x%x\n", port_map);
503 503
@@ -593,8 +593,22 @@ EXPORT_SYMBOL_GPL(ahci_start_engine);
593int ahci_stop_engine(struct ata_port *ap) 593int ahci_stop_engine(struct ata_port *ap)
594{ 594{
595 void __iomem *port_mmio = ahci_port_base(ap); 595 void __iomem *port_mmio = ahci_port_base(ap);
596 struct ahci_host_priv *hpriv = ap->host->private_data;
596 u32 tmp; 597 u32 tmp;
597 598
599 /*
600 * On some controllers, stopping a port's DMA engine while the port
601 * is in ALPM state (partial or slumber) results in failures on
602 * subsequent DMA engine starts. For those controllers, put the
603 * port back in active state before stopping its DMA engine.
604 */
605 if ((hpriv->flags & AHCI_HFLAG_WAKE_BEFORE_STOP) &&
606 (ap->link.lpm_policy > ATA_LPM_MAX_POWER) &&
607 ahci_set_lpm(&ap->link, ATA_LPM_MAX_POWER, ATA_LPM_WAKE_ONLY)) {
608 dev_err(ap->host->dev, "Failed to wake up port before engine stop\n");
609 return -EIO;
610 }
611
598 tmp = readl(port_mmio + PORT_CMD); 612 tmp = readl(port_mmio + PORT_CMD);
599 613
600 /* check if the HBA is idle */ 614 /* check if the HBA is idle */
@@ -689,6 +703,9 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
689 void __iomem *port_mmio = ahci_port_base(ap); 703 void __iomem *port_mmio = ahci_port_base(ap);
690 704
691 if (policy != ATA_LPM_MAX_POWER) { 705 if (policy != ATA_LPM_MAX_POWER) {
706 /* wakeup flag only applies to the max power policy */
707 hints &= ~ATA_LPM_WAKE_ONLY;
708
692 /* 709 /*
693 * Disable interrupts on Phy Ready. This keeps us from 710 * Disable interrupts on Phy Ready. This keeps us from
694 * getting woken up due to spurious phy ready 711 * getting woken up due to spurious phy ready
@@ -704,7 +721,8 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
704 u32 cmd = readl(port_mmio + PORT_CMD); 721 u32 cmd = readl(port_mmio + PORT_CMD);
705 722
706 if (policy == ATA_LPM_MAX_POWER || !(hints & ATA_LPM_HIPM)) { 723 if (policy == ATA_LPM_MAX_POWER || !(hints & ATA_LPM_HIPM)) {
707 cmd &= ~(PORT_CMD_ASP | PORT_CMD_ALPE); 724 if (!(hints & ATA_LPM_WAKE_ONLY))
725 cmd &= ~(PORT_CMD_ASP | PORT_CMD_ALPE);
708 cmd |= PORT_CMD_ICC_ACTIVE; 726 cmd |= PORT_CMD_ICC_ACTIVE;
709 727
710 writel(cmd, port_mmio + PORT_CMD); 728 writel(cmd, port_mmio + PORT_CMD);
@@ -712,6 +730,9 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
712 730
713 /* wait 10ms to be sure we've come out of LPM state */ 731 /* wait 10ms to be sure we've come out of LPM state */
714 ata_msleep(ap, 10); 732 ata_msleep(ap, 10);
733
734 if (hints & ATA_LPM_WAKE_ONLY)
735 return 0;
715 } else { 736 } else {
716 cmd |= PORT_CMD_ALPE; 737 cmd |= PORT_CMD_ALPE;
717 if (policy == ATA_LPM_MIN_POWER) 738 if (policy == ATA_LPM_MIN_POWER)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index cbb74719d2c1..55e257c268dd 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4125,6 +4125,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4125 { "SAMSUNG CD-ROM SN-124", "N001", ATA_HORKAGE_NODMA }, 4125 { "SAMSUNG CD-ROM SN-124", "N001", ATA_HORKAGE_NODMA },
4126 { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA }, 4126 { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA },
4127 { " 2GB ATA Flash Disk", "ADMA428M", ATA_HORKAGE_NODMA }, 4127 { " 2GB ATA Flash Disk", "ADMA428M", ATA_HORKAGE_NODMA },
4128 { "VRFDFC22048UCHC-TE*", NULL, ATA_HORKAGE_NODMA },
4128 /* Odd clown on sil3726/4726 PMPs */ 4129 /* Odd clown on sil3726/4726 PMPs */
4129 { "Config Disk", NULL, ATA_HORKAGE_DISABLE }, 4130 { "Config Disk", NULL, ATA_HORKAGE_DISABLE },
4130 4131
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index cdf6215a9a22..051b6158d1b7 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -997,12 +997,9 @@ static inline int ata_hsm_ok_in_wq(struct ata_port *ap,
997static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq) 997static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
998{ 998{
999 struct ata_port *ap = qc->ap; 999 struct ata_port *ap = qc->ap;
1000 unsigned long flags;
1001 1000
1002 if (ap->ops->error_handler) { 1001 if (ap->ops->error_handler) {
1003 if (in_wq) { 1002 if (in_wq) {
1004 spin_lock_irqsave(ap->lock, flags);
1005
1006 /* EH might have kicked in while host lock is 1003 /* EH might have kicked in while host lock is
1007 * released. 1004 * released.
1008 */ 1005 */
@@ -1014,8 +1011,6 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
1014 } else 1011 } else
1015 ata_port_freeze(ap); 1012 ata_port_freeze(ap);
1016 } 1013 }
1017
1018 spin_unlock_irqrestore(ap->lock, flags);
1019 } else { 1014 } else {
1020 if (likely(!(qc->err_mask & AC_ERR_HSM))) 1015 if (likely(!(qc->err_mask & AC_ERR_HSM)))
1021 ata_qc_complete(qc); 1016 ata_qc_complete(qc);
@@ -1024,10 +1019,8 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
1024 } 1019 }
1025 } else { 1020 } else {
1026 if (in_wq) { 1021 if (in_wq) {
1027 spin_lock_irqsave(ap->lock, flags);
1028 ata_sff_irq_on(ap); 1022 ata_sff_irq_on(ap);
1029 ata_qc_complete(qc); 1023 ata_qc_complete(qc);
1030 spin_unlock_irqrestore(ap->lock, flags);
1031 } else 1024 } else
1032 ata_qc_complete(qc); 1025 ata_qc_complete(qc);
1033 } 1026 }
@@ -1048,9 +1041,10 @@ int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
1048{ 1041{
1049 struct ata_link *link = qc->dev->link; 1042 struct ata_link *link = qc->dev->link;
1050 struct ata_eh_info *ehi = &link->eh_info; 1043 struct ata_eh_info *ehi = &link->eh_info;
1051 unsigned long flags = 0;
1052 int poll_next; 1044 int poll_next;
1053 1045
1046 lockdep_assert_held(ap->lock);
1047
1054 WARN_ON_ONCE((qc->flags & ATA_QCFLAG_ACTIVE) == 0); 1048 WARN_ON_ONCE((qc->flags & ATA_QCFLAG_ACTIVE) == 0);
1055 1049
1056 /* Make sure ata_sff_qc_issue() does not throw things 1050 /* Make sure ata_sff_qc_issue() does not throw things
@@ -1112,14 +1106,6 @@ fsm_start:
1112 } 1106 }
1113 } 1107 }
1114 1108
1115 /* Send the CDB (atapi) or the first data block (ata pio out).
1116 * During the state transition, interrupt handler shouldn't
1117 * be invoked before the data transfer is complete and
1118 * hsm_task_state is changed. Hence, the following locking.
1119 */
1120 if (in_wq)
1121 spin_lock_irqsave(ap->lock, flags);
1122
1123 if (qc->tf.protocol == ATA_PROT_PIO) { 1109 if (qc->tf.protocol == ATA_PROT_PIO) {
1124 /* PIO data out protocol. 1110 /* PIO data out protocol.
1125 * send first data block. 1111 * send first data block.
@@ -1135,9 +1121,6 @@ fsm_start:
1135 /* send CDB */ 1121 /* send CDB */
1136 atapi_send_cdb(ap, qc); 1122 atapi_send_cdb(ap, qc);
1137 1123
1138 if (in_wq)
1139 spin_unlock_irqrestore(ap->lock, flags);
1140
1141 /* if polling, ata_sff_pio_task() handles the rest. 1124 /* if polling, ata_sff_pio_task() handles the rest.
1142 * otherwise, interrupt handler takes over from here. 1125 * otherwise, interrupt handler takes over from here.
1143 */ 1126 */
@@ -1296,7 +1279,8 @@ fsm_start:
1296 break; 1279 break;
1297 default: 1280 default:
1298 poll_next = 0; 1281 poll_next = 0;
1299 BUG(); 1282 WARN(true, "ata%d: SFF host state machine in invalid state %d",
1283 ap->print_id, ap->hsm_task_state);
1300 } 1284 }
1301 1285
1302 return poll_next; 1286 return poll_next;
@@ -1361,12 +1345,14 @@ static void ata_sff_pio_task(struct work_struct *work)
1361 u8 status; 1345 u8 status;
1362 int poll_next; 1346 int poll_next;
1363 1347
1348 spin_lock_irq(ap->lock);
1349
1364 BUG_ON(ap->sff_pio_task_link == NULL); 1350 BUG_ON(ap->sff_pio_task_link == NULL);
1365 /* qc can be NULL if timeout occurred */ 1351 /* qc can be NULL if timeout occurred */
1366 qc = ata_qc_from_tag(ap, link->active_tag); 1352 qc = ata_qc_from_tag(ap, link->active_tag);
1367 if (!qc) { 1353 if (!qc) {
1368 ap->sff_pio_task_link = NULL; 1354 ap->sff_pio_task_link = NULL;
1369 return; 1355 goto out_unlock;
1370 } 1356 }
1371 1357
1372fsm_start: 1358fsm_start:
@@ -1381,11 +1367,14 @@ fsm_start:
1381 */ 1367 */
1382 status = ata_sff_busy_wait(ap, ATA_BUSY, 5); 1368 status = ata_sff_busy_wait(ap, ATA_BUSY, 5);
1383 if (status & ATA_BUSY) { 1369 if (status & ATA_BUSY) {
1370 spin_unlock_irq(ap->lock);
1384 ata_msleep(ap, 2); 1371 ata_msleep(ap, 2);
1372 spin_lock_irq(ap->lock);
1373
1385 status = ata_sff_busy_wait(ap, ATA_BUSY, 10); 1374 status = ata_sff_busy_wait(ap, ATA_BUSY, 10);
1386 if (status & ATA_BUSY) { 1375 if (status & ATA_BUSY) {
1387 ata_sff_queue_pio_task(link, ATA_SHORT_PAUSE); 1376 ata_sff_queue_pio_task(link, ATA_SHORT_PAUSE);
1388 return; 1377 goto out_unlock;
1389 } 1378 }
1390 } 1379 }
1391 1380
@@ -1402,6 +1391,8 @@ fsm_start:
1402 */ 1391 */
1403 if (poll_next) 1392 if (poll_next)
1404 goto fsm_start; 1393 goto fsm_start;
1394out_unlock:
1395 spin_unlock_irq(ap->lock);
1405} 1396}
1406 1397
1407/** 1398/**
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 851821bfd553..bec2abbd7ab2 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -526,6 +526,7 @@ enum ata_lpm_policy {
526enum ata_lpm_hints { 526enum ata_lpm_hints {
527 ATA_LPM_EMPTY = (1 << 0), /* port empty/probing */ 527 ATA_LPM_EMPTY = (1 << 0), /* port empty/probing */
528 ATA_LPM_HIPM = (1 << 1), /* may use HIPM */ 528 ATA_LPM_HIPM = (1 << 1), /* may use HIPM */
529 ATA_LPM_WAKE_ONLY = (1 << 2), /* only wake up link */
529}; 530};
530 531
531/* forward declarations */ 532/* forward declarations */