sata_nv: fix generic, nf2/3 detection regression

All three flavors of sata_nv's are different in how their hardreset
behaves.

* generic: Hardreset is not reliable. Link often doesn't come online
after hardreset.

* nf2/3: A little bit better - link comes online with longer debounce
timing. However, nf2/3 can't reliable wait for the first D2H
Register FIS, so it can't wait for device readiness or classify the
device after hardreset. Follow-up SRST required.

* ck804: Hardreset finally works.

The core layer change to prefer hardreset and follow up changes
exposed the above issues and caused various detection regressions for
all three flavors. This patch, hopefully, fixes all the known issues
and should make sata_nv error handling more reliable.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>

authored by Tejun Heo and committed by Jeff Garzik 3c324283 554d491d

+25 -28
+25 -28
drivers/ata/sata_nv.c
··· 307 308 static void nv_nf2_freeze(struct ata_port *ap); 309 static void nv_nf2_thaw(struct ata_port *ap); 310 static void nv_ck804_freeze(struct ata_port *ap); 311 static void nv_ck804_thaw(struct ata_port *ap); 312 - static int nv_hardreset(struct ata_link *link, unsigned int *class, 313 - unsigned long deadline); 314 static int nv_adma_slave_config(struct scsi_device *sdev); 315 static int nv_adma_check_atapi_dma(struct ata_queued_cmd *qc); 316 static void nv_adma_qc_prep(struct ata_queued_cmd *qc); ··· 405 .slave_configure = nv_swncq_slave_config, 406 }; 407 408 - /* OSDL bz3352 reports that some nv controllers can't determine device 409 - * signature reliably and nv_hardreset is implemented to work around 410 - * the problem. This was reported on nf3 and it's unclear whether any 411 - * other controllers are affected. However, the workaround has been 412 - * applied to all variants and there isn't much to gain by trying to 413 - * find out exactly which ones are affected at this point especially 414 - * because NV has moved over to ahci for newer controllers. 415 - */ 416 static struct ata_port_operations nv_common_ops = { 417 .inherits = &ata_bmdma_port_ops, 418 - .hardreset = nv_hardreset, 419 .scr_read = nv_scr_read, 420 .scr_write = nv_scr_write, 421 }; ··· 420 .hardreset = ATA_OP_NULL, 421 }; 422 423 static struct ata_port_operations nv_nf2_ops = { 424 .inherits = &nv_common_ops, 425 .freeze = nv_nf2_freeze, 426 .thaw = nv_nf2_thaw, 427 }; 428 429 static struct ata_port_operations nv_ck804_ops = { 430 .inherits = &nv_common_ops, 431 .freeze = nv_ck804_freeze, ··· 444 }; 445 446 static struct ata_port_operations nv_adma_ops = { 447 - .inherits = &nv_common_ops, 448 449 .check_atapi_dma = nv_adma_check_atapi_dma, 450 .sff_tf_read = nv_adma_tf_read, ··· 468 }; 469 470 static struct ata_port_operations nv_swncq_ops = { 471 - .inherits = &nv_common_ops, 472 473 .qc_defer = ata_std_qc_defer, 474 .qc_prep = nv_swncq_qc_prep, ··· 1554 iowrite8(mask, scr_addr + NV_INT_ENABLE); 1555 } 1556 1557 static void nv_ck804_freeze(struct ata_port *ap) 1558 { 1559 void __iomem *mmio_base = ap->host->iomap[NV_MMIO_BAR]; ··· 1615 mask |= (NV_INT_MASK_MCP55 << shift); 1616 writel(mask, mmio_base + NV_INT_ENABLE_MCP55); 1617 ata_sff_thaw(ap); 1618 - } 1619 - 1620 - static int nv_hardreset(struct ata_link *link, unsigned int *class, 1621 - unsigned long deadline) 1622 - { 1623 - int rc; 1624 - 1625 - /* SATA hardreset fails to retrieve proper device signature on 1626 - * some controllers. Request follow up SRST. For more info, 1627 - * see http://bugzilla.kernel.org/show_bug.cgi?id=3352 1628 - */ 1629 - rc = sata_sff_hardreset(link, class, deadline); 1630 - if (rc) 1631 - return rc; 1632 - return -EAGAIN; 1633 } 1634 1635 static void nv_adma_error_handler(struct ata_port *ap)
··· 307 308 static void nv_nf2_freeze(struct ata_port *ap); 309 static void nv_nf2_thaw(struct ata_port *ap); 310 + static int nv_nf2_hardreset(struct ata_link *link, unsigned int *class, 311 + unsigned long deadline); 312 static void nv_ck804_freeze(struct ata_port *ap); 313 static void nv_ck804_thaw(struct ata_port *ap); 314 static int nv_adma_slave_config(struct scsi_device *sdev); 315 static int nv_adma_check_atapi_dma(struct ata_queued_cmd *qc); 316 static void nv_adma_qc_prep(struct ata_queued_cmd *qc); ··· 405 .slave_configure = nv_swncq_slave_config, 406 }; 407 408 static struct ata_port_operations nv_common_ops = { 409 .inherits = &ata_bmdma_port_ops, 410 .scr_read = nv_scr_read, 411 .scr_write = nv_scr_write, 412 }; ··· 429 .hardreset = ATA_OP_NULL, 430 }; 431 432 + /* OSDL bz3352 reports that nf2/3 controllers can't determine device 433 + * signature reliably. Also, the following thread reports detection 434 + * failure on cold boot with the standard debouncing timing. 435 + * 436 + * http://thread.gmane.org/gmane.linux.ide/34098 437 + * 438 + * Debounce with hotplug timing and request follow-up SRST. 439 + */ 440 static struct ata_port_operations nv_nf2_ops = { 441 .inherits = &nv_common_ops, 442 .freeze = nv_nf2_freeze, 443 .thaw = nv_nf2_thaw, 444 + .hardreset = nv_nf2_hardreset, 445 }; 446 447 + /* CK804 finally gets hardreset right */ 448 static struct ata_port_operations nv_ck804_ops = { 449 .inherits = &nv_common_ops, 450 .freeze = nv_ck804_freeze, ··· 443 }; 444 445 static struct ata_port_operations nv_adma_ops = { 446 + .inherits = &nv_ck804_ops, 447 448 .check_atapi_dma = nv_adma_check_atapi_dma, 449 .sff_tf_read = nv_adma_tf_read, ··· 467 }; 468 469 static struct ata_port_operations nv_swncq_ops = { 470 + .inherits = &nv_generic_ops, 471 472 .qc_defer = ata_std_qc_defer, 473 .qc_prep = nv_swncq_qc_prep, ··· 1553 iowrite8(mask, scr_addr + NV_INT_ENABLE); 1554 } 1555 1556 + static int nv_nf2_hardreset(struct ata_link *link, unsigned int *class, 1557 + unsigned long deadline) 1558 + { 1559 + bool online; 1560 + int rc; 1561 + 1562 + rc = sata_link_hardreset(link, sata_deb_timing_hotplug, deadline, 1563 + &online, NULL); 1564 + return online ? -EAGAIN : rc; 1565 + } 1566 + 1567 static void nv_ck804_freeze(struct ata_port *ap) 1568 { 1569 void __iomem *mmio_base = ap->host->iomap[NV_MMIO_BAR]; ··· 1603 mask |= (NV_INT_MASK_MCP55 << shift); 1604 writel(mask, mmio_base + NV_INT_ENABLE_MCP55); 1605 ata_sff_thaw(ap); 1606 } 1607 1608 static void nv_adma_error_handler(struct ata_port *ap)