trivial: fix typos s/paramter/parameter/ and s/excute/execute/ in documentation and...
[sfrench/cifs-2.6.git] / drivers / ata / libata-eh.c
index 01831312c3607e3bc8aa98cfb42604e14cc3eba1..fa22f94ca4150247b39a0e26fa7541d4cbee4ba4 100644 (file)
@@ -2783,6 +2783,12 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
                } else if (dev->class == ATA_DEV_UNKNOWN &&
                           ehc->tries[dev->devno] &&
                           ata_class_enabled(ehc->classes[dev->devno])) {
+                       /* Temporarily set dev->class, it will be
+                        * permanently set once all configurations are
+                        * complete.  This is necessary because new
+                        * device configuration is done in two
+                        * separate loops.
+                        */
                        dev->class = ehc->classes[dev->devno];
 
                        if (dev->class == ATA_DEV_PMP)
@@ -2790,6 +2796,11 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
                        else
                                rc = ata_dev_read_id(dev, &dev->class,
                                                     readid_flags, dev->id);
+
+                       /* read_id might have changed class, store and reset */
+                       ehc->classes[dev->devno] = dev->class;
+                       dev->class = ATA_DEV_UNKNOWN;
+
                        switch (rc) {
                        case 0:
                                /* clear error info accumulated during probe */
@@ -2799,13 +2810,11 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
                        case -ENOENT:
                                /* IDENTIFY was issued to non-existent
                                 * device.  No need to reset.  Just
-                                * thaw and kill the device.
+                                * thaw and ignore the device.
                                 */
                                ata_eh_thaw_port(ap);
-                               dev->class = ATA_DEV_UNKNOWN;
                                break;
                        default:
-                               dev->class = ATA_DEV_UNKNOWN;
                                goto err;
                        }
                }
@@ -2826,11 +2835,15 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
                    dev->class == ATA_DEV_PMP)
                        continue;
 
+               dev->class = ehc->classes[dev->devno];
+
                ehc->i.flags |= ATA_EHI_PRINTINFO;
                rc = ata_dev_configure(dev);
                ehc->i.flags &= ~ATA_EHI_PRINTINFO;
-               if (rc)
+               if (rc) {
+                       dev->class = ATA_DEV_UNKNOWN;
                        goto err;
+               }
 
                spin_lock_irqsave(ap->lock, flags);
                ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG;
@@ -2851,7 +2864,7 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
 /**
  *     ata_set_mode - Program timings and issue SET FEATURES - XFER
  *     @link: link on which timings will be programmed
- *     @r_failed_dev: out paramter for failed device
+ *     @r_failed_dev: out parameter for failed device
  *
  *     Set ATA device disk transfer mode (PIO3, UDMA6, etc.).  If
  *     ata_set_mode() fails, pointer to the failing device is
@@ -3494,6 +3507,8 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap)
  */
 static void ata_eh_handle_port_resume(struct ata_port *ap)
 {
+       struct ata_link *link;
+       struct ata_device *dev;
        unsigned long flags;
        int rc = 0;
 
@@ -3508,6 +3523,17 @@ static void ata_eh_handle_port_resume(struct ata_port *ap)
 
        WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED));
 
+       /*
+        * Error timestamps are in jiffies which doesn't run while
+        * suspended and PHY events during resume isn't too uncommon.
+        * When the two are combined, it can lead to unnecessary speed
+        * downs if the machine is suspended and resumed repeatedly.
+        * Clear error history.
+        */
+       ata_for_each_link(link, ap, HOST_FIRST)
+               ata_for_each_dev(dev, link, ALL)
+                       ata_ering_clear(&dev->ering);
+
        ata_acpi_set_state(ap, PMSG_ON);
 
        if (ap->ops->port_resume)