Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev

* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev:
libata: mask off DET when restoring SControl for detach
libata: implement ATA_HORKAGE_ATAPI_MOD16_DMA and apply it
libata: Fix a potential race condition in ata_scsi_park_show()
sata_nv: fix generic, nf2/3 detection regression
sata_via: restore vt*_prepare_host error handling
sata_promise: add ATA engine reset to reset ops

+58 -34
+4 -2
drivers/ata/libata-core.c
··· 4024 4024 4025 4025 /* Weird ATAPI devices */ 4026 4026 { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 }, 4027 + { "QUANTUM DAT DAT72-000", NULL, ATA_HORKAGE_ATAPI_MOD16_DMA }, 4027 4028 4028 4029 /* Devices we expect to fail diagnostics */ 4029 4030 ··· 4445 4444 /* Don't allow DMA if it isn't multiple of 16 bytes. Quite a 4446 4445 * few ATAPI devices choke on such DMA requests. 4447 4446 */ 4448 - if (unlikely(qc->nbytes & 15)) 4447 + if (!(qc->dev->horkage & ATA_HORKAGE_ATAPI_MOD16_DMA) && 4448 + unlikely(qc->nbytes & 15)) 4449 4449 return 1; 4450 4450 4451 4451 if (ap->ops->check_atapi_dma) ··· 5936 5934 * to us. Restore SControl and disable all existing devices. 5937 5935 */ 5938 5936 __ata_port_for_each_link(link, ap) { 5939 - sata_scr_write(link, SCR_CONTROL, link->saved_scontrol); 5937 + sata_scr_write(link, SCR_CONTROL, link->saved_scontrol & 0xff0); 5940 5938 ata_link_for_each_dev(dev, link) 5941 5939 ata_dev_disable(dev); 5942 5940 }
+4 -3
drivers/ata/libata-scsi.c
··· 190 190 struct ata_port *ap; 191 191 struct ata_link *link; 192 192 struct ata_device *dev; 193 - unsigned long flags; 193 + unsigned long flags, now; 194 194 unsigned int uninitialized_var(msecs); 195 195 int rc = 0; 196 196 ··· 208 208 } 209 209 210 210 link = dev->link; 211 + now = jiffies; 211 212 if (ap->pflags & ATA_PFLAG_EH_IN_PROGRESS && 212 213 link->eh_context.unloaded_mask & (1 << dev->devno) && 213 - time_after(dev->unpark_deadline, jiffies)) 214 - msecs = jiffies_to_msecs(dev->unpark_deadline - jiffies); 214 + time_after(dev->unpark_deadline, now)) 215 + msecs = jiffies_to_msecs(dev->unpark_deadline - now); 215 216 else 216 217 msecs = 0; 217 218
+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)
+20
drivers/ata/sata_promise.c
··· 153 153 static void pdc_sata_freeze(struct ata_port *ap); 154 154 static void pdc_thaw(struct ata_port *ap); 155 155 static void pdc_sata_thaw(struct ata_port *ap); 156 + static int pdc_pata_softreset(struct ata_link *link, unsigned int *class, 157 + unsigned long deadline); 158 + static int pdc_sata_hardreset(struct ata_link *link, unsigned int *class, 159 + unsigned long deadline); 156 160 static void pdc_error_handler(struct ata_port *ap); 157 161 static void pdc_post_internal_cmd(struct ata_queued_cmd *qc); 158 162 static int pdc_pata_cable_detect(struct ata_port *ap); ··· 190 186 .scr_read = pdc_sata_scr_read, 191 187 .scr_write = pdc_sata_scr_write, 192 188 .port_start = pdc_sata_port_start, 189 + .hardreset = pdc_sata_hardreset, 193 190 }; 194 191 195 192 /* First-generation chips need a more restrictive ->check_atapi_dma op */ ··· 205 200 .freeze = pdc_freeze, 206 201 .thaw = pdc_thaw, 207 202 .port_start = pdc_common_port_start, 203 + .softreset = pdc_pata_softreset, 208 204 }; 209 205 210 206 static const struct ata_port_info pdc_port_info[] = { ··· 697 691 hotplug_status &= ~(0x11 << (ata_no + 16)); 698 692 writel(hotplug_status, host_mmio + hotplug_offset); 699 693 readl(host_mmio + hotplug_offset); /* flush */ 694 + } 695 + 696 + static int pdc_pata_softreset(struct ata_link *link, unsigned int *class, 697 + unsigned long deadline) 698 + { 699 + pdc_reset_port(link->ap); 700 + return ata_sff_softreset(link, class, deadline); 701 + } 702 + 703 + static int pdc_sata_hardreset(struct ata_link *link, unsigned int *class, 704 + unsigned long deadline) 705 + { 706 + pdc_reset_port(link->ap); 707 + return sata_sff_hardreset(link, class, deadline); 700 708 } 701 709 702 710 static void pdc_error_handler(struct ata_port *ap)
+3 -1
drivers/ata/sata_via.c
··· 602 602 rc = vt8251_prepare_host(pdev, &host); 603 603 break; 604 604 default: 605 - return -EINVAL; 605 + rc = -EINVAL; 606 606 } 607 + if (rc) 608 + return rc; 607 609 608 610 svia_configure(pdev); 609 611
+2
include/linux/libata.h
··· 373 373 ATA_HORKAGE_IVB = (1 << 8), /* cbl det validity bit bugs */ 374 374 ATA_HORKAGE_STUCK_ERR = (1 << 9), /* stuck ERR on next PACKET */ 375 375 ATA_HORKAGE_BRIDGE_OK = (1 << 10), /* no bridge limits */ 376 + ATA_HORKAGE_ATAPI_MOD16_DMA = (1 << 11), /* use ATAPI DMA for commands 377 + not multiple of 16 bytes */ 376 378 377 379 /* DMA mask for user DMA control: User visible values; DO NOT 378 380 renumber */