aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/Kconfig4
-rw-r--r--drivers/scsi/libata-bmdma.c37
-rw-r--r--drivers/scsi/libata-core.c27
-rw-r--r--drivers/scsi/libata-scsi.c140
-rw-r--r--drivers/scsi/pdc_adma.c2
-rw-r--r--drivers/scsi/sata_mv.c5
-rw-r--r--drivers/scsi/sata_svw.c56
-rw-r--r--drivers/scsi/sata_vsc.c124
-rw-r--r--include/linux/ata.h7
-rw-r--r--include/linux/libata.h4
10 files changed, 254 insertions, 152 deletions
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 5c94a5d4efc0..4035920ce3d8 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -595,10 +595,10 @@ config SCSI_SATA_VIA
595 If unsure, say N. 595 If unsure, say N.
596 596
597config SCSI_SATA_VITESSE 597config SCSI_SATA_VITESSE
598 tristate "VITESSE VSC-7174 SATA support" 598 tristate "VITESSE VSC-7174 / INTEL 31244 SATA support"
599 depends on SCSI_SATA && PCI 599 depends on SCSI_SATA && PCI
600 help 600 help
601 This option enables support for Vitesse VSC7174 Serial ATA. 601 This option enables support for Vitesse VSC7174 and Intel 31244 Serial ATA.
602 602
603 If unsure, say N. 603 If unsure, say N.
604 604
diff --git a/drivers/scsi/libata-bmdma.c b/drivers/scsi/libata-bmdma.c
index a93336adcd23..999725ca8d09 100644
--- a/drivers/scsi/libata-bmdma.c
+++ b/drivers/scsi/libata-bmdma.c
@@ -648,6 +648,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
648 goto err_out_regions; 648 goto err_out_regions;
649 } 649 }
650 650
651 /* FIXME: If we get no DMA mask we should fall back to PIO */
651 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); 652 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
652 if (rc) 653 if (rc)
653 goto err_out_regions; 654 goto err_out_regions;
@@ -699,5 +700,41 @@ err_out:
699 return rc; 700 return rc;
700} 701}
701 702
703/**
704 * ata_pci_clear_simplex - attempt to kick device out of simplex
705 * @pdev: PCI device
706 *
707 * Some PCI ATA devices report simplex mode but in fact can be told to
708 * enter non simplex mode. This implements the neccessary logic to
709 * perform the task on such devices. Calling it on other devices will
710 * have -undefined- behaviour.
711 */
712
713int ata_pci_clear_simplex(struct pci_dev *pdev)
714{
715 unsigned long bmdma = pci_resource_start(pdev, 4);
716 u8 simplex;
717
718 if (bmdma == 0)
719 return -ENOENT;
720
721 simplex = inb(bmdma + 0x02);
722 outb(simplex & 0x60, bmdma + 0x02);
723 simplex = inb(bmdma + 0x02);
724 if (simplex & 0x80)
725 return -EOPNOTSUPP;
726 return 0;
727}
728
729unsigned long ata_pci_default_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long xfer_mask)
730{
731 /* Filter out DMA modes if the device has been configured by
732 the BIOS as PIO only */
733
734 if (ap->ioaddr.bmdma_addr == 0)
735 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
736 return xfer_mask;
737}
738
702#endif /* CONFIG_PCI */ 739#endif /* CONFIG_PCI */
703 740
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 714b42bad935..c8d2201b126f 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -962,6 +962,8 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
962 spin_unlock_irqrestore(&ap->host_set->lock, flags); 962 spin_unlock_irqrestore(&ap->host_set->lock, flags);
963 963
964 if (!wait_for_completion_timeout(&wait, ATA_TMOUT_INTERNAL)) { 964 if (!wait_for_completion_timeout(&wait, ATA_TMOUT_INTERNAL)) {
965 ata_port_flush_task(ap);
966
965 spin_lock_irqsave(&ap->host_set->lock, flags); 967 spin_lock_irqsave(&ap->host_set->lock, flags);
966 968
967 /* We're racing with irq here. If we lose, the 969 /* We're racing with irq here. If we lose, the
@@ -1737,7 +1739,7 @@ static int ata_host_set_pio(struct ata_port *ap)
1737 continue; 1739 continue;
1738 1740
1739 if (!dev->pio_mode) { 1741 if (!dev->pio_mode) {
1740 printk(KERN_WARNING "ata%u: no PIO support\n", ap->id); 1742 printk(KERN_WARNING "ata%u: no PIO support for device %d.\n", ap->id, i);
1741 return -1; 1743 return -1;
1742 } 1744 }
1743 1745
@@ -2863,6 +2865,8 @@ void ata_qc_prep(struct ata_queued_cmd *qc)
2863 ata_fill_sg(qc); 2865 ata_fill_sg(qc);
2864} 2866}
2865 2867
2868void ata_noop_qc_prep(struct ata_queued_cmd *qc) { }
2869
2866/** 2870/**
2867 * ata_sg_init_one - Associate command with memory buffer 2871 * ata_sg_init_one - Associate command with memory buffer
2868 * @qc: Command to be associated 2872 * @qc: Command to be associated
@@ -3907,7 +3911,6 @@ static inline int ata_should_dma_map(struct ata_queued_cmd *qc)
3907 3911
3908 case ATA_PROT_ATAPI: 3912 case ATA_PROT_ATAPI:
3909 case ATA_PROT_PIO: 3913 case ATA_PROT_PIO:
3910 case ATA_PROT_PIO_MULT:
3911 if (ap->flags & ATA_FLAG_PIO_DMA) 3914 if (ap->flags & ATA_FLAG_PIO_DMA)
3912 return 1; 3915 return 1;
3913 3916
@@ -4199,14 +4202,17 @@ void ata_bmdma_setup(struct ata_queued_cmd *qc)
4199 4202
4200void ata_bmdma_irq_clear(struct ata_port *ap) 4203void ata_bmdma_irq_clear(struct ata_port *ap)
4201{ 4204{
4202 if (ap->flags & ATA_FLAG_MMIO) { 4205 if (!ap->ioaddr.bmdma_addr)
4203 void __iomem *mmio = ((void __iomem *) ap->ioaddr.bmdma_addr) + ATA_DMA_STATUS; 4206 return;
4204 writeb(readb(mmio), mmio);
4205 } else {
4206 unsigned long addr = ap->ioaddr.bmdma_addr + ATA_DMA_STATUS;
4207 outb(inb(addr), addr);
4208 }
4209 4207
4208 if (ap->flags & ATA_FLAG_MMIO) {
4209 void __iomem *mmio =
4210 ((void __iomem *) ap->ioaddr.bmdma_addr) + ATA_DMA_STATUS;
4211 writeb(readb(mmio), mmio);
4212 } else {
4213 unsigned long addr = ap->ioaddr.bmdma_addr + ATA_DMA_STATUS;
4214 outb(inb(addr), addr);
4215 }
4210} 4216}
4211 4217
4212 4218
@@ -4337,9 +4343,9 @@ idle_irq:
4337 4343
4338#ifdef ATA_IRQ_TRAP 4344#ifdef ATA_IRQ_TRAP
4339 if ((ap->stats.idle_irq % 1000) == 0) { 4345 if ((ap->stats.idle_irq % 1000) == 0) {
4340 handled = 1;
4341 ata_irq_ack(ap, 0); /* debug trap */ 4346 ata_irq_ack(ap, 0); /* debug trap */
4342 printk(KERN_WARNING "ata%d: irq trap\n", ap->id); 4347 printk(KERN_WARNING "ata%d: irq trap\n", ap->id);
4348 return 1;
4343 } 4349 }
4344#endif 4350#endif
4345 return 0; /* irq not handled */ 4351 return 0; /* irq not handled */
@@ -5062,6 +5068,7 @@ EXPORT_SYMBOL_GPL(ata_port_stop);
5062EXPORT_SYMBOL_GPL(ata_host_stop); 5068EXPORT_SYMBOL_GPL(ata_host_stop);
5063EXPORT_SYMBOL_GPL(ata_interrupt); 5069EXPORT_SYMBOL_GPL(ata_interrupt);
5064EXPORT_SYMBOL_GPL(ata_qc_prep); 5070EXPORT_SYMBOL_GPL(ata_qc_prep);
5071EXPORT_SYMBOL_GPL(ata_noop_qc_prep);
5065EXPORT_SYMBOL_GPL(ata_bmdma_setup); 5072EXPORT_SYMBOL_GPL(ata_bmdma_setup);
5066EXPORT_SYMBOL_GPL(ata_bmdma_start); 5073EXPORT_SYMBOL_GPL(ata_bmdma_start);
5067EXPORT_SYMBOL_GPL(ata_bmdma_irq_clear); 5074EXPORT_SYMBOL_GPL(ata_bmdma_irq_clear);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index ccedb4536977..dd954a23b357 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -511,13 +511,11 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
511 printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n", 511 printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n",
512 id, drv_stat); 512 id, drv_stat);
513 513
514 /* For our last chance pick, use medium read error because 514 /* We need a sensible error return here, which is tricky, and one
515 * it's much more common than an ATA drive telling you a write 515 that won't cause people to do things like return a disk wrongly */
516 * has failed. 516 *sk = ABORTED_COMMAND;
517 */ 517 *asc = 0x00;
518 *sk = MEDIUM_ERROR; 518 *ascq = 0x00;
519 *asc = 0x11; /* "unrecovered read error" */
520 *ascq = 0x04; /* "auto-reallocation failed" */
521 519
522 translate_done: 520 translate_done:
523 printk(KERN_ERR "ata%u: translated ATA stat/err 0x%02x/%02x to " 521 printk(KERN_ERR "ata%u: translated ATA stat/err 0x%02x/%02x to "
@@ -662,6 +660,41 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
662 } 660 }
663} 661}
664 662
663static void ata_scsi_sdev_config(struct scsi_device *sdev)
664{
665 sdev->use_10_for_rw = 1;
666 sdev->use_10_for_ms = 1;
667}
668
669static void ata_scsi_dev_config(struct scsi_device *sdev,
670 struct ata_device *dev)
671{
672 unsigned int max_sectors;
673
674 /* TODO: 2048 is an arbitrary number, not the
675 * hardware maximum. This should be increased to
676 * 65534 when Jens Axboe's patch for dynamically
677 * determining max_sectors is merged.
678 */
679 max_sectors = ATA_MAX_SECTORS;
680 if (dev->flags & ATA_DFLAG_LBA48)
681 max_sectors = 2048;
682 if (dev->max_sectors)
683 max_sectors = dev->max_sectors;
684
685 blk_queue_max_sectors(sdev->request_queue, max_sectors);
686
687 /*
688 * SATA DMA transfers must be multiples of 4 byte, so
689 * we need to pad ATAPI transfers using an extra sg.
690 * Decrement max hw segments accordingly.
691 */
692 if (dev->class == ATA_DEV_ATAPI) {
693 request_queue_t *q = sdev->request_queue;
694 blk_queue_max_hw_segments(q, q->max_hw_segments - 1);
695 }
696}
697
665/** 698/**
666 * ata_scsi_slave_config - Set SCSI device attributes 699 * ata_scsi_slave_config - Set SCSI device attributes
667 * @sdev: SCSI device to examine 700 * @sdev: SCSI device to examine
@@ -676,41 +709,18 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
676 709
677int ata_scsi_slave_config(struct scsi_device *sdev) 710int ata_scsi_slave_config(struct scsi_device *sdev)
678{ 711{
679 sdev->use_10_for_rw = 1; 712 ata_scsi_sdev_config(sdev);
680 sdev->use_10_for_ms = 1;
681 713
682 blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD); 714 blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD);
683 715
684 if (sdev->id < ATA_MAX_DEVICES) { 716 if (sdev->id < ATA_MAX_DEVICES) {
685 struct ata_port *ap; 717 struct ata_port *ap;
686 struct ata_device *dev; 718 struct ata_device *dev;
687 unsigned int max_sectors;
688 719
689 ap = (struct ata_port *) &sdev->host->hostdata[0]; 720 ap = (struct ata_port *) &sdev->host->hostdata[0];
690 dev = &ap->device[sdev->id]; 721 dev = &ap->device[sdev->id];
691 722
692 /* TODO: 2048 is an arbitrary number, not the 723 ata_scsi_dev_config(sdev, dev);
693 * hardware maximum. This should be increased to
694 * 65534 when Jens Axboe's patch for dynamically
695 * determining max_sectors is merged.
696 */
697 max_sectors = ATA_MAX_SECTORS;
698 if (dev->flags & ATA_DFLAG_LBA48)
699 max_sectors = 2048;
700 if (dev->max_sectors)
701 max_sectors = dev->max_sectors;
702
703 blk_queue_max_sectors(sdev->request_queue, max_sectors);
704
705 /*
706 * SATA DMA transfers must be multiples of 4 byte, so
707 * we need to pad ATAPI transfers using an extra sg.
708 * Decrement max hw segments accordingly.
709 */
710 if (dev->class == ATA_DEV_ATAPI) {
711 request_queue_t *q = sdev->request_queue;
712 blk_queue_max_hw_segments(q, q->max_hw_segments - 1);
713 }
714 } 724 }
715 725
716 return 0; /* scsi layer doesn't check return value, sigh */ 726 return 0; /* scsi layer doesn't check return value, sigh */
@@ -1542,7 +1552,7 @@ void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
1542 * @buflen: Response buffer length. 1552 * @buflen: Response buffer length.
1543 * 1553 *
1544 * Returns standard device identification data associated 1554 * Returns standard device identification data associated
1545 * with non-EVPD INQUIRY command output. 1555 * with non-VPD INQUIRY command output.
1546 * 1556 *
1547 * LOCKING: 1557 * LOCKING:
1548 * spin_lock_irqsave(host_set lock) 1558 * spin_lock_irqsave(host_set lock)
@@ -1593,12 +1603,12 @@ unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
1593} 1603}
1594 1604
1595/** 1605/**
1596 * ata_scsiop_inq_00 - Simulate INQUIRY EVPD page 0, list of pages 1606 * ata_scsiop_inq_00 - Simulate INQUIRY VPD page 0, list of pages
1597 * @args: device IDENTIFY data / SCSI command of interest. 1607 * @args: device IDENTIFY data / SCSI command of interest.
1598 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. 1608 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
1599 * @buflen: Response buffer length. 1609 * @buflen: Response buffer length.
1600 * 1610 *
1601 * Returns list of inquiry EVPD pages available. 1611 * Returns list of inquiry VPD pages available.
1602 * 1612 *
1603 * LOCKING: 1613 * LOCKING:
1604 * spin_lock_irqsave(host_set lock) 1614 * spin_lock_irqsave(host_set lock)
@@ -1612,7 +1622,7 @@ unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf,
1612 0x80, /* page 0x80, unit serial no page */ 1622 0x80, /* page 0x80, unit serial no page */
1613 0x83 /* page 0x83, device ident page */ 1623 0x83 /* page 0x83, device ident page */
1614 }; 1624 };
1615 rbuf[3] = sizeof(pages); /* number of supported EVPD pages */ 1625 rbuf[3] = sizeof(pages); /* number of supported VPD pages */
1616 1626
1617 if (buflen > 6) 1627 if (buflen > 6)
1618 memcpy(rbuf + 4, pages, sizeof(pages)); 1628 memcpy(rbuf + 4, pages, sizeof(pages));
@@ -1621,7 +1631,7 @@ unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf,
1621} 1631}
1622 1632
1623/** 1633/**
1624 * ata_scsiop_inq_80 - Simulate INQUIRY EVPD page 80, device serial number 1634 * ata_scsiop_inq_80 - Simulate INQUIRY VPD page 80, device serial number
1625 * @args: device IDENTIFY data / SCSI command of interest. 1635 * @args: device IDENTIFY data / SCSI command of interest.
1626 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. 1636 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
1627 * @buflen: Response buffer length. 1637 * @buflen: Response buffer length.
@@ -1650,16 +1660,16 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
1650 return 0; 1660 return 0;
1651} 1661}
1652 1662
1653static const char * const inq_83_str = "Linux ATA-SCSI simulator";
1654
1655/** 1663/**
1656 * ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity 1664 * ata_scsiop_inq_83 - Simulate INQUIRY VPD page 83, device identity
1657 * @args: device IDENTIFY data / SCSI command of interest. 1665 * @args: device IDENTIFY data / SCSI command of interest.
1658 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. 1666 * @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
1659 * @buflen: Response buffer length. 1667 * @buflen: Response buffer length.
1660 * 1668 *
1661 * Returns device identification. Currently hardcoded to 1669 * Yields two logical unit device identification designators:
1662 * return "Linux ATA-SCSI simulator". 1670 * - vendor specific ASCII containing the ATA serial number
1671 * - SAT defined "t10 vendor id based" containing ASCII vendor
1672 * name ("ATA "), model and serial numbers.
1663 * 1673 *
1664 * LOCKING: 1674 * LOCKING:
1665 * spin_lock_irqsave(host_set lock) 1675 * spin_lock_irqsave(host_set lock)
@@ -1668,16 +1678,39 @@ static const char * const inq_83_str = "Linux ATA-SCSI simulator";
1668unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf, 1678unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
1669 unsigned int buflen) 1679 unsigned int buflen)
1670{ 1680{
1671 rbuf[1] = 0x83; /* this page code */ 1681 int num;
1672 rbuf[3] = 4 + strlen(inq_83_str); /* page len */ 1682 const int sat_model_serial_desc_len = 68;
1683 const int ata_model_byte_len = 40;
1673 1684
1674 /* our one and only identification descriptor (vendor-specific) */ 1685 rbuf[1] = 0x83; /* this page code */
1675 if (buflen > (strlen(inq_83_str) + 4 + 4 - 1)) { 1686 num = 4;
1676 rbuf[4 + 0] = 2; /* code set: ASCII */ 1687
1677 rbuf[4 + 3] = strlen(inq_83_str); 1688 if (buflen > (ATA_SERNO_LEN + num + 3)) {
1678 memcpy(rbuf + 4 + 4, inq_83_str, strlen(inq_83_str)); 1689 /* piv=0, assoc=lu, code_set=ACSII, designator=vendor */
1690 rbuf[num + 0] = 2;
1691 rbuf[num + 3] = ATA_SERNO_LEN;
1692 num += 4;
1693 ata_id_string(args->id, (unsigned char *) rbuf + num,
1694 ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
1695 num += ATA_SERNO_LEN;
1679 } 1696 }
1680 1697 if (buflen > (sat_model_serial_desc_len + num + 3)) {
1698 /* SAT defined lu model and serial numbers descriptor */
1699 /* piv=0, assoc=lu, code_set=ACSII, designator=t10 vendor id */
1700 rbuf[num + 0] = 2;
1701 rbuf[num + 1] = 1;
1702 rbuf[num + 3] = sat_model_serial_desc_len;
1703 num += 4;
1704 memcpy(rbuf + num, "ATA ", 8);
1705 num += 8;
1706 ata_id_string(args->id, (unsigned char *) rbuf + num,
1707 ATA_ID_PROD_OFS, ata_model_byte_len);
1708 num += ata_model_byte_len;
1709 ata_id_string(args->id, (unsigned char *) rbuf + num,
1710 ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
1711 num += ATA_SERNO_LEN;
1712 }
1713 rbuf[3] = num - 4; /* page len (assume less than 256 bytes) */
1681 return 0; 1714 return 0;
1682} 1715}
1683 1716
@@ -2356,9 +2389,6 @@ ata_scsi_map_proto(u8 byte1)
2356 2389
2357 case 4: /* PIO Data-in */ 2390 case 4: /* PIO Data-in */
2358 case 5: /* PIO Data-out */ 2391 case 5: /* PIO Data-out */
2359 if (byte1 & 0xe0) {
2360 return ATA_PROT_PIO_MULT;
2361 }
2362 return ATA_PROT_PIO; 2392 return ATA_PROT_PIO;
2363 2393
2364 case 10: /* Device Reset */ 2394 case 10: /* Device Reset */
@@ -2397,6 +2427,10 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
2397 if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN) 2427 if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN)
2398 goto invalid_fld; 2428 goto invalid_fld;
2399 2429
2430 if (scsicmd[1] & 0xe0)
2431 /* PIO multi not supported yet */
2432 goto invalid_fld;
2433
2400 /* 2434 /*
2401 * 12 and 16 byte CDBs use different offsets to 2435 * 12 and 16 byte CDBs use different offsets to
2402 * provide the various register values. 2436 * provide the various register values.
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index 5f33cc932e70..b7b2300f6768 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -322,7 +322,7 @@ static int adma_fill_sg(struct ata_queued_cmd *qc)
322 = (pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4); 322 = (pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4);
323 i += 4; 323 i += 4;
324 324
325 VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", nelem, 325 VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", i/4,
326 (unsigned long)addr, len); 326 (unsigned long)addr, len);
327 } 327 }
328 return i; 328 return i;
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index e561281967dd..eed67ae2dc08 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -1263,6 +1263,7 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
1263 void __iomem *port_mmio = mv_ap_base(ap); 1263 void __iomem *port_mmio = mv_ap_base(ap);
1264 struct mv_port_priv *pp = ap->private_data; 1264 struct mv_port_priv *pp = ap->private_data;
1265 u32 out_ptr; 1265 u32 out_ptr;
1266 u8 ata_status;
1266 1267
1267 out_ptr = readl(port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 1268 out_ptr = readl(port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
1268 1269
@@ -1270,6 +1271,8 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
1270 WARN_ON(((out_ptr >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) != 1271 WARN_ON(((out_ptr >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) !=
1271 pp->rsp_consumer); 1272 pp->rsp_consumer);
1272 1273
1274 ata_status = pp->crpb[pp->rsp_consumer].flags >> CRPB_FLAG_STATUS_SHIFT;
1275
1273 /* increment our consumer index... */ 1276 /* increment our consumer index... */
1274 pp->rsp_consumer = mv_inc_q_index(&pp->rsp_consumer); 1277 pp->rsp_consumer = mv_inc_q_index(&pp->rsp_consumer);
1275 1278
@@ -1284,7 +1287,7 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
1284 writelfl(out_ptr, port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 1287 writelfl(out_ptr, port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
1285 1288
1286 /* Return ATA status register for completed CRPB */ 1289 /* Return ATA status register for completed CRPB */
1287 return (pp->crpb[pp->rsp_consumer].flags >> CRPB_FLAG_STATUS_SHIFT); 1290 return ata_status;
1288} 1291}
1289 1292
1290/** 1293/**
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index 4aaccd53e736..b023b6958487 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -56,33 +56,35 @@
56#define DRV_NAME "sata_svw" 56#define DRV_NAME "sata_svw"
57#define DRV_VERSION "1.07" 57#define DRV_VERSION "1.07"
58 58
59/* Taskfile registers offsets */ 59enum {
60#define K2_SATA_TF_CMD_OFFSET 0x00 60 /* Taskfile registers offsets */
61#define K2_SATA_TF_DATA_OFFSET 0x00 61 K2_SATA_TF_CMD_OFFSET = 0x00,
62#define K2_SATA_TF_ERROR_OFFSET 0x04 62 K2_SATA_TF_DATA_OFFSET = 0x00,
63#define K2_SATA_TF_NSECT_OFFSET 0x08 63 K2_SATA_TF_ERROR_OFFSET = 0x04,
64#define K2_SATA_TF_LBAL_OFFSET 0x0c 64 K2_SATA_TF_NSECT_OFFSET = 0x08,
65#define K2_SATA_TF_LBAM_OFFSET 0x10 65 K2_SATA_TF_LBAL_OFFSET = 0x0c,
66#define K2_SATA_TF_LBAH_OFFSET 0x14 66 K2_SATA_TF_LBAM_OFFSET = 0x10,
67#define K2_SATA_TF_DEVICE_OFFSET 0x18 67 K2_SATA_TF_LBAH_OFFSET = 0x14,
68#define K2_SATA_TF_CMDSTAT_OFFSET 0x1c 68 K2_SATA_TF_DEVICE_OFFSET = 0x18,
69#define K2_SATA_TF_CTL_OFFSET 0x20 69 K2_SATA_TF_CMDSTAT_OFFSET = 0x1c,
70 70 K2_SATA_TF_CTL_OFFSET = 0x20,
71/* DMA base */ 71
72#define K2_SATA_DMA_CMD_OFFSET 0x30 72 /* DMA base */
73 73 K2_SATA_DMA_CMD_OFFSET = 0x30,
74/* SCRs base */ 74
75#define K2_SATA_SCR_STATUS_OFFSET 0x40 75 /* SCRs base */
76#define K2_SATA_SCR_ERROR_OFFSET 0x44 76 K2_SATA_SCR_STATUS_OFFSET = 0x40,
77#define K2_SATA_SCR_CONTROL_OFFSET 0x48 77 K2_SATA_SCR_ERROR_OFFSET = 0x44,
78 78 K2_SATA_SCR_CONTROL_OFFSET = 0x48,
79/* Others */ 79
80#define K2_SATA_SICR1_OFFSET 0x80 80 /* Others */
81#define K2_SATA_SICR2_OFFSET 0x84 81 K2_SATA_SICR1_OFFSET = 0x80,
82#define K2_SATA_SIM_OFFSET 0x88 82 K2_SATA_SICR2_OFFSET = 0x84,
83 83 K2_SATA_SIM_OFFSET = 0x88,
84/* Port stride */ 84
85#define K2_SATA_PORT_OFFSET 0x100 85 /* Port stride */
86 K2_SATA_PORT_OFFSET = 0x100,
87};
86 88
87static u8 k2_stat_check_status(struct ata_port *ap); 89static u8 k2_stat_check_status(struct ata_port *ap);
88 90
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index b574379a7a82..fbf0713f9aba 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -47,52 +47,58 @@
47#include <linux/libata.h> 47#include <linux/libata.h>
48 48
49#define DRV_NAME "sata_vsc" 49#define DRV_NAME "sata_vsc"
50#define DRV_VERSION "1.1" 50#define DRV_VERSION "1.2"
51 51
52/* Interrupt register offsets (from chip base address) */ 52enum {
53#define VSC_SATA_INT_STAT_OFFSET 0x00 53 /* Interrupt register offsets (from chip base address) */
54#define VSC_SATA_INT_MASK_OFFSET 0x04 54 VSC_SATA_INT_STAT_OFFSET = 0x00,
55 55 VSC_SATA_INT_MASK_OFFSET = 0x04,
56/* Taskfile registers offsets */ 56
57#define VSC_SATA_TF_CMD_OFFSET 0x00 57 /* Taskfile registers offsets */
58#define VSC_SATA_TF_DATA_OFFSET 0x00 58 VSC_SATA_TF_CMD_OFFSET = 0x00,
59#define VSC_SATA_TF_ERROR_OFFSET 0x04 59 VSC_SATA_TF_DATA_OFFSET = 0x00,
60#define VSC_SATA_TF_FEATURE_OFFSET 0x06 60 VSC_SATA_TF_ERROR_OFFSET = 0x04,
61#define VSC_SATA_TF_NSECT_OFFSET 0x08 61 VSC_SATA_TF_FEATURE_OFFSET = 0x06,
62#define VSC_SATA_TF_LBAL_OFFSET 0x0c 62 VSC_SATA_TF_NSECT_OFFSET = 0x08,
63#define VSC_SATA_TF_LBAM_OFFSET 0x10 63 VSC_SATA_TF_LBAL_OFFSET = 0x0c,
64#define VSC_SATA_TF_LBAH_OFFSET 0x14 64 VSC_SATA_TF_LBAM_OFFSET = 0x10,
65#define VSC_SATA_TF_DEVICE_OFFSET 0x18 65 VSC_SATA_TF_LBAH_OFFSET = 0x14,
66#define VSC_SATA_TF_STATUS_OFFSET 0x1c 66 VSC_SATA_TF_DEVICE_OFFSET = 0x18,
67#define VSC_SATA_TF_COMMAND_OFFSET 0x1d 67 VSC_SATA_TF_STATUS_OFFSET = 0x1c,
68#define VSC_SATA_TF_ALTSTATUS_OFFSET 0x28 68 VSC_SATA_TF_COMMAND_OFFSET = 0x1d,
69#define VSC_SATA_TF_CTL_OFFSET 0x29 69 VSC_SATA_TF_ALTSTATUS_OFFSET = 0x28,
70 70 VSC_SATA_TF_CTL_OFFSET = 0x29,
71/* DMA base */ 71
72#define VSC_SATA_UP_DESCRIPTOR_OFFSET 0x64 72 /* DMA base */
73#define VSC_SATA_UP_DATA_BUFFER_OFFSET 0x6C 73 VSC_SATA_UP_DESCRIPTOR_OFFSET = 0x64,
74#define VSC_SATA_DMA_CMD_OFFSET 0x70 74 VSC_SATA_UP_DATA_BUFFER_OFFSET = 0x6C,
75 75 VSC_SATA_DMA_CMD_OFFSET = 0x70,
76/* SCRs base */ 76
77#define VSC_SATA_SCR_STATUS_OFFSET 0x100 77 /* SCRs base */
78#define VSC_SATA_SCR_ERROR_OFFSET 0x104 78 VSC_SATA_SCR_STATUS_OFFSET = 0x100,
79#define VSC_SATA_SCR_CONTROL_OFFSET 0x108 79 VSC_SATA_SCR_ERROR_OFFSET = 0x104,
80 80 VSC_SATA_SCR_CONTROL_OFFSET = 0x108,
81/* Port stride */ 81
82#define VSC_SATA_PORT_OFFSET 0x200 82 /* Port stride */
83 83 VSC_SATA_PORT_OFFSET = 0x200,
84/* Error interrupt status bit offsets */ 84
85#define VSC_SATA_INT_ERROR_E_OFFSET 2 85 /* Error interrupt status bit offsets */
86#define VSC_SATA_INT_ERROR_P_OFFSET 4 86 VSC_SATA_INT_ERROR_CRC = 0x40,
87#define VSC_SATA_INT_ERROR_T_OFFSET 5 87 VSC_SATA_INT_ERROR_T = 0x20,
88#define VSC_SATA_INT_ERROR_M_OFFSET 1 88 VSC_SATA_INT_ERROR_P = 0x10,
89 VSC_SATA_INT_ERROR_R = 0x8,
90 VSC_SATA_INT_ERROR_E = 0x4,
91 VSC_SATA_INT_ERROR_M = 0x2,
92 VSC_SATA_INT_PHY_CHANGE = 0x1,
93 VSC_SATA_INT_ERROR = (VSC_SATA_INT_ERROR_CRC | VSC_SATA_INT_ERROR_T | \
94 VSC_SATA_INT_ERROR_P | VSC_SATA_INT_ERROR_R | \
95 VSC_SATA_INT_ERROR_E | VSC_SATA_INT_ERROR_M | \
96 VSC_SATA_INT_PHY_CHANGE),
97};
98
99
89#define is_vsc_sata_int_err(port_idx, int_status) \ 100#define is_vsc_sata_int_err(port_idx, int_status) \
90 (int_status & ((1 << (VSC_SATA_INT_ERROR_E_OFFSET + (8 * port_idx))) | \ 101 (int_status & (VSC_SATA_INT_ERROR << (8 * port_idx)))
91 (1 << (VSC_SATA_INT_ERROR_P_OFFSET + (8 * port_idx))) | \
92 (1 << (VSC_SATA_INT_ERROR_T_OFFSET + (8 * port_idx))) | \
93 (1 << (VSC_SATA_INT_ERROR_M_OFFSET + (8 * port_idx))) \
94 )\
95 )
96 102
97 103
98static u32 vsc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) 104static u32 vsc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
@@ -215,14 +221,6 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
215 221
216 ap = host_set->ports[i]; 222 ap = host_set->ports[i];
217 223
218 if (is_vsc_sata_int_err(i, int_status)) {
219 u32 err_status;
220 printk(KERN_DEBUG "%s: ignoring interrupt(s)\n", __FUNCTION__);
221 err_status = ap ? vsc_sata_scr_read(ap, SCR_ERROR) : 0;
222 vsc_sata_scr_write(ap, SCR_ERROR, err_status);
223 handled++;
224 }
225
226 if (ap && !(ap->flags & 224 if (ap && !(ap->flags &
227 (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) { 225 (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) {
228 struct ata_queued_cmd *qc; 226 struct ata_queued_cmd *qc;
@@ -230,12 +228,26 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
230 qc = ata_qc_from_tag(ap, ap->active_tag); 228 qc = ata_qc_from_tag(ap, ap->active_tag);
231 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 229 if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
232 handled += ata_host_intr(ap, qc); 230 handled += ata_host_intr(ap, qc);
233 } else { 231 } else if (is_vsc_sata_int_err(i, int_status)) {
234 printk(KERN_DEBUG "%s: ignoring interrupt(s)\n", __FUNCTION__); 232 /*
233 * On some chips (i.e. Intel 31244), an error
234 * interrupt will sneak in at initialization
235 * time (phy state changes). Clearing the SCR
236 * error register is not required, but it prevents
237 * the phy state change interrupts from recurring
238 * later.
239 */
240 u32 err_status;
241 err_status = vsc_sata_scr_read(ap, SCR_ERROR);
242 printk(KERN_DEBUG "%s: clearing interrupt, "
243 "status %x; sata err status %x\n",
244 __FUNCTION__,
245 int_status, err_status);
246 vsc_sata_scr_write(ap, SCR_ERROR, err_status);
247 /* Clear interrupt status */
235 ata_chk_status(ap); 248 ata_chk_status(ap);
236 handled++; 249 handled++;
237 } 250 }
238
239 } 251 }
240 } 252 }
241 } 253 }
diff --git a/include/linux/ata.h b/include/linux/ata.h
index b02a16c435e7..312a2c0c64e6 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -146,6 +146,8 @@ enum {
146 ATA_CMD_STANDBYNOW1 = 0xE0, 146 ATA_CMD_STANDBYNOW1 = 0xE0,
147 ATA_CMD_IDLEIMMEDIATE = 0xE1, 147 ATA_CMD_IDLEIMMEDIATE = 0xE1,
148 ATA_CMD_INIT_DEV_PARAMS = 0x91, 148 ATA_CMD_INIT_DEV_PARAMS = 0x91,
149 ATA_CMD_READ_NATIVE_MAX = 0xF8,
150 ATA_CMD_READ_NATIVE_MAX_EXT = 0x27,
149 151
150 /* SETFEATURES stuff */ 152 /* SETFEATURES stuff */
151 SETFEATURES_XFER = 0x03, 153 SETFEATURES_XFER = 0x03,
@@ -204,7 +206,6 @@ enum ata_tf_protocols {
204 ATA_PROT_UNKNOWN, /* unknown/invalid */ 206 ATA_PROT_UNKNOWN, /* unknown/invalid */
205 ATA_PROT_NODATA, /* no data */ 207 ATA_PROT_NODATA, /* no data */
206 ATA_PROT_PIO, /* PIO single sector */ 208 ATA_PROT_PIO, /* PIO single sector */
207 ATA_PROT_PIO_MULT, /* PIO multiple sector */
208 ATA_PROT_DMA, /* DMA */ 209 ATA_PROT_DMA, /* DMA */
209 ATA_PROT_ATAPI, /* packet command, PIO data xfer*/ 210 ATA_PROT_ATAPI, /* packet command, PIO data xfer*/
210 ATA_PROT_ATAPI_NODATA, /* packet command, no data */ 211 ATA_PROT_ATAPI_NODATA, /* packet command, no data */
@@ -247,18 +248,22 @@ struct ata_taskfile {
247}; 248};
248 249
249#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) 250#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0)
251#define ata_id_is_cfa(id) ((id)[0] == 0x848A)
250#define ata_id_is_sata(id) ((id)[93] == 0) 252#define ata_id_is_sata(id) ((id)[93] == 0)
251#define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6)) 253#define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6))
252#define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5)) 254#define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5))
255#define ata_id_hpa_enabled(id) ((id)[85] & (1 << 10))
253#define ata_id_has_fua(id) ((id)[84] & (1 << 6)) 256#define ata_id_has_fua(id) ((id)[84] & (1 << 6))
254#define ata_id_has_flush(id) ((id)[83] & (1 << 12)) 257#define ata_id_has_flush(id) ((id)[83] & (1 << 12))
255#define ata_id_has_flush_ext(id) ((id)[83] & (1 << 13)) 258#define ata_id_has_flush_ext(id) ((id)[83] & (1 << 13))
256#define ata_id_has_lba48(id) ((id)[83] & (1 << 10)) 259#define ata_id_has_lba48(id) ((id)[83] & (1 << 10))
260#define ata_id_has_hpa(id) ((id)[82] & (1 << 10))
257#define ata_id_has_wcache(id) ((id)[82] & (1 << 5)) 261#define ata_id_has_wcache(id) ((id)[82] & (1 << 5))
258#define ata_id_has_pm(id) ((id)[82] & (1 << 3)) 262#define ata_id_has_pm(id) ((id)[82] & (1 << 3))
259#define ata_id_has_lba(id) ((id)[49] & (1 << 9)) 263#define ata_id_has_lba(id) ((id)[49] & (1 << 9))
260#define ata_id_has_dma(id) ((id)[49] & (1 << 8)) 264#define ata_id_has_dma(id) ((id)[49] & (1 << 8))
261#define ata_id_removeable(id) ((id)[0] & (1 << 7)) 265#define ata_id_removeable(id) ((id)[0] & (1 << 7))
266#define ata_id_has_dword_io(id) ((id)[50] & (1 << 0))
262#define ata_id_u32(id,n) \ 267#define ata_id_u32(id,n) \
263 (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)])) 268 (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)]))
264#define ata_id_u64(id,n) \ 269#define ata_id_u64(id,n) \
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 239408ecfddf..d81cecdda4f3 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -502,6 +502,7 @@ extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_i
502extern void ata_pci_remove_one (struct pci_dev *pdev); 502extern void ata_pci_remove_one (struct pci_dev *pdev);
503extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state); 503extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state);
504extern int ata_pci_device_resume(struct pci_dev *pdev); 504extern int ata_pci_device_resume(struct pci_dev *pdev);
505extern int ata_pci_clear_simplex(struct pci_dev *pdev);
505#endif /* CONFIG_PCI */ 506#endif /* CONFIG_PCI */
506extern int ata_device_add(const struct ata_probe_ent *ent); 507extern int ata_device_add(const struct ata_probe_ent *ent);
507extern void ata_host_set_remove(struct ata_host_set *host_set); 508extern void ata_host_set_remove(struct ata_host_set *host_set);
@@ -543,6 +544,7 @@ extern void ata_port_stop (struct ata_port *ap);
543extern void ata_host_stop (struct ata_host_set *host_set); 544extern void ata_host_stop (struct ata_host_set *host_set);
544extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs); 545extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
545extern void ata_qc_prep(struct ata_queued_cmd *qc); 546extern void ata_qc_prep(struct ata_queued_cmd *qc);
547extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
546extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); 548extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc);
547extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, 549extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf,
548 unsigned int buflen); 550 unsigned int buflen);
@@ -609,7 +611,7 @@ extern void ata_pci_host_stop (struct ata_host_set *host_set);
609extern struct ata_probe_ent * 611extern struct ata_probe_ent *
610ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask); 612ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask);
611extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); 613extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
612 614extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long);
613#endif /* CONFIG_PCI */ 615#endif /* CONFIG_PCI */
614 616
615 617