]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ata/libata-core.c
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[linux-2.6-omap-h63xx.git] / drivers / ata / libata-core.c
index 5718c247e23ad2ad33d4d925b406efda7345f94b..60e78bef469fed2f49423deea956a16b60a0448b 100644 (file)
@@ -2389,21 +2389,35 @@ int sata_down_spd_limit(struct ata_port *ap)
        u32 sstatus, spd, mask;
        int rc, highbit;
 
+       if (!sata_scr_valid(ap))
+               return -EOPNOTSUPP;
+
+       /* If SCR can be read, use it to determine the current SPD.
+        * If not, use cached value in ap->sata_spd.
+        */
        rc = sata_scr_read(ap, SCR_STATUS, &sstatus);
-       if (rc)
-               return rc;
+       if (rc == 0)
+               spd = (sstatus >> 4) & 0xf;
+       else
+               spd = ap->sata_spd;
 
        mask = ap->sata_spd_limit;
        if (mask <= 1)
                return -EINVAL;
+
+       /* unconditionally mask off the highest bit */
        highbit = fls(mask) - 1;
        mask &= ~(1 << highbit);
 
-       spd = (sstatus >> 4) & 0xf;
-       if (spd <= 1)
-               return -EINVAL;
-       spd--;
-       mask &= (1 << spd) - 1;
+       /* Mask off all speeds higher than or equal to the current
+        * one.  Force 1.5Gbps if current SPD is not available.
+        */
+       if (spd > 1)
+               mask &= (1 << (spd - 1)) - 1;
+       else
+               mask &= 1;
+
+       /* were we already at the bottom? */
        if (!mask)
                return -EINVAL;
 
@@ -3253,9 +3267,11 @@ int sata_phy_debounce(struct ata_port *ap, const unsigned long *params,
                last = cur;
                last_jiffies = jiffies;
 
-               /* check deadline */
+               /* Check deadline.  If debouncing failed, return
+                * -EPIPE to tell upper layer to lower link speed.
+                */
                if (time_after(jiffies, deadline))
-                       return -EBUSY;
+                       return -EPIPE;
        }
 }
 
@@ -3772,6 +3788,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
        { "WDC WD740ADFD-00NLR1", NULL,         ATA_HORKAGE_NONCQ, },
        { "FUJITSU MHV2080BH",  "00840028",     ATA_HORKAGE_NONCQ, },
        { "ST9160821AS",        "3.CLF",        ATA_HORKAGE_NONCQ, },
+       { "SAMSUNG HD401LJ",    "ZZ100-15",     ATA_HORKAGE_NONCQ, },
 
        /* Devices with NCQ limits */
 
@@ -5995,6 +6012,7 @@ void ata_dev_init(struct ata_device *dev)
 
        /* SATA spd limit is bound to the first device */
        ap->sata_spd_limit = ap->hw_sata_spd_limit;
+       ap->sata_spd = 0;
 
        /* High bits of dev->flags are used to record warm plug
         * requests which occur asynchronously.  Synchronize using
@@ -6060,6 +6078,9 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
        INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan);
        INIT_LIST_HEAD(&ap->eh_done_q);
        init_waitqueue_head(&ap->eh_wait_q);
+       init_timer_deferrable(&ap->fastdrain_timer);
+       ap->fastdrain_timer.function = ata_eh_fastdrain_timerfn;
+       ap->fastdrain_timer.data = (unsigned long)ap;
 
        ap->cbl = ATA_CBL_NONE;
 
@@ -6436,7 +6457,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
        for (i = 0; i < host->n_ports; i++) {
                struct ata_port *ap = host->ports[i];
 
-               ata_scsi_scan_host(ap);
+               ata_scsi_scan_host(ap, 1);
        }
 
        return 0;