libata: reimplement link iterator
[safe/jmp/linux-2.6] / drivers / ata / libata-core.c
index a01e02c..d156616 100644 (file)
 #include <linux/completion.h>
 #include <linux/suspend.h>
 #include <linux/workqueue.h>
-#include <linux/jiffies.h>
 #include <linux/scatterlist.h>
 #include <linux/io.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
-#include <asm/semaphore.h>
 #include <asm/byteorder.h>
 #include <linux/cdrom.h>
 
@@ -74,10 +72,8 @@ const unsigned long sata_deb_timing_hotplug[]                = {  25,  500, 2000 };
 const unsigned long sata_deb_timing_long[]             = { 100, 2000, 5000 };
 
 const struct ata_port_operations ata_base_port_ops = {
-       .sff_irq_clear          = ata_noop_irq_clear,
-       .prereset               = ata_sff_prereset,
-       .hardreset              = sata_sff_hardreset,
-       .postreset              = ata_sff_postreset,
+       .prereset               = ata_std_prereset,
+       .postreset              = ata_std_postreset,
        .error_handler          = ata_std_error_handler,
 };
 
@@ -85,16 +81,7 @@ const struct ata_port_operations sata_port_ops = {
        .inherits               = &ata_base_port_ops,
 
        .qc_defer               = ata_std_qc_defer,
-       .sff_dev_select         = ata_noop_dev_select,
-};
-
-const struct ata_port_operations sata_pmp_port_ops = {
-       .inherits               = &sata_port_ops,
-
-       .pmp_prereset           = sata_pmp_std_prereset,
-       .pmp_hardreset          = sata_pmp_std_hardreset,
-       .pmp_postreset          = sata_pmp_std_postreset,
-       .error_handler          = sata_pmp_error_handler,
+       .hardreset              = sata_std_hardreset,
 };
 
 static unsigned int ata_dev_init_params(struct ata_device *dev,
@@ -117,6 +104,7 @@ struct ata_force_param {
        unsigned long   xfer_mask;
        unsigned int    horkage_on;
        unsigned int    horkage_off;
+       unsigned int    lflags;
 };
 
 struct ata_force_ent {
@@ -133,7 +121,7 @@ static char ata_force_param_buf[PAGE_SIZE] __initdata;
 module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0);
 MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/kernel-parameters.txt for details)");
 
-int atapi_enabled = 1;
+static int atapi_enabled = 1;
 module_param(atapi_enabled, int, 0444);
 MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)");
 
@@ -157,7 +145,7 @@ static int libata_dma_mask = ATA_DMA_MASK_ATA|ATA_DMA_MASK_ATAPI|ATA_DMA_MASK_CF
 module_param_named(dma, libata_dma_mask, int, 0444);
 MODULE_PARM_DESC(dma, "DMA enable/disable (0x1==ATA, 0x2==ATAPI, 0x4==CF)");
 
-static int ata_probe_timeout = ATA_TMOUT_INTERNAL / HZ;
+static int ata_probe_timeout;
 module_param(ata_probe_timeout, int, 0444);
 MODULE_PARM_DESC(ata_probe_timeout, "Set ATA probing timeout (seconds)");
 
@@ -175,6 +163,35 @@ MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
 
 
+/*
+ * Iterator helpers.  Don't use directly.
+ *
+ * LOCKING:
+ * Host lock or EH context.
+ */
+struct ata_link *__ata_port_next_link(struct ata_port *ap,
+                                     struct ata_link *link, bool dev_only)
+{
+       /* NULL link indicates start of iteration */
+       if (!link) {
+               if (dev_only && sata_pmp_attached(ap))
+                       return ap->pmp_link;
+               return &ap->link;
+       }
+
+       /* we just iterated over the host link, what's next? */
+       if (ata_is_host_link(link)) {
+               if (!sata_pmp_attached(ap))
+                       return NULL;
+               return ap->pmp_link;
+       }
+
+       /* iterate to the next PMP link */
+       if (++link < ap->pmp_link + ap->nr_pmp_links)
+               return link;
+       return NULL;
+}
+
 /**
  *     ata_force_cbl - force cable type according to libata.force
  *     @ap: ATA port of interest
@@ -209,22 +226,23 @@ void ata_force_cbl(struct ata_port *ap)
 }
 
 /**
- *     ata_force_spd_limit - force SATA spd limit according to libata.force
+ *     ata_force_link_limits - force link limits according to libata.force
  *     @link: ATA link of interest
  *
- *     Force SATA spd limit according to libata.force and whine about
- *     it.  When only the port part is specified (e.g. 1:), the limit
- *     applies to all links connected to both the host link and all
- *     fan-out ports connected via PMP.  If the device part is
- *     specified as 0 (e.g. 1.00:), it specifies the first fan-out
- *     link not the host link.  Device number 15 always points to the
- *     host link whether PMP is attached or not.
+ *     Force link flags and SATA spd limit according to libata.force
+ *     and whine about it.  When only the port part is specified
+ *     (e.g. 1:), the limit applies to all links connected to both
+ *     the host link and all fan-out ports connected via PMP.  If the
+ *     device part is specified as 0 (e.g. 1.00:), it specifies the
+ *     first fan-out link not the host link.  Device number 15 always
+ *     points to the host link whether PMP is attached or not.
  *
  *     LOCKING:
  *     EH context.
  */
-static void ata_force_spd_limit(struct ata_link *link)
+static void ata_force_link_limits(struct ata_link *link)
 {
+       bool did_spd = false;
        int linkno, i;
 
        if (ata_is_host_link(link))
@@ -241,13 +259,22 @@ static void ata_force_spd_limit(struct ata_link *link)
                if (fe->device != -1 && fe->device != linkno)
                        continue;
 
-               if (!fe->param.spd_limit)
-                       continue;
+               /* only honor the first spd limit */
+               if (!did_spd && fe->param.spd_limit) {
+                       link->hw_sata_spd_limit = (1 << fe->param.spd_limit) - 1;
+                       ata_link_printk(link, KERN_NOTICE,
+                                       "FORCE: PHY spd limit set to %s\n",
+                                       fe->param.name);
+                       did_spd = true;
+               }
 
-               link->hw_sata_spd_limit = (1 << fe->param.spd_limit) - 1;
-               ata_link_printk(link, KERN_NOTICE,
-                       "FORCE: PHY spd limit set to %s\n", fe->param.name);
-               return;
+               /* let lflags stack */
+               if (fe->param.lflags) {
+                       link->flags |= fe->param.lflags;
+                       ata_link_printk(link, KERN_NOTICE,
+                                       "FORCE: link flag 0x%x forced -> 0x%x\n",
+                                       fe->param.lflags, link->flags);
+               }
        }
 }
 
@@ -387,14 +414,6 @@ int atapi_cmd_type(u8 opcode)
 }
 
 /**
- *     ata_noop_irq_clear - Noop placeholder for irq_clear
- *     @ap: Port associated with this ATA transaction.
- */
-void ata_noop_irq_clear(struct ata_port *ap)
-{
-}
-
-/**
  *     ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure
  *     @tf: Taskfile to convert
  *     @pmp: Port multiplier port
@@ -1153,6 +1172,8 @@ void ata_id_string(const u16 *id, unsigned char *s,
 {
        unsigned int c;
 
+       BUG_ON(len & 1);
+
        while (len > 0) {
                c = id[ofs] >> 8;
                *s = c;
@@ -1186,8 +1207,6 @@ void ata_id_c_string(const u16 *id, unsigned char *s,
 {
        unsigned char *p;
 
-       WARN_ON(!(len & 1));
-
        ata_id_string(id, s, ofs, len - 1);
 
        p = s + strnlen(s, len - 1);
@@ -1441,22 +1460,6 @@ static int ata_hpa_resize(struct ata_device *dev)
 }
 
 /**
- *     ata_noop_dev_select - Select device 0/1 on ATA bus
- *     @ap: ATA channel to manipulate
- *     @device: ATA device (numbered from zero) to select
- *
- *     This function performs no actual function.
- *
- *     May be used as the dev_select() entry in ata_port_operations.
- *
- *     LOCKING:
- *     caller.
- */
-void ata_noop_dev_select(struct ata_port *ap, unsigned int device)
-{
-}
-
-/**
  *     ata_dump_id - IDENTIFY DEVICE info debugging output
  *     @id: IDENTIFY DEVICE page to dump
  *
@@ -1569,7 +1572,7 @@ unsigned long ata_id_xfermask(const u16 *id)
  *     @ap: The ata_port to queue port_task for
  *     @fn: workqueue function to be scheduled
  *     @data: data for @fn to use
- *     @delay: delay time for workqueue function
+ *     @delay: delay time in msecs for workqueue function
  *
  *     Schedule @fn(@data) for execution after @delay jiffies using
  *     port_task.  There is one port_task per port and it's the
@@ -1588,7 +1591,7 @@ void ata_pio_queue_task(struct ata_port *ap, void *data, unsigned long delay)
        ap->port_task_data = data;
 
        /* may fail if ata_port_flush_task() in progress */
-       queue_delayed_work(ata_wq, &ap->port_task, delay);
+       queue_delayed_work(ata_wq, &ap->port_task, msecs_to_jiffies(delay));
 }
 
 /**
@@ -1648,6 +1651,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
        struct ata_link *link = dev->link;
        struct ata_port *ap = link->ap;
        u8 command = tf->command;
+       int auto_timeout = 0;
        struct ata_queued_cmd *qc;
        unsigned int tag, preempted_tag;
        u32 preempted_sactive, preempted_qc_active;
@@ -1720,8 +1724,14 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
 
        spin_unlock_irqrestore(ap->lock, flags);
 
-       if (!timeout)
-               timeout = ata_probe_timeout * 1000 / HZ;
+       if (!timeout) {
+               if (ata_probe_timeout)
+                       timeout = ata_probe_timeout * 1000;
+               else {
+                       timeout = ata_internal_cmd_timeout(dev, command);
+                       auto_timeout = 1;
+               }
+       }
 
        rc = wait_for_completion_timeout(&wait, msecs_to_jiffies(timeout));
 
@@ -1797,6 +1807,9 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
 
        spin_unlock_irqrestore(ap->lock, flags);
 
+       if ((err_mask & AC_ERR_TIMEOUT) && auto_timeout)
+               ata_internal_cmd_timed_out(dev, command);
+
        return err_mask;
 }
 
@@ -1913,6 +1926,23 @@ static u32 ata_pio_mask_no_iordy(const struct ata_device *adev)
 }
 
 /**
+ *     ata_do_dev_read_id              -       default ID read method
+ *     @dev: device
+ *     @tf: proposed taskfile
+ *     @id: data buffer
+ *
+ *     Issue the identify taskfile and hand back the buffer containing
+ *     identify data. For some RAID controllers and for pre ATA devices
+ *     this function is wrapped or replaced by the driver
+ */
+unsigned int ata_do_dev_read_id(struct ata_device *dev,
+                                       struct ata_taskfile *tf, u16 *id)
+{
+       return ata_exec_internal(dev, tf, NULL, DMA_FROM_DEVICE,
+                                    id, sizeof(id[0]) * ATA_ID_WORDS, 0);
+}
+
+/**
  *     ata_dev_read_id - Read ID data from the specified device
  *     @dev: target device
  *     @p_class: pointer to class of the target device (may be changed)
@@ -1947,7 +1977,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
        if (ata_msg_ctl(ap))
                ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__);
 
- retry:
+retry:
        ata_tf_init(dev, &tf);
 
        switch (class) {
@@ -1975,8 +2005,11 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
         */
        tf.flags |= ATA_TFLAG_POLLING;
 
-       err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE,
-                                    id, sizeof(id[0]) * ATA_ID_WORDS, 0);
+       if (ap->ops->read_id)
+               err_mask = ap->ops->read_id(dev, &tf, id);
+       else
+               err_mask = ata_do_dev_read_id(dev, &tf, id);
+
        if (err_mask) {
                if (err_mask & AC_ERR_NODEV_HINT) {
                        ata_dev_printk(dev, KERN_DEBUG,
@@ -2162,6 +2195,23 @@ int ata_dev_configure(struct ata_device *dev)
        dev->horkage |= ata_dev_blacklisted(dev);
        ata_force_horkage(dev);
 
+       if (dev->horkage & ATA_HORKAGE_DISABLE) {
+               ata_dev_printk(dev, KERN_INFO,
+                              "unsupported device, disabling\n");
+               ata_dev_disable(dev);
+               return 0;
+       }
+
+       if ((!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) &&
+           dev->class == ATA_DEV_ATAPI) {
+               ata_dev_printk(dev, KERN_WARNING,
+                       "WARNING: ATAPI is %s, device ignored.\n",
+                       atapi_enabled ? "not supported with this driver"
+                                     : "disabled");
+               ata_dev_disable(dev);
+               return 0;
+       }
+
        /* let ACPI work its magic */
        rc = ata_acpi_on_devcfg(dev);
        if (rc)
@@ -2313,7 +2363,7 @@ int ata_dev_configure(struct ata_device *dev)
                 * changed notifications and ATAPI ANs.
                 */
                if ((ap->flags & ATA_FLAG_AN) && ata_id_has_atapi_AN(id) &&
-                   (!ap->nr_pmp_links ||
+                   (!sata_pmp_attached(ap) ||
                     sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf) == 0)) {
                        unsigned int err_mask;
 
@@ -2652,7 +2702,7 @@ void ata_port_probe(struct ata_port *ap)
  *     LOCKING:
  *     None.
  */
-void sata_print_link_status(struct ata_link *link)
+static void sata_print_link_status(struct ata_link *link)
 {
        u32 sstatus, scontrol, tmp;
 
@@ -2808,7 +2858,7 @@ static int __sata_set_spd_needed(struct ata_link *link, u32 *scontrol)
  *     RETURNS:
  *     1 if SATA spd configuration is needed, 0 otherwise.
  */
-int sata_set_spd_needed(struct ata_link *link)
+static int sata_set_spd_needed(struct ata_link *link)
 {
        u32 scontrol;
 
@@ -3167,16 +3217,21 @@ static int ata_dev_set_mode(struct ata_device *dev)
        if (rc)
                return rc;
 
-       /* Old CFA may refuse this command, which is just fine */
-       if (dev->xfer_shift == ATA_SHIFT_PIO && ata_id_is_cfa(dev->id))
-               ign_dev_err = 1;
-
-       /* Some very old devices and some bad newer ones fail any kind of
-          SET_XFERMODE request but support PIO0-2 timings and no IORDY */
-       if (dev->xfer_shift == ATA_SHIFT_PIO && !ata_id_has_iordy(dev->id) &&
-                       dev->pio_mode <= XFER_PIO_2)
-               ign_dev_err = 1;
-
+       if (dev->xfer_shift == ATA_SHIFT_PIO) {
+               /* Old CFA may refuse this command, which is just fine */
+               if (ata_id_is_cfa(dev->id))
+                       ign_dev_err = 1;
+               /* Catch several broken garbage emulations plus some pre
+                  ATA devices */
+               if (ata_id_major_version(dev->id) == 0 &&
+                                       dev->pio_mode <= XFER_PIO_2)
+                       ign_dev_err = 1;
+               /* Some very old devices and some bad newer ones fail
+                  any kind of SET_XFERMODE request but support PIO0-2
+                  timings and no IORDY */
+               if (!ata_id_has_iordy(dev->id) && dev->pio_mode <= XFER_PIO_2)
+                       ign_dev_err = 1;
+       }
        /* Early MWDMA devices do DMA but don't allow DMA mode setting.
           Don't fail an MWDMA0 set IFF the device indicates it is in MWDMA0 */
        if (dev->xfer_shift == ATA_SHIFT_MWDMA &&
@@ -3262,7 +3317,7 @@ int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
                dev->dma_mode = ata_xfer_mask2mode(dma_mask);
 
                found = 1;
-               if (dev->dma_mode != 0xff)
+               if (ata_dma_enabled(dev))
                        used_dma = 1;
        }
        if (!found)
@@ -3287,7 +3342,7 @@ int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
 
        /* step 3: set host DMA timings */
        ata_link_for_each_dev(dev, link) {
-               if (!ata_dev_enabled(dev) || dev->dma_mode == 0xff)
+               if (!ata_dev_enabled(dev) || !ata_dma_enabled(dev))
                        continue;
 
                dev->xfer_mode = dev->dma_mode;
@@ -3320,6 +3375,103 @@ int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
 }
 
 /**
+ *     ata_wait_ready - wait for link to become ready
+ *     @link: link to be waited on
+ *     @deadline: deadline jiffies for the operation
+ *     @check_ready: callback to check link readiness
+ *
+ *     Wait for @link to become ready.  @check_ready should return
+ *     positive number if @link is ready, 0 if it isn't, -ENODEV if
+ *     link doesn't seem to be occupied, other errno for other error
+ *     conditions.
+ *
+ *     Transient -ENODEV conditions are allowed for
+ *     ATA_TMOUT_FF_WAIT.
+ *
+ *     LOCKING:
+ *     EH context.
+ *
+ *     RETURNS:
+ *     0 if @linke is ready before @deadline; otherwise, -errno.
+ */
+int ata_wait_ready(struct ata_link *link, unsigned long deadline,
+                  int (*check_ready)(struct ata_link *link))
+{
+       unsigned long start = jiffies;
+       unsigned long nodev_deadline = ata_deadline(start, ATA_TMOUT_FF_WAIT);
+       int warned = 0;
+
+       if (time_after(nodev_deadline, deadline))
+               nodev_deadline = deadline;
+
+       while (1) {
+               unsigned long now = jiffies;
+               int ready, tmp;
+
+               ready = tmp = check_ready(link);
+               if (ready > 0)
+                       return 0;
+
+               /* -ENODEV could be transient.  Ignore -ENODEV if link
+                * is online.  Also, some SATA devices take a long
+                * time to clear 0xff after reset.  For example,
+                * HHD424020F7SV00 iVDR needs >= 800ms while Quantum
+                * GoVault needs even more than that.  Wait for
+                * ATA_TMOUT_FF_WAIT on -ENODEV if link isn't offline.
+                *
+                * Note that some PATA controllers (pata_ali) explode
+                * if status register is read more than once when
+                * there's no device attached.
+                */
+               if (ready == -ENODEV) {
+                       if (ata_link_online(link))
+                               ready = 0;
+                       else if ((link->ap->flags & ATA_FLAG_SATA) &&
+                                !ata_link_offline(link) &&
+                                time_before(now, nodev_deadline))
+                               ready = 0;
+               }
+
+               if (ready)
+                       return ready;
+               if (time_after(now, deadline))
+                       return -EBUSY;
+
+               if (!warned && time_after(now, start + 5 * HZ) &&
+                   (deadline - now > 3 * HZ)) {
+                       ata_link_printk(link, KERN_WARNING,
+                               "link is slow to respond, please be patient "
+                               "(ready=%d)\n", tmp);
+                       warned = 1;
+               }
+
+               msleep(50);
+       }
+}
+
+/**
+ *     ata_wait_after_reset - wait for link to become ready after reset
+ *     @link: link to be waited on
+ *     @deadline: deadline jiffies for the operation
+ *     @check_ready: callback to check link readiness
+ *
+ *     Wait for @link to become ready after reset.
+ *
+ *     LOCKING:
+ *     EH context.
+ *
+ *     RETURNS:
+ *     0 if @linke is ready before @deadline; otherwise, -errno.
+ */
+int ata_wait_after_reset(struct ata_link *link, unsigned long deadline,
+                               int (*check_ready)(struct ata_link *link))
+{
+       msleep(ATA_WAIT_AFTER_RESET);
+
+       return ata_wait_ready(link, deadline, check_ready);
+}
+
+/**
  *     sata_link_debounce - debounce SATA phy status
  *     @link: ATA link to debounce SATA phy status for
  *     @params: timing parameters { interval, duratinon, timeout } in msec
@@ -3344,13 +3496,13 @@ int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
 int sata_link_debounce(struct ata_link *link, const unsigned long *params,
                       unsigned long deadline)
 {
-       unsigned long interval_msec = params[0];
-       unsigned long duration = msecs_to_jiffies(params[1]);
+       unsigned long interval = params[0];
+       unsigned long duration = params[1];
        unsigned long last_jiffies, t;
        u32 last, cur;
        int rc;
 
-       t = jiffies + msecs_to_jiffies(params[2]);
+       t = ata_deadline(jiffies, params[2]);
        if (time_before(t, deadline))
                deadline = t;
 
@@ -3362,7 +3514,7 @@ int sata_link_debounce(struct ata_link *link, const unsigned long *params,
        last_jiffies = jiffies;
 
        while (1) {
-               msleep(interval_msec);
+               msleep(interval);
                if ((rc = sata_scr_read(link, SCR_STATUS, &cur)))
                        return rc;
                cur &= 0xf;
@@ -3371,7 +3523,8 @@ int sata_link_debounce(struct ata_link *link, const unsigned long *params,
                if (cur == last) {
                        if (cur == 1 && time_before(jiffies, deadline))
                                continue;
-                       if (time_after(jiffies, last_jiffies + duration))
+                       if (time_after(jiffies,
+                                      ata_deadline(last_jiffies, duration)))
                                return 0;
                        continue;
                }
@@ -3405,7 +3558,7 @@ int sata_link_debounce(struct ata_link *link, const unsigned long *params,
 int sata_link_resume(struct ata_link *link, const unsigned long *params,
                     unsigned long deadline)
 {
-       u32 scontrol;
+       u32 scontrol, serror;
        int rc;
 
        if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol)))
@@ -3421,11 +3574,18 @@ int sata_link_resume(struct ata_link *link, const unsigned long *params,
         */
        msleep(200);
 
-       return sata_link_debounce(link, params, deadline);
+       if ((rc = sata_link_debounce(link, params, deadline)))
+               return rc;
+
+       /* clear SError, some PHYs require this even for SRST to work */
+       if (!(rc = sata_scr_read(link, SCR_ERROR, &serror)))
+               rc = sata_scr_write(link, SCR_ERROR, serror);
+
+       return rc != -EINVAL ? rc : 0;
 }
 
 /**
- *     ata_sff_prereset - prepare for reset
+ *     ata_std_prereset - prepare for reset
  *     @link: ATA link to be reset
  *     @deadline: deadline jiffies for the operation
  *
@@ -3441,7 +3601,7 @@ int sata_link_resume(struct ata_link *link, const unsigned long *params,
  *     RETURNS:
  *     0 on success, -errno otherwise.
  */
-int ata_sff_prereset(struct ata_link *link, unsigned long deadline)
+int ata_std_prereset(struct ata_link *link, unsigned long deadline)
 {
        struct ata_port *ap = link->ap;
        struct ata_eh_context *ehc = &link->eh_context;
@@ -3461,15 +3621,9 @@ int ata_sff_prereset(struct ata_link *link, unsigned long deadline)
                                        "link for reset (errno=%d)\n", rc);
        }
 
-       /* wait for !BSY if we don't know that no device is attached */
-       if (!ata_link_offline(link)) {
-               rc = ata_sff_wait_ready(ap, deadline);
-               if (rc && rc != -ENODEV) {
-                       ata_link_printk(link, KERN_WARNING, "device not ready "
-                                       "(errno=%d), forcing hardreset\n", rc);
-                       ehc->i.action |= ATA_EH_HARDRESET;
-               }
-       }
+       /* no point in trying softreset on offline link */
+       if (ata_link_offline(link))
+               ehc->i.action &= ~ATA_EH_SOFTRESET;
 
        return 0;
 }
@@ -3479,8 +3633,18 @@ int ata_sff_prereset(struct ata_link *link, unsigned long deadline)
  *     @link: link to reset
  *     @timing: timing parameters { interval, duratinon, timeout } in msec
  *     @deadline: deadline jiffies for the operation
+ *     @online: optional out parameter indicating link onlineness
+ *     @check_ready: optional callback to check link readiness
  *
  *     SATA phy-reset @link using DET bits of SControl register.
+ *     After hardreset, link readiness is waited upon using
+ *     ata_wait_ready() if @check_ready is specified.  LLDs are
+ *     allowed to not specify @check_ready and wait itself after this
+ *     function returns.  Device classification is LLD's
+ *     responsibility.
+ *
+ *     *@online is set to one iff reset succeeded and @link is online
+ *     after reset.
  *
  *     LOCKING:
  *     Kernel thread context (may sleep)
@@ -3489,13 +3653,17 @@ int ata_sff_prereset(struct ata_link *link, unsigned long deadline)
  *     0 on success, -errno otherwise.
  */
 int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
-                       unsigned long deadline)
+                       unsigned long deadline,
+                       bool *online, int (*check_ready)(struct ata_link *))
 {
        u32 scontrol;
        int rc;
 
        DPRINTK("ENTER\n");
 
+       if (online)
+               *online = false;
+
        if (sata_set_spd_needed(link)) {
                /* SATA spec says nothing about how to reconfigure
                 * spd.  To be on the safe side, turn off phy during
@@ -3529,13 +3697,78 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
 
        /* bring link back */
        rc = sata_link_resume(link, timing, deadline);
+       if (rc)
+               goto out;
+       /* if link is offline nothing more to do */
+       if (ata_link_offline(link))
+               goto out;
+
+       /* Link is online.  From this point, -ENODEV too is an error. */
+       if (online)
+               *online = true;
+
+       if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) {
+               /* If PMP is supported, we have to do follow-up SRST.
+                * Some PMPs don't send D2H Reg FIS after hardreset if
+                * the first port is empty.  Wait only for
+                * ATA_TMOUT_PMP_SRST_WAIT.
+                */
+               if (check_ready) {
+                       unsigned long pmp_deadline;
+
+                       pmp_deadline = ata_deadline(jiffies,
+                                                   ATA_TMOUT_PMP_SRST_WAIT);
+                       if (time_after(pmp_deadline, deadline))
+                               pmp_deadline = deadline;
+                       ata_wait_ready(link, pmp_deadline, check_ready);
+               }
+               rc = -EAGAIN;
+               goto out;
+       }
+
+       rc = 0;
+       if (check_ready)
+               rc = ata_wait_ready(link, deadline, check_ready);
  out:
+       if (rc && rc != -EAGAIN) {
+               /* online is set iff link is online && reset succeeded */
+               if (online)
+                       *online = false;
+               ata_link_printk(link, KERN_ERR,
+                               "COMRESET failed (errno=%d)\n", rc);
+       }
        DPRINTK("EXIT, rc=%d\n", rc);
        return rc;
 }
 
 /**
- *     ata_sff_postreset - standard postreset callback
+ *     sata_std_hardreset - COMRESET w/o waiting or classification
+ *     @link: link to reset
+ *     @class: resulting class of attached device
+ *     @deadline: deadline jiffies for the operation
+ *
+ *     Standard SATA COMRESET w/o waiting or classification.
+ *
+ *     LOCKING:
+ *     Kernel thread context (may sleep)
+ *
+ *     RETURNS:
+ *     0 if link offline, -EAGAIN if link online, -errno on errors.
+ */
+int sata_std_hardreset(struct ata_link *link, unsigned int *class,
+                      unsigned long deadline)
+{
+       const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context);
+       bool online;
+       int rc;
+
+       /* do hardreset */
+       rc = sata_link_hardreset(link, timing, deadline, &online, NULL);
+       return online ? -EAGAIN : rc;
+}
+
+/**
+ *     ata_std_postreset - standard postreset callback
  *     @link: the target ata_link
  *     @classes: classes of attached devices
  *
@@ -3546,36 +3779,18 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
  *     LOCKING:
  *     Kernel thread context (may sleep)
  */
-void ata_sff_postreset(struct ata_link *link, unsigned int *classes)
+void ata_std_postreset(struct ata_link *link, unsigned int *classes)
 {
-       struct ata_port *ap = link->ap;
        u32 serror;
 
        DPRINTK("ENTER\n");
 
-       /* print link status */
-       sata_print_link_status(link);
-
-       /* clear SError */
-       if (sata_scr_read(link, SCR_ERROR, &serror) == 0)
+       /* reset complete, clear SError */
+       if (!sata_scr_read(link, SCR_ERROR, &serror))
                sata_scr_write(link, SCR_ERROR, serror);
-       link->eh_info.serror = 0;
-
-       /* is double-select really necessary? */
-       if (classes[0] != ATA_DEV_NONE)
-               ap->ops->sff_dev_select(ap, 1);
-       if (classes[1] != ATA_DEV_NONE)
-               ap->ops->sff_dev_select(ap, 0);
 
-       /* bail out if no device is present */
-       if (classes[0] == ATA_DEV_NONE && classes[1] == ATA_DEV_NONE) {
-               DPRINTK("EXIT, no device\n");
-               return;
-       }
-
-       /* set up device control */
-       if (ap->ioaddr.ctl_addr)
-               iowrite8(ap->ctl, ap->ioaddr.ctl_addr);
+       /* print link status */
+       sata_print_link_status(link);
 
        DPRINTK("EXIT\n");
 }
@@ -3766,8 +3981,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
        { "SAMSUNG CD-ROM SN-124", "N001",      ATA_HORKAGE_NODMA },
        { "Seagate STT20000A", NULL,            ATA_HORKAGE_NODMA },
        /* Odd clown on sil3726/4726 PMPs */
-       { "Config  Disk",       NULL,           ATA_HORKAGE_NODMA |
-                                               ATA_HORKAGE_SKIP_PM },
+       { "Config  Disk",       NULL,           ATA_HORKAGE_DISABLE },
 
        /* Weird ATAPI devices */
        { "TORiSAN DVD-ROM DRD-N216", NULL,     ATA_HORKAGE_MAX_SEC_128 },
@@ -3805,6 +4019,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
 
        /* Devices which get the IVB wrong */
        { "QUANTUM FIREBALLlct10 05", "A03.0900", ATA_HORKAGE_IVB, },
+       /* Maybe we should just blacklist TSSTcorp... */
+       { "TSSTcorp CDDVDW SH-S202H", "SB00",     ATA_HORKAGE_IVB, },
+       { "TSSTcorp CDDVDW SH-S202H", "SB01",     ATA_HORKAGE_IVB, },
        { "TSSTcorp CDDVDW SH-S202J", "SB00",     ATA_HORKAGE_IVB, },
        { "TSSTcorp CDDVDW SH-S202J", "SB01",     ATA_HORKAGE_IVB, },
        { "TSSTcorp CDDVDW SH-S202N", "SB00",     ATA_HORKAGE_IVB, },
@@ -3909,6 +4126,10 @@ static int cable_is_40wire(struct ata_port *ap)
        /* If the controller thinks we are 80 wire, we are */
        if (ap->cbl == ATA_CBL_PATA80 || ap->cbl == ATA_CBL_SATA)
                return 0;
+       /* If the system is known to be 40 wire short cable (eg laptop),
+          then we allow 80 wire modes even if the drive isn't sure */
+       if (ap->cbl == ATA_CBL_PATA40_SHORT)
+               return 0;
        /* If the controller doesn't know we scan
 
           - Note: We look for all 40 wire detects at this point.
@@ -4157,7 +4378,7 @@ void ata_sg_clean(struct ata_queued_cmd *qc)
 }
 
 /**
- *     ata_check_atapi_dma - Check whether ATAPI DMA can be supported
+ *     atapi_check_dma - Check whether ATAPI DMA can be supported
  *     @qc: Metadata associated with taskfile to check
  *
  *     Allow low-level driver to filter ATA PACKET commands, returning
@@ -4170,7 +4391,7 @@ void ata_sg_clean(struct ata_queued_cmd *qc)
  *     RETURNS: 0 when ATAPI DMA can be used
  *               nonzero otherwise
  */
-int ata_check_atapi_dma(struct ata_queued_cmd *qc)
+int atapi_check_dma(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
 
@@ -4416,7 +4637,7 @@ static void fill_result_tf(struct ata_queued_cmd *qc)
        struct ata_port *ap = qc->ap;
 
        qc->result_tf.flags = qc->tf.flags;
-       ap->ops->sff_tf_read(ap, &qc->result_tf);
+       ap->ops->qc_fill_rtf(qc);
 }
 
 static void ata_verify_xfer(struct ata_queued_cmd *qc)
@@ -4526,7 +4747,6 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
  *     ata_qc_complete_multiple - Complete multiple qcs successfully
  *     @ap: port in question
  *     @qc_active: new qc_active mask
- *     @finish_qc: LLDD callback invoked before completing a qc
  *
  *     Complete in-flight commands.  This functions is meant to be
  *     called from low-level driver's interrupt routine to complete
@@ -4539,8 +4759,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
  *     RETURNS:
  *     Number of completed commands on success, -errno otherwise.
  */
-int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active,
-                            void (*finish_qc)(struct ata_queued_cmd *))
+int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active)
 {
        int nr_done = 0;
        u32 done_mask;
@@ -4561,8 +4780,6 @@ int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active,
                        continue;
 
                if ((qc = ata_qc_from_tag(ap, i))) {
-                       if (finish_qc)
-                               finish_qc(qc);
                        ata_qc_complete(qc);
                        nr_done++;
                }
@@ -4680,10 +4897,8 @@ int sata_scr_valid(struct ata_link *link)
 int sata_scr_read(struct ata_link *link, int reg, u32 *val)
 {
        if (ata_is_host_link(link)) {
-               struct ata_port *ap = link->ap;
-
                if (sata_scr_valid(link))
-                       return ap->ops->scr_read(ap, reg, val);
+                       return link->ap->ops->scr_read(link, reg, val);
                return -EOPNOTSUPP;
        }
 
@@ -4709,10 +4924,8 @@ int sata_scr_read(struct ata_link *link, int reg, u32 *val)
 int sata_scr_write(struct ata_link *link, int reg, u32 val)
 {
        if (ata_is_host_link(link)) {
-               struct ata_port *ap = link->ap;
-
                if (sata_scr_valid(link))
-                       return ap->ops->scr_write(ap, reg, val);
+                       return link->ap->ops->scr_write(link, reg, val);
                return -EOPNOTSUPP;
        }
 
@@ -4737,13 +4950,12 @@ int sata_scr_write(struct ata_link *link, int reg, u32 val)
 int sata_scr_write_flush(struct ata_link *link, int reg, u32 val)
 {
        if (ata_is_host_link(link)) {
-               struct ata_port *ap = link->ap;
                int rc;
 
                if (sata_scr_valid(link)) {
-                       rc = ap->ops->scr_write(ap, reg, val);
+                       rc = link->ap->ops->scr_write(link, reg, val);
                        if (rc == 0)
-                               rc = ap->ops->scr_read(ap, reg, &val);
+                               rc = link->ap->ops->scr_read(link, reg, &val);
                        return rc;
                }
                return -EOPNOTSUPP;
@@ -5011,19 +5223,18 @@ void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp)
  */
 int sata_link_init_spd(struct ata_link *link)
 {
-       u32 scontrol;
        u8 spd;
        int rc;
 
-       rc = sata_scr_read(link, SCR_CONTROL, &scontrol);
+       rc = sata_scr_read(link, SCR_CONTROL, &link->saved_scontrol);
        if (rc)
                return rc;
 
-       spd = (scontrol >> 4) & 0xf;
+       spd = (link->saved_scontrol >> 4) & 0xf;
        if (spd)
                link->hw_sata_spd_limit &= (1 << spd) - 1;
 
-       ata_force_spd_limit(link);
+       ata_force_link_limits(link);
 
        link->sata_spd_limit = link->hw_sata_spd_limit;
 
@@ -5070,7 +5281,9 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
        ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN;
 #endif
 
+#ifdef CONFIG_ATA_SFF
        INIT_DELAYED_WORK(&ap->port_task, ata_pio_task);
+#endif
        INIT_DELAYED_WORK(&ap->hotplug_task, ata_scsi_hotplug);
        INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan);
        INIT_LIST_HEAD(&ap->eh_done_q);
@@ -5265,7 +5478,7 @@ static void ata_host_stop(struct device *gendev, void *res)
  */
 static void ata_finalize_port_ops(struct ata_port_operations *ops)
 {
-       static spinlock_t lock = SPIN_LOCK_UNLOCKED;
+       static DEFINE_SPINLOCK(lock);
        const struct ata_port_operations *cur;
        void **begin = (void **)ops;
        void **end = (void **)&ops->inherits;
@@ -5483,7 +5696,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
                        spin_lock_irqsave(ap->lock, flags);
 
                        ehi->probe_mask |= ATA_ALL_DEVICES;
-                       ehi->action |= ATA_EH_RESET;
+                       ehi->action |= ATA_EH_RESET | ATA_EH_LPM;
                        ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET;
 
                        ap->pflags &= ~ATA_PFLAG_INITIALIZING;
@@ -5516,7 +5729,6 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
                struct ata_port *ap = host->ports[i];
 
                ata_scsi_scan_host(ap, 1);
-               ata_lpm_schedule(ap, ap->pm_policy);
        }
 
        return 0;
@@ -5605,9 +5817,10 @@ static void ata_port_detach(struct ata_port *ap)
        ata_port_wait_eh(ap);
 
        /* EH is now guaranteed to see UNLOADING - EH context belongs
-        * to us.  Disable all existing devices.
+        * to us.  Restore SControl and disable all existing devices.
         */
-       ata_port_for_each_link(link, ap) {
+       __ata_port_for_each_link(link, ap) {
+               sata_scr_write(link, SCR_CONTROL, link->saved_scontrol);
                ata_link_for_each_dev(dev, link)
                        ata_dev_disable(dev);
        }
@@ -5813,6 +6026,9 @@ static int __init ata_parse_force_one(char **cur,
                { "udma133",    .xfer_mask      = 1 << (ATA_SHIFT_UDMA + 6) },
                { "udma/133",   .xfer_mask      = 1 << (ATA_SHIFT_UDMA + 6) },
                { "udma7",      .xfer_mask      = 1 << (ATA_SHIFT_UDMA + 7) },
+               { "nohrst",     .lflags         = ATA_LFLAG_NO_HRST },
+               { "nosrst",     .lflags         = ATA_LFLAG_NO_SRST },
+               { "norst",      .lflags         = ATA_LFLAG_NO_HRST | ATA_LFLAG_NO_SRST },
        };
        char *start = *cur, *p = *cur;
        char *id, *val, *endp;
@@ -5936,22 +6152,24 @@ static void __init ata_parse_force_param(void)
 
 static int __init ata_init(void)
 {
-       ata_probe_timeout *= HZ;
-
        ata_parse_force_param();
 
        ata_wq = create_workqueue("ata");
        if (!ata_wq)
-               return -ENOMEM;
+               goto free_force_tbl;
 
        ata_aux_wq = create_singlethread_workqueue("ata_aux");
-       if (!ata_aux_wq) {
-               destroy_workqueue(ata_wq);
-               return -ENOMEM;
-       }
+       if (!ata_aux_wq)
+               goto free_wq;
 
        printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n");
        return 0;
+
+free_wq:
+       destroy_workqueue(ata_wq);
+free_force_tbl:
+       kfree(ata_force_tbl);
+       return -ENOMEM;
 }
 
 static void __exit ata_exit(void)
@@ -5990,8 +6208,8 @@ int ata_ratelimit(void)
  *     @reg: IO-mapped register
  *     @mask: Mask to apply to read register value
  *     @val: Wait condition
- *     @interval_msec: polling interval in milliseconds
- *     @timeout_msec: timeout in milliseconds
+ *     @interval: polling interval in milliseconds
+ *     @timeout: timeout in milliseconds
  *
  *     Waiting for some bits of register to change is a common
  *     operation for ATA controllers.  This function reads 32bit LE
@@ -6009,10 +6227,9 @@ int ata_ratelimit(void)
  *     The final register value.
  */
 u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
-                     unsigned long interval_msec,
-                     unsigned long timeout_msec)
+                     unsigned long interval, unsigned long timeout)
 {
-       unsigned long timeout;
+       unsigned long deadline;
        u32 tmp;
 
        tmp = ioread32(reg);
@@ -6021,10 +6238,10 @@ u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
         * preceding writes reach the controller before starting to
         * eat away the timeout.
         */
-       timeout = jiffies + (timeout_msec * HZ) / 1000;
+       deadline = ata_deadline(jiffies, timeout);
 
-       while ((tmp & mask) == val && time_before(jiffies, timeout)) {
-               msleep(interval_msec);
+       while ((tmp & mask) == val && time_before(jiffies, deadline)) {
+               msleep(interval);
                tmp = ioread32(reg);
        }
 
@@ -6034,33 +6251,20 @@ u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
 /*
  * Dummy port_ops
  */
-static void ata_dummy_noret(struct ata_port *ap)       { }
-static int ata_dummy_ret0(struct ata_port *ap)         { return 0; }
-static void ata_dummy_qc_noret(struct ata_queued_cmd *qc) { }
-
-static u8 ata_dummy_check_status(struct ata_port *ap)
+static unsigned int ata_dummy_qc_issue(struct ata_queued_cmd *qc)
 {
-       return ATA_DRDY;
+       return AC_ERR_SYSTEM;
 }
 
-static unsigned int ata_dummy_qc_issue(struct ata_queued_cmd *qc)
+static void ata_dummy_error_handler(struct ata_port *ap)
 {
-       return AC_ERR_SYSTEM;
+       /* truly dummy */
 }
 
 struct ata_port_operations ata_dummy_port_ops = {
-       .sff_check_status       = ata_dummy_check_status,
-       .sff_check_altstatus    = ata_dummy_check_status,
-       .sff_dev_select         = ata_noop_dev_select,
        .qc_prep                = ata_noop_qc_prep,
        .qc_issue               = ata_dummy_qc_issue,
-       .freeze                 = ata_dummy_noret,
-       .thaw                   = ata_dummy_noret,
-       .error_handler          = ata_dummy_noret,
-       .post_internal_cmd      = ata_dummy_qc_noret,
-       .sff_irq_clear          = ata_dummy_noret,
-       .port_start             = ata_dummy_ret0,
-       .port_stop              = ata_dummy_noret,
+       .error_handler          = ata_dummy_error_handler,
 };
 
 const struct ata_port_info ata_dummy_port_info = {
@@ -6078,9 +6282,9 @@ EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug);
 EXPORT_SYMBOL_GPL(sata_deb_timing_long);
 EXPORT_SYMBOL_GPL(ata_base_port_ops);
 EXPORT_SYMBOL_GPL(sata_port_ops);
-EXPORT_SYMBOL_GPL(sata_pmp_port_ops);
 EXPORT_SYMBOL_GPL(ata_dummy_port_ops);
 EXPORT_SYMBOL_GPL(ata_dummy_port_info);
+EXPORT_SYMBOL_GPL(__ata_port_next_link);
 EXPORT_SYMBOL_GPL(ata_std_bios_param);
 EXPORT_SYMBOL_GPL(ata_host_init);
 EXPORT_SYMBOL_GPL(ata_host_alloc);
@@ -6092,8 +6296,6 @@ EXPORT_SYMBOL_GPL(ata_host_detach);
 EXPORT_SYMBOL_GPL(ata_sg_init);
 EXPORT_SYMBOL_GPL(ata_qc_complete);
 EXPORT_SYMBOL_GPL(ata_qc_complete_multiple);
-EXPORT_SYMBOL_GPL(ata_noop_dev_select);
-EXPORT_SYMBOL_GPL(sata_print_link_status);
 EXPORT_SYMBOL_GPL(atapi_cmd_type);
 EXPORT_SYMBOL_GPL(ata_tf_to_fis);
 EXPORT_SYMBOL_GPL(ata_tf_from_fis);
@@ -6108,13 +6310,16 @@ EXPORT_SYMBOL_GPL(ata_port_start);
 EXPORT_SYMBOL_GPL(ata_do_set_mode);
 EXPORT_SYMBOL_GPL(ata_std_qc_defer);
 EXPORT_SYMBOL_GPL(ata_noop_qc_prep);
-EXPORT_SYMBOL_GPL(ata_noop_irq_clear);
 EXPORT_SYMBOL_GPL(ata_port_probe);
 EXPORT_SYMBOL_GPL(ata_dev_disable);
 EXPORT_SYMBOL_GPL(sata_set_spd);
+EXPORT_SYMBOL_GPL(ata_wait_after_reset);
 EXPORT_SYMBOL_GPL(sata_link_debounce);
 EXPORT_SYMBOL_GPL(sata_link_resume);
+EXPORT_SYMBOL_GPL(ata_std_prereset);
 EXPORT_SYMBOL_GPL(sata_link_hardreset);
+EXPORT_SYMBOL_GPL(sata_std_hardreset);
+EXPORT_SYMBOL_GPL(ata_std_postreset);
 EXPORT_SYMBOL_GPL(ata_dev_classify);
 EXPORT_SYMBOL_GPL(ata_dev_pair);
 EXPORT_SYMBOL_GPL(ata_port_disable);
@@ -6137,6 +6342,7 @@ EXPORT_SYMBOL_GPL(ata_host_resume);
 #endif /* CONFIG_PM */
 EXPORT_SYMBOL_GPL(ata_id_string);
 EXPORT_SYMBOL_GPL(ata_id_c_string);
+EXPORT_SYMBOL_GPL(ata_do_dev_read_id);
 EXPORT_SYMBOL_GPL(ata_scsi_simulate);
 
 EXPORT_SYMBOL_GPL(ata_pio_need_iordy);
@@ -6156,12 +6362,6 @@ EXPORT_SYMBOL_GPL(ata_pci_device_resume);
 #endif /* CONFIG_PM */
 #endif /* CONFIG_PCI */
 
-EXPORT_SYMBOL_GPL(sata_pmp_qc_defer_cmd_switch);
-EXPORT_SYMBOL_GPL(sata_pmp_std_prereset);
-EXPORT_SYMBOL_GPL(sata_pmp_std_hardreset);
-EXPORT_SYMBOL_GPL(sata_pmp_std_postreset);
-EXPORT_SYMBOL_GPL(sata_pmp_error_handler);
-
 EXPORT_SYMBOL_GPL(__ata_ehi_push_desc);
 EXPORT_SYMBOL_GPL(ata_ehi_push_desc);
 EXPORT_SYMBOL_GPL(ata_ehi_clear_desc);
@@ -6178,6 +6378,7 @@ EXPORT_SYMBOL_GPL(ata_eh_freeze_port);
 EXPORT_SYMBOL_GPL(ata_eh_thaw_port);
 EXPORT_SYMBOL_GPL(ata_eh_qc_complete);
 EXPORT_SYMBOL_GPL(ata_eh_qc_retry);
+EXPORT_SYMBOL_GPL(ata_eh_analyze_ncq_error);
 EXPORT_SYMBOL_GPL(ata_do_eh);
 EXPORT_SYMBOL_GPL(ata_std_error_handler);