and changed files
[powerpc.git] / drivers / ata / libata-core.c
index 49d2667..4595d1f 100644 (file)
@@ -895,6 +895,7 @@ static u64 ata_read_native_max_address(struct ata_device *dev)
 /**
  *     ata_set_native_max_address_ext  -       LBA48 native max set
  *     @dev: Device to query
+ *     @new_sectors: new max sectors value to set for the device
  *
  *     Perform an LBA48 size set max upon the device in question. Return the
  *     actual LBA48 size or zero if the command fails.
@@ -932,6 +933,7 @@ static u64 ata_set_native_max_address_ext(struct ata_device *dev, u64 new_sector
 /**
  *     ata_set_native_max_address      -       LBA28 native max set
  *     @dev: Device to query
+ *     @new_sectors: new max sectors value to set for the device
  *
  *     Perform an LBA28 size set max upon the device in question. Return the
  *     actual LBA28 size or zero if the command fails.
@@ -1316,7 +1318,7 @@ void ata_port_flush_task(struct ata_port *ap)
        spin_unlock_irqrestore(ap->lock, flags);
 
        DPRINTK("flush #1\n");
-       flush_workqueue(ata_wq);
+       cancel_work_sync(&ap->port_task.work); /* akpm: seems unneeded */
 
        /*
         * At this point, if a task is running, it's guaranteed to see
@@ -1327,7 +1329,7 @@ void ata_port_flush_task(struct ata_port *ap)
                if (ata_msg_ctl(ap))
                        ata_port_printk(ap, KERN_DEBUG, "%s: flush #2\n",
                                        __FUNCTION__);
-               flush_workqueue(ata_wq);
+               cancel_work_sync(&ap->port_task.work);
        }
 
        spin_lock_irqsave(ap->lock, flags);
@@ -3304,41 +3306,16 @@ int sata_phy_resume(struct ata_port *ap, const unsigned long *params,
        return sata_phy_debounce(ap, params, deadline);
 }
 
-static void ata_wait_spinup(struct ata_port *ap, unsigned long deadline)
-{
-       struct ata_eh_context *ehc = &ap->eh_context;
-       unsigned long end, secs;
-       int rc;
-
-       /* first, debounce phy if SATA */
-       if (ap->cbl == ATA_CBL_SATA) {
-               rc = sata_phy_debounce(ap, sata_deb_timing_hotplug, deadline);
-
-               /* if debounced successfully and offline, no need to wait */
-               if ((rc == 0 || rc == -EOPNOTSUPP) && ata_port_offline(ap))
-                       return;
-       }
-
-       /* okay, let's give the drive time to spin up */
-       end = ehc->i.hotplug_timestamp + ATA_SPINUP_WAIT * HZ / 1000;
-       secs = ((end - jiffies) + HZ - 1) / HZ;
-
-       if (time_after(jiffies, end))
-               return;
-
-       if (secs > 5)
-               ata_port_printk(ap, KERN_INFO, "waiting for device to spin up "
-                               "(%lu secs)\n", secs);
-
-       schedule_timeout_uninterruptible(end - jiffies);
-}
-
 /**
  *     ata_std_prereset - prepare for reset
  *     @ap: ATA port to be reset
  *     @deadline: deadline jiffies for the operation
  *
- *     @ap is about to be reset.  Initialize it.
+ *     @ap is about to be reset.  Initialize it.  Failure from
+ *     prereset makes libata abort whole reset sequence and give up
+ *     that port, so prereset should be best-effort.  It does its
+ *     best to prepare for reset sequence but if things go wrong, it
+ *     should just whine, not fail.
  *
  *     LOCKING:
  *     Kernel thread context (may sleep)
@@ -3352,15 +3329,11 @@ int ata_std_prereset(struct ata_port *ap, unsigned long deadline)
        const unsigned long *timing = sata_ehc_deb_timing(ehc);
        int rc;
 
-       /* handle link resume & hotplug spinup */
+       /* handle link resume */
        if ((ehc->i.flags & ATA_EHI_RESUME_LINK) &&
            (ap->flags & ATA_FLAG_HRST_TO_RESUME))
                ehc->i.action |= ATA_EH_HARDRESET;
 
-       if ((ehc->i.flags & ATA_EHI_HOTPLUGGED) &&
-           (ap->flags & ATA_FLAG_SKIP_D2H_BSY))
-               ata_wait_spinup(ap, deadline);
-
        /* if we're about to do hardreset, nothing more to do */
        if (ehc->i.action & ATA_EH_HARDRESET)
                return 0;
@@ -3368,19 +3341,23 @@ int ata_std_prereset(struct ata_port *ap, unsigned long deadline)
        /* if SATA, resume phy */
        if (ap->cbl == ATA_CBL_SATA) {
                rc = sata_phy_resume(ap, timing, deadline);
-               if (rc && rc != -EOPNOTSUPP) {
-                       /* phy resume failed */
+               /* whine about phy resume failure but proceed */
+               if (rc && rc != -EOPNOTSUPP)
                        ata_port_printk(ap, KERN_WARNING, "failed to resume "
                                        "link for reset (errno=%d)\n", rc);
-                       return rc;
-               }
        }
 
        /* Wait for !BSY if the controller can wait for the first D2H
         * Reg FIS and we don't know that no device is attached.
         */
-       if (!(ap->flags & ATA_FLAG_SKIP_D2H_BSY) && !ata_port_offline(ap))
-               ata_wait_ready(ap, deadline);
+       if (!(ap->flags & ATA_FLAG_SKIP_D2H_BSY) && !ata_port_offline(ap)) {
+               rc = ata_wait_ready(ap, deadline);
+               if (rc) {
+                       ata_port_printk(ap, KERN_WARNING, "device not ready "
+                                       "(errno=%d), forcing hardreset\n", rc);
+                       ehc->i.action |= ATA_EH_HARDRESET;
+               }
+       }
 
        return 0;
 }
@@ -6500,9 +6477,9 @@ void ata_port_detach(struct ata_port *ap)
        /* Flush hotplug task.  The sequence is similar to
         * ata_port_flush_task().
         */
-       flush_workqueue(ata_aux_wq);
+       cancel_work_sync(&ap->hotplug_task.work); /* akpm: why? */
        cancel_delayed_work(&ap->hotplug_task);
-       flush_workqueue(ata_aux_wq);
+       cancel_work_sync(&ap->hotplug_task.work);
 
  skip_eh:
        /* remove the associated SCSI host */