aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-03-30 17:29:20 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-30 17:29:20 -0500
commit256414dee44eaa0983f5ab1a71877de23c4e9ce7 (patch)
tree770768cdd6ff6324f55fd305cb26109e89322fb0 /drivers
parent63e8d9114dab88c101be2372cb1f83a4fe74d9c1 (diff)
parent55d8ca4f8094246da6e71889a4e04bfafaa78b10 (diff)
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev: [PATCH] sata_mv: three bug fixes [PATCH] libata: ata_dev_init_params() fixes [PATCH] libata: Fix interesting use of "extern" and also some bracketing [PATCH] libata: Simplex and other mode filtering logic [PATCH] libata - ATA is both ATA and CFA [PATCH] libata: Add ->set_mode hook for odd drivers [PATCH] libata: BMDMA handling updates [PATCH] libata: kill trailing whitespace [PATCH] libata: add FIXME above ata_dev_xfermask() [PATCH] libata: cosmetic changes in ata_bus_softreset() [PATCH] libata: kill E.D.D.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/libata-bmdma.c26
-rw-r--r--drivers/scsi/libata-core.c168
-rw-r--r--drivers/scsi/sata_mv.c42
3 files changed, 112 insertions, 124 deletions
diff --git a/drivers/scsi/libata-bmdma.c b/drivers/scsi/libata-bmdma.c
index 95d81d86d8b7..835dff0bafdc 100644
--- a/drivers/scsi/libata-bmdma.c
+++ b/drivers/scsi/libata-bmdma.c
@@ -703,6 +703,7 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
703 struct ata_probe_ent *probe_ent = 703 struct ata_probe_ent *probe_ent =
704 ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]); 704 ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]);
705 int p = 0; 705 int p = 0;
706 unsigned long bmdma;
706 707
707 if (!probe_ent) 708 if (!probe_ent)
708 return NULL; 709 return NULL;
@@ -716,7 +717,12 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
716 probe_ent->port[p].altstatus_addr = 717 probe_ent->port[p].altstatus_addr =
717 probe_ent->port[p].ctl_addr = 718 probe_ent->port[p].ctl_addr =
718 pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS; 719 pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS;
719 probe_ent->port[p].bmdma_addr = pci_resource_start(pdev, 4); 720 bmdma = pci_resource_start(pdev, 4);
721 if (bmdma) {
722 if (inb(bmdma + 2) & 0x80)
723 probe_ent->host_set_flags |= ATA_HOST_SIMPLEX;
724 probe_ent->port[p].bmdma_addr = bmdma;
725 }
720 ata_std_ports(&probe_ent->port[p]); 726 ata_std_ports(&probe_ent->port[p]);
721 p++; 727 p++;
722 } 728 }
@@ -726,7 +732,13 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
726 probe_ent->port[p].altstatus_addr = 732 probe_ent->port[p].altstatus_addr =
727 probe_ent->port[p].ctl_addr = 733 probe_ent->port[p].ctl_addr =
728 pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS; 734 pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS;
729 probe_ent->port[p].bmdma_addr = pci_resource_start(pdev, 4) + 8; 735 bmdma = pci_resource_start(pdev, 4);
736 if (bmdma) {
737 bmdma += 8;
738 if(inb(bmdma + 2) & 0x80)
739 probe_ent->host_set_flags |= ATA_HOST_SIMPLEX;
740 probe_ent->port[p].bmdma_addr = bmdma;
741 }
730 ata_std_ports(&probe_ent->port[p]); 742 ata_std_ports(&probe_ent->port[p]);
731 p++; 743 p++;
732 } 744 }
@@ -740,6 +752,7 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
740 struct ata_port_info *port, int port_num) 752 struct ata_port_info *port, int port_num)
741{ 753{
742 struct ata_probe_ent *probe_ent; 754 struct ata_probe_ent *probe_ent;
755 unsigned long bmdma;
743 756
744 probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port); 757 probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port);
745 if (!probe_ent) 758 if (!probe_ent)
@@ -766,8 +779,13 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev,
766 break; 779 break;
767 } 780 }
768 781
769 probe_ent->port[0].bmdma_addr = 782 bmdma = pci_resource_start(pdev, 4);
770 pci_resource_start(pdev, 4) + 8 * port_num; 783 if (bmdma != 0) {
784 bmdma += 8 * port_num;
785 probe_ent->port[0].bmdma_addr = bmdma;
786 if (inb(bmdma + 2) & 0x80)
787 probe_ent->host_set_flags |= ATA_HOST_SIMPLEX;
788 }
771 ata_std_ports(&probe_ent->port[0]); 789 ata_std_ports(&probe_ent->port[0]);
772 790
773 return probe_ent; 791 return probe_ent;
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index d279666dcb38..21b0ed583b8a 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -62,7 +62,9 @@
62#include "libata.h" 62#include "libata.h"
63 63
64static unsigned int ata_dev_init_params(struct ata_port *ap, 64static unsigned int ata_dev_init_params(struct ata_port *ap,
65 struct ata_device *dev); 65 struct ata_device *dev,
66 u16 heads,
67 u16 sectors);
66static void ata_set_mode(struct ata_port *ap); 68static void ata_set_mode(struct ata_port *ap);
67static unsigned int ata_dev_set_xfermode(struct ata_port *ap, 69static unsigned int ata_dev_set_xfermode(struct ata_port *ap,
68 struct ata_device *dev); 70 struct ata_device *dev);
@@ -1081,9 +1083,8 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev)
1081 * 1083 *
1082 * Read ID data from the specified device. ATA_CMD_ID_ATA is 1084 * Read ID data from the specified device. ATA_CMD_ID_ATA is
1083 * performed on ATA devices and ATA_CMD_ID_ATAPI on ATAPI 1085 * performed on ATA devices and ATA_CMD_ID_ATAPI on ATAPI
1084 * devices. This function also takes care of EDD signature 1086 * devices. This function also issues ATA_CMD_INIT_DEV_PARAMS
1085 * misreporting (to be removed once EDD support is gone) and 1087 * for pre-ATA4 drives.
1086 * issues ATA_CMD_INIT_DEV_PARAMS for pre-ATA4 drives.
1087 * 1088 *
1088 * LOCKING: 1089 * LOCKING:
1089 * Kernel thread context (may sleep) 1090 * Kernel thread context (may sleep)
@@ -1095,7 +1096,6 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev,
1095 unsigned int *p_class, int post_reset, u16 **p_id) 1096 unsigned int *p_class, int post_reset, u16 **p_id)
1096{ 1097{
1097 unsigned int class = *p_class; 1098 unsigned int class = *p_class;
1098 unsigned int using_edd;
1099 struct ata_taskfile tf; 1099 struct ata_taskfile tf;
1100 unsigned int err_mask = 0; 1100 unsigned int err_mask = 0;
1101 u16 *id; 1101 u16 *id;
@@ -1104,12 +1104,6 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev,
1104 1104
1105 DPRINTK("ENTER, host %u, dev %u\n", ap->id, dev->devno); 1105 DPRINTK("ENTER, host %u, dev %u\n", ap->id, dev->devno);
1106 1106
1107 if (ap->ops->probe_reset ||
1108 ap->flags & (ATA_FLAG_SRST | ATA_FLAG_SATA_RESET))
1109 using_edd = 0;
1110 else
1111 using_edd = 1;
1112
1113 ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ 1107 ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */
1114 1108
1115 id = kmalloc(sizeof(id[0]) * ATA_ID_WORDS, GFP_KERNEL); 1109 id = kmalloc(sizeof(id[0]) * ATA_ID_WORDS, GFP_KERNEL);
@@ -1139,39 +1133,16 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev,
1139 1133
1140 err_mask = ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE, 1134 err_mask = ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE,
1141 id, sizeof(id[0]) * ATA_ID_WORDS); 1135 id, sizeof(id[0]) * ATA_ID_WORDS);
1142
1143 if (err_mask) { 1136 if (err_mask) {
1144 rc = -EIO; 1137 rc = -EIO;
1145 reason = "I/O error"; 1138 reason = "I/O error";
1146
1147 if (err_mask & ~AC_ERR_DEV)
1148 goto err_out;
1149
1150 /*
1151 * arg! EDD works for all test cases, but seems to return
1152 * the ATA signature for some ATAPI devices. Until the
1153 * reason for this is found and fixed, we fix up the mess
1154 * here. If IDENTIFY DEVICE returns command aborted
1155 * (as ATAPI devices do), then we issue an
1156 * IDENTIFY PACKET DEVICE.
1157 *
1158 * ATA software reset (SRST, the default) does not appear
1159 * to have this problem.
1160 */
1161 if ((using_edd) && (class == ATA_DEV_ATA)) {
1162 u8 err = tf.feature;
1163 if (err & ATA_ABORTED) {
1164 class = ATA_DEV_ATAPI;
1165 goto retry;
1166 }
1167 }
1168 goto err_out; 1139 goto err_out;
1169 } 1140 }
1170 1141
1171 swap_buf_le16(id, ATA_ID_WORDS); 1142 swap_buf_le16(id, ATA_ID_WORDS);
1172 1143
1173 /* sanity check */ 1144 /* sanity check */
1174 if ((class == ATA_DEV_ATA) != ata_id_is_ata(id)) { 1145 if ((class == ATA_DEV_ATA) != (ata_id_is_ata(id) | ata_id_is_cfa(id))) {
1175 rc = -EINVAL; 1146 rc = -EINVAL;
1176 reason = "device reports illegal type"; 1147 reason = "device reports illegal type";
1177 goto err_out; 1148 goto err_out;
@@ -1187,7 +1158,7 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev,
1187 * Some drives were very specific about that exact sequence. 1158 * Some drives were very specific about that exact sequence.
1188 */ 1159 */
1189 if (ata_id_major_version(id) < 4 || !ata_id_has_lba(id)) { 1160 if (ata_id_major_version(id) < 4 || !ata_id_has_lba(id)) {
1190 err_mask = ata_dev_init_params(ap, dev); 1161 err_mask = ata_dev_init_params(ap, dev, id[3], id[6]);
1191 if (err_mask) { 1162 if (err_mask) {
1192 rc = -EIO; 1163 rc = -EIO;
1193 reason = "INIT_DEV_PARAMS failed"; 1164 reason = "INIT_DEV_PARAMS failed";
@@ -1440,7 +1411,11 @@ static int ata_bus_probe(struct ata_port *ap)
1440 if (!found) 1411 if (!found)
1441 goto err_out_disable; 1412 goto err_out_disable;
1442 1413
1443 ata_set_mode(ap); 1414 if (ap->ops->set_mode)
1415 ap->ops->set_mode(ap);
1416 else
1417 ata_set_mode(ap);
1418
1444 if (ap->flags & ATA_FLAG_PORT_DISABLED) 1419 if (ap->flags & ATA_FLAG_PORT_DISABLED)
1445 goto err_out_disable; 1420 goto err_out_disable;
1446 1421
@@ -1845,7 +1820,7 @@ static void ata_host_set_dma(struct ata_port *ap)
1845 */ 1820 */
1846static void ata_set_mode(struct ata_port *ap) 1821static void ata_set_mode(struct ata_port *ap)
1847{ 1822{
1848 int i, rc; 1823 int i, rc, used_dma = 0;
1849 1824
1850 /* step 1: calculate xfer_mask */ 1825 /* step 1: calculate xfer_mask */
1851 for (i = 0; i < ATA_MAX_DEVICES; i++) { 1826 for (i = 0; i < ATA_MAX_DEVICES; i++) {
@@ -1863,6 +1838,9 @@ static void ata_set_mode(struct ata_port *ap)
1863 dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); 1838 dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask);
1864 dev->pio_mode = ata_xfer_mask2mode(pio_mask); 1839 dev->pio_mode = ata_xfer_mask2mode(pio_mask);
1865 dev->dma_mode = ata_xfer_mask2mode(dma_mask); 1840 dev->dma_mode = ata_xfer_mask2mode(dma_mask);
1841
1842 if (dev->dma_mode)
1843 used_dma = 1;
1866 } 1844 }
1867 1845
1868 /* step 2: always set host PIO timings */ 1846 /* step 2: always set host PIO timings */
@@ -1884,6 +1862,17 @@ static void ata_set_mode(struct ata_port *ap)
1884 goto err_out; 1862 goto err_out;
1885 } 1863 }
1886 1864
1865 /*
1866 * Record simplex status. If we selected DMA then the other
1867 * host channels are not permitted to do so.
1868 */
1869
1870 if (used_dma && (ap->host_set->flags & ATA_HOST_SIMPLEX))
1871 ap->host_set->simplex_claimed = 1;
1872
1873 /*
1874 * Chip specific finalisation
1875 */
1887 if (ap->ops->post_set_mode) 1876 if (ap->ops->post_set_mode)
1888 ap->ops->post_set_mode(ap); 1877 ap->ops->post_set_mode(ap);
1889 1878
@@ -2005,45 +1994,6 @@ static void ata_bus_post_reset(struct ata_port *ap, unsigned int devmask)
2005 ap->ops->dev_select(ap, 0); 1994 ap->ops->dev_select(ap, 0);
2006} 1995}
2007 1996
2008/**
2009 * ata_bus_edd - Issue EXECUTE DEVICE DIAGNOSTIC command.
2010 * @ap: Port to reset and probe
2011 *
2012 * Use the EXECUTE DEVICE DIAGNOSTIC command to reset and
2013 * probe the bus. Not often used these days.
2014 *
2015 * LOCKING:
2016 * PCI/etc. bus probe sem.
2017 * Obtains host_set lock.
2018 *
2019 */
2020
2021static unsigned int ata_bus_edd(struct ata_port *ap)
2022{
2023 struct ata_taskfile tf;
2024 unsigned long flags;
2025
2026 /* set up execute-device-diag (bus reset) taskfile */
2027 /* also, take interrupts to a known state (disabled) */
2028 DPRINTK("execute-device-diag\n");
2029 ata_tf_init(ap, &tf, 0);
2030 tf.ctl |= ATA_NIEN;
2031 tf.command = ATA_CMD_EDD;
2032 tf.protocol = ATA_PROT_NODATA;
2033
2034 /* do bus reset */
2035 spin_lock_irqsave(&ap->host_set->lock, flags);
2036 ata_tf_to_host(ap, &tf);
2037 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2038
2039 /* spec says at least 2ms. but who knows with those
2040 * crazy ATAPI devices...
2041 */
2042 msleep(150);
2043
2044 return ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT);
2045}
2046
2047static unsigned int ata_bus_softreset(struct ata_port *ap, 1997static unsigned int ata_bus_softreset(struct ata_port *ap,
2048 unsigned int devmask) 1998 unsigned int devmask)
2049{ 1999{
@@ -2078,13 +2028,12 @@ static unsigned int ata_bus_softreset(struct ata_port *ap,
2078 */ 2028 */
2079 msleep(150); 2029 msleep(150);
2080 2030
2081
2082 /* Before we perform post reset processing we want to see if 2031 /* Before we perform post reset processing we want to see if
2083 the bus shows 0xFF because the odd clown forgets the D7 pulldown 2032 * the bus shows 0xFF because the odd clown forgets the D7
2084 resistor */ 2033 * pulldown resistor.
2085 2034 */
2086 if (ata_check_status(ap) == 0xFF) 2035 if (ata_check_status(ap) == 0xFF)
2087 return 1; /* Positive is failure for some reason */ 2036 return AC_ERR_OTHER;
2088 2037
2089 ata_bus_post_reset(ap, devmask); 2038 ata_bus_post_reset(ap, devmask);
2090 2039
@@ -2116,7 +2065,7 @@ void ata_bus_reset(struct ata_port *ap)
2116 struct ata_ioports *ioaddr = &ap->ioaddr; 2065 struct ata_ioports *ioaddr = &ap->ioaddr;
2117 unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; 2066 unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS;
2118 u8 err; 2067 u8 err;
2119 unsigned int dev0, dev1 = 0, rc = 0, devmask = 0; 2068 unsigned int dev0, dev1 = 0, devmask = 0;
2120 2069
2121 DPRINTK("ENTER, host %u, port %u\n", ap->id, ap->port_no); 2070 DPRINTK("ENTER, host %u, port %u\n", ap->id, ap->port_no);
2122 2071
@@ -2139,18 +2088,8 @@ void ata_bus_reset(struct ata_port *ap)
2139 2088
2140 /* issue bus reset */ 2089 /* issue bus reset */
2141 if (ap->flags & ATA_FLAG_SRST) 2090 if (ap->flags & ATA_FLAG_SRST)
2142 rc = ata_bus_softreset(ap, devmask); 2091 if (ata_bus_softreset(ap, devmask))
2143 else if ((ap->flags & ATA_FLAG_SATA_RESET) == 0) { 2092 goto err_out;
2144 /* set up device control */
2145 if (ap->flags & ATA_FLAG_MMIO)
2146 writeb(ap->ctl, (void __iomem *) ioaddr->ctl_addr);
2147 else
2148 outb(ap->ctl, ioaddr->ctl_addr);
2149 rc = ata_bus_edd(ap);
2150 }
2151
2152 if (rc)
2153 goto err_out;
2154 2093
2155 /* 2094 /*
2156 * determine by signature whether we have ATA or ATAPI devices 2095 * determine by signature whether we have ATA or ATAPI devices
@@ -2223,9 +2162,9 @@ static int sata_phy_resume(struct ata_port *ap)
2223 * so makes reset sequence different from the original 2162 * so makes reset sequence different from the original
2224 * ->phy_reset implementation and Jeff nervous. :-P 2163 * ->phy_reset implementation and Jeff nervous. :-P
2225 */ 2164 */
2226extern void ata_std_probeinit(struct ata_port *ap) 2165void ata_std_probeinit(struct ata_port *ap)
2227{ 2166{
2228 if (ap->flags & ATA_FLAG_SATA && ap->ops->scr_read) { 2167 if ((ap->flags & ATA_FLAG_SATA) && ap->ops->scr_read) {
2229 sata_phy_resume(ap); 2168 sata_phy_resume(ap);
2230 if (sata_dev_present(ap)) 2169 if (sata_dev_present(ap))
2231 ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); 2170 ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT);
@@ -2714,18 +2653,23 @@ static int ata_dma_blacklisted(const struct ata_device *dev)
2714 * known limits including host controller limits, device 2653 * known limits including host controller limits, device
2715 * blacklist, etc... 2654 * blacklist, etc...
2716 * 2655 *
2656 * FIXME: The current implementation limits all transfer modes to
2657 * the fastest of the lowested device on the port. This is not
2658 * required on most controllers.
2659 *
2717 * LOCKING: 2660 * LOCKING:
2718 * None. 2661 * None.
2719 */ 2662 */
2720static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev) 2663static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev)
2721{ 2664{
2665 struct ata_host_set *hs = ap->host_set;
2722 unsigned long xfer_mask; 2666 unsigned long xfer_mask;
2723 int i; 2667 int i;
2724 2668
2725 xfer_mask = ata_pack_xfermask(ap->pio_mask, ap->mwdma_mask, 2669 xfer_mask = ata_pack_xfermask(ap->pio_mask, ap->mwdma_mask,
2726 ap->udma_mask); 2670 ap->udma_mask);
2727 2671
2728 /* use port-wide xfermask for now */ 2672 /* FIXME: Use port-wide xfermask for now */
2729 for (i = 0; i < ATA_MAX_DEVICES; i++) { 2673 for (i = 0; i < ATA_MAX_DEVICES; i++) {
2730 struct ata_device *d = &ap->device[i]; 2674 struct ata_device *d = &ap->device[i];
2731 if (!ata_dev_present(d)) 2675 if (!ata_dev_present(d))
@@ -2735,12 +2679,23 @@ static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev)
2735 xfer_mask &= ata_id_xfermask(d->id); 2679 xfer_mask &= ata_id_xfermask(d->id);
2736 if (ata_dma_blacklisted(d)) 2680 if (ata_dma_blacklisted(d))
2737 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); 2681 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
2682 /* Apply cable rule here. Don't apply it early because when
2683 we handle hot plug the cable type can itself change */
2684 if (ap->cbl == ATA_CBL_PATA40)
2685 xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA);
2738 } 2686 }
2739 2687
2740 if (ata_dma_blacklisted(dev)) 2688 if (ata_dma_blacklisted(dev))
2741 printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, " 2689 printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, "
2742 "disabling DMA\n", ap->id, dev->devno); 2690 "disabling DMA\n", ap->id, dev->devno);
2743 2691
2692 if (hs->flags & ATA_HOST_SIMPLEX) {
2693 if (hs->simplex_claimed)
2694 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
2695 }
2696 if (ap->ops->mode_filter)
2697 xfer_mask = ap->ops->mode_filter(ap, dev, xfer_mask);
2698
2744 ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask, 2699 ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask,
2745 &dev->udma_mask); 2700 &dev->udma_mask);
2746} 2701}
@@ -2795,16 +2750,16 @@ static unsigned int ata_dev_set_xfermode(struct ata_port *ap,
2795 */ 2750 */
2796 2751
2797static unsigned int ata_dev_init_params(struct ata_port *ap, 2752static unsigned int ata_dev_init_params(struct ata_port *ap,
2798 struct ata_device *dev) 2753 struct ata_device *dev,
2754 u16 heads,
2755 u16 sectors)
2799{ 2756{
2800 struct ata_taskfile tf; 2757 struct ata_taskfile tf;
2801 unsigned int err_mask; 2758 unsigned int err_mask;
2802 u16 sectors = dev->id[6];
2803 u16 heads = dev->id[3];
2804 2759
2805 /* Number of sectors per track 1-255. Number of heads 1-16 */ 2760 /* Number of sectors per track 1-255. Number of heads 1-16 */
2806 if (sectors < 1 || sectors > 255 || heads < 1 || heads > 16) 2761 if (sectors < 1 || sectors > 255 || heads < 1 || heads > 16)
2807 return 0; 2762 return AC_ERR_INVALID;
2808 2763
2809 /* set up init dev params taskfile */ 2764 /* set up init dev params taskfile */
2810 DPRINTK("init dev params \n"); 2765 DPRINTK("init dev params \n");
@@ -4536,6 +4491,14 @@ static struct ata_port * ata_host_add(const struct ata_probe_ent *ent,
4536 int rc; 4491 int rc;
4537 4492
4538 DPRINTK("ENTER\n"); 4493 DPRINTK("ENTER\n");
4494
4495 if (!ent->port_ops->probe_reset &&
4496 !(ent->host_flags & (ATA_FLAG_SATA_RESET | ATA_FLAG_SRST))) {
4497 printk(KERN_ERR "ata%u: no reset mechanism available\n",
4498 port_no);
4499 return NULL;
4500 }
4501
4539 host = scsi_host_alloc(ent->sht, sizeof(struct ata_port)); 4502 host = scsi_host_alloc(ent->sht, sizeof(struct ata_port));
4540 if (!host) 4503 if (!host)
4541 return NULL; 4504 return NULL;
@@ -4596,6 +4559,7 @@ int ata_device_add(const struct ata_probe_ent *ent)
4596 host_set->mmio_base = ent->mmio_base; 4559 host_set->mmio_base = ent->mmio_base;
4597 host_set->private_data = ent->private_data; 4560 host_set->private_data = ent->private_data;
4598 host_set->ops = ent->port_ops; 4561 host_set->ops = ent->port_ops;
4562 host_set->flags = ent->host_set_flags;
4599 4563
4600 /* register each port bound to this device */ 4564 /* register each port bound to this device */
4601 for (i = 0; i < ent->n_ports; i++) { 4565 for (i = 0; i < ent->n_ports; i++) {
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index 275ed9bd898c..fa901fd65085 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -1010,7 +1010,7 @@ static void mv_fill_sg(struct ata_queued_cmd *qc)
1010 1010
1011 pp->sg_tbl[i].addr = cpu_to_le32(addr & 0xffffffff); 1011 pp->sg_tbl[i].addr = cpu_to_le32(addr & 0xffffffff);
1012 pp->sg_tbl[i].addr_hi = cpu_to_le32((addr >> 16) >> 16); 1012 pp->sg_tbl[i].addr_hi = cpu_to_le32((addr >> 16) >> 16);
1013 pp->sg_tbl[i].flags_size = cpu_to_le32(len); 1013 pp->sg_tbl[i].flags_size = cpu_to_le32(len & 0xffff);
1014 1014
1015 sg_len -= len; 1015 sg_len -= len;
1016 addr += len; 1016 addr += len;
@@ -1350,7 +1350,6 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1350{ 1350{
1351 void __iomem *mmio = host_set->mmio_base; 1351 void __iomem *mmio = host_set->mmio_base;
1352 void __iomem *hc_mmio = mv_hc_base(mmio, hc); 1352 void __iomem *hc_mmio = mv_hc_base(mmio, hc);
1353 struct ata_port *ap;
1354 struct ata_queued_cmd *qc; 1353 struct ata_queued_cmd *qc;
1355 u32 hc_irq_cause; 1354 u32 hc_irq_cause;
1356 int shift, port, port0, hard_port, handled; 1355 int shift, port, port0, hard_port, handled;
@@ -1373,25 +1372,32 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1373 1372
1374 for (port = port0; port < port0 + MV_PORTS_PER_HC; port++) { 1373 for (port = port0; port < port0 + MV_PORTS_PER_HC; port++) {
1375 u8 ata_status = 0; 1374 u8 ata_status = 0;
1376 ap = host_set->ports[port]; 1375 struct ata_port *ap = host_set->ports[port];
1376 struct mv_port_priv *pp = ap->private_data;
1377
1377 hard_port = port & MV_PORT_MASK; /* range 0-3 */ 1378 hard_port = port & MV_PORT_MASK; /* range 0-3 */
1378 handled = 0; /* ensure ata_status is set if handled++ */ 1379 handled = 0; /* ensure ata_status is set if handled++ */
1379 1380
1380 if ((CRPB_DMA_DONE << hard_port) & hc_irq_cause) { 1381 /* Note that DEV_IRQ might happen spuriously during EDMA,
1381 /* new CRPB on the queue; just one at a time until NCQ 1382 * and should be ignored in such cases. We could mask it,
1382 */ 1383 * but it's pretty rare and may not be worth the overhead.
1383 ata_status = mv_get_crpb_status(ap); 1384 */
1384 handled++; 1385 if (pp->pp_flags & MV_PP_FLAG_EDMA_EN) {
1385 } else if ((DEV_IRQ << hard_port) & hc_irq_cause) { 1386 /* EDMA: check for response queue interrupt */
1386 /* received ATA IRQ; read the status reg to clear INTRQ 1387 if ((CRPB_DMA_DONE << hard_port) & hc_irq_cause) {
1387 */ 1388 ata_status = mv_get_crpb_status(ap);
1388 ata_status = readb((void __iomem *) 1389 handled = 1;
1390 }
1391 } else {
1392 /* PIO: check for device (drive) interrupt */
1393 if ((DEV_IRQ << hard_port) & hc_irq_cause) {
1394 ata_status = readb((void __iomem *)
1389 ap->ioaddr.status_addr); 1395 ap->ioaddr.status_addr);
1390 handled++; 1396 handled = 1;
1397 }
1391 } 1398 }
1392 1399
1393 if (ap && 1400 if (ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))
1394 (ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)))
1395 continue; 1401 continue;
1396 1402
1397 err_mask = ac_err_mask(ata_status); 1403 err_mask = ac_err_mask(ata_status);
@@ -1403,12 +1409,12 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1403 if ((PORT0_ERR << shift) & relevant) { 1409 if ((PORT0_ERR << shift) & relevant) {
1404 mv_err_intr(ap); 1410 mv_err_intr(ap);
1405 err_mask |= AC_ERR_OTHER; 1411 err_mask |= AC_ERR_OTHER;
1406 handled++; 1412 handled = 1;
1407 } 1413 }
1408 1414
1409 if (handled && ap) { 1415 if (handled) {
1410 qc = ata_qc_from_tag(ap, ap->active_tag); 1416 qc = ata_qc_from_tag(ap, ap->active_tag);
1411 if (NULL != qc) { 1417 if (qc && (qc->flags & ATA_QCFLAG_ACTIVE)) {
1412 VPRINTK("port %u IRQ found for qc, " 1418 VPRINTK("port %u IRQ found for qc, "
1413 "ata_status 0x%x\n", port,ata_status); 1419 "ata_status 0x%x\n", port,ata_status);
1414 /* mark qc status appropriately */ 1420 /* mark qc status appropriately */