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 307 308 308 static void nv_nf2_freeze(struct ata_port *ap); 309 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); 310 312 static void nv_ck804_freeze(struct ata_port *ap); 311 313 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 314 static int nv_adma_slave_config(struct scsi_device *sdev); 315 315 static int nv_adma_check_atapi_dma(struct ata_queued_cmd *qc); 316 316 static void nv_adma_qc_prep(struct ata_queued_cmd *qc); ··· 405 405 .slave_configure = nv_swncq_slave_config, 406 406 }; 407 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 408 static struct ata_port_operations nv_common_ops = { 417 409 .inherits = &ata_bmdma_port_ops, 418 - .hardreset = nv_hardreset, 419 410 .scr_read = nv_scr_read, 420 411 .scr_write = nv_scr_write, 421 412 }; ··· 420 429 .hardreset = ATA_OP_NULL, 421 430 }; 422 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 + */ 423 440 static struct ata_port_operations nv_nf2_ops = { 424 441 .inherits = &nv_common_ops, 425 442 .freeze = nv_nf2_freeze, 426 443 .thaw = nv_nf2_thaw, 444 + .hardreset = nv_nf2_hardreset, 427 445 }; 428 446 447 + /* CK804 finally gets hardreset right */ 429 448 static struct ata_port_operations nv_ck804_ops = { 430 449 .inherits = &nv_common_ops, 431 450 .freeze = nv_ck804_freeze, ··· 444 443 }; 445 444 446 445 static struct ata_port_operations nv_adma_ops = { 447 - .inherits = &nv_common_ops, 446 + .inherits = &nv_ck804_ops, 448 447 449 448 .check_atapi_dma = nv_adma_check_atapi_dma, 450 449 .sff_tf_read = nv_adma_tf_read, ··· 468 467 }; 469 468 470 469 static struct ata_port_operations nv_swncq_ops = { 471 - .inherits = &nv_common_ops, 470 + .inherits = &nv_generic_ops, 472 471 473 472 .qc_defer = ata_std_qc_defer, 474 473 .qc_prep = nv_swncq_qc_prep, ··· 1554 1553 iowrite8(mask, scr_addr + NV_INT_ENABLE); 1555 1554 } 1556 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 + 1557 1567 static void nv_ck804_freeze(struct ata_port *ap) 1558 1568 { 1559 1569 void __iomem *mmio_base = ap->host->iomap[NV_MMIO_BAR]; ··· 1615 1603 mask |= (NV_INT_MASK_MCP55 << shift); 1616 1604 writel(mask, mmio_base + NV_INT_ENABLE_MCP55); 1617 1605 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 1606 } 1634 1607 1635 1608 static void nv_adma_error_handler(struct ata_port *ap)