aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-09-11 19:38:33 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-11 19:38:33 -0400
commit86373435d2299b722ec87c416005953215f049c1 (patch)
tree40d9c8e8bdf2f48b9c69c3423cdad3c0feded67e /drivers
parent483e3cd6a34ad2d7e41100bc1b98614ac42a4567 (diff)
parentc984123c7a888731b7e971e1c878b6f2b716b292 (diff)
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: (25 commits) pata_rz1000: use printk_once ahci: kill @force_restart and refine CLO for ahci_kick_engine() pata_cs5535: add pci id for AMD based CS5535 controllers ahci: Add AMD SB900 SATA/IDE controller device IDs drivers/ata: use resource_size sata_fsl: Defer non-ncq commands when ncq commands active libata: add SATA PMP revision information for spec 1.2 libata: fix off-by-one error in ata_tf_read_block() ahci: Gigabyte GA-MA69VM-S2 can't do 64bit DMA ahci: make ahci_asus_m2a_vm_32bit_only() quirk more generic dmi: extend dmi_get_year() to dmi_get_date() dmi: fix date handling in dmi_get_year() libata: unbreak TPM filtering by reorganizing ata_scsi_pass_thru() sata_sis: convert to slave_link sata_sil24: always set protocol override for non-ATAPI data commands libata: Export AHCI capabilities libata: Delegate nonrot flag setting to SCSI [libata] Add pata_rdc driver for RDC ATA devices drivers/ata: Remove unnecessary semicolons libata: remove spindown skipping and warning ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/blacklist.c5
-rw-r--r--drivers/ata/Kconfig21
-rw-r--r--drivers/ata/Makefile1
-rw-r--r--drivers/ata/ahci.c143
-rw-r--r--drivers/ata/libata-acpi.c7
-rw-r--r--drivers/ata/libata-core.c44
-rw-r--r--drivers/ata/libata-eh.c146
-rw-r--r--drivers/ata/libata-pmp.c2
-rw-r--r--drivers/ata/libata-scsi.c159
-rw-r--r--drivers/ata/libata.h1
-rw-r--r--drivers/ata/pata_atiixp.c1
-rw-r--r--drivers/ata/pata_cs5535.c3
-rw-r--r--drivers/ata/pata_octeon_cf.c4
-rw-r--r--drivers/ata/pata_platform.c8
-rw-r--r--drivers/ata/pata_rb532_cf.c2
-rw-r--r--drivers/ata/pata_rdc.c400
-rw-r--r--drivers/ata/pata_rz1000.c4
-rw-r--r--drivers/ata/sata_fsl.c1
-rw-r--r--drivers/ata/sata_inic162x.c2
-rw-r--r--drivers/ata/sata_mv.c2
-rw-r--r--drivers/ata/sata_sil.c13
-rw-r--r--drivers/ata/sata_sil24.c11
-rw-r--r--drivers/ata/sata_sis.c75
-rw-r--r--drivers/firmware/dmi_scan.c77
-rw-r--r--drivers/ide/atiixp.c1
-rw-r--r--drivers/pci/quirks.c4
26 files changed, 891 insertions, 246 deletions
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index f6baa77deefb..0c4ca4d318b3 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -78,9 +78,10 @@ static struct acpi_blacklist_item acpi_blacklist[] __initdata = {
78 78
79static int __init blacklist_by_year(void) 79static int __init blacklist_by_year(void)
80{ 80{
81 int year = dmi_get_year(DMI_BIOS_DATE); 81 int year;
82
82 /* Doesn't exist? Likely an old system */ 83 /* Doesn't exist? Likely an old system */
83 if (year == -1) { 84 if (!dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL)) {
84 printk(KERN_ERR PREFIX "no DMI BIOS year, " 85 printk(KERN_ERR PREFIX "no DMI BIOS year, "
85 "acpi=force is required to enable ACPI\n" ); 86 "acpi=force is required to enable ACPI\n" );
86 return 1; 87 return 1;
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index b17c57f85032..ab2fa4eeb364 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -26,6 +26,17 @@ config ATA_NONSTANDARD
26 bool 26 bool
27 default n 27 default n
28 28
29config ATA_VERBOSE_ERROR
30 bool "Verbose ATA error reporting"
31 default y
32 help
33 This option adds parsing of ATA command descriptions and error bits
34 in libata kernel output, making it easier to interpret.
35 This option will enlarge the kernel by approx. 6KB. Disable it only
36 if kernel size is more important than ease of debugging.
37
38 If unsure, say Y.
39
29config ATA_ACPI 40config ATA_ACPI
30 bool "ATA ACPI Support" 41 bool "ATA ACPI Support"
31 depends on ACPI && PCI 42 depends on ACPI && PCI
@@ -586,6 +597,16 @@ config PATA_RB532
586 597
587 If unsure, say N. 598 If unsure, say N.
588 599
600config PATA_RDC
601 tristate "RDC PATA support"
602 depends on PCI
603 help
604 This option enables basic support for the later RDC PATA controllers
605 controllers via the new ATA layer. For the RDC 1010, you need to
606 enable the IT821X driver instead.
607
608 If unsure, say N.
609
589config PATA_RZ1000 610config PATA_RZ1000
590 tristate "PC Tech RZ1000 PATA support" 611 tristate "PC Tech RZ1000 PATA support"
591 depends on PCI 612 depends on PCI
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 38906f9bbb4e..463eb52236aa 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_PATA_PDC_OLD) += pata_pdc202xx_old.o
57obj-$(CONFIG_PATA_QDI) += pata_qdi.o 57obj-$(CONFIG_PATA_QDI) += pata_qdi.o
58obj-$(CONFIG_PATA_RADISYS) += pata_radisys.o 58obj-$(CONFIG_PATA_RADISYS) += pata_radisys.o
59obj-$(CONFIG_PATA_RB532) += pata_rb532_cf.o 59obj-$(CONFIG_PATA_RB532) += pata_rb532_cf.o
60obj-$(CONFIG_PATA_RDC) += pata_rdc.o
60obj-$(CONFIG_PATA_RZ1000) += pata_rz1000.o 61obj-$(CONFIG_PATA_RZ1000) += pata_rz1000.o
61obj-$(CONFIG_PATA_SC1200) += pata_sc1200.o 62obj-$(CONFIG_PATA_SC1200) += pata_sc1200.o
62obj-$(CONFIG_PATA_SERVERWORKS) += pata_serverworks.o 63obj-$(CONFIG_PATA_SERVERWORKS) += pata_serverworks.o
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index fe3eba5d6b3e..d4cd9c203314 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -329,10 +329,24 @@ static ssize_t ahci_activity_store(struct ata_device *dev,
329 enum sw_activity val); 329 enum sw_activity val);
330static void ahci_init_sw_activity(struct ata_link *link); 330static void ahci_init_sw_activity(struct ata_link *link);
331 331
332static ssize_t ahci_show_host_caps(struct device *dev,
333 struct device_attribute *attr, char *buf);
334static ssize_t ahci_show_host_version(struct device *dev,
335 struct device_attribute *attr, char *buf);
336static ssize_t ahci_show_port_cmd(struct device *dev,
337 struct device_attribute *attr, char *buf);
338
339DEVICE_ATTR(ahci_host_caps, S_IRUGO, ahci_show_host_caps, NULL);
340DEVICE_ATTR(ahci_host_version, S_IRUGO, ahci_show_host_version, NULL);
341DEVICE_ATTR(ahci_port_cmd, S_IRUGO, ahci_show_port_cmd, NULL);
342
332static struct device_attribute *ahci_shost_attrs[] = { 343static struct device_attribute *ahci_shost_attrs[] = {
333 &dev_attr_link_power_management_policy, 344 &dev_attr_link_power_management_policy,
334 &dev_attr_em_message_type, 345 &dev_attr_em_message_type,
335 &dev_attr_em_message, 346 &dev_attr_em_message,
347 &dev_attr_ahci_host_caps,
348 &dev_attr_ahci_host_version,
349 &dev_attr_ahci_port_cmd,
336 NULL 350 NULL
337}; 351};
338 352
@@ -539,6 +553,12 @@ static const struct pci_device_id ahci_pci_tbl[] = {
539 { PCI_VDEVICE(ATI, 0x4394), board_ahci_sb700 }, /* ATI SB700/800 */ 553 { PCI_VDEVICE(ATI, 0x4394), board_ahci_sb700 }, /* ATI SB700/800 */
540 { PCI_VDEVICE(ATI, 0x4395), board_ahci_sb700 }, /* ATI SB700/800 */ 554 { PCI_VDEVICE(ATI, 0x4395), board_ahci_sb700 }, /* ATI SB700/800 */
541 555
556 /* AMD */
557 { PCI_VDEVICE(AMD, 0x7800), board_ahci }, /* AMD SB900 */
558 /* AMD is using RAID class only for ahci controllers */
559 { PCI_VENDOR_ID_AMD, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
560 PCI_CLASS_STORAGE_RAID << 8, 0xffffff, board_ahci },
561
542 /* VIA */ 562 /* VIA */
543 { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */ 563 { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */
544 { PCI_VDEVICE(VIA, 0x6287), board_ahci_vt8251 }, /* VIA VT8251 */ 564 { PCI_VDEVICE(VIA, 0x6287), board_ahci_vt8251 }, /* VIA VT8251 */
@@ -702,6 +722,36 @@ static void ahci_enable_ahci(void __iomem *mmio)
702 WARN_ON(1); 722 WARN_ON(1);
703} 723}
704 724
725static ssize_t ahci_show_host_caps(struct device *dev,
726 struct device_attribute *attr, char *buf)
727{
728 struct Scsi_Host *shost = class_to_shost(dev);
729 struct ata_port *ap = ata_shost_to_port(shost);
730 struct ahci_host_priv *hpriv = ap->host->private_data;
731
732 return sprintf(buf, "%x\n", hpriv->cap);
733}
734
735static ssize_t ahci_show_host_version(struct device *dev,
736 struct device_attribute *attr, char *buf)
737{
738 struct Scsi_Host *shost = class_to_shost(dev);
739 struct ata_port *ap = ata_shost_to_port(shost);
740 void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
741
742 return sprintf(buf, "%x\n", readl(mmio + HOST_VERSION));
743}
744
745static ssize_t ahci_show_port_cmd(struct device *dev,
746 struct device_attribute *attr, char *buf)
747{
748 struct Scsi_Host *shost = class_to_shost(dev);
749 struct ata_port *ap = ata_shost_to_port(shost);
750 void __iomem *port_mmio = ahci_port_base(ap);
751
752 return sprintf(buf, "%x\n", readl(port_mmio + PORT_CMD));
753}
754
705/** 755/**
706 * ahci_save_initial_config - Save and fixup initial config values 756 * ahci_save_initial_config - Save and fixup initial config values
707 * @pdev: target PCI device 757 * @pdev: target PCI device
@@ -1584,7 +1634,7 @@ static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
1584 pp->cmd_slot[tag].tbl_addr_hi = cpu_to_le32((cmd_tbl_dma >> 16) >> 16); 1634 pp->cmd_slot[tag].tbl_addr_hi = cpu_to_le32((cmd_tbl_dma >> 16) >> 16);
1585} 1635}
1586 1636
1587static int ahci_kick_engine(struct ata_port *ap, int force_restart) 1637static int ahci_kick_engine(struct ata_port *ap)
1588{ 1638{
1589 void __iomem *port_mmio = ahci_port_base(ap); 1639 void __iomem *port_mmio = ahci_port_base(ap);
1590 struct ahci_host_priv *hpriv = ap->host->private_data; 1640 struct ahci_host_priv *hpriv = ap->host->private_data;
@@ -1592,18 +1642,16 @@ static int ahci_kick_engine(struct ata_port *ap, int force_restart)
1592 u32 tmp; 1642 u32 tmp;
1593 int busy, rc; 1643 int busy, rc;
1594 1644
1595 /* do we need to kick the port? */
1596 busy = status & (ATA_BUSY | ATA_DRQ);
1597 if (!busy && !force_restart)
1598 return 0;
1599
1600 /* stop engine */ 1645 /* stop engine */
1601 rc = ahci_stop_engine(ap); 1646 rc = ahci_stop_engine(ap);
1602 if (rc) 1647 if (rc)
1603 goto out_restart; 1648 goto out_restart;
1604 1649
1605 /* need to do CLO? */ 1650 /* need to do CLO?
1606 if (!busy) { 1651 * always do CLO if PMP is attached (AHCI-1.3 9.2)
1652 */
1653 busy = status & (ATA_BUSY | ATA_DRQ);
1654 if (!busy && !sata_pmp_attached(ap)) {
1607 rc = 0; 1655 rc = 0;
1608 goto out_restart; 1656 goto out_restart;
1609 } 1657 }
@@ -1651,7 +1699,7 @@ static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
1651 tmp = ata_wait_register(port_mmio + PORT_CMD_ISSUE, 0x1, 0x1, 1699 tmp = ata_wait_register(port_mmio + PORT_CMD_ISSUE, 0x1, 0x1,
1652 1, timeout_msec); 1700 1, timeout_msec);
1653 if (tmp & 0x1) { 1701 if (tmp & 0x1) {
1654 ahci_kick_engine(ap, 1); 1702 ahci_kick_engine(ap);
1655 return -EBUSY; 1703 return -EBUSY;
1656 } 1704 }
1657 } else 1705 } else
@@ -1674,7 +1722,7 @@ static int ahci_do_softreset(struct ata_link *link, unsigned int *class,
1674 DPRINTK("ENTER\n"); 1722 DPRINTK("ENTER\n");
1675 1723
1676 /* prepare for SRST (AHCI-1.1 10.4.1) */ 1724 /* prepare for SRST (AHCI-1.1 10.4.1) */
1677 rc = ahci_kick_engine(ap, 1); 1725 rc = ahci_kick_engine(ap);
1678 if (rc && rc != -EOPNOTSUPP) 1726 if (rc && rc != -EOPNOTSUPP)
1679 ata_link_printk(link, KERN_WARNING, 1727 ata_link_printk(link, KERN_WARNING,
1680 "failed to reset engine (errno=%d)\n", rc); 1728 "failed to reset engine (errno=%d)\n", rc);
@@ -1890,7 +1938,7 @@ static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
1890 rc = ata_wait_after_reset(link, jiffies + 2 * HZ, 1938 rc = ata_wait_after_reset(link, jiffies + 2 * HZ,
1891 ahci_check_ready); 1939 ahci_check_ready);
1892 if (rc) 1940 if (rc)
1893 ahci_kick_engine(ap, 0); 1941 ahci_kick_engine(ap);
1894 } 1942 }
1895 return rc; 1943 return rc;
1896} 1944}
@@ -2271,7 +2319,7 @@ static void ahci_post_internal_cmd(struct ata_queued_cmd *qc)
2271 2319
2272 /* make DMA engine forget about the failed command */ 2320 /* make DMA engine forget about the failed command */
2273 if (qc->flags & ATA_QCFLAG_FAILED) 2321 if (qc->flags & ATA_QCFLAG_FAILED)
2274 ahci_kick_engine(ap, 1); 2322 ahci_kick_engine(ap);
2275} 2323}
2276 2324
2277static void ahci_pmp_attach(struct ata_port *ap) 2325static void ahci_pmp_attach(struct ata_port *ap)
@@ -2603,14 +2651,18 @@ static void ahci_p5wdh_workaround(struct ata_host *host)
2603} 2651}
2604 2652
2605/* 2653/*
2606 * SB600 ahci controller on ASUS M2A-VM can't do 64bit DMA with older 2654 * SB600 ahci controller on certain boards can't do 64bit DMA with
2607 * BIOS. The oldest version known to be broken is 0901 and working is 2655 * older BIOS.
2608 * 1501 which was released on 2007-10-26. Force 32bit DMA on anything
2609 * older than 1501. Please read bko#9412 for more info.
2610 */ 2656 */
2611static bool ahci_asus_m2a_vm_32bit_only(struct pci_dev *pdev) 2657static bool ahci_sb600_32bit_only(struct pci_dev *pdev)
2612{ 2658{
2613 static const struct dmi_system_id sysids[] = { 2659 static const struct dmi_system_id sysids[] = {
2660 /*
2661 * The oldest version known to be broken is 0901 and
2662 * working is 1501 which was released on 2007-10-26.
2663 * Force 32bit DMA on anything older than 1501.
2664 * Please read bko#9412 for more info.
2665 */
2614 { 2666 {
2615 .ident = "ASUS M2A-VM", 2667 .ident = "ASUS M2A-VM",
2616 .matches = { 2668 .matches = {
@@ -2618,31 +2670,48 @@ static bool ahci_asus_m2a_vm_32bit_only(struct pci_dev *pdev)
2618 "ASUSTeK Computer INC."), 2670 "ASUSTeK Computer INC."),
2619 DMI_MATCH(DMI_BOARD_NAME, "M2A-VM"), 2671 DMI_MATCH(DMI_BOARD_NAME, "M2A-VM"),
2620 }, 2672 },
2673 .driver_data = "20071026", /* yyyymmdd */
2674 },
2675 /*
2676 * It's yet unknown whether more recent BIOS fixes the
2677 * problem. Blacklist the whole board for the time
2678 * being. Please read the following thread for more
2679 * info.
2680 *
2681 * http://thread.gmane.org/gmane.linux.ide/42326
2682 */
2683 {
2684 .ident = "Gigabyte GA-MA69VM-S2",
2685 .matches = {
2686 DMI_MATCH(DMI_BOARD_VENDOR,
2687 "Gigabyte Technology Co., Ltd."),
2688 DMI_MATCH(DMI_BOARD_NAME, "GA-MA69VM-S2"),
2689 },
2621 }, 2690 },
2622 { } 2691 { }
2623 }; 2692 };
2624 const char *cutoff_mmdd = "10/26"; 2693 const struct dmi_system_id *match;
2625 const char *date;
2626 int year;
2627 2694
2695 match = dmi_first_match(sysids);
2628 if (pdev->bus->number != 0 || pdev->devfn != PCI_DEVFN(0x12, 0) || 2696 if (pdev->bus->number != 0 || pdev->devfn != PCI_DEVFN(0x12, 0) ||
2629 !dmi_check_system(sysids)) 2697 !match)
2630 return false; 2698 return false;
2631 2699
2632 /* 2700 if (match->driver_data) {
2633 * Argh.... both version and date are free form strings. 2701 int year, month, date;
2634 * Let's hope they're using the same date format across 2702 char buf[9];
2635 * different versions. 2703
2636 */ 2704 dmi_get_date(DMI_BIOS_DATE, &year, &month, &date);
2637 date = dmi_get_system_info(DMI_BIOS_DATE); 2705 snprintf(buf, sizeof(buf), "%04d%02d%02d", year, month, date);
2638 year = dmi_get_year(DMI_BIOS_DATE);
2639 if (date && strlen(date) >= 10 && date[2] == '/' && date[5] == '/' &&
2640 (year > 2007 ||
2641 (year == 2007 && strncmp(date, cutoff_mmdd, 5) >= 0)))
2642 return false;
2643 2706
2644 dev_printk(KERN_WARNING, &pdev->dev, "ASUS M2A-VM: BIOS too old, " 2707 if (strcmp(buf, match->driver_data) >= 0)
2645 "forcing 32bit DMA, update BIOS\n"); 2708 return false;
2709
2710 dev_printk(KERN_WARNING, &pdev->dev, "%s: BIOS too old, "
2711 "forcing 32bit DMA, update BIOS\n", match->ident);
2712 } else
2713 dev_printk(KERN_WARNING, &pdev->dev, "%s: this board can't "
2714 "do 64bit DMA, forcing 32bit\n", match->ident);
2646 2715
2647 return true; 2716 return true;
2648} 2717}
@@ -2857,8 +2926,8 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2857 if (board_id == board_ahci_sb700 && pdev->revision >= 0x40) 2926 if (board_id == board_ahci_sb700 && pdev->revision >= 0x40)
2858 hpriv->flags &= ~AHCI_HFLAG_IGN_SERR_INTERNAL; 2927 hpriv->flags &= ~AHCI_HFLAG_IGN_SERR_INTERNAL;
2859 2928
2860 /* apply ASUS M2A_VM quirk */ 2929 /* apply sb600 32bit only quirk */
2861 if (ahci_asus_m2a_vm_32bit_only(pdev)) 2930 if (ahci_sb600_32bit_only(pdev))
2862 hpriv->flags |= AHCI_HFLAG_32BIT_ONLY; 2931 hpriv->flags |= AHCI_HFLAG_32BIT_ONLY;
2863 2932
2864 if (!(hpriv->flags & AHCI_HFLAG_NO_MSI)) 2933 if (!(hpriv->flags & AHCI_HFLAG_NO_MSI))
@@ -2869,7 +2938,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2869 2938
2870 /* prepare host */ 2939 /* prepare host */
2871 if (hpriv->cap & HOST_CAP_NCQ) 2940 if (hpriv->cap & HOST_CAP_NCQ)
2872 pi.flags |= ATA_FLAG_NCQ; 2941 pi.flags |= ATA_FLAG_NCQ | ATA_FLAG_FPDMA_AA;
2873 2942
2874 if (hpriv->cap & HOST_CAP_PMP) 2943 if (hpriv->cap & HOST_CAP_PMP)
2875 pi.flags |= ATA_FLAG_PMP; 2944 pi.flags |= ATA_FLAG_PMP;
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index ac176da1f94e..01964b6e6f6b 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -689,6 +689,7 @@ static int ata_acpi_run_tf(struct ata_device *dev,
689 struct ata_taskfile tf, ptf, rtf; 689 struct ata_taskfile tf, ptf, rtf;
690 unsigned int err_mask; 690 unsigned int err_mask;
691 const char *level; 691 const char *level;
692 const char *descr;
692 char msg[60]; 693 char msg[60];
693 int rc; 694 int rc;
694 695
@@ -736,11 +737,13 @@ static int ata_acpi_run_tf(struct ata_device *dev,
736 snprintf(msg, sizeof(msg), "filtered out"); 737 snprintf(msg, sizeof(msg), "filtered out");
737 rc = 0; 738 rc = 0;
738 } 739 }
740 descr = ata_get_cmd_descript(tf.command);
739 741
740 ata_dev_printk(dev, level, 742 ata_dev_printk(dev, level,
741 "ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x %s\n", 743 "ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x (%s) %s\n",
742 tf.command, tf.feature, tf.nsect, tf.lbal, 744 tf.command, tf.feature, tf.nsect, tf.lbal,
743 tf.lbam, tf.lbah, tf.device, msg); 745 tf.lbam, tf.lbah, tf.device,
746 (descr ? descr : "unknown"), msg);
744 747
745 return rc; 748 return rc;
746} 749}
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 072ba5ea138f..df31deac5c82 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -709,7 +709,13 @@ u64 ata_tf_read_block(struct ata_taskfile *tf, struct ata_device *dev)
709 head = tf->device & 0xf; 709 head = tf->device & 0xf;
710 sect = tf->lbal; 710 sect = tf->lbal;
711 711
712 block = (cyl * dev->heads + head) * dev->sectors + sect; 712 if (!sect) {
713 ata_dev_printk(dev, KERN_WARNING, "device reported "
714 "invalid CHS sector 0\n");
715 sect = 1; /* oh well */
716 }
717
718 block = (cyl * dev->heads + head) * dev->sectors + sect - 1;
713 } 719 }
714 720
715 return block; 721 return block;
@@ -2299,29 +2305,49 @@ static inline u8 ata_dev_knobble(struct ata_device *dev)
2299 return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id))); 2305 return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id)));
2300} 2306}
2301 2307
2302static void ata_dev_config_ncq(struct ata_device *dev, 2308static int ata_dev_config_ncq(struct ata_device *dev,
2303 char *desc, size_t desc_sz) 2309 char *desc, size_t desc_sz)
2304{ 2310{
2305 struct ata_port *ap = dev->link->ap; 2311 struct ata_port *ap = dev->link->ap;
2306 int hdepth = 0, ddepth = ata_id_queue_depth(dev->id); 2312 int hdepth = 0, ddepth = ata_id_queue_depth(dev->id);
2313 unsigned int err_mask;
2314 char *aa_desc = "";
2307 2315
2308 if (!ata_id_has_ncq(dev->id)) { 2316 if (!ata_id_has_ncq(dev->id)) {
2309 desc[0] = '\0'; 2317 desc[0] = '\0';
2310 return; 2318 return 0;
2311 } 2319 }
2312 if (dev->horkage & ATA_HORKAGE_NONCQ) { 2320 if (dev->horkage & ATA_HORKAGE_NONCQ) {
2313 snprintf(desc, desc_sz, "NCQ (not used)"); 2321 snprintf(desc, desc_sz, "NCQ (not used)");
2314 return; 2322 return 0;
2315 } 2323 }
2316 if (ap->flags & ATA_FLAG_NCQ) { 2324 if (ap->flags & ATA_FLAG_NCQ) {
2317 hdepth = min(ap->scsi_host->can_queue, ATA_MAX_QUEUE - 1); 2325 hdepth = min(ap->scsi_host->can_queue, ATA_MAX_QUEUE - 1);
2318 dev->flags |= ATA_DFLAG_NCQ; 2326 dev->flags |= ATA_DFLAG_NCQ;
2319 } 2327 }
2320 2328
2329 if (!(dev->horkage & ATA_HORKAGE_BROKEN_FPDMA_AA) &&
2330 (ap->flags & ATA_FLAG_FPDMA_AA) &&
2331 ata_id_has_fpdma_aa(dev->id)) {
2332 err_mask = ata_dev_set_feature(dev, SETFEATURES_SATA_ENABLE,
2333 SATA_FPDMA_AA);
2334 if (err_mask) {
2335 ata_dev_printk(dev, KERN_ERR, "failed to enable AA"
2336 "(error_mask=0x%x)\n", err_mask);
2337 if (err_mask != AC_ERR_DEV) {
2338 dev->horkage |= ATA_HORKAGE_BROKEN_FPDMA_AA;
2339 return -EIO;
2340 }
2341 } else
2342 aa_desc = ", AA";
2343 }
2344
2321 if (hdepth >= ddepth) 2345 if (hdepth >= ddepth)
2322 snprintf(desc, desc_sz, "NCQ (depth %d)", ddepth); 2346 snprintf(desc, desc_sz, "NCQ (depth %d)%s", ddepth, aa_desc);
2323 else 2347 else
2324 snprintf(desc, desc_sz, "NCQ (depth %d/%d)", hdepth, ddepth); 2348 snprintf(desc, desc_sz, "NCQ (depth %d/%d)%s", hdepth,
2349 ddepth, aa_desc);
2350 return 0;
2325} 2351}
2326 2352
2327/** 2353/**
@@ -2461,7 +2487,7 @@ int ata_dev_configure(struct ata_device *dev)
2461 2487
2462 if (ata_id_has_lba(id)) { 2488 if (ata_id_has_lba(id)) {
2463 const char *lba_desc; 2489 const char *lba_desc;
2464 char ncq_desc[20]; 2490 char ncq_desc[24];
2465 2491
2466 lba_desc = "LBA"; 2492 lba_desc = "LBA";
2467 dev->flags |= ATA_DFLAG_LBA; 2493 dev->flags |= ATA_DFLAG_LBA;
@@ -2475,7 +2501,9 @@ int ata_dev_configure(struct ata_device *dev)
2475 } 2501 }
2476 2502
2477 /* config NCQ */ 2503 /* config NCQ */
2478 ata_dev_config_ncq(dev, ncq_desc, sizeof(ncq_desc)); 2504 rc = ata_dev_config_ncq(dev, ncq_desc, sizeof(ncq_desc));
2505 if (rc)
2506 return rc;
2479 2507
2480 /* print device info to dmesg */ 2508 /* print device info to dmesg */
2481 if (ata_msg_drv(ap) && print_info) { 2509 if (ata_msg_drv(ap) && print_info) {
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 79711b64054b..a04488f0de88 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -40,6 +40,7 @@
40#include <scsi/scsi_eh.h> 40#include <scsi/scsi_eh.h>
41#include <scsi/scsi_device.h> 41#include <scsi/scsi_device.h>
42#include <scsi/scsi_cmnd.h> 42#include <scsi/scsi_cmnd.h>
43#include <scsi/scsi_dbg.h>
43#include "../scsi/scsi_transport_api.h" 44#include "../scsi/scsi_transport_api.h"
44 45
45#include <linux/libata.h> 46#include <linux/libata.h>
@@ -999,7 +1000,9 @@ static void __ata_port_freeze(struct ata_port *ap)
999 * ata_port_freeze - abort & freeze port 1000 * ata_port_freeze - abort & freeze port
1000 * @ap: ATA port to freeze 1001 * @ap: ATA port to freeze
1001 * 1002 *
1002 * Abort and freeze @ap. 1003 * Abort and freeze @ap. The freeze operation must be called
1004 * first, because some hardware requires special operations
1005 * before the taskfile registers are accessible.
1003 * 1006 *
1004 * LOCKING: 1007 * LOCKING:
1005 * spin_lock_irqsave(host lock) 1008 * spin_lock_irqsave(host lock)
@@ -1013,8 +1016,8 @@ int ata_port_freeze(struct ata_port *ap)
1013 1016
1014 WARN_ON(!ap->ops->error_handler); 1017 WARN_ON(!ap->ops->error_handler);
1015 1018
1016 nr_aborted = ata_port_abort(ap);
1017 __ata_port_freeze(ap); 1019 __ata_port_freeze(ap);
1020 nr_aborted = ata_port_abort(ap);
1018 1021
1019 return nr_aborted; 1022 return nr_aborted;
1020} 1023}
@@ -2110,6 +2113,116 @@ void ata_eh_autopsy(struct ata_port *ap)
2110} 2113}
2111 2114
2112/** 2115/**
2116 * ata_get_cmd_descript - get description for ATA command
2117 * @command: ATA command code to get description for
2118 *
2119 * Return a textual description of the given command, or NULL if the
2120 * command is not known.
2121 *
2122 * LOCKING:
2123 * None
2124 */
2125const char *ata_get_cmd_descript(u8 command)
2126{
2127#ifdef CONFIG_ATA_VERBOSE_ERROR
2128 static const struct
2129 {
2130 u8 command;
2131 const char *text;
2132 } cmd_descr[] = {
2133 { ATA_CMD_DEV_RESET, "DEVICE RESET" },
2134 { ATA_CMD_CHK_POWER, "CHECK POWER MODE" },
2135 { ATA_CMD_STANDBY, "STANDBY" },
2136 { ATA_CMD_IDLE, "IDLE" },
2137 { ATA_CMD_EDD, "EXECUTE DEVICE DIAGNOSTIC" },
2138 { ATA_CMD_DOWNLOAD_MICRO, "DOWNLOAD MICROCODE" },
2139 { ATA_CMD_NOP, "NOP" },
2140 { ATA_CMD_FLUSH, "FLUSH CACHE" },
2141 { ATA_CMD_FLUSH_EXT, "FLUSH CACHE EXT" },
2142 { ATA_CMD_ID_ATA, "IDENTIFY DEVICE" },
2143 { ATA_CMD_ID_ATAPI, "IDENTIFY PACKET DEVICE" },
2144 { ATA_CMD_SERVICE, "SERVICE" },
2145 { ATA_CMD_READ, "READ DMA" },
2146 { ATA_CMD_READ_EXT, "READ DMA EXT" },
2147 { ATA_CMD_READ_QUEUED, "READ DMA QUEUED" },
2148 { ATA_CMD_READ_STREAM_EXT, "READ STREAM EXT" },
2149 { ATA_CMD_READ_STREAM_DMA_EXT, "READ STREAM DMA EXT" },
2150 { ATA_CMD_WRITE, "WRITE DMA" },
2151 { ATA_CMD_WRITE_EXT, "WRITE DMA EXT" },
2152 { ATA_CMD_WRITE_QUEUED, "WRITE DMA QUEUED EXT" },
2153 { ATA_CMD_WRITE_STREAM_EXT, "WRITE STREAM EXT" },
2154 { ATA_CMD_WRITE_STREAM_DMA_EXT, "WRITE STREAM DMA EXT" },
2155 { ATA_CMD_WRITE_FUA_EXT, "WRITE DMA FUA EXT" },
2156 { ATA_CMD_WRITE_QUEUED_FUA_EXT, "WRITE DMA QUEUED FUA EXT" },
2157 { ATA_CMD_FPDMA_READ, "READ FPDMA QUEUED" },
2158 { ATA_CMD_FPDMA_WRITE, "WRITE FPDMA QUEUED" },
2159 { ATA_CMD_PIO_READ, "READ SECTOR(S)" },
2160 { ATA_CMD_PIO_READ_EXT, "READ SECTOR(S) EXT" },
2161 { ATA_CMD_PIO_WRITE, "WRITE SECTOR(S)" },
2162 { ATA_CMD_PIO_WRITE_EXT, "WRITE SECTOR(S) EXT" },
2163 { ATA_CMD_READ_MULTI, "READ MULTIPLE" },
2164 { ATA_CMD_READ_MULTI_EXT, "READ MULTIPLE EXT" },
2165 { ATA_CMD_WRITE_MULTI, "WRITE MULTIPLE" },
2166 { ATA_CMD_WRITE_MULTI_EXT, "WRITE MULTIPLE EXT" },
2167 { ATA_CMD_WRITE_MULTI_FUA_EXT, "WRITE MULTIPLE FUA EXT" },
2168 { ATA_CMD_SET_FEATURES, "SET FEATURES" },
2169 { ATA_CMD_SET_MULTI, "SET MULTIPLE MODE" },
2170 { ATA_CMD_VERIFY, "READ VERIFY SECTOR(S)" },
2171 { ATA_CMD_VERIFY_EXT, "READ VERIFY SECTOR(S) EXT" },
2172 { ATA_CMD_WRITE_UNCORR_EXT, "WRITE UNCORRECTABLE EXT" },
2173 { ATA_CMD_STANDBYNOW1, "STANDBY IMMEDIATE" },
2174 { ATA_CMD_IDLEIMMEDIATE, "IDLE IMMEDIATE" },
2175 { ATA_CMD_SLEEP, "SLEEP" },
2176 { ATA_CMD_INIT_DEV_PARAMS, "INITIALIZE DEVICE PARAMETERS" },
2177 { ATA_CMD_READ_NATIVE_MAX, "READ NATIVE MAX ADDRESS" },
2178 { ATA_CMD_READ_NATIVE_MAX_EXT, "READ NATIVE MAX ADDRESS EXT" },
2179 { ATA_CMD_SET_MAX, "SET MAX ADDRESS" },
2180 { ATA_CMD_SET_MAX_EXT, "SET MAX ADDRESS EXT" },
2181 { ATA_CMD_READ_LOG_EXT, "READ LOG EXT" },
2182 { ATA_CMD_WRITE_LOG_EXT, "WRITE LOG EXT" },
2183 { ATA_CMD_READ_LOG_DMA_EXT, "READ LOG DMA EXT" },
2184 { ATA_CMD_WRITE_LOG_DMA_EXT, "WRITE LOG DMA EXT" },
2185 { ATA_CMD_TRUSTED_RCV, "TRUSTED RECEIVE" },
2186 { ATA_CMD_TRUSTED_RCV_DMA, "TRUSTED RECEIVE DMA" },
2187 { ATA_CMD_TRUSTED_SND, "TRUSTED SEND" },
2188 { ATA_CMD_TRUSTED_SND_DMA, "TRUSTED SEND DMA" },
2189 { ATA_CMD_PMP_READ, "READ BUFFER" },
2190 { ATA_CMD_PMP_WRITE, "WRITE BUFFER" },
2191 { ATA_CMD_CONF_OVERLAY, "DEVICE CONFIGURATION OVERLAY" },
2192 { ATA_CMD_SEC_SET_PASS, "SECURITY SET PASSWORD" },
2193 { ATA_CMD_SEC_UNLOCK, "SECURITY UNLOCK" },
2194 { ATA_CMD_SEC_ERASE_PREP, "SECURITY ERASE PREPARE" },
2195 { ATA_CMD_SEC_ERASE_UNIT, "SECURITY ERASE UNIT" },
2196 { ATA_CMD_SEC_FREEZE_LOCK, "SECURITY FREEZE LOCK" },
2197 { ATA_CMD_SEC_DISABLE_PASS, "SECURITY DISABLE PASSWORD" },
2198 { ATA_CMD_CONFIG_STREAM, "CONFIGURE STREAM" },
2199 { ATA_CMD_SMART, "SMART" },
2200 { ATA_CMD_MEDIA_LOCK, "DOOR LOCK" },
2201 { ATA_CMD_MEDIA_UNLOCK, "DOOR UNLOCK" },
2202 { ATA_CMD_CHK_MED_CRD_TYP, "CHECK MEDIA CARD TYPE" },
2203 { ATA_CMD_CFA_REQ_EXT_ERR, "CFA REQUEST EXTENDED ERROR" },
2204 { ATA_CMD_CFA_WRITE_NE, "CFA WRITE SECTORS WITHOUT ERASE" },
2205 { ATA_CMD_CFA_TRANS_SECT, "CFA TRANSLATE SECTOR" },
2206 { ATA_CMD_CFA_ERASE, "CFA ERASE SECTORS" },
2207 { ATA_CMD_CFA_WRITE_MULT_NE, "CFA WRITE MULTIPLE WITHOUT ERASE" },
2208 { ATA_CMD_READ_LONG, "READ LONG (with retries)" },
2209 { ATA_CMD_READ_LONG_ONCE, "READ LONG (without retries)" },
2210 { ATA_CMD_WRITE_LONG, "WRITE LONG (with retries)" },
2211 { ATA_CMD_WRITE_LONG_ONCE, "WRITE LONG (without retries)" },
2212 { ATA_CMD_RESTORE, "RECALIBRATE" },
2213 { 0, NULL } /* terminate list */
2214 };
2215
2216 unsigned int i;
2217 for (i = 0; cmd_descr[i].text; i++)
2218 if (cmd_descr[i].command == command)
2219 return cmd_descr[i].text;
2220#endif
2221
2222 return NULL;
2223}
2224
2225/**
2113 * ata_eh_link_report - report error handling to user 2226 * ata_eh_link_report - report error handling to user
2114 * @link: ATA link EH is going on 2227 * @link: ATA link EH is going on
2115 * 2228 *
@@ -2175,6 +2288,7 @@ static void ata_eh_link_report(struct ata_link *link)
2175 ata_link_printk(link, KERN_ERR, "%s\n", desc); 2288 ata_link_printk(link, KERN_ERR, "%s\n", desc);
2176 } 2289 }
2177 2290
2291#ifdef CONFIG_ATA_VERBOSE_ERROR
2178 if (ehc->i.serror) 2292 if (ehc->i.serror)
2179 ata_link_printk(link, KERN_ERR, 2293 ata_link_printk(link, KERN_ERR,
2180 "SError: { %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s}\n", 2294 "SError: { %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s}\n",
@@ -2195,6 +2309,7 @@ static void ata_eh_link_report(struct ata_link *link)
2195 ehc->i.serror & SERR_TRANS_ST_ERROR ? "TrStaTrns " : "", 2309 ehc->i.serror & SERR_TRANS_ST_ERROR ? "TrStaTrns " : "",
2196 ehc->i.serror & SERR_UNRECOG_FIS ? "UnrecFIS " : "", 2310 ehc->i.serror & SERR_UNRECOG_FIS ? "UnrecFIS " : "",
2197 ehc->i.serror & SERR_DEV_XCHG ? "DevExch " : ""); 2311 ehc->i.serror & SERR_DEV_XCHG ? "DevExch " : "");
2312#endif
2198 2313
2199 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { 2314 for (tag = 0; tag < ATA_MAX_QUEUE; tag++) {
2200 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); 2315 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
@@ -2226,14 +2341,23 @@ static void ata_eh_link_report(struct ata_link *link)
2226 dma_str[qc->dma_dir]); 2341 dma_str[qc->dma_dir]);
2227 } 2342 }
2228 2343
2229 if (ata_is_atapi(qc->tf.protocol)) 2344 if (ata_is_atapi(qc->tf.protocol)) {
2230 snprintf(cdb_buf, sizeof(cdb_buf), 2345 if (qc->scsicmd)
2346 scsi_print_command(qc->scsicmd);
2347 else
2348 snprintf(cdb_buf, sizeof(cdb_buf),
2231 "cdb %02x %02x %02x %02x %02x %02x %02x %02x " 2349 "cdb %02x %02x %02x %02x %02x %02x %02x %02x "
2232 "%02x %02x %02x %02x %02x %02x %02x %02x\n ", 2350 "%02x %02x %02x %02x %02x %02x %02x %02x\n ",
2233 cdb[0], cdb[1], cdb[2], cdb[3], 2351 cdb[0], cdb[1], cdb[2], cdb[3],
2234 cdb[4], cdb[5], cdb[6], cdb[7], 2352 cdb[4], cdb[5], cdb[6], cdb[7],
2235 cdb[8], cdb[9], cdb[10], cdb[11], 2353 cdb[8], cdb[9], cdb[10], cdb[11],
2236 cdb[12], cdb[13], cdb[14], cdb[15]); 2354 cdb[12], cdb[13], cdb[14], cdb[15]);
2355 } else {
2356 const char *descr = ata_get_cmd_descript(cmd->command);
2357 if (descr)
2358 ata_dev_printk(qc->dev, KERN_ERR,
2359 "failed command: %s\n", descr);
2360 }
2237 2361
2238 ata_dev_printk(qc->dev, KERN_ERR, 2362 ata_dev_printk(qc->dev, KERN_ERR,
2239 "cmd %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x " 2363 "cmd %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x "
@@ -2252,6 +2376,7 @@ static void ata_eh_link_report(struct ata_link *link)
2252 res->device, qc->err_mask, ata_err_string(qc->err_mask), 2376 res->device, qc->err_mask, ata_err_string(qc->err_mask),
2253 qc->err_mask & AC_ERR_NCQ ? " <F>" : ""); 2377 qc->err_mask & AC_ERR_NCQ ? " <F>" : "");
2254 2378
2379#ifdef CONFIG_ATA_VERBOSE_ERROR
2255 if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | 2380 if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ |
2256 ATA_ERR)) { 2381 ATA_ERR)) {
2257 if (res->command & ATA_BUSY) 2382 if (res->command & ATA_BUSY)
@@ -2275,6 +2400,7 @@ static void ata_eh_link_report(struct ata_link *link)
2275 res->feature & ATA_UNC ? "UNC " : "", 2400 res->feature & ATA_UNC ? "UNC " : "",
2276 res->feature & ATA_IDNF ? "IDNF " : "", 2401 res->feature & ATA_IDNF ? "IDNF " : "",
2277 res->feature & ATA_ABORTED ? "ABRT " : ""); 2402 res->feature & ATA_ABORTED ? "ABRT " : "");
2403#endif
2278 } 2404 }
2279} 2405}
2280 2406
@@ -2574,11 +2700,17 @@ int ata_eh_reset(struct ata_link *link, int classify,
2574 postreset(slave, classes); 2700 postreset(slave, classes);
2575 } 2701 }
2576 2702
2577 /* clear cached SError */ 2703 /*
2704 * Some controllers can't be frozen very well and may set
2705 * spuruious error conditions during reset. Clear accumulated
2706 * error information. As reset is the final recovery action,
2707 * nothing is lost by doing this.
2708 */
2578 spin_lock_irqsave(link->ap->lock, flags); 2709 spin_lock_irqsave(link->ap->lock, flags);
2579 link->eh_info.serror = 0; 2710 memset(&link->eh_info, 0, sizeof(link->eh_info));
2580 if (slave) 2711 if (slave)
2581 slave->eh_info.serror = 0; 2712 memset(&slave->eh_info, 0, sizeof(link->eh_info));
2713 ap->pflags &= ~ATA_PFLAG_EH_PENDING;
2582 spin_unlock_irqrestore(link->ap->lock, flags); 2714 spin_unlock_irqrestore(link->ap->lock, flags);
2583 2715
2584 /* Make sure onlineness and classification result correspond. 2716 /* Make sure onlineness and classification result correspond.
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index 619f2c33950e..51f0ffb78cbd 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -221,6 +221,8 @@ static const char *sata_pmp_spec_rev_str(const u32 *gscr)
221{ 221{
222 u32 rev = gscr[SATA_PMP_GSCR_REV]; 222 u32 rev = gscr[SATA_PMP_GSCR_REV];
223 223
224 if (rev & (1 << 3))
225 return "1.2";
224 if (rev & (1 << 2)) 226 if (rev & (1 << 2))
225 return "1.1"; 227 return "1.1";
226 if (rev & (1 << 1)) 228 if (rev & (1 << 1))
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index d0dfeef55db5..b4ee28dec521 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1119,10 +1119,6 @@ static int ata_scsi_dev_config(struct scsi_device *sdev,
1119 1119
1120 blk_queue_dma_drain(q, atapi_drain_needed, buf, ATAPI_MAX_DRAIN); 1120 blk_queue_dma_drain(q, atapi_drain_needed, buf, ATAPI_MAX_DRAIN);
1121 } else { 1121 } else {
1122 if (ata_id_is_ssd(dev->id))
1123 queue_flag_set_unlocked(QUEUE_FLAG_NONROT,
1124 sdev->request_queue);
1125
1126 /* ATA devices must be sector aligned */ 1122 /* ATA devices must be sector aligned */
1127 blk_queue_update_dma_alignment(sdev->request_queue, 1123 blk_queue_update_dma_alignment(sdev->request_queue,
1128 ATA_SECT_SIZE - 1); 1124 ATA_SECT_SIZE - 1);
@@ -1257,23 +1253,6 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth)
1257 return queue_depth; 1253 return queue_depth;
1258} 1254}
1259 1255
1260/* XXX: for spindown warning */
1261static void ata_delayed_done_timerfn(unsigned long arg)
1262{
1263 struct scsi_cmnd *scmd = (void *)arg;
1264
1265 scmd->scsi_done(scmd);
1266}
1267
1268/* XXX: for spindown warning */
1269static void ata_delayed_done(struct scsi_cmnd *scmd)
1270{
1271 static struct timer_list timer;
1272
1273 setup_timer(&timer, ata_delayed_done_timerfn, (unsigned long)scmd);
1274 mod_timer(&timer, jiffies + 5 * HZ);
1275}
1276
1277/** 1256/**
1278 * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command 1257 * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command
1279 * @qc: Storage for translated ATA taskfile 1258 * @qc: Storage for translated ATA taskfile
@@ -1338,32 +1317,6 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
1338 system_entering_hibernation()) 1317 system_entering_hibernation())
1339 goto skip; 1318 goto skip;
1340 1319
1341 /* XXX: This is for backward compatibility, will be
1342 * removed. Read Documentation/feature-removal-schedule.txt
1343 * for more info.
1344 */
1345 if ((qc->dev->flags & ATA_DFLAG_SPUNDOWN) &&
1346 (system_state == SYSTEM_HALT ||
1347 system_state == SYSTEM_POWER_OFF)) {
1348 static unsigned long warned;
1349
1350 if (!test_and_set_bit(0, &warned)) {
1351 ata_dev_printk(qc->dev, KERN_WARNING,
1352 "DISK MIGHT NOT BE SPUN DOWN PROPERLY. "
1353 "UPDATE SHUTDOWN UTILITY\n");
1354 ata_dev_printk(qc->dev, KERN_WARNING,
1355 "For more info, visit "
1356 "http://linux-ata.org/shutdown.html\n");
1357
1358 /* ->scsi_done is not used, use it for
1359 * delayed completion.
1360 */
1361 scmd->scsi_done = qc->scsidone;
1362 qc->scsidone = ata_delayed_done;
1363 }
1364 goto skip;
1365 }
1366
1367 /* Issue ATA STANDBY IMMEDIATE command */ 1320 /* Issue ATA STANDBY IMMEDIATE command */
1368 tf->command = ATA_CMD_STANDBYNOW1; 1321 tf->command = ATA_CMD_STANDBYNOW1;
1369 } 1322 }
@@ -1764,14 +1717,6 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1764 } 1717 }
1765 } 1718 }
1766 1719
1767 /* XXX: track spindown state for spindown skipping and warning */
1768 if (unlikely(qc->tf.command == ATA_CMD_STANDBY ||
1769 qc->tf.command == ATA_CMD_STANDBYNOW1))
1770 qc->dev->flags |= ATA_DFLAG_SPUNDOWN;
1771 else if (likely(system_state != SYSTEM_HALT &&
1772 system_state != SYSTEM_POWER_OFF))
1773 qc->dev->flags &= ~ATA_DFLAG_SPUNDOWN;
1774
1775 if (need_sense && !ap->ops->error_handler) 1720 if (need_sense && !ap->ops->error_handler)
1776 ata_dump_status(ap->print_id, &qc->result_tf); 1721 ata_dump_status(ap->print_id, &qc->result_tf);
1777 1722
@@ -2815,28 +2760,6 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2815 goto invalid_fld; 2760 goto invalid_fld;
2816 2761
2817 /* 2762 /*
2818 * Filter TPM commands by default. These provide an
2819 * essentially uncontrolled encrypted "back door" between
2820 * applications and the disk. Set libata.allow_tpm=1 if you
2821 * have a real reason for wanting to use them. This ensures
2822 * that installed software cannot easily mess stuff up without
2823 * user intent. DVR type users will probably ship with this enabled
2824 * for movie content management.
2825 *
2826 * Note that for ATA8 we can issue a DCS change and DCS freeze lock
2827 * for this and should do in future but that it is not sufficient as
2828 * DCS is an optional feature set. Thus we also do the software filter
2829 * so that we comply with the TC consortium stated goal that the user
2830 * can turn off TC features of their system.
2831 */
2832 if (tf->command >= 0x5C && tf->command <= 0x5F && !libata_allow_tpm)
2833 goto invalid_fld;
2834
2835 /* We may not issue DMA commands if no DMA mode is set */
2836 if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0)
2837 goto invalid_fld;
2838
2839 /*
2840 * 12 and 16 byte CDBs use different offsets to 2763 * 12 and 16 byte CDBs use different offsets to
2841 * provide the various register values. 2764 * provide the various register values.
2842 */ 2765 */
@@ -2885,6 +2808,41 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2885 tf->device = dev->devno ? 2808 tf->device = dev->devno ?
2886 tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1; 2809 tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1;
2887 2810
2811 /* READ/WRITE LONG use a non-standard sect_size */
2812 qc->sect_size = ATA_SECT_SIZE;
2813 switch (tf->command) {
2814 case ATA_CMD_READ_LONG:
2815 case ATA_CMD_READ_LONG_ONCE:
2816 case ATA_CMD_WRITE_LONG:
2817 case ATA_CMD_WRITE_LONG_ONCE:
2818 if (tf->protocol != ATA_PROT_PIO || tf->nsect != 1)
2819 goto invalid_fld;
2820 qc->sect_size = scsi_bufflen(scmd);
2821 }
2822
2823 /*
2824 * Set flags so that all registers will be written, pass on
2825 * write indication (used for PIO/DMA setup), result TF is
2826 * copied back and we don't whine too much about its failure.
2827 */
2828 tf->flags = ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
2829 if (scmd->sc_data_direction == DMA_TO_DEVICE)
2830 tf->flags |= ATA_TFLAG_WRITE;
2831
2832 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET;
2833
2834 /*
2835 * Set transfer length.
2836 *
2837 * TODO: find out if we need to do more here to
2838 * cover scatter/gather case.
2839 */
2840 ata_qc_set_pc_nbytes(qc);
2841
2842 /* We may not issue DMA commands if no DMA mode is set */
2843 if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0)
2844 goto invalid_fld;
2845
2888 /* sanity check for pio multi commands */ 2846 /* sanity check for pio multi commands */
2889 if ((cdb[1] & 0xe0) && !is_multi_taskfile(tf)) 2847 if ((cdb[1] & 0xe0) && !is_multi_taskfile(tf))
2890 goto invalid_fld; 2848 goto invalid_fld;
@@ -2901,18 +2859,6 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2901 multi_count); 2859 multi_count);
2902 } 2860 }
2903 2861
2904 /* READ/WRITE LONG use a non-standard sect_size */
2905 qc->sect_size = ATA_SECT_SIZE;
2906 switch (tf->command) {
2907 case ATA_CMD_READ_LONG:
2908 case ATA_CMD_READ_LONG_ONCE:
2909 case ATA_CMD_WRITE_LONG:
2910 case ATA_CMD_WRITE_LONG_ONCE:
2911 if (tf->protocol != ATA_PROT_PIO || tf->nsect != 1)
2912 goto invalid_fld;
2913 qc->sect_size = scsi_bufflen(scmd);
2914 }
2915
2916 /* 2862 /*
2917 * Filter SET_FEATURES - XFER MODE command -- otherwise, 2863 * Filter SET_FEATURES - XFER MODE command -- otherwise,
2918 * SET_FEATURES - XFER MODE must be preceded/succeeded 2864 * SET_FEATURES - XFER MODE must be preceded/succeeded
@@ -2920,30 +2866,27 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2920 * controller (i.e. the reason for ->set_piomode(), 2866 * controller (i.e. the reason for ->set_piomode(),
2921 * ->set_dmamode(), and ->post_set_mode() hooks). 2867 * ->set_dmamode(), and ->post_set_mode() hooks).
2922 */ 2868 */
2923 if ((tf->command == ATA_CMD_SET_FEATURES) 2869 if (tf->command == ATA_CMD_SET_FEATURES &&
2924 && (tf->feature == SETFEATURES_XFER)) 2870 tf->feature == SETFEATURES_XFER)
2925 goto invalid_fld; 2871 goto invalid_fld;
2926 2872
2927 /* 2873 /*
2928 * Set flags so that all registers will be written, 2874 * Filter TPM commands by default. These provide an
2929 * and pass on write indication (used for PIO/DMA 2875 * essentially uncontrolled encrypted "back door" between
2930 * setup.) 2876 * applications and the disk. Set libata.allow_tpm=1 if you
2931 */ 2877 * have a real reason for wanting to use them. This ensures
2932 tf->flags |= (ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE); 2878 * that installed software cannot easily mess stuff up without
2933 2879 * user intent. DVR type users will probably ship with this enabled
2934 if (scmd->sc_data_direction == DMA_TO_DEVICE) 2880 * for movie content management.
2935 tf->flags |= ATA_TFLAG_WRITE;
2936
2937 /*
2938 * Set transfer length.
2939 * 2881 *
2940 * TODO: find out if we need to do more here to 2882 * Note that for ATA8 we can issue a DCS change and DCS freeze lock
2941 * cover scatter/gather case. 2883 * for this and should do in future but that it is not sufficient as
2884 * DCS is an optional feature set. Thus we also do the software filter
2885 * so that we comply with the TC consortium stated goal that the user
2886 * can turn off TC features of their system.
2942 */ 2887 */
2943 ata_qc_set_pc_nbytes(qc); 2888 if (tf->command >= 0x5C && tf->command <= 0x5F && !libata_allow_tpm)
2944 2889 goto invalid_fld;
2945 /* request result TF and be quiet about device error */
2946 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET;
2947 2890
2948 return 0; 2891 return 0;
2949 2892
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 89a1e0018e71..be8e2628f82c 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -164,6 +164,7 @@ extern void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev,
164extern void ata_eh_done(struct ata_link *link, struct ata_device *dev, 164extern void ata_eh_done(struct ata_link *link, struct ata_device *dev,
165 unsigned int action); 165 unsigned int action);
166extern void ata_eh_autopsy(struct ata_port *ap); 166extern void ata_eh_autopsy(struct ata_port *ap);
167const char *ata_get_cmd_descript(u8 command);
167extern void ata_eh_report(struct ata_port *ap); 168extern void ata_eh_report(struct ata_port *ap);
168extern int ata_eh_reset(struct ata_link *link, int classify, 169extern int ata_eh_reset(struct ata_link *link, int classify,
169 ata_prereset_fn_t prereset, ata_reset_fn_t softreset, 170 ata_prereset_fn_t prereset, ata_reset_fn_t softreset,
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index 45915566e4e9..aa4b3f6ae771 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -246,6 +246,7 @@ static const struct pci_device_id atiixp[] = {
246 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP400_IDE), }, 246 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP400_IDE), },
247 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP600_IDE), }, 247 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP600_IDE), },
248 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP700_IDE), }, 248 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP700_IDE), },
249 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_SB900_IDE), },
249 250
250 { }, 251 { },
251}; 252};
diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
index d33aa28239a9..403f56165cec 100644
--- a/drivers/ata/pata_cs5535.c
+++ b/drivers/ata/pata_cs5535.c
@@ -202,7 +202,8 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id)
202} 202}
203 203
204static const struct pci_device_id cs5535[] = { 204static const struct pci_device_id cs5535[] = {
205 { PCI_VDEVICE(NS, 0x002D), }, 205 { PCI_VDEVICE(NS, PCI_DEVICE_ID_NS_CS5535_IDE), },
206 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5535_IDE), },
206 207
207 { }, 208 { },
208}; 209};
diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
index abdd19fe990a..d6f69561dc86 100644
--- a/drivers/ata/pata_octeon_cf.c
+++ b/drivers/ata/pata_octeon_cf.c
@@ -213,7 +213,7 @@ static void octeon_cf_set_dmamode(struct ata_port *ap, struct ata_device *dev)
213 * This is tI, C.F. spec. says 0, but Sony CF card requires 213 * This is tI, C.F. spec. says 0, but Sony CF card requires
214 * more, we use 20 nS. 214 * more, we use 20 nS.
215 */ 215 */
216 dma_tim.s.dmack_s = ns_to_tim_reg(tim_mult, 20);; 216 dma_tim.s.dmack_s = ns_to_tim_reg(tim_mult, 20);
217 dma_tim.s.dmack_h = ns_to_tim_reg(tim_mult, dma_ackh); 217 dma_tim.s.dmack_h = ns_to_tim_reg(tim_mult, dma_ackh);
218 218
219 dma_tim.s.dmarq = dma_arq; 219 dma_tim.s.dmarq = dma_arq;
@@ -841,7 +841,7 @@ static int __devinit octeon_cf_probe(struct platform_device *pdev)
841 ocd = pdev->dev.platform_data; 841 ocd = pdev->dev.platform_data;
842 842
843 cs0 = devm_ioremap_nocache(&pdev->dev, res_cs0->start, 843 cs0 = devm_ioremap_nocache(&pdev->dev, res_cs0->start,
844 res_cs0->end - res_cs0->start + 1); 844 resource_size(res_cs0));
845 845
846 if (!cs0) 846 if (!cs0)
847 return -ENOMEM; 847 return -ENOMEM;
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index d8d743af3225..3f6ebc6c665a 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -151,14 +151,14 @@ int __devinit __pata_platform_probe(struct device *dev,
151 */ 151 */
152 if (mmio) { 152 if (mmio) {
153 ap->ioaddr.cmd_addr = devm_ioremap(dev, io_res->start, 153 ap->ioaddr.cmd_addr = devm_ioremap(dev, io_res->start,
154 io_res->end - io_res->start + 1); 154 resource_size(io_res));
155 ap->ioaddr.ctl_addr = devm_ioremap(dev, ctl_res->start, 155 ap->ioaddr.ctl_addr = devm_ioremap(dev, ctl_res->start,
156 ctl_res->end - ctl_res->start + 1); 156 resource_size(ctl_res));
157 } else { 157 } else {
158 ap->ioaddr.cmd_addr = devm_ioport_map(dev, io_res->start, 158 ap->ioaddr.cmd_addr = devm_ioport_map(dev, io_res->start,
159 io_res->end - io_res->start + 1); 159 resource_size(io_res));
160 ap->ioaddr.ctl_addr = devm_ioport_map(dev, ctl_res->start, 160 ap->ioaddr.ctl_addr = devm_ioport_map(dev, ctl_res->start,
161 ctl_res->end - ctl_res->start + 1); 161 resource_size(ctl_res));
162 } 162 }
163 if (!ap->ioaddr.cmd_addr || !ap->ioaddr.ctl_addr) { 163 if (!ap->ioaddr.cmd_addr || !ap->ioaddr.ctl_addr) {
164 dev_err(dev, "failed to map IO/CTL base\n"); 164 dev_err(dev, "failed to map IO/CTL base\n");
diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c
index 8e3cdef8a25f..45f1e10f917b 100644
--- a/drivers/ata/pata_rb532_cf.c
+++ b/drivers/ata/pata_rb532_cf.c
@@ -151,7 +151,7 @@ static __devinit int rb532_pata_driver_probe(struct platform_device *pdev)
151 info->irq = irq; 151 info->irq = irq;
152 152
153 info->iobase = devm_ioremap_nocache(&pdev->dev, res->start, 153 info->iobase = devm_ioremap_nocache(&pdev->dev, res->start,
154 res->end - res->start + 1); 154 resource_size(res));
155 if (!info->iobase) 155 if (!info->iobase)
156 return -ENOMEM; 156 return -ENOMEM;
157 157
diff --git a/drivers/ata/pata_rdc.c b/drivers/ata/pata_rdc.c
new file mode 100644
index 000000000000..c843a1e07c4f
--- /dev/null
+++ b/drivers/ata/pata_rdc.c
@@ -0,0 +1,400 @@
1/*
2 * pata_rdc - Driver for later RDC PATA controllers
3 *
4 * This is actually a driver for hardware meeting
5 * INCITS 370-2004 (1510D): ATA Host Adapter Standards
6 *
7 * Based on ata_piix.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; see the file COPYING. If not, write to
21 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/pci.h>
27#include <linux/init.h>
28#include <linux/blkdev.h>
29#include <linux/delay.h>
30#include <linux/device.h>
31#include <scsi/scsi_host.h>
32#include <linux/libata.h>
33#include <linux/dmi.h>
34
35#define DRV_NAME "pata_rdc"
36#define DRV_VERSION "0.01"
37
38struct rdc_host_priv {
39 u32 saved_iocfg;
40};
41
42/**
43 * rdc_pata_cable_detect - Probe host controller cable detect info
44 * @ap: Port for which cable detect info is desired
45 *
46 * Read 80c cable indicator from ATA PCI device's PCI config
47 * register. This register is normally set by firmware (BIOS).
48 *
49 * LOCKING:
50 * None (inherited from caller).
51 */
52
53static int rdc_pata_cable_detect(struct ata_port *ap)
54{
55 struct rdc_host_priv *hpriv = ap->host->private_data;
56 u8 mask;
57
58 /* check BIOS cable detect results */
59 mask = 0x30 << (2 * ap->port_no);
60 if ((hpriv->saved_iocfg & mask) == 0)
61 return ATA_CBL_PATA40;
62 return ATA_CBL_PATA80;
63}
64
65/**
66 * rdc_pata_prereset - prereset for PATA host controller
67 * @link: Target link
68 * @deadline: deadline jiffies for the operation
69 *
70 * LOCKING:
71 * None (inherited from caller).
72 */
73static int rdc_pata_prereset(struct ata_link *link, unsigned long deadline)
74{
75 struct ata_port *ap = link->ap;
76 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
77
78 static const struct pci_bits rdc_enable_bits[] = {
79 { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */
80 { 0x43U, 1U, 0x80UL, 0x80UL }, /* port 1 */
81 };
82
83 if (!pci_test_config_bits(pdev, &rdc_enable_bits[ap->port_no]))
84 return -ENOENT;
85 return ata_sff_prereset(link, deadline);
86}
87
88/**
89 * rdc_set_piomode - Initialize host controller PATA PIO timings
90 * @ap: Port whose timings we are configuring
91 * @adev: um
92 *
93 * Set PIO mode for device, in host controller PCI config space.
94 *
95 * LOCKING:
96 * None (inherited from caller).
97 */
98
99static void rdc_set_piomode(struct ata_port *ap, struct ata_device *adev)
100{
101 unsigned int pio = adev->pio_mode - XFER_PIO_0;
102 struct pci_dev *dev = to_pci_dev(ap->host->dev);
103 unsigned int is_slave = (adev->devno != 0);
104 unsigned int master_port= ap->port_no ? 0x42 : 0x40;
105 unsigned int slave_port = 0x44;
106 u16 master_data;
107 u8 slave_data;
108 u8 udma_enable;
109 int control = 0;
110
111 static const /* ISP RTC */
112 u8 timings[][2] = { { 0, 0 },
113 { 0, 0 },
114 { 1, 0 },
115 { 2, 1 },
116 { 2, 3 }, };
117
118 if (pio >= 2)
119 control |= 1; /* TIME1 enable */
120 if (ata_pio_need_iordy(adev))
121 control |= 2; /* IE enable */
122
123 if (adev->class == ATA_DEV_ATA)
124 control |= 4; /* PPE enable */
125
126 /* PIO configuration clears DTE unconditionally. It will be
127 * programmed in set_dmamode which is guaranteed to be called
128 * after set_piomode if any DMA mode is available.
129 */
130 pci_read_config_word(dev, master_port, &master_data);
131 if (is_slave) {
132 /* clear TIME1|IE1|PPE1|DTE1 */
133 master_data &= 0xff0f;
134 /* Enable SITRE (separate slave timing register) */
135 master_data |= 0x4000;
136 /* enable PPE1, IE1 and TIME1 as needed */
137 master_data |= (control << 4);
138 pci_read_config_byte(dev, slave_port, &slave_data);
139 slave_data &= (ap->port_no ? 0x0f : 0xf0);
140 /* Load the timing nibble for this slave */
141 slave_data |= ((timings[pio][0] << 2) | timings[pio][1])
142 << (ap->port_no ? 4 : 0);
143 } else {
144 /* clear ISP|RCT|TIME0|IE0|PPE0|DTE0 */
145 master_data &= 0xccf0;
146 /* Enable PPE, IE and TIME as appropriate */
147 master_data |= control;
148 /* load ISP and RCT */
149 master_data |=
150 (timings[pio][0] << 12) |
151 (timings[pio][1] << 8);
152 }
153 pci_write_config_word(dev, master_port, master_data);
154 if (is_slave)
155 pci_write_config_byte(dev, slave_port, slave_data);
156
157 /* Ensure the UDMA bit is off - it will be turned back on if
158 UDMA is selected */
159
160 pci_read_config_byte(dev, 0x48, &udma_enable);
161 udma_enable &= ~(1 << (2 * ap->port_no + adev->devno));
162 pci_write_config_byte(dev, 0x48, udma_enable);
163}
164
165/**
166 * rdc_set_dmamode - Initialize host controller PATA PIO timings
167 * @ap: Port whose timings we are configuring
168 * @adev: Drive in question
169 *
170 * Set UDMA mode for device, in host controller PCI config space.
171 *
172 * LOCKING:
173 * None (inherited from caller).
174 */
175
176static void rdc_set_dmamode(struct ata_port *ap, struct ata_device *adev)
177{
178 struct pci_dev *dev = to_pci_dev(ap->host->dev);
179 u8 master_port = ap->port_no ? 0x42 : 0x40;
180 u16 master_data;
181 u8 speed = adev->dma_mode;
182 int devid = adev->devno + 2 * ap->port_no;
183 u8 udma_enable = 0;
184
185 static const /* ISP RTC */
186 u8 timings[][2] = { { 0, 0 },
187 { 0, 0 },
188 { 1, 0 },
189 { 2, 1 },
190 { 2, 3 }, };
191
192 pci_read_config_word(dev, master_port, &master_data);
193 pci_read_config_byte(dev, 0x48, &udma_enable);
194
195 if (speed >= XFER_UDMA_0) {
196 unsigned int udma = adev->dma_mode - XFER_UDMA_0;
197 u16 udma_timing;
198 u16 ideconf;
199 int u_clock, u_speed;
200
201 /*
202 * UDMA is handled by a combination of clock switching and
203 * selection of dividers
204 *
205 * Handy rule: Odd modes are UDMATIMx 01, even are 02
206 * except UDMA0 which is 00
207 */
208 u_speed = min(2 - (udma & 1), udma);
209 if (udma == 5)
210 u_clock = 0x1000; /* 100Mhz */
211 else if (udma > 2)
212 u_clock = 1; /* 66Mhz */
213 else
214 u_clock = 0; /* 33Mhz */
215
216 udma_enable |= (1 << devid);
217
218 /* Load the CT/RP selection */
219 pci_read_config_word(dev, 0x4A, &udma_timing);
220 udma_timing &= ~(3 << (4 * devid));
221 udma_timing |= u_speed << (4 * devid);
222 pci_write_config_word(dev, 0x4A, udma_timing);
223
224 /* Select a 33/66/100Mhz clock */
225 pci_read_config_word(dev, 0x54, &ideconf);
226 ideconf &= ~(0x1001 << devid);
227 ideconf |= u_clock << devid;
228 pci_write_config_word(dev, 0x54, ideconf);
229 } else {
230 /*
231 * MWDMA is driven by the PIO timings. We must also enable
232 * IORDY unconditionally along with TIME1. PPE has already
233 * been set when the PIO timing was set.
234 */
235 unsigned int mwdma = adev->dma_mode - XFER_MW_DMA_0;
236 unsigned int control;
237 u8 slave_data;
238 const unsigned int needed_pio[3] = {
239 XFER_PIO_0, XFER_PIO_3, XFER_PIO_4
240 };
241 int pio = needed_pio[mwdma] - XFER_PIO_0;
242
243 control = 3; /* IORDY|TIME1 */
244
245 /* If the drive MWDMA is faster than it can do PIO then
246 we must force PIO into PIO0 */
247
248 if (adev->pio_mode < needed_pio[mwdma])
249 /* Enable DMA timing only */
250 control |= 8; /* PIO cycles in PIO0 */
251
252 if (adev->devno) { /* Slave */
253 master_data &= 0xFF4F; /* Mask out IORDY|TIME1|DMAONLY */
254 master_data |= control << 4;
255 pci_read_config_byte(dev, 0x44, &slave_data);
256 slave_data &= (ap->port_no ? 0x0f : 0xf0);
257 /* Load the matching timing */
258 slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->port_no ? 4 : 0);
259 pci_write_config_byte(dev, 0x44, slave_data);
260 } else { /* Master */
261 master_data &= 0xCCF4; /* Mask out IORDY|TIME1|DMAONLY
262 and master timing bits */
263 master_data |= control;
264 master_data |=
265 (timings[pio][0] << 12) |
266 (timings[pio][1] << 8);
267 }
268
269 udma_enable &= ~(1 << devid);
270 pci_write_config_word(dev, master_port, master_data);
271 }
272 pci_write_config_byte(dev, 0x48, udma_enable);
273}
274
275static struct ata_port_operations rdc_pata_ops = {
276 .inherits = &ata_bmdma32_port_ops,
277 .cable_detect = rdc_pata_cable_detect,
278 .set_piomode = rdc_set_piomode,
279 .set_dmamode = rdc_set_dmamode,
280 .prereset = rdc_pata_prereset,
281};
282
283static struct ata_port_info rdc_port_info = {
284
285 .flags = ATA_FLAG_SLAVE_POSS,
286 .pio_mask = ATA_PIO4,
287 .mwdma_mask = ATA_MWDMA2,
288 .udma_mask = ATA_UDMA5,
289 .port_ops = &rdc_pata_ops,
290};
291
292static struct scsi_host_template rdc_sht = {
293 ATA_BMDMA_SHT(DRV_NAME),
294};
295
296/**
297 * rdc_init_one - Register PIIX ATA PCI device with kernel services
298 * @pdev: PCI device to register
299 * @ent: Entry in rdc_pci_tbl matching with @pdev
300 *
301 * Called from kernel PCI layer. We probe for combined mode (sigh),
302 * and then hand over control to libata, for it to do the rest.
303 *
304 * LOCKING:
305 * Inherited from PCI layer (may sleep).
306 *
307 * RETURNS:
308 * Zero on success, or -ERRNO value.
309 */
310
311static int __devinit rdc_init_one(struct pci_dev *pdev,
312 const struct pci_device_id *ent)
313{
314 static int printed_version;
315 struct device *dev = &pdev->dev;
316 struct ata_port_info port_info[2];
317 const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] };
318 unsigned long port_flags;
319 struct ata_host *host;
320 struct rdc_host_priv *hpriv;
321 int rc;
322
323 if (!printed_version++)
324 dev_printk(KERN_DEBUG, &pdev->dev,
325 "version " DRV_VERSION "\n");
326
327 port_info[0] = rdc_port_info;
328 port_info[1] = rdc_port_info;
329
330 port_flags = port_info[0].flags;
331
332 /* enable device and prepare host */
333 rc = pcim_enable_device(pdev);
334 if (rc)
335 return rc;
336
337 hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
338 if (!hpriv)
339 return -ENOMEM;
340
341 /* Save IOCFG, this will be used for cable detection, quirk
342 * detection and restoration on detach.
343 */
344 pci_read_config_dword(pdev, 0x54, &hpriv->saved_iocfg);
345
346 rc = ata_pci_sff_prepare_host(pdev, ppi, &host);
347 if (rc)
348 return rc;
349 host->private_data = hpriv;
350
351 pci_intx(pdev, 1);
352
353 host->flags |= ATA_HOST_PARALLEL_SCAN;
354
355 pci_set_master(pdev);
356 return ata_pci_sff_activate_host(host, ata_sff_interrupt, &rdc_sht);
357}
358
359static void rdc_remove_one(struct pci_dev *pdev)
360{
361 struct ata_host *host = dev_get_drvdata(&pdev->dev);
362 struct rdc_host_priv *hpriv = host->private_data;
363
364 pci_write_config_dword(pdev, 0x54, hpriv->saved_iocfg);
365
366 ata_pci_remove_one(pdev);
367}
368
369static const struct pci_device_id rdc_pci_tbl[] = {
370 { PCI_DEVICE(0x17F3, 0x1011), },
371 { PCI_DEVICE(0x17F3, 0x1012), },
372 { } /* terminate list */
373};
374
375static struct pci_driver rdc_pci_driver = {
376 .name = DRV_NAME,
377 .id_table = rdc_pci_tbl,
378 .probe = rdc_init_one,
379 .remove = rdc_remove_one,
380};
381
382
383static int __init rdc_init(void)
384{
385 return pci_register_driver(&rdc_pci_driver);
386}
387
388static void __exit rdc_exit(void)
389{
390 pci_unregister_driver(&rdc_pci_driver);
391}
392
393module_init(rdc_init);
394module_exit(rdc_exit);
395
396MODULE_AUTHOR("Alan Cox (based on ata_piix)");
397MODULE_DESCRIPTION("SCSI low-level driver for RDC PATA controllers");
398MODULE_LICENSE("GPL");
399MODULE_DEVICE_TABLE(pci, rdc_pci_tbl);
400MODULE_VERSION(DRV_VERSION);
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
index 0c574c065c62..a5e4dfe60b41 100644
--- a/drivers/ata/pata_rz1000.c
+++ b/drivers/ata/pata_rz1000.c
@@ -85,7 +85,6 @@ static int rz1000_fifo_disable(struct pci_dev *pdev)
85 85
86static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 86static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
87{ 87{
88 static int printed_version;
89 static const struct ata_port_info info = { 88 static const struct ata_port_info info = {
90 .flags = ATA_FLAG_SLAVE_POSS, 89 .flags = ATA_FLAG_SLAVE_POSS,
91 .pio_mask = ATA_PIO4, 90 .pio_mask = ATA_PIO4,
@@ -93,8 +92,7 @@ static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *en
93 }; 92 };
94 const struct ata_port_info *ppi[] = { &info, NULL }; 93 const struct ata_port_info *ppi[] = { &info, NULL };
95 94
96 if (!printed_version++) 95 printk_once(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
97 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
98 96
99 if (rz1000_fifo_disable(pdev) == 0) 97 if (rz1000_fifo_disable(pdev) == 0)
100 return ata_pci_sff_init_one(pdev, ppi, &rz1000_sht, NULL); 98 return ata_pci_sff_init_one(pdev, ppi, &rz1000_sht, NULL);
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index 94eaa432c40a..d344db42a002 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -1257,6 +1257,7 @@ static struct scsi_host_template sata_fsl_sht = {
1257static struct ata_port_operations sata_fsl_ops = { 1257static struct ata_port_operations sata_fsl_ops = {
1258 .inherits = &sata_pmp_port_ops, 1258 .inherits = &sata_pmp_port_ops,
1259 1259
1260 .qc_defer = ata_std_qc_defer,
1260 .qc_prep = sata_fsl_qc_prep, 1261 .qc_prep = sata_fsl_qc_prep,
1261 .qc_issue = sata_fsl_qc_issue, 1262 .qc_issue = sata_fsl_qc_issue,
1262 .qc_fill_rtf = sata_fsl_qc_fill_rtf, 1263 .qc_fill_rtf = sata_fsl_qc_fill_rtf,
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index 8d890cc5a7ee..4406902b4293 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -405,7 +405,7 @@ static irqreturn_t inic_interrupt(int irq, void *dev_instance)
405 struct ata_host *host = dev_instance; 405 struct ata_host *host = dev_instance;
406 struct inic_host_priv *hpriv = host->private_data; 406 struct inic_host_priv *hpriv = host->private_data;
407 u16 host_irq_stat; 407 u16 host_irq_stat;
408 int i, handled = 0;; 408 int i, handled = 0;
409 409
410 host_irq_stat = readw(hpriv->mmio_base + HOST_IRQ_STAT); 410 host_irq_stat = readw(hpriv->mmio_base + HOST_IRQ_STAT);
411 411
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index c19417e02208..17f9ff9067a2 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -4013,7 +4013,7 @@ static int mv_platform_probe(struct platform_device *pdev)
4013 4013
4014 host->iomap = NULL; 4014 host->iomap = NULL;
4015 hpriv->base = devm_ioremap(&pdev->dev, res->start, 4015 hpriv->base = devm_ioremap(&pdev->dev, res->start,
4016 res->end - res->start + 1); 4016 resource_size(res));
4017 hpriv->base -= SATAHC0_REG_BASE; 4017 hpriv->base -= SATAHC0_REG_BASE;
4018 4018
4019 /* 4019 /*
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index 35bd5cc7f285..3cb69d5fb817 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -565,6 +565,19 @@ static void sil_freeze(struct ata_port *ap)
565 tmp |= SIL_MASK_IDE0_INT << ap->port_no; 565 tmp |= SIL_MASK_IDE0_INT << ap->port_no;
566 writel(tmp, mmio_base + SIL_SYSCFG); 566 writel(tmp, mmio_base + SIL_SYSCFG);
567 readl(mmio_base + SIL_SYSCFG); /* flush */ 567 readl(mmio_base + SIL_SYSCFG); /* flush */
568
569 /* Ensure DMA_ENABLE is off.
570 *
571 * This is because the controller will not give us access to the
572 * taskfile registers while a DMA is in progress
573 */
574 iowrite8(ioread8(ap->ioaddr.bmdma_addr) & ~SIL_DMA_ENABLE,
575 ap->ioaddr.bmdma_addr);
576
577 /* According to ata_bmdma_stop, an HDMA transition requires
578 * on PIO cycle. But we can't read a taskfile register.
579 */
580 ioread8(ap->ioaddr.bmdma_addr);
568} 581}
569 582
570static void sil_thaw(struct ata_port *ap) 583static void sil_thaw(struct ata_port *ap)
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index 77aa8d7ecec4..e6946fc527d0 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -846,6 +846,17 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc)
846 if (!ata_is_atapi(qc->tf.protocol)) { 846 if (!ata_is_atapi(qc->tf.protocol)) {
847 prb = &cb->ata.prb; 847 prb = &cb->ata.prb;
848 sge = cb->ata.sge; 848 sge = cb->ata.sge;
849 if (ata_is_data(qc->tf.protocol)) {
850 u16 prot = 0;
851 ctrl = PRB_CTRL_PROTOCOL;
852 if (ata_is_ncq(qc->tf.protocol))
853 prot |= PRB_PROT_NCQ;
854 if (qc->tf.flags & ATA_TFLAG_WRITE)
855 prot |= PRB_PROT_WRITE;
856 else
857 prot |= PRB_PROT_READ;
858 prb->prot = cpu_to_le16(prot);
859 }
849 } else { 860 } else {
850 prb = &cb->atapi.prb; 861 prb = &cb->atapi.prb;
851 sge = cb->atapi.sge; 862 sge = cb->atapi.sge;
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c
index 8f9833228619..f8a91bfd66a8 100644
--- a/drivers/ata/sata_sis.c
+++ b/drivers/ata/sata_sis.c
@@ -109,8 +109,9 @@ MODULE_LICENSE("GPL");
109MODULE_DEVICE_TABLE(pci, sis_pci_tbl); 109MODULE_DEVICE_TABLE(pci, sis_pci_tbl);
110MODULE_VERSION(DRV_VERSION); 110MODULE_VERSION(DRV_VERSION);
111 111
112static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg) 112static unsigned int get_scr_cfg_addr(struct ata_link *link, unsigned int sc_reg)
113{ 113{
114 struct ata_port *ap = link->ap;
114 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 115 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
115 unsigned int addr = SIS_SCR_BASE + (4 * sc_reg); 116 unsigned int addr = SIS_SCR_BASE + (4 * sc_reg);
116 u8 pmr; 117 u8 pmr;
@@ -131,6 +132,9 @@ static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg)
131 break; 132 break;
132 } 133 }
133 } 134 }
135 if (link->pmp)
136 addr += 0x10;
137
134 return addr; 138 return addr;
135} 139}
136 140
@@ -138,24 +142,12 @@ static u32 sis_scr_cfg_read(struct ata_link *link,
138 unsigned int sc_reg, u32 *val) 142 unsigned int sc_reg, u32 *val)
139{ 143{
140 struct pci_dev *pdev = to_pci_dev(link->ap->host->dev); 144 struct pci_dev *pdev = to_pci_dev(link->ap->host->dev);
141 unsigned int cfg_addr = get_scr_cfg_addr(link->ap, sc_reg); 145 unsigned int cfg_addr = get_scr_cfg_addr(link, sc_reg);
142 u32 val2 = 0;
143 u8 pmr;
144 146
145 if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */ 147 if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */
146 return -EINVAL; 148 return -EINVAL;
147 149
148 pci_read_config_byte(pdev, SIS_PMR, &pmr);
149
150 pci_read_config_dword(pdev, cfg_addr, val); 150 pci_read_config_dword(pdev, cfg_addr, val);
151
152 if ((pdev->device == 0x0182) || (pdev->device == 0x0183) ||
153 (pdev->device == 0x1182) || (pmr & SIS_PMR_COMBINED))
154 pci_read_config_dword(pdev, cfg_addr+0x10, &val2);
155
156 *val |= val2;
157 *val &= 0xfffffffb; /* avoid problems with powerdowned ports */
158
159 return 0; 151 return 0;
160} 152}
161 153
@@ -163,28 +155,16 @@ static int sis_scr_cfg_write(struct ata_link *link,
163 unsigned int sc_reg, u32 val) 155 unsigned int sc_reg, u32 val)
164{ 156{
165 struct pci_dev *pdev = to_pci_dev(link->ap->host->dev); 157 struct pci_dev *pdev = to_pci_dev(link->ap->host->dev);
166 unsigned int cfg_addr = get_scr_cfg_addr(link->ap, sc_reg); 158 unsigned int cfg_addr = get_scr_cfg_addr(link, sc_reg);
167 u8 pmr;
168
169 if (sc_reg == SCR_ERROR) /* doesn't exist in PCI cfg space */
170 return -EINVAL;
171
172 pci_read_config_byte(pdev, SIS_PMR, &pmr);
173 159
174 pci_write_config_dword(pdev, cfg_addr, val); 160 pci_write_config_dword(pdev, cfg_addr, val);
175
176 if ((pdev->device == 0x0182) || (pdev->device == 0x0183) ||
177 (pdev->device == 0x1182) || (pmr & SIS_PMR_COMBINED))
178 pci_write_config_dword(pdev, cfg_addr+0x10, val);
179
180 return 0; 161 return 0;
181} 162}
182 163
183static int sis_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val) 164static int sis_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val)
184{ 165{
185 struct ata_port *ap = link->ap; 166 struct ata_port *ap = link->ap;
186 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 167 void __iomem *base = ap->ioaddr.scr_addr + link->pmp * 0x10;
187 u8 pmr;
188 168
189 if (sc_reg > SCR_CONTROL) 169 if (sc_reg > SCR_CONTROL)
190 return -EINVAL; 170 return -EINVAL;
@@ -192,39 +172,23 @@ static int sis_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val)
192 if (ap->flags & SIS_FLAG_CFGSCR) 172 if (ap->flags & SIS_FLAG_CFGSCR)
193 return sis_scr_cfg_read(link, sc_reg, val); 173 return sis_scr_cfg_read(link, sc_reg, val);
194 174
195 pci_read_config_byte(pdev, SIS_PMR, &pmr); 175 *val = ioread32(base + sc_reg * 4);
196
197 *val = ioread32(ap->ioaddr.scr_addr + (sc_reg * 4));
198
199 if ((pdev->device == 0x0182) || (pdev->device == 0x0183) ||
200 (pdev->device == 0x1182) || (pmr & SIS_PMR_COMBINED))
201 *val |= ioread32(ap->ioaddr.scr_addr + (sc_reg * 4) + 0x10);
202
203 *val &= 0xfffffffb;
204
205 return 0; 176 return 0;
206} 177}
207 178
208static int sis_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val) 179static int sis_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
209{ 180{
210 struct ata_port *ap = link->ap; 181 struct ata_port *ap = link->ap;
211 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 182 void __iomem *base = ap->ioaddr.scr_addr + link->pmp * 0x10;
212 u8 pmr;
213 183
214 if (sc_reg > SCR_CONTROL) 184 if (sc_reg > SCR_CONTROL)
215 return -EINVAL; 185 return -EINVAL;
216 186
217 pci_read_config_byte(pdev, SIS_PMR, &pmr);
218
219 if (ap->flags & SIS_FLAG_CFGSCR) 187 if (ap->flags & SIS_FLAG_CFGSCR)
220 return sis_scr_cfg_write(link, sc_reg, val); 188 return sis_scr_cfg_write(link, sc_reg, val);
221 else { 189
222 iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4)); 190 iowrite32(val, base + (sc_reg * 4));
223 if ((pdev->device == 0x0182) || (pdev->device == 0x0183) || 191 return 0;
224 (pdev->device == 0x1182) || (pmr & SIS_PMR_COMBINED))
225 iowrite32(val, ap->ioaddr.scr_addr + (sc_reg * 4)+0x10);
226 return 0;
227 }
228} 192}
229 193
230static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 194static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
@@ -236,7 +200,7 @@ static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
236 u32 genctl, val; 200 u32 genctl, val;
237 u8 pmr; 201 u8 pmr;
238 u8 port2_start = 0x20; 202 u8 port2_start = 0x20;
239 int rc; 203 int i, rc;
240 204
241 if (!printed_version++) 205 if (!printed_version++)
242 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); 206 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
@@ -319,6 +283,17 @@ static int sis_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
319 if (rc) 283 if (rc)
320 return rc; 284 return rc;
321 285
286 for (i = 0; i < 2; i++) {
287 struct ata_port *ap = host->ports[i];
288
289 if (ap->flags & ATA_FLAG_SATA &&
290 ap->flags & ATA_FLAG_SLAVE_POSS) {
291 rc = ata_slave_link_init(ap);
292 if (rc)
293 return rc;
294 }
295 }
296
322 if (!(pi.flags & SIS_FLAG_CFGSCR)) { 297 if (!(pi.flags & SIS_FLAG_CFGSCR)) {
323 void __iomem *mmio; 298 void __iomem *mmio;
324 299
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 24c84ae81527..938100f14b16 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -568,35 +568,76 @@ const struct dmi_device * dmi_find_device(int type, const char *name,
568EXPORT_SYMBOL(dmi_find_device); 568EXPORT_SYMBOL(dmi_find_device);
569 569
570/** 570/**
571 * dmi_get_year - Return year of a DMI date 571 * dmi_get_date - parse a DMI date
572 * @field: data index (like dmi_get_system_info) 572 * @field: data index (see enum dmi_field)
573 * @yearp: optional out parameter for the year
574 * @monthp: optional out parameter for the month
575 * @dayp: optional out parameter for the day
573 * 576 *
574 * Returns -1 when the field doesn't exist. 0 when it is broken. 577 * The date field is assumed to be in the form resembling
578 * [mm[/dd]]/yy[yy] and the result is stored in the out
579 * parameters any or all of which can be omitted.
580 *
581 * If the field doesn't exist, all out parameters are set to zero
582 * and false is returned. Otherwise, true is returned with any
583 * invalid part of date set to zero.
584 *
585 * On return, year, month and day are guaranteed to be in the
586 * range of [0,9999], [0,12] and [0,31] respectively.
575 */ 587 */
576int dmi_get_year(int field) 588bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp)
577{ 589{
578 int year; 590 int year = 0, month = 0, day = 0;
579 const char *s = dmi_get_system_info(field); 591 bool exists;
592 const char *s, *y;
593 char *e;
580 594
581 if (!s) 595 s = dmi_get_system_info(field);
582 return -1; 596 exists = s;
583 if (*s == '\0') 597 if (!exists)
584 return 0; 598 goto out;
585 s = strrchr(s, '/');
586 if (!s)
587 return 0;
588 599
589 s += 1; 600 /*
590 year = simple_strtoul(s, NULL, 0); 601 * Determine year first. We assume the date string resembles
591 if (year && year < 100) { /* 2-digit year */ 602 * mm/dd/yy[yy] but the original code extracted only the year
603 * from the end. Keep the behavior in the spirit of no
604 * surprises.
605 */
606 y = strrchr(s, '/');
607 if (!y)
608 goto out;
609
610 y++;
611 year = simple_strtoul(y, &e, 10);
612 if (y != e && year < 100) { /* 2-digit year */
592 year += 1900; 613 year += 1900;
593 if (year < 1996) /* no dates < spec 1.0 */ 614 if (year < 1996) /* no dates < spec 1.0 */
594 year += 100; 615 year += 100;
595 } 616 }
617 if (year > 9999) /* year should fit in %04d */
618 year = 0;
619
620 /* parse the mm and dd */
621 month = simple_strtoul(s, &e, 10);
622 if (s == e || *e != '/' || !month || month > 12) {
623 month = 0;
624 goto out;
625 }
596 626
597 return year; 627 s = e + 1;
628 day = simple_strtoul(s, &e, 10);
629 if (s == y || s == e || *e != '/' || day > 31)
630 day = 0;
631out:
632 if (yearp)
633 *yearp = year;
634 if (monthp)
635 *monthp = month;
636 if (dayp)
637 *dayp = day;
638 return exists;
598} 639}
599EXPORT_SYMBOL(dmi_get_year); 640EXPORT_SYMBOL(dmi_get_date);
600 641
601/** 642/**
602 * dmi_walk - Walk the DMI table and get called back for every record 643 * dmi_walk - Walk the DMI table and get called back for every record
diff --git a/drivers/ide/atiixp.c b/drivers/ide/atiixp.c
index 923cbfe259d3..6396c3ad3252 100644
--- a/drivers/ide/atiixp.c
+++ b/drivers/ide/atiixp.c
@@ -177,6 +177,7 @@ static const struct pci_device_id atiixp_pci_tbl[] = {
177 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP400_IDE), 0 }, 177 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP400_IDE), 0 },
178 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP600_IDE), 1 }, 178 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP600_IDE), 1 },
179 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP700_IDE), 0 }, 179 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP700_IDE), 0 },
180 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_SB900_IDE), 0 },
180 { 0, }, 181 { 0, },
181}; 182};
182MODULE_DEVICE_TABLE(pci, atiixp_pci_tbl); 183MODULE_DEVICE_TABLE(pci, atiixp_pci_tbl);
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 06b965623962..85ce23997be4 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -992,7 +992,7 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX,
992 992
993static void __devinit quirk_amd_ide_mode(struct pci_dev *pdev) 993static void __devinit quirk_amd_ide_mode(struct pci_dev *pdev)
994{ 994{
995 /* set sb600/sb700/sb800 sata to ahci mode */ 995 /* set SBX00 SATA in IDE mode to AHCI mode */
996 u8 tmp; 996 u8 tmp;
997 997
998 pci_read_config_byte(pdev, PCI_CLASS_DEVICE, &tmp); 998 pci_read_config_byte(pdev, PCI_CLASS_DEVICE, &tmp);
@@ -1011,6 +1011,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk
1011DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode); 1011DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode);
1012DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode); 1012DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode);
1013DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode); 1013DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode);
1014DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_SB900_SATA_IDE, quirk_amd_ide_mode);
1015DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_SB900_SATA_IDE, quirk_amd_ide_mode);
1014 1016
1015/* 1017/*
1016 * Serverworks CSB5 IDE does not fully support native mode 1018 * Serverworks CSB5 IDE does not fully support native mode