diff options
| -rw-r--r-- | drivers/scsi/libata-core.c | 78 |
1 files changed, 49 insertions, 29 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index da13deccc0e0..597e9e8bcd2c 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
| @@ -65,7 +65,7 @@ static unsigned int ata_dev_init_params(struct ata_port *ap, | |||
| 65 | struct ata_device *dev, | 65 | struct ata_device *dev, |
| 66 | u16 heads, | 66 | u16 heads, |
| 67 | u16 sectors); | 67 | u16 sectors); |
| 68 | static void ata_set_mode(struct ata_port *ap); | 68 | static int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev); |
| 69 | static unsigned int ata_dev_set_xfermode(struct ata_port *ap, | 69 | static unsigned int ata_dev_set_xfermode(struct ata_port *ap, |
| 70 | struct ata_device *dev); | 70 | struct ata_device *dev); |
| 71 | static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev); | 71 | static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev); |
| @@ -1382,6 +1382,7 @@ static int ata_bus_probe(struct ata_port *ap) | |||
| 1382 | { | 1382 | { |
| 1383 | unsigned int classes[ATA_MAX_DEVICES]; | 1383 | unsigned int classes[ATA_MAX_DEVICES]; |
| 1384 | int i, rc, found = 0; | 1384 | int i, rc, found = 0; |
| 1385 | struct ata_device *dev; | ||
| 1385 | 1386 | ||
| 1386 | ata_port_probe(ap); | 1387 | ata_port_probe(ap); |
| 1387 | 1388 | ||
| @@ -1411,8 +1412,7 @@ static int ata_bus_probe(struct ata_port *ap) | |||
| 1411 | 1412 | ||
| 1412 | /* read IDENTIFY page and configure devices */ | 1413 | /* read IDENTIFY page and configure devices */ |
| 1413 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 1414 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
| 1414 | struct ata_device *dev = &ap->device[i]; | 1415 | dev = &ap->device[i]; |
| 1415 | |||
| 1416 | dev->class = classes[i]; | 1416 | dev->class = classes[i]; |
| 1417 | 1417 | ||
| 1418 | if (!ata_dev_enabled(dev)) | 1418 | if (!ata_dev_enabled(dev)) |
| @@ -1432,20 +1432,26 @@ static int ata_bus_probe(struct ata_port *ap) | |||
| 1432 | found = 1; | 1432 | found = 1; |
| 1433 | } | 1433 | } |
| 1434 | 1434 | ||
| 1435 | if (!found) | 1435 | /* configure transfer mode */ |
| 1436 | goto err_out_disable; | 1436 | if (ap->ops->set_mode) { |
| 1437 | 1437 | /* FIXME: make ->set_mode handle no device case and | |
| 1438 | if (ap->ops->set_mode) | 1438 | * return error code and failing device on failure as |
| 1439 | ap->ops->set_mode(ap); | 1439 | * ata_set_mode() does. |
| 1440 | else | 1440 | */ |
| 1441 | ata_set_mode(ap); | 1441 | if (found) |
| 1442 | 1442 | ap->ops->set_mode(ap); | |
| 1443 | if (ap->flags & ATA_FLAG_PORT_DISABLED) | 1443 | rc = 0; |
| 1444 | goto err_out_disable; | 1444 | } else { |
| 1445 | while (ata_set_mode(ap, &dev)) | ||
| 1446 | ata_dev_disable(ap, dev); | ||
| 1447 | } | ||
| 1445 | 1448 | ||
| 1446 | return 0; | 1449 | for (i = 0; i < ATA_MAX_DEVICES; i++) |
| 1450 | if (ata_dev_enabled(&ap->device[i])) | ||
| 1451 | return 0; | ||
| 1447 | 1452 | ||
| 1448 | err_out_disable: | 1453 | /* no device present, disable port */ |
| 1454 | ata_port_disable(ap); | ||
| 1449 | ap->ops->port_disable(ap); | 1455 | ap->ops->port_disable(ap); |
| 1450 | return -ENODEV; | 1456 | return -ENODEV; |
| 1451 | } | 1457 | } |
| @@ -1788,16 +1794,22 @@ static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) | |||
| 1788 | /** | 1794 | /** |
| 1789 | * ata_set_mode - Program timings and issue SET FEATURES - XFER | 1795 | * ata_set_mode - Program timings and issue SET FEATURES - XFER |
| 1790 | * @ap: port on which timings will be programmed | 1796 | * @ap: port on which timings will be programmed |
| 1797 | * @r_failed_dev: out paramter for failed device | ||
| 1791 | * | 1798 | * |
| 1792 | * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). | 1799 | * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). If |
| 1800 | * ata_set_mode() fails, pointer to the failing device is | ||
| 1801 | * returned in @r_failed_dev. | ||
| 1793 | * | 1802 | * |
| 1794 | * LOCKING: | 1803 | * LOCKING: |
| 1795 | * PCI/etc. bus probe sem. | 1804 | * PCI/etc. bus probe sem. |
| 1805 | * | ||
| 1806 | * RETURNS: | ||
| 1807 | * 0 on success, negative errno otherwise | ||
| 1796 | */ | 1808 | */ |
| 1797 | static void ata_set_mode(struct ata_port *ap) | 1809 | static int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) |
| 1798 | { | 1810 | { |
| 1799 | struct ata_device *dev; | 1811 | struct ata_device *dev; |
| 1800 | int i, rc, used_dma = 0, found = 0; | 1812 | int i, rc = 0, used_dma = 0, found = 0; |
| 1801 | 1813 | ||
| 1802 | /* step 1: calculate xfer_mask */ | 1814 | /* step 1: calculate xfer_mask */ |
| 1803 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 1815 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
| @@ -1820,7 +1832,7 @@ static void ata_set_mode(struct ata_port *ap) | |||
| 1820 | used_dma = 1; | 1832 | used_dma = 1; |
| 1821 | } | 1833 | } |
| 1822 | if (!found) | 1834 | if (!found) |
| 1823 | return; | 1835 | goto out; |
| 1824 | 1836 | ||
| 1825 | /* step 2: always set host PIO timings */ | 1837 | /* step 2: always set host PIO timings */ |
| 1826 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 1838 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
| @@ -1832,7 +1844,7 @@ static void ata_set_mode(struct ata_port *ap) | |||
| 1832 | printk(KERN_WARNING "ata%u: dev %u no PIO support\n", | 1844 | printk(KERN_WARNING "ata%u: dev %u no PIO support\n", |
| 1833 | ap->id, dev->devno); | 1845 | ap->id, dev->devno); |
| 1834 | rc = -EINVAL; | 1846 | rc = -EINVAL; |
| 1835 | goto err_out; | 1847 | goto out; |
| 1836 | } | 1848 | } |
| 1837 | 1849 | ||
| 1838 | dev->xfer_mode = dev->pio_mode; | 1850 | dev->xfer_mode = dev->pio_mode; |
| @@ -1863,7 +1875,7 @@ static void ata_set_mode(struct ata_port *ap) | |||
| 1863 | 1875 | ||
| 1864 | rc = ata_dev_set_mode(ap, dev); | 1876 | rc = ata_dev_set_mode(ap, dev); |
| 1865 | if (rc) | 1877 | if (rc) |
| 1866 | goto err_out; | 1878 | goto out; |
| 1867 | } | 1879 | } |
| 1868 | 1880 | ||
| 1869 | /* Record simplex status. If we selected DMA then the other | 1881 | /* Record simplex status. If we selected DMA then the other |
| @@ -1876,10 +1888,10 @@ static void ata_set_mode(struct ata_port *ap) | |||
| 1876 | if (ap->ops->post_set_mode) | 1888 | if (ap->ops->post_set_mode) |
| 1877 | ap->ops->post_set_mode(ap); | 1889 | ap->ops->post_set_mode(ap); |
| 1878 | 1890 | ||
| 1879 | return; | 1891 | out: |
| 1880 | 1892 | if (rc) | |
| 1881 | err_out: | 1893 | *r_failed_dev = dev; |
| 1882 | ata_port_disable(ap); | 1894 | return rc; |
| 1883 | } | 1895 | } |
| 1884 | 1896 | ||
| 1885 | /** | 1897 | /** |
| @@ -2134,9 +2146,11 @@ err_out: | |||
| 2134 | static int sata_phy_resume(struct ata_port *ap) | 2146 | static int sata_phy_resume(struct ata_port *ap) |
| 2135 | { | 2147 | { |
| 2136 | unsigned long timeout = jiffies + (HZ * 5); | 2148 | unsigned long timeout = jiffies + (HZ * 5); |
| 2137 | u32 sstatus; | 2149 | u32 scontrol, sstatus; |
| 2138 | 2150 | ||
| 2139 | scr_write_flush(ap, SCR_CONTROL, 0x300); | 2151 | scontrol = scr_read(ap, SCR_CONTROL); |
| 2152 | scontrol = (scontrol & 0x0f0) | 0x300; | ||
| 2153 | scr_write_flush(ap, SCR_CONTROL, scontrol); | ||
| 2140 | 2154 | ||
| 2141 | /* Wait for phy to become ready, if necessary. */ | 2155 | /* Wait for phy to become ready, if necessary. */ |
| 2142 | do { | 2156 | do { |
| @@ -2249,10 +2263,14 @@ int ata_std_softreset(struct ata_port *ap, int verbose, unsigned int *classes) | |||
| 2249 | */ | 2263 | */ |
| 2250 | int sata_std_hardreset(struct ata_port *ap, int verbose, unsigned int *class) | 2264 | int sata_std_hardreset(struct ata_port *ap, int verbose, unsigned int *class) |
| 2251 | { | 2265 | { |
| 2266 | u32 scontrol; | ||
| 2267 | |||
| 2252 | DPRINTK("ENTER\n"); | 2268 | DPRINTK("ENTER\n"); |
| 2253 | 2269 | ||
| 2254 | /* Issue phy wake/reset */ | 2270 | /* Issue phy wake/reset */ |
| 2255 | scr_write_flush(ap, SCR_CONTROL, 0x301); | 2271 | scontrol = scr_read(ap, SCR_CONTROL); |
| 2272 | scontrol = (scontrol & 0x0f0) | 0x301; | ||
| 2273 | scr_write_flush(ap, SCR_CONTROL, scontrol); | ||
| 2256 | 2274 | ||
| 2257 | /* | 2275 | /* |
| 2258 | * Couldn't find anything in SATA I/II specs, but AHCI-1.1 | 2276 | * Couldn't find anything in SATA I/II specs, but AHCI-1.1 |
| @@ -4452,8 +4470,10 @@ static int ata_start_drive(struct ata_port *ap, struct ata_device *dev) | |||
| 4452 | int ata_device_resume(struct ata_port *ap, struct ata_device *dev) | 4470 | int ata_device_resume(struct ata_port *ap, struct ata_device *dev) |
| 4453 | { | 4471 | { |
| 4454 | if (ap->flags & ATA_FLAG_SUSPENDED) { | 4472 | if (ap->flags & ATA_FLAG_SUSPENDED) { |
| 4473 | struct ata_device *failed_dev; | ||
| 4455 | ap->flags &= ~ATA_FLAG_SUSPENDED; | 4474 | ap->flags &= ~ATA_FLAG_SUSPENDED; |
| 4456 | ata_set_mode(ap); | 4475 | while (ata_set_mode(ap, &failed_dev)) |
| 4476 | ata_dev_disable(ap, failed_dev); | ||
| 4457 | } | 4477 | } |
| 4458 | if (!ata_dev_enabled(dev)) | 4478 | if (!ata_dev_enabled(dev)) |
| 4459 | return 0; | 4479 | return 0; |
