aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r--drivers/ata/libata-core.c108
1 files changed, 24 insertions, 84 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 81898036dbca..33f06277b3be 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -30,6 +30,14 @@
30 * Hardware documentation available from http://www.t13.org/ and 30 * Hardware documentation available from http://www.t13.org/ and
31 * http://www.sata-io.org/ 31 * http://www.sata-io.org/
32 * 32 *
33 * Standards documents from:
34 * http://www.t13.org (ATA standards, PCI DMA IDE spec)
35 * http://www.t10.org (SCSI MMC - for ATAPI MMC)
36 * http://www.sata-io.org (SATA)
37 * http://www.compactflash.org (CF)
38 * http://www.qic.org (QIC157 - Tape and DSC)
39 * http://www.ce-ata.org (CE-ATA: not supported)
40 *
33 */ 41 */
34 42
35#include <linux/kernel.h> 43#include <linux/kernel.h>
@@ -2307,8 +2315,10 @@ int ata_dev_configure(struct ata_device *dev)
2307 } 2315 }
2308 2316
2309 if ((dev->class == ATA_DEV_ATAPI) && 2317 if ((dev->class == ATA_DEV_ATAPI) &&
2310 (atapi_command_packet_set(id) == TYPE_TAPE)) 2318 (atapi_command_packet_set(id) == TYPE_TAPE)) {
2311 dev->max_sectors = ATA_MAX_SECTORS_TAPE; 2319 dev->max_sectors = ATA_MAX_SECTORS_TAPE;
2320 dev->horkage |= ATA_HORKAGE_STUCK_ERR;
2321 }
2312 2322
2313 if (dev->horkage & ATA_HORKAGE_MAX_SEC_128) 2323 if (dev->horkage & ATA_HORKAGE_MAX_SEC_128)
2314 dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128, 2324 dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128,
@@ -2581,81 +2591,6 @@ void sata_print_link_status(struct ata_link *link)
2581} 2591}
2582 2592
2583/** 2593/**
2584 * __sata_phy_reset - Wake/reset a low-level SATA PHY
2585 * @ap: SATA port associated with target SATA PHY.
2586 *
2587 * This function issues commands to standard SATA Sxxx
2588 * PHY registers, to wake up the phy (and device), and
2589 * clear any reset condition.
2590 *
2591 * LOCKING:
2592 * PCI/etc. bus probe sem.
2593 *
2594 */
2595void __sata_phy_reset(struct ata_port *ap)
2596{
2597 struct ata_link *link = &ap->link;
2598 unsigned long timeout = jiffies + (HZ * 5);
2599 u32 sstatus;
2600
2601 if (ap->flags & ATA_FLAG_SATA_RESET) {
2602 /* issue phy wake/reset */
2603 sata_scr_write_flush(link, SCR_CONTROL, 0x301);
2604 /* Couldn't find anything in SATA I/II specs, but
2605 * AHCI-1.1 10.4.2 says at least 1 ms. */
2606 mdelay(1);
2607 }
2608 /* phy wake/clear reset */
2609 sata_scr_write_flush(link, SCR_CONTROL, 0x300);
2610
2611 /* wait for phy to become ready, if necessary */
2612 do {
2613 msleep(200);
2614 sata_scr_read(link, SCR_STATUS, &sstatus);
2615 if ((sstatus & 0xf) != 1)
2616 break;
2617 } while (time_before(jiffies, timeout));
2618
2619 /* print link status */
2620 sata_print_link_status(link);
2621
2622 /* TODO: phy layer with polling, timeouts, etc. */
2623 if (!ata_link_offline(link))
2624 ata_port_probe(ap);
2625 else
2626 ata_port_disable(ap);
2627
2628 if (ap->flags & ATA_FLAG_DISABLED)
2629 return;
2630
2631 if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) {
2632 ata_port_disable(ap);
2633 return;
2634 }
2635
2636 ap->cbl = ATA_CBL_SATA;
2637}
2638
2639/**
2640 * sata_phy_reset - Reset SATA bus.
2641 * @ap: SATA port associated with target SATA PHY.
2642 *
2643 * This function resets the SATA bus, and then probes
2644 * the bus for devices.
2645 *
2646 * LOCKING:
2647 * PCI/etc. bus probe sem.
2648 *
2649 */
2650void sata_phy_reset(struct ata_port *ap)
2651{
2652 __sata_phy_reset(ap);
2653 if (ap->flags & ATA_FLAG_DISABLED)
2654 return;
2655 ata_bus_reset(ap);
2656}
2657
2658/**
2659 * ata_dev_pair - return other device on cable 2594 * ata_dev_pair - return other device on cable
2660 * @adev: device 2595 * @adev: device
2661 * 2596 *
@@ -5490,11 +5425,19 @@ fsm_start:
5490 * let the EH abort the command or reset the device. 5425 * let the EH abort the command or reset the device.
5491 */ 5426 */
5492 if (unlikely(status & (ATA_ERR | ATA_DF))) { 5427 if (unlikely(status & (ATA_ERR | ATA_DF))) {
5493 ata_port_printk(ap, KERN_WARNING, "DRQ=1 with device " 5428 /* Some ATAPI tape drives forget to clear the ERR bit
5494 "error, dev_stat 0x%X\n", status); 5429 * when doing the next command (mostly request sense).
5495 qc->err_mask |= AC_ERR_HSM; 5430 * We ignore ERR here to workaround and proceed sending
5496 ap->hsm_task_state = HSM_ST_ERR; 5431 * the CDB.
5497 goto fsm_start; 5432 */
5433 if (!(qc->dev->horkage & ATA_HORKAGE_STUCK_ERR)) {
5434 ata_port_printk(ap, KERN_WARNING,
5435 "DRQ=1 with device error, "
5436 "dev_stat 0x%X\n", status);
5437 qc->err_mask |= AC_ERR_HSM;
5438 ap->hsm_task_state = HSM_ST_ERR;
5439 goto fsm_start;
5440 }
5498 } 5441 }
5499 5442
5500 /* Send the CDB (atapi) or the first data block (ata pio out). 5443 /* Send the CDB (atapi) or the first data block (ata pio out).
@@ -7653,8 +7596,6 @@ EXPORT_SYMBOL_GPL(ata_dev_disable);
7653EXPORT_SYMBOL_GPL(sata_set_spd); 7596EXPORT_SYMBOL_GPL(sata_set_spd);
7654EXPORT_SYMBOL_GPL(sata_link_debounce); 7597EXPORT_SYMBOL_GPL(sata_link_debounce);
7655EXPORT_SYMBOL_GPL(sata_link_resume); 7598EXPORT_SYMBOL_GPL(sata_link_resume);
7656EXPORT_SYMBOL_GPL(sata_phy_reset);
7657EXPORT_SYMBOL_GPL(__sata_phy_reset);
7658EXPORT_SYMBOL_GPL(ata_bus_reset); 7599EXPORT_SYMBOL_GPL(ata_bus_reset);
7659EXPORT_SYMBOL_GPL(ata_std_prereset); 7600EXPORT_SYMBOL_GPL(ata_std_prereset);
7660EXPORT_SYMBOL_GPL(ata_std_softreset); 7601EXPORT_SYMBOL_GPL(ata_std_softreset);
@@ -7725,7 +7666,6 @@ EXPORT_SYMBOL_GPL(ata_port_desc);
7725#ifdef CONFIG_PCI 7666#ifdef CONFIG_PCI
7726EXPORT_SYMBOL_GPL(ata_port_pbar_desc); 7667EXPORT_SYMBOL_GPL(ata_port_pbar_desc);
7727#endif /* CONFIG_PCI */ 7668#endif /* CONFIG_PCI */
7728EXPORT_SYMBOL_GPL(ata_eng_timeout);
7729EXPORT_SYMBOL_GPL(ata_port_schedule_eh); 7669EXPORT_SYMBOL_GPL(ata_port_schedule_eh);
7730EXPORT_SYMBOL_GPL(ata_link_abort); 7670EXPORT_SYMBOL_GPL(ata_link_abort);
7731EXPORT_SYMBOL_GPL(ata_port_abort); 7671EXPORT_SYMBOL_GPL(ata_port_abort);