libata: fix infinite EH waiting bug
[linux-drm-fsl-dcu.git] / drivers / ata / libata-eh.c
index 361953a502035e4c846196f05ad3ad256ac6220b..f7582c9c320e029aa916912646ec48f0991c6467 100644 (file)
@@ -50,34 +50,39 @@ enum {
        ATA_EH_SPDN_FALLBACK_TO_PIO     = (1 << 2),
 };
 
+/* Waiting in ->prereset can never be reliable.  It's sometimes nice
+ * to wait there but it can't be depended upon; otherwise, we wouldn't
+ * be resetting.  Just give it enough time for most drives to spin up.
+ */
+enum {
+       ATA_EH_PRERESET_TIMEOUT         = 10 * HZ,
+};
+
+/* The following table determines how we sequence resets.  Each entry
+ * represents timeout for that try.  The first try can be soft or
+ * hardreset.  All others are hardreset if available.  In most cases
+ * the first reset w/ 10sec timeout should succeed.  Following entries
+ * are mostly for error handling, hotplug and retarded devices.
+ */
+static const unsigned long ata_eh_reset_timeouts[] = {
+       10 * HZ,        /* most drives spin up by 10sec */
+       10 * HZ,        /* > 99% working drives spin up before 20sec */
+       35 * HZ,        /* give > 30 secs of idleness for retarded devices */
+       5 * HZ,         /* and sweet one last chance */
+       /* > 1 min has elapsed, give up */
+};
+
 static void __ata_port_freeze(struct ata_port *ap);
 static void ata_eh_finish(struct ata_port *ap);
 #ifdef CONFIG_PM
 static void ata_eh_handle_port_suspend(struct ata_port *ap);
 static void ata_eh_handle_port_resume(struct ata_port *ap);
-static int ata_eh_suspend(struct ata_port *ap,
-                         struct ata_device **r_failed_dev);
-static void ata_eh_prep_resume(struct ata_port *ap);
-static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev);
 #else /* CONFIG_PM */
 static void ata_eh_handle_port_suspend(struct ata_port *ap)
 { }
 
 static void ata_eh_handle_port_resume(struct ata_port *ap)
 { }
-
-static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev)
-{
-       return 0;
-}
-
-static void ata_eh_prep_resume(struct ata_port *ap)
-{ }
-
-static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev)
-{
-       return 0;
-}
 #endif /* CONFIG_PM */
 
 static void ata_ering_record(struct ata_ering *ering, int is_io,
@@ -331,6 +336,7 @@ void ata_scsi_error(struct Scsi_Host *host)
                        }
                        ata_port_printk(ap, KERN_ERR, "EH pending after %d "
                                        "tries, giving up\n", ATA_EH_MAX_REPEAT);
+                       ap->pflags &= ~ATA_PFLAG_EH_PENDING;
                }
 
                /* this run is complete, make sure EH info is clear */
@@ -546,6 +552,9 @@ void ata_port_schedule_eh(struct ata_port *ap)
 {
        WARN_ON(!ap->ops->error_handler);
 
+       if (ap->pflags & ATA_PFLAG_INITIALIZING)
+               return;
+
        ap->pflags |= ATA_PFLAG_EH_PENDING;
        scsi_schedule_eh(ap->scsi_host);
 
@@ -982,26 +991,27 @@ static int ata_eh_read_log_10h(struct ata_device *dev,
  *     RETURNS:
  *     0 on success, AC_ERR_* mask on failure
  */
-static unsigned int atapi_eh_request_sense(struct ata_device *dev,
-                                          unsigned char *sense_buf)
+static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc)
 {
+       struct ata_device *dev = qc->dev;
+       unsigned char *sense_buf = qc->scsicmd->sense_buffer;
        struct ata_port *ap = dev->ap;
        struct ata_taskfile tf;
        u8 cdb[ATAPI_CDB_LEN];
 
        DPRINTK("ATAPI request sense\n");
 
-       ata_tf_init(dev, &tf);
-
        /* FIXME: is this needed? */
        memset(sense_buf, 0, SCSI_SENSE_BUFFERSIZE);
 
-       /* XXX: why tf_read here? */
-       ap->ops->tf_read(ap, &tf);
-
-       /* fill these in, for the case where they are -not- overwritten */
+       /* initialize sense_buf with the error register,
+        * for the case where they are -not- overwritten
+        */
        sense_buf[0] = 0x70;
-       sense_buf[2] = tf.feature >> 4;
+       sense_buf[2] = qc->result_tf.feature >> 4;
+
+       /* some devices time out if garbage left in tf */
+       ata_tf_init(dev, &tf);
 
        memset(cdb, 0, ATAPI_CDB_LEN);
        cdb[0] = REQUEST_SENSE;
@@ -1055,7 +1065,7 @@ static void ata_eh_analyze_serror(struct ata_port *ap)
        }
        if (serror & SERR_INTERNAL) {
                err_mask |= AC_ERR_SYSTEM;
-               action |= ATA_EH_SOFTRESET;
+               action |= ATA_EH_HARDRESET;
        }
        if (serror & (SERR_PHYRDY_CHG | SERR_DEV_XCHG))
                ata_ehi_hotplugged(&ehc->i);
@@ -1150,7 +1160,9 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
                return ATA_EH_SOFTRESET;
        }
 
-       if (!(qc->err_mask & AC_ERR_DEV))
+       if (stat & (ATA_ERR | ATA_DF))
+               qc->err_mask |= AC_ERR_DEV;
+       else
                return 0;
 
        switch (qc->dev->class) {
@@ -1165,8 +1177,7 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
 
        case ATA_DEV_ATAPI:
                if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) {
-                       tmp = atapi_eh_request_sense(qc->dev,
-                                                    qc->scsicmd->sense_buffer);
+                       tmp = atapi_eh_request_sense(qc);
                        if (!tmp) {
                                /* ATA_QCFLAG_SENSE_VALID is used to
                                 * tell atapi_qc_complete() that sense
@@ -1556,14 +1567,14 @@ static void ata_eh_report(struct ata_port *ap)
 }
 
 static int ata_do_reset(struct ata_port *ap, ata_reset_fn_t reset,
-                       unsigned int *classes)
+                       unsigned int *classes, unsigned long deadline)
 {
        int i, rc;
 
        for (i = 0; i < ATA_MAX_DEVICES; i++)
                classes[i] = ATA_DEV_UNKNOWN;
 
-       rc = reset(ap, classes);
+       rc = reset(ap, classes, deadline);
        if (rc)
                return rc;
 
@@ -1601,11 +1612,12 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
 {
        struct ata_eh_context *ehc = &ap->eh_context;
        unsigned int *classes = ehc->classes;
-       int tries = ATA_EH_RESET_TRIES;
        int verbose = !(ehc->i.flags & ATA_EHI_QUIET);
+       int try = 0;
+       unsigned long deadline;
        unsigned int action;
        ata_reset_fn_t reset;
-       int i, did_followup_srst, rc;
+       int i, rc;
 
        /* about to reset */
        ata_eh_about_to_do(ap, NULL, ehc->i.action & ATA_EH_RESET_MASK);
@@ -1622,7 +1634,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
                ehc->i.action |= ATA_EH_HARDRESET;
 
        if (prereset) {
-               rc = prereset(ap);
+               rc = prereset(ap, jiffies + ATA_EH_PRERESET_TIMEOUT);
                if (rc) {
                        if (rc == -ENOENT) {
                                ata_port_printk(ap, KERN_DEBUG,
@@ -1654,8 +1666,6 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
 
        /* did prereset() screw up?  if so, fix up to avoid oopsing */
        if (!reset) {
-               ata_port_printk(ap, KERN_ERR, "BUG: prereset() requested "
-                               "invalid reset type\n");
                if (softreset)
                        reset = softreset;
                else
@@ -1663,21 +1673,24 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
        }
 
  retry:
+       deadline = jiffies + ata_eh_reset_timeouts[try++];
+
        /* shut up during boot probing */
        if (verbose)
                ata_port_printk(ap, KERN_INFO, "%s resetting port\n",
                                reset == softreset ? "soft" : "hard");
 
        /* mark that this EH session started with reset */
-       ehc->i.flags |= ATA_EHI_DID_RESET;
+       if (reset == hardreset)
+               ehc->i.flags |= ATA_EHI_DID_HARDRESET;
+       else
+               ehc->i.flags |= ATA_EHI_DID_SOFTRESET;
 
-       rc = ata_do_reset(ap, reset, classes);
+       rc = ata_do_reset(ap, reset, classes, deadline);
 
-       did_followup_srst = 0;
        if (reset == hardreset &&
            ata_eh_followup_srst_needed(rc, classify, classes)) {
                /* okay, let's do follow-up softreset */
-               did_followup_srst = 1;
                reset = softreset;
 
                if (!reset) {
@@ -1688,7 +1701,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
                }
 
                ata_eh_about_to_do(ap, NULL, ATA_EH_RESET_MASK);
-               rc = ata_do_reset(ap, reset, classes);
+               rc = ata_do_reset(ap, reset, classes, deadline);
 
                if (rc == 0 && classify &&
                    classes[0] == ATA_DEV_UNKNOWN) {
@@ -1698,22 +1711,21 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
                }
        }
 
-       if (rc && --tries) {
-               const char *type;
+       if (rc && try < ARRAY_SIZE(ata_eh_reset_timeouts)) {
+               unsigned long now = jiffies;
 
-               if (reset == softreset) {
-                       if (did_followup_srst)
-                               type = "follow-up soft";
-                       else
-                               type = "soft";
-               } else
-                       type = "hard";
+               if (time_before(now, deadline)) {
+                       unsigned long delta = deadline - jiffies;
 
-               ata_port_printk(ap, KERN_WARNING,
-                               "%sreset failed, retrying in 5 secs\n", type);
-               ssleep(5);
+                       ata_port_printk(ap, KERN_WARNING, "reset failed "
+                               "(errno=%d), retrying in %u secs\n",
+                               rc, (jiffies_to_msecs(delta) + 999) / 1000);
+
+                       schedule_timeout_uninterruptible(delta);
+               }
 
-               if (reset == hardreset)
+               if (reset == hardreset &&
+                   try == ARRAY_SIZE(ata_eh_reset_timeouts) - 1)
                        sata_down_spd_limit(ap);
                if (hardreset)
                        reset = hardreset;
@@ -1743,12 +1755,17 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
 {
        struct ata_eh_context *ehc = &ap->eh_context;
        struct ata_device *dev;
+       unsigned int new_mask = 0;
        unsigned long flags;
        int i, rc = 0;
 
        DPRINTK("ENTER\n");
 
-       for (i = 0; i < ATA_MAX_DEVICES; i++) {
+       /* For PATA drive side cable detection to work, IDENTIFY must
+        * be done backwards such that PDIAG- is released by the slave
+        * device before the master device is identified.
+        */
+       for (i = ATA_MAX_DEVICES - 1; i >= 0; i--) {
                unsigned int action, readid_flags = 0;
 
                dev = &ap->device[i];
@@ -1757,16 +1774,16 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
                if (ehc->i.flags & ATA_EHI_DID_RESET)
                        readid_flags |= ATA_READID_POSTRESET;
 
-               if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) {
+               if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) {
                        if (ata_port_offline(ap)) {
                                rc = -EIO;
-                               break;
+                               goto err;
                        }
 
                        ata_eh_about_to_do(ap, dev, ATA_EH_REVALIDATE);
                        rc = ata_dev_revalidate(dev, readid_flags);
                        if (rc)
-                               break;
+                               goto err;
 
                        ata_eh_done(ap, dev, ATA_EH_REVALIDATE);
 
@@ -1784,203 +1801,60 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
 
                        rc = ata_dev_read_id(dev, &dev->class, readid_flags,
                                             dev->id);
-                       if (rc == 0) {
-                               ehc->i.flags |= ATA_EHI_PRINTINFO;
-                               rc = ata_dev_configure(dev);
-                               ehc->i.flags &= ~ATA_EHI_PRINTINFO;
-                       } else if (rc == -ENOENT) {
+                       switch (rc) {
+                       case 0:
+                               new_mask |= 1 << i;
+                               break;
+                       case -ENOENT:
                                /* IDENTIFY was issued to non-existent
                                 * device.  No need to reset.  Just
                                 * thaw and kill the device.
                                 */
                                ata_eh_thaw_port(ap);
-                               dev->class = ATA_DEV_UNKNOWN;
-                               rc = 0;
-                       }
-
-                       if (rc) {
                                dev->class = ATA_DEV_UNKNOWN;
                                break;
-                       }
-
-                       if (ata_dev_enabled(dev)) {
-                               spin_lock_irqsave(ap->lock, flags);
-                               ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG;
-                               spin_unlock_irqrestore(ap->lock, flags);
-
-                               /* new device discovered, configure xfermode */
-                               ehc->i.flags |= ATA_EHI_SETMODE;
+                       default:
+                               dev->class = ATA_DEV_UNKNOWN;
+                               goto err;
                        }
                }
        }
 
-       if (rc)
-               *r_failed_dev = dev;
-
-       DPRINTK("EXIT\n");
-       return rc;
-}
-
-#ifdef CONFIG_PM
-/**
- *     ata_eh_suspend - handle suspend EH action
- *     @ap: target host port
- *     @r_failed_dev: result parameter to indicate failing device
- *
- *     Handle suspend EH action.  Disk devices are spinned down and
- *     other types of devices are just marked suspended.  Once
- *     suspended, no EH action to the device is allowed until it is
- *     resumed.
- *
- *     LOCKING:
- *     Kernel thread context (may sleep).
- *
- *     RETURNS:
- *     0 on success, -errno otherwise
- */
-static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev)
-{
-       struct ata_device *dev;
-       int i, rc = 0;
-
-       DPRINTK("ENTER\n");
+       /* PDIAG- should have been released, ask cable type if post-reset */
+       if ((ehc->i.flags & ATA_EHI_DID_RESET) && ap->ops->cable_detect)
+               ap->cbl = ap->ops->cable_detect(ap);
 
+       /* Configure new devices forward such that user doesn't see
+        * device detection messages backwards.
+        */
        for (i = 0; i < ATA_MAX_DEVICES; i++) {
-               unsigned long flags;
-               unsigned int action, err_mask;
-
                dev = &ap->device[i];
-               action = ata_eh_dev_action(dev);
 
-               if (!ata_dev_enabled(dev) || !(action & ATA_EH_SUSPEND))
+               if (!(new_mask & (1 << i)))
                        continue;
 
-               WARN_ON(dev->flags & ATA_DFLAG_SUSPENDED);
-
-               ata_eh_about_to_do(ap, dev, ATA_EH_SUSPEND);
-
-               if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) {
-                       /* flush cache */
-                       rc = ata_flush_cache(dev);
-                       if (rc)
-                               break;
-
-                       /* spin down */
-                       err_mask = ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1);
-                       if (err_mask) {
-                               ata_dev_printk(dev, KERN_ERR, "failed to "
-                                              "spin down (err_mask=0x%x)\n",
-                                              err_mask);
-                               rc = -EIO;
-                               break;
-                       }
-               }
+               ehc->i.flags |= ATA_EHI_PRINTINFO;
+               rc = ata_dev_configure(dev);
+               ehc->i.flags &= ~ATA_EHI_PRINTINFO;
+               if (rc)
+                       goto err;
 
                spin_lock_irqsave(ap->lock, flags);
-               dev->flags |= ATA_DFLAG_SUSPENDED;
+               ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG;
                spin_unlock_irqrestore(ap->lock, flags);
 
-               ata_eh_done(ap, dev, ATA_EH_SUSPEND);
+               /* new device discovered, configure xfermode */
+               ehc->i.flags |= ATA_EHI_SETMODE;
        }
 
-       if (rc)
-               *r_failed_dev = dev;
+       return 0;
 
-       DPRINTK("EXIT\n");
+ err:
+       *r_failed_dev = dev;
+       DPRINTK("EXIT rc=%d\n", rc);
        return rc;
 }
 
-/**
- *     ata_eh_prep_resume - prep for resume EH action
- *     @ap: target host port
- *
- *     Clear SUSPENDED in preparation for scheduled resume actions.
- *     This allows other parts of EH to access the devices being
- *     resumed.
- *
- *     LOCKING:
- *     Kernel thread context (may sleep).
- */
-static void ata_eh_prep_resume(struct ata_port *ap)
-{
-       struct ata_device *dev;
-       unsigned long flags;
-       int i;
-
-       DPRINTK("ENTER\n");
-
-       for (i = 0; i < ATA_MAX_DEVICES; i++) {
-               unsigned int action;
-
-               dev = &ap->device[i];
-               action = ata_eh_dev_action(dev);
-
-               if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME))
-                       continue;
-
-               spin_lock_irqsave(ap->lock, flags);
-               dev->flags &= ~ATA_DFLAG_SUSPENDED;
-               spin_unlock_irqrestore(ap->lock, flags);
-       }
-
-       DPRINTK("EXIT\n");
-}
-
-/**
- *     ata_eh_resume - handle resume EH action
- *     @ap: target host port
- *     @r_failed_dev: result parameter to indicate failing device
- *
- *     Handle resume EH action.  Target devices are already reset and
- *     revalidated.  Spinning up is the only operation left.
- *
- *     LOCKING:
- *     Kernel thread context (may sleep).
- *
- *     RETURNS:
- *     0 on success, -errno otherwise
- */
-static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev)
-{
-       struct ata_device *dev;
-       int i, rc = 0;
-
-       DPRINTK("ENTER\n");
-
-       for (i = 0; i < ATA_MAX_DEVICES; i++) {
-               unsigned int action, err_mask;
-
-               dev = &ap->device[i];
-               action = ata_eh_dev_action(dev);
-
-               if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME))
-                       continue;
-
-               ata_eh_about_to_do(ap, dev, ATA_EH_RESUME);
-
-               if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) {
-                       err_mask = ata_do_simple_cmd(dev,
-                                                    ATA_CMD_IDLEIMMEDIATE);
-                       if (err_mask) {
-                               ata_dev_printk(dev, KERN_ERR, "failed to "
-                                              "spin up (err_mask=0x%x)\n",
-                                              err_mask);
-                               rc = -EIO;
-                               break;
-                       }
-               }
-
-               ata_eh_done(ap, dev, ATA_EH_RESUME);
-       }
-
-       if (rc)
-               *r_failed_dev = dev;
-
-       DPRINTK("EXIT\n");
-       return 0;
-}
-#endif /* CONFIG_PM */
-
 static int ata_port_nr_enabled(struct ata_port *ap)
 {
        int i, cnt = 0;
@@ -2006,17 +1880,6 @@ static int ata_eh_skip_recovery(struct ata_port *ap)
        struct ata_eh_context *ehc = &ap->eh_context;
        int i;
 
-       /* skip if all possible devices are suspended */
-       for (i = 0; i < ata_port_max_devices(ap); i++) {
-               struct ata_device *dev = &ap->device[i];
-
-               if (!(dev->flags & ATA_DFLAG_SUSPENDED))
-                       break;
-       }
-
-       if (i == ata_port_max_devices(ap))
-               return 1;
-
        /* thaw frozen port, resume link and recover failed devices */
        if ((ap->pflags & ATA_PFLAG_FROZEN) ||
            (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap))
@@ -2096,9 +1959,6 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
        if (ap->pflags & ATA_PFLAG_UNLOADING)
                goto out;
 
-       /* prep for resume */
-       ata_eh_prep_resume(ap);
-
        /* skip EH if possible. */
        if (ata_eh_skip_recovery(ap))
                ehc->i.action = 0;
@@ -2126,11 +1986,6 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
        if (rc)
                goto dev_fail;
 
-       /* resume devices */
-       rc = ata_eh_resume(ap, &dev);
-       if (rc)
-               goto dev_fail;
-
        /* configure transfer mode if necessary */
        if (ehc->i.flags & ATA_EHI_SETMODE) {
                rc = ata_set_mode(ap, &dev);
@@ -2139,25 +1994,16 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
                ehc->i.flags &= ~ATA_EHI_SETMODE;
        }
 
-       /* suspend devices */
-       rc = ata_eh_suspend(ap, &dev);
-       if (rc)
-               goto dev_fail;
-
        goto out;
 
  dev_fail:
        ehc->tries[dev->devno]--;
 
        switch (rc) {
-       case -EINVAL:
-               /* eeek, something went very wrong, give up */
-               ehc->tries[dev->devno] = 0;
-               break;
-
        case -ENODEV:
                /* device missing or wrong IDENTIFY data, schedule probing */
                ehc->i.probe_mask |= (1 << dev->devno);
+       case -EINVAL:
                /* give it just one more chance */
                ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1);
        case -EIO:
@@ -2339,22 +2185,13 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap)
  *
  *     Resume @ap.
  *
- *     This function also waits upto one second until all devices
- *     hanging off this port requests resume EH action.  This is to
- *     prevent invoking EH and thus reset multiple times on resume.
- *
- *     On DPM resume, where some of devices might not be resumed
- *     together, this may delay port resume upto one second, but such
- *     DPM resumes are rare and 1 sec delay isn't too bad.
- *
  *     LOCKING:
  *     Kernel thread context (may sleep).
  */
 static void ata_eh_handle_port_resume(struct ata_port *ap)
 {
-       unsigned long timeout;
        unsigned long flags;
-       int i, rc = 0;
+       int rc = 0;
 
        /* are we resuming? */
        spin_lock_irqsave(ap->lock, flags);
@@ -2365,31 +2202,12 @@ static void ata_eh_handle_port_resume(struct ata_port *ap)
        }
        spin_unlock_irqrestore(ap->lock, flags);
 
-       /* spurious? */
-       if (!(ap->pflags & ATA_PFLAG_SUSPENDED))
-               goto done;
+       WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED));
 
        if (ap->ops->port_resume)
                rc = ap->ops->port_resume(ap);
 
-       /* give devices time to request EH */
-       timeout = jiffies + HZ; /* 1s max */
-       while (1) {
-               for (i = 0; i < ATA_MAX_DEVICES; i++) {
-                       struct ata_device *dev = &ap->device[i];
-                       unsigned int action = ata_eh_dev_action(dev);
-
-                       if ((dev->flags & ATA_DFLAG_SUSPENDED) &&
-                           !(action & ATA_EH_RESUME))
-                               break;
-               }
-
-               if (i == ATA_MAX_DEVICES || time_after(jiffies, timeout))
-                       break;
-               msleep(10);
-       }
-
- done:
+       /* report result */
        spin_lock_irqsave(ap->lock, flags);
        ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED);
        if (ap->pm_result) {