patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / scsi / libata-core.c
index 1f43996..29dee2c 100644 (file)
 #include <linux/delay.h>
 #include <linux/timer.h>
 #include <linux/interrupt.h>
+#include <linux/completion.h>
 #include <linux/suspend.h>
+#include <linux/workqueue.h>
 #include <scsi/scsi.h>
 #include "scsi.h"
-#include "hosts.h"
+#include <scsi/scsi_host.h>
 #include <linux/libata.h>
 #include <asm/io.h>
 #include <asm/semaphore.h>
 
 #include "libata.h"
 
-static void atapi_cdb_send(struct ata_port *ap);
 static unsigned int ata_busy_sleep (struct ata_port *ap,
                                    unsigned long tmout_pat,
                                    unsigned long tmout);
 static void __ata_dev_select (struct ata_port *ap, unsigned int device);
-#if 0 /* to be used eventually */
-static void ata_qc_push (struct ata_queued_cmd *qc, unsigned int append);
-#endif
-static void ata_dma_complete(struct ata_port *ap, u8 host_stat,
-                            unsigned int done_late);
+static void ata_dma_complete(struct ata_queued_cmd *qc, u8 host_stat);
 static void ata_host_set_pio(struct ata_port *ap);
 static void ata_host_set_udma(struct ata_port *ap);
 static void ata_dev_set_pio(struct ata_port *ap, unsigned int device);
 static void ata_dev_set_udma(struct ata_port *ap, unsigned int device);
 static void ata_set_mode(struct ata_port *ap);
+static int ata_qc_issue_prot(struct ata_queued_cmd *qc);
 
 static unsigned int ata_unique_id = 1;
+static struct workqueue_struct *ata_wq;
 
 MODULE_AUTHOR("Jeff Garzik");
 MODULE_DESCRIPTION("Library module for ATA devices");
@@ -74,13 +73,6 @@ static const char * thr_state_name[] = {
        "THR_IDLE",
        "THR_PROBE_SUCCESS",
        "THR_PROBE_START",
-       "THR_PIO_POLL",
-       "THR_PIO_TMOUT",
-       "THR_PIO",
-       "THR_PIO_LAST",
-       "THR_PIO_LAST_POLL",
-       "THR_PIO_ERR",
-       "THR_PACKET",
 };
 
 /**
@@ -104,26 +96,9 @@ static const char *ata_thr_state_name(unsigned int thr_state)
        return "<invalid THR_xxx state>";
 }
 
-/**
- *     msleep - sleep for a number of milliseconds
- *     @msecs: number of milliseconds to sleep
- *
- *     Issues schedule_timeout call for the specified number
- *     of milliseconds.
- *
- *     LOCKING:
- *     None.
- */
-
-static void msleep(unsigned long msecs)
-{
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(msecs_to_jiffies(msecs) + 1);
-}
-
 /**
  *     ata_tf_load_pio - send taskfile registers to host controller
- *     @ioaddr: set of IO ports to which output is sent
+ *     @ap: Port to which output is sent
  *     @tf: ATA taskfile register set
  *
  *     Outputs ATA taskfile to standard ATA host controller using PIO.
@@ -181,7 +156,7 @@ void ata_tf_load_pio(struct ata_port *ap, struct ata_taskfile *tf)
 
 /**
  *     ata_tf_load_mmio - send taskfile registers to host controller
- *     @ioaddr: set of IO ports to which output is sent
+ *     @ap: Port to which output is sent
  *     @tf: ATA taskfile register set
  *
  *     Outputs ATA taskfile to standard ATA host controller using MMIO.
@@ -315,8 +290,6 @@ static inline void ata_exec(struct ata_port *ap, struct ata_taskfile *tf)
 
 static void ata_tf_to_host(struct ata_port *ap, struct ata_taskfile *tf)
 {
-       init_MUTEX_LOCKED(&ap->sem);
-
        ap->ops->tf_load(ap, tf);
 
        ata_exec(ap, tf);
@@ -337,15 +310,13 @@ static void ata_tf_to_host(struct ata_port *ap, struct ata_taskfile *tf)
 
 void ata_tf_to_host_nolock(struct ata_port *ap, struct ata_taskfile *tf)
 {
-       init_MUTEX_LOCKED(&ap->sem);
-
        ap->ops->tf_load(ap, tf);
        ap->ops->exec_command(ap, tf);
 }
 
 /**
  *     ata_tf_read_pio - input device's ATA taskfile shadow registers
- *     @ioaddr: set of IO ports from which input is read
+ *     @ap: Port from which input is read
  *     @tf: ATA taskfile register set for storing input
  *
  *     Reads ATA taskfile registers for currently-selected device
@@ -377,7 +348,7 @@ void ata_tf_read_pio(struct ata_port *ap, struct ata_taskfile *tf)
 
 /**
  *     ata_tf_read_mmio - input device's ATA taskfile shadow registers
- *     @ioaddr: set of IO ports from which input is read
+ *     @ap: Port from which input is read
  *     @tf: ATA taskfile register set for storing input
  *
  *     Reads ATA taskfile registers for currently-selected device
@@ -439,6 +410,78 @@ u8 ata_check_status_mmio(struct ata_port *ap)
                return readb((void *) ap->ioaddr.status_addr);
 }
 
+/**
+ *     ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure
+ *     @tf: Taskfile to convert
+ *     @fis: Buffer into which data will output
+ *     @pmp: Port multiplier port
+ *
+ *     Converts a standard ATA taskfile to a Serial ATA
+ *     FIS structure (Register - Host to Device).
+ *
+ *     LOCKING:
+ *     Inherited from caller.
+ */
+
+void ata_tf_to_fis(struct ata_taskfile *tf, u8 *fis, u8 pmp)
+{
+       fis[0] = 0x27;  /* Register - Host to Device FIS */
+       fis[1] = (pmp & 0xf) | (1 << 7); /* Port multiplier number,
+                                           bit 7 indicates Command FIS */
+       fis[2] = tf->command;
+       fis[3] = tf->feature;
+
+       fis[4] = tf->lbal;
+       fis[5] = tf->lbam;
+       fis[6] = tf->lbah;
+       fis[7] = tf->device;
+
+       fis[8] = tf->hob_lbal;
+       fis[9] = tf->hob_lbam;
+       fis[10] = tf->hob_lbah;
+       fis[11] = tf->hob_feature;
+
+       fis[12] = tf->nsect;
+       fis[13] = tf->hob_nsect;
+       fis[14] = 0;
+       fis[15] = tf->ctl;
+
+       fis[16] = 0;
+       fis[17] = 0;
+       fis[18] = 0;
+       fis[19] = 0;
+}
+
+/**
+ *     ata_tf_from_fis - Convert SATA FIS to ATA taskfile
+ *     @fis: Buffer from which data will be input
+ *     @tf: Taskfile to output
+ *
+ *     Converts a standard ATA taskfile to a Serial ATA
+ *     FIS structure (Register - Host to Device).
+ *
+ *     LOCKING:
+ *     Inherited from caller.
+ */
+
+void ata_tf_from_fis(u8 *fis, struct ata_taskfile *tf)
+{
+       tf->command     = fis[2];       /* status */
+       tf->feature     = fis[3];       /* error */
+
+       tf->lbal        = fis[4];
+       tf->lbam        = fis[5];
+       tf->lbah        = fis[6];
+       tf->device      = fis[7];
+
+       tf->hob_lbal    = fis[8];
+       tf->hob_lbam    = fis[9];
+       tf->hob_lbah    = fis[10];
+
+       tf->nsect       = fis[12];
+       tf->hob_nsect   = fis[13];
+}
+
 /**
  *     ata_prot_to_cmd - determine which read/write opcodes to use
  *     @protocol: ATA_PROT_xxx taskfile protocol
@@ -759,7 +802,7 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device)
  *     @dev: Device whose IDENTIFY DEVICE results we will examine
  *     @s: string into which data is output
  *     @ofs: offset into identify device page
- *     @len: length of string to return
+ *     @len: length of string to return. must be an even number.
  *
  *     The strings in the IDENTIFY DEVICE page are broken up into
  *     16-bit chunks.  Run through the string, and output each
@@ -788,29 +831,6 @@ void ata_dev_id_string(struct ata_device *dev, unsigned char *s,
        }
 }
 
-/**
- *     ata_dev_parse_strings - Store useful IDENTIFY DEVICE page strings
- *     @dev: Device whose IDENTIFY DEVICE page info we use
- *
- *     We store 'vendor' and 'product' strings read from the device,
- *     for later use in the SCSI simulator's INQUIRY data.
- *
- *     Set these strings here, in the case of 'product', using
- *     data read from the ATA IDENTIFY DEVICE page.
- *
- *     LOCKING:
- *     caller.
- */
-
-static void ata_dev_parse_strings(struct ata_device *dev)
-{
-       assert (dev->class == ATA_DEV_ATA);
-       memcpy(dev->vendor, "ATA     ", 8);
-
-       ata_dev_id_string(dev, dev->product, ATA_ID_PROD_OFS,
-                         sizeof(dev->product));
-}
-
 /**
  *     __ata_dev_select - Select device 0/1 on ATA bus
  *     @ap: ATA channel to manipulate
@@ -1068,8 +1088,6 @@ retry:
 
        ata_dump_id(dev);
 
-       ata_dev_parse_strings(dev);
-
        /* ATA-specific feature tests */
        if (dev->class == ATA_DEV_ATA) {
                if (!ata_id_is_ata(dev))        /* sanity check */
@@ -1096,11 +1114,11 @@ retry:
                ap->host->max_cmd_len = 16;
 
                /* print device info to dmesg */
-               printk(KERN_INFO "ata%u: dev %u ATA, max %s, %Lu sectors%s\n",
+               printk(KERN_INFO "ata%u: dev %u ATA, max %s, %Lu sectors:%s\n",
                       ap->id, device,
                       ata_udma_string(udma_modes),
                       (unsigned long long)dev->n_sectors,
-                      dev->flags & ATA_DFLAG_LBA48 ? " (lba48)" : "");
+                      dev->flags & ATA_DFLAG_LBA48 ? " lba48" : "");
        }
 
        /* ATAPI-specific feature tests */
@@ -1663,9 +1681,9 @@ err_out:
 }
 
 /**
- *     ata_dev_set_xfermode -
- *     @ap:
- *     @dev:
+ *     ata_dev_set_xfermode - Issue SET FEATURES - XFER MODE command
+ *     @ap: Port associated with device @dev
+ *     @dev: Device to which command will be sent
  *
  *     LOCKING:
  */
@@ -1704,9 +1722,9 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
 }
 
 /**
- *     ata_dev_set_udma -
- *     @ap:
- *     @device:
+ *     ata_dev_set_udma - Set ATA device's transfer mode to Ultra DMA
+ *     @ap: Port associated with device @dev
+ *     @device: Device whose mode will be set
  *
  *     LOCKING:
  */
@@ -1728,9 +1746,9 @@ static void ata_dev_set_udma(struct ata_port *ap, unsigned int device)
 }
 
 /**
- *     ata_dev_set_pio -
- *     @ap:
- *     @device:
+ *     ata_dev_set_pio - Set ATA device's transfer mode to PIO
+ *     @ap: Port associated with device @dev
+ *     @device: Device whose mode will be set
  *
  *     LOCKING:
  */
@@ -1928,20 +1946,20 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
 static unsigned long ata_pio_poll(struct ata_port *ap)
 {
        u8 status;
-       unsigned int poll_state = THR_UNKNOWN;
-       unsigned int reg_state = THR_UNKNOWN;
-       const unsigned int tmout_state = THR_PIO_TMOUT;
-
-       switch (ap->thr_state) {
-       case THR_PIO:
-       case THR_PIO_POLL:
-               poll_state = THR_PIO_POLL;
-               reg_state = THR_PIO;
+       unsigned int poll_state = PIO_ST_UNKNOWN;
+       unsigned int reg_state = PIO_ST_UNKNOWN;
+       const unsigned int tmout_state = PIO_ST_TMOUT;
+
+       switch (ap->pio_task_state) {
+       case PIO_ST:
+       case PIO_ST_POLL:
+               poll_state = PIO_ST_POLL;
+               reg_state = PIO_ST;
                break;
-       case THR_PIO_LAST:
-       case THR_PIO_LAST_POLL:
-               poll_state = THR_PIO_LAST_POLL;
-               reg_state = THR_PIO_LAST;
+       case PIO_ST_LAST:
+       case PIO_ST_LAST_POLL:
+               poll_state = PIO_ST_LAST_POLL;
+               reg_state = PIO_ST_LAST;
                break;
        default:
                BUG();
@@ -1950,38 +1968,18 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
 
        status = ata_chk_status(ap);
        if (status & ATA_BUSY) {
-               if (time_after(jiffies, ap->thr_timeout)) {
-                       ap->thr_state = tmout_state;
+               if (time_after(jiffies, ap->pio_task_timeout)) {
+                       ap->pio_task_state = tmout_state;
                        return 0;
                }
-               ap->thr_state = poll_state;
+               ap->pio_task_state = poll_state;
                return ATA_SHORT_PAUSE;
        }
 
-       ap->thr_state = reg_state;
+       ap->pio_task_state = reg_state;
        return 0;
 }
 
-/**
- *     ata_pio_start -
- *     @qc:
- *
- *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
- */
-
-static void ata_pio_start (struct ata_queued_cmd *qc)
-{
-       struct ata_port *ap = qc->ap;
-
-       assert(qc->tf.protocol == ATA_PROT_PIO);
-
-       qc->flags |= ATA_QCFLAG_POLL;
-       qc->tf.ctl |= ATA_NIEN; /* disable interrupts */
-       ata_tf_to_host_nolock(ap, &qc->tf);
-       ata_thread_wake(ap, THR_PIO);
-}
-
 /**
  *     ata_pio_complete -
  *     @ap:
@@ -1992,7 +1990,6 @@ static void ata_pio_start (struct ata_queued_cmd *qc)
 static void ata_pio_complete (struct ata_port *ap)
 {
        struct ata_queued_cmd *qc;
-       unsigned long flags;
        u8 drv_stat;
 
        /*
@@ -2001,35 +1998,33 @@ static void ata_pio_complete (struct ata_port *ap)
         * a chk-status or two.  If not, the drive is probably seeking
         * or something.  Snooze for a couple msecs, then
         * chk-status again.  If still busy, fall back to
-        * THR_PIO_POLL state.
+        * PIO_ST_POLL state.
         */
        drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10);
        if (drv_stat & (ATA_BUSY | ATA_DRQ)) {
                msleep(2);
                drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10);
                if (drv_stat & (ATA_BUSY | ATA_DRQ)) {
-                       ap->thr_state = THR_PIO_LAST_POLL;
-                       ap->thr_timeout = jiffies + ATA_TMOUT_PIO;
+                       ap->pio_task_state = PIO_ST_LAST_POLL;
+                       ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO;
                        return;
                }
        }
 
        drv_stat = ata_wait_idle(ap);
        if (drv_stat & (ATA_BUSY | ATA_DRQ)) {
-               ap->thr_state = THR_PIO_ERR;
+               ap->pio_task_state = PIO_ST_ERR;
                return;
        }
 
        qc = ata_qc_from_tag(ap, ap->active_tag);
        assert(qc != NULL);
 
-       spin_lock_irqsave(&ap->host_set->lock, flags);
-       ap->thr_state = THR_IDLE;
-       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+       ap->pio_task_state = PIO_ST_IDLE;
 
        ata_irq_on(ap);
 
-       ata_qc_complete(qc, drv_stat, 0);
+       ata_qc_complete(qc, drv_stat);
 }
 
 /**
@@ -2053,22 +2048,22 @@ static void ata_pio_sector(struct ata_port *ap)
         * a chk-status or two.  If not, the drive is probably seeking
         * or something.  Snooze for a couple msecs, then
         * chk-status again.  If still busy, fall back to
-        * THR_PIO_POLL state.
+        * PIO_ST_POLL state.
         */
        status = ata_busy_wait(ap, ATA_BUSY, 5);
        if (status & ATA_BUSY) {
                msleep(2);
                status = ata_busy_wait(ap, ATA_BUSY, 10);
                if (status & ATA_BUSY) {
-                       ap->thr_state = THR_PIO_POLL;
-                       ap->thr_timeout = jiffies + ATA_TMOUT_PIO;
+                       ap->pio_task_state = PIO_ST_POLL;
+                       ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO;
                        return;
                }
        }
 
        /* handle BSY=0, DRQ=0 as error */
        if ((status & ATA_DRQ) == 0) {
-               ap->thr_state = THR_PIO_ERR;
+               ap->pio_task_state = PIO_ST_ERR;
                return;
        }
 
@@ -2079,7 +2074,7 @@ static void ata_pio_sector(struct ata_port *ap)
        sg = qc->sg;
 
        if (qc->cursect == (qc->nsect - 1))
-               ap->thr_state = THR_PIO_LAST;
+               ap->pio_task_state = PIO_ST_LAST;
 
        buf = kmap(sg[qc->cursg].page) +
              sg[qc->cursg].offset + (qc->cursg_ofs * ATA_SECT_SIZE);
@@ -2107,20 +2102,48 @@ static void ata_pio_sector(struct ata_port *ap)
        kunmap(sg[qc->cursg].page);
 }
 
-#if 0 /* to be used eventually */
-/**
- *     ata_eng_schedule - run an iteration of the pio/dma/whatever engine
- *     @ap: port on which activity will occur
- *     @eng: instance of engine
- *
- *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
- */
-static void ata_eng_schedule (struct ata_port *ap, struct ata_engine *eng)
+static void ata_pio_task(void *_data)
 {
-       /* FIXME */
+       struct ata_port *ap = _data;
+       unsigned long timeout = 0;
+
+       switch (ap->pio_task_state) {
+       case PIO_ST:
+               ata_pio_sector(ap);
+               break;
+
+       case PIO_ST_LAST:
+               ata_pio_complete(ap);
+               break;
+
+       case PIO_ST_POLL:
+       case PIO_ST_LAST_POLL:
+               timeout = ata_pio_poll(ap);
+               break;
+
+       case PIO_ST_TMOUT:
+               printk(KERN_ERR "ata%d: FIXME: PIO_ST_TMOUT\n", /* FIXME */
+                      ap->id);
+               timeout = 11 * HZ;
+               break;
+
+       case PIO_ST_ERR:
+               printk(KERN_ERR "ata%d: FIXME: PIO_ST_ERR\n", /* FIXME */
+                      ap->id);
+               timeout = 11 * HZ;
+               break;
+       }
+
+       if ((ap->pio_task_state != PIO_ST_IDLE) &&
+           (ap->pio_task_state != PIO_ST_TMOUT) &&
+           (ap->pio_task_state != PIO_ST_ERR)) {
+               if (timeout)
+                       queue_delayed_work(ata_wq, &ap->pio_task,
+                                          timeout);
+               else
+                       queue_work(ata_wq, &ap->pio_task);
+       }
 }
-#endif
 
 /**
  *     ata_eng_timeout - Handle timeout of queued command
@@ -2174,7 +2197,7 @@ void ata_eng_timeout(struct ata_port *ap)
                printk(KERN_ERR "ata%u: DMA timeout, stat 0x%x\n",
                       ap->id, host_stat);
 
-               ata_dma_complete(ap, host_stat, 1);
+               ata_dma_complete(qc, host_stat);
                break;
 
        case ATA_PROT_NODATA:
@@ -2183,7 +2206,7 @@ void ata_eng_timeout(struct ata_port *ap)
                printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x\n",
                       ap->id, qc->tf.command, drv_stat);
 
-               ata_qc_complete(qc, drv_stat, 1);
+               ata_qc_complete(qc, drv_stat);
                break;
 
        default:
@@ -2192,7 +2215,7 @@ void ata_eng_timeout(struct ata_port *ap)
                printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n",
                       ap->id, qc->tf.command, drv_stat);
 
-               ata_qc_complete(qc, drv_stat, 1);
+               ata_qc_complete(qc, drv_stat);
                break;
        }
 
@@ -2201,9 +2224,9 @@ out:
 }
 
 /**
- *     ata_qc_new -
- *     @ap:
- *     @dev:
+ *     ata_qc_new - Request an available ATA command, for queueing
+ *     @ap: Port associated with device @dev
+ *     @dev: Device from whom we request an available command structure
  *
  *     LOCKING:
  */
@@ -2226,9 +2249,9 @@ static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap)
 }
 
 /**
- *     ata_qc_new_init -
- *     @ap:
- *     @dev:
+ *     ata_qc_new_init - Request an available ATA command, and initialize it
+ *     @ap: Port associated with device @dev
+ *     @dev: Device from whom we request an available command structure
  *
  *     LOCKING:
  */
@@ -2246,8 +2269,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
                qc->ap = ap;
                qc->dev = dev;
                qc->cursect = qc->cursg = qc->cursg_ofs = 0;
-               INIT_LIST_HEAD(&qc->node);
-               init_MUTEX_LOCKED(&qc->sem);
+               qc->nsect = 0;
 
                ata_tf_init(ap, &qc->tf, dev->devno);
 
@@ -2261,16 +2283,15 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
 }
 
 /**
- *     ata_qc_complete -
- *     @qc:
- *     @drv_stat:
- *     @done_late:
+ *     ata_qc_complete - Complete an active ATA command
+ *     @qc: Command to complete
+ *     @drv_stat: ATA status register contents
  *
  *     LOCKING:
  *
  */
 
-void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat, unsigned int done_late)
+void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
 {
        struct ata_port *ap = qc->ap;
        struct scsi_cmnd *cmd = qc->scsicmd;
@@ -2284,7 +2305,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat, unsigned int done_l
 
        if (cmd) {
                if (unlikely(drv_stat & (ATA_ERR | ATA_BUSY | ATA_DRQ))) {
-                       if (qc->flags & ATA_QCFLAG_ATAPI)
+                       if (is_atapi_taskfile(&qc->tf))
                                cmd->result = SAM_STAT_CHECK_CONDITION;
                        else
                                ata_to_sense_error(qc);
@@ -2304,89 +2325,124 @@ void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat, unsigned int done_l
                do_clear = 1;
        }
 
-       up(&qc->sem);
+       if (qc->waiting)
+               complete(qc->waiting);
 
        if (likely(do_clear))
                clear_bit(tag, &ap->qactive);
 }
 
-#if 0 /* to be used eventually */
 /**
- *     ata_qc_push -
- *     @qc:
- *     @append:
+ *     ata_qc_issue - issue taskfile to device
+ *     @qc: command to issue to device
+ *
+ *     Prepare an ATA command to submission to device.
+ *     This includes mapping the data into a DMA-able
+ *     area, filling in the S/G table, and finally
+ *     writing the taskfile to hardware, starting the command.
  *
  *     LOCKING:
  *     spin_lock_irqsave(host_set lock)
+ *
+ *     RETURNS:
+ *     Zero on success, negative on error.
  */
-static void ata_qc_push (struct ata_queued_cmd *qc, unsigned int append)
+
+int ata_qc_issue(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
-       struct ata_engine *eng = &ap->eng;
+       struct scsi_cmnd *cmd = qc->scsicmd;
 
-       if (likely(append))
-               list_add_tail(&qc->node, &eng->q);
-       else
-               list_add(&qc->node, &eng->q);
+       if (qc->flags & ATA_QCFLAG_SG) {
+               /* set up SG table */
+               if (cmd->use_sg) {
+                       if (ata_sg_setup(qc))
+                               goto err_out;
+               } else {
+                       if (ata_sg_setup_one(qc))
+                               goto err_out;
+               }
 
-       if (!test_and_set_bit(ATA_EFLG_ACTIVE, &eng->flags))
-               ata_eng_schedule(ap, eng);
+               ap->ops->fill_sg(qc);
+       }
+
+       qc->ap->active_tag = qc->tag;
+       qc->flags |= ATA_QCFLAG_ACTIVE;
+
+       return ata_qc_issue_prot(qc);
+
+err_out:
+       return -1;
 }
-#endif
 
 /**
- *     ata_qc_issue -
- *     @qc:
+ *     ata_qc_issue_prot - issue taskfile to device in proto-dependent manner
+ *     @qc: command to issue to device
+ *
+ *     Using various libata functions and hooks, this function
+ *     starts an ATA command.  ATA commands are grouped into
+ *     classes called "protocols", and issuing each type of protocol
+ *     is slightly different.
  *
  *     LOCKING:
+ *     spin_lock_irqsave(host_set lock)
  *
  *     RETURNS:
- *
+ *     Zero on success, negative on error.
  */
-int ata_qc_issue(struct ata_queued_cmd *qc)
+
+static int ata_qc_issue_prot(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
-       struct scsi_cmnd *cmd = qc->scsicmd;
-       unsigned int dma = qc->flags & ATA_QCFLAG_DMA;
 
        ata_dev_select(ap, qc->dev->devno, 1, 0);
 
-       /* set up SG table */
-       if (cmd->use_sg) {
-               if (ata_sg_setup(qc))
-                       goto err_out;
-       } else {
-               if (ata_sg_setup_one(qc))
-                       goto err_out;
-       }
+       switch (qc->tf.protocol) {
+       case ATA_PROT_NODATA:
+               ata_tf_to_host_nolock(ap, &qc->tf);
+               break;
 
-       ap->ops->fill_sg(qc);
+       case ATA_PROT_DMA:
+               ap->ops->tf_load(ap, &qc->tf);   /* load tf registers */
+               ap->ops->bmdma_setup(qc);           /* set up bmdma */
+               ap->ops->bmdma_start(qc);           /* initiate bmdma */
+               break;
 
-       qc->ap->active_tag = qc->tag;
-       qc->flags |= ATA_QCFLAG_ACTIVE;
+       case ATA_PROT_PIO: /* load tf registers, initiate polling pio */
+               ata_qc_set_polling(qc);
+               ata_tf_to_host_nolock(ap, &qc->tf);
+               ap->pio_task_state = PIO_ST;
+               queue_work(ata_wq, &ap->pio_task);
+               break;
 
-       if (likely(dma)) {
-               ap->ops->tf_load(ap, &qc->tf);  /* load tf registers */
-               ap->ops->bmdma_start(qc);       /* initiate bmdma */
-       } else
-               /* load tf registers, initiate polling pio */
-               ata_pio_start(qc);
+       case ATA_PROT_ATAPI:
+               ata_tf_to_host_nolock(ap, &qc->tf);
+               queue_work(ata_wq, &ap->packet_task);
+               break;
 
-       return 0;
+       case ATA_PROT_ATAPI_DMA:
+               ap->ops->tf_load(ap, &qc->tf);   /* load tf registers */
+               ap->ops->bmdma_setup(qc);           /* set up bmdma */
+               queue_work(ata_wq, &ap->packet_task);
+               break;
 
-err_out:
-       return -1;
+       default:
+               WARN_ON(1);
+               return -1;
+       }
+
+       return 0;
 }
 
 /**
- *     ata_bmdma_start_mmio -
- *     @qc:
+ *     ata_bmdma_setup_mmio - Set up PCI IDE BMDMA transaction (MMIO)
+ *     @qc: Info associated with this ATA transaction.
  *
  *     LOCKING:
  *     spin_lock_irqsave(host_set lock)
  */
 
-void ata_bmdma_start_mmio (struct ata_queued_cmd *qc)
+void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
        unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
@@ -2410,8 +2466,24 @@ void ata_bmdma_start_mmio (struct ata_queued_cmd *qc)
 
        /* issue r/w command */
        ap->ops->exec_command(ap, &qc->tf);
+}
+
+/**
+ *     ata_bmdma_start_mmio - Start a PCI IDE BMDMA transaction (MMIO)
+ *     @qc: Info associated with this ATA transaction.
+ *
+ *     LOCKING:
+ *     spin_lock_irqsave(host_set lock)
+ */
+
+void ata_bmdma_start_mmio (struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+       void *mmio = (void *) ap->ioaddr.bmdma_addr;
+       u8 dmactl;
 
        /* start host DMA transaction */
+       dmactl = readb(mmio + ATA_DMA_CMD);
        writeb(dmactl | ATA_DMA_START, mmio + ATA_DMA_CMD);
 
        /* Strictly, one may wish to issue a readb() here, to
@@ -2428,14 +2500,14 @@ void ata_bmdma_start_mmio (struct ata_queued_cmd *qc)
 }
 
 /**
- *     ata_bmdma_start_pio -
- *     @qc:
+ *     ata_bmdma_setup_pio - Set up PCI IDE BMDMA transaction (PIO)
+ *     @qc: Info associated with this ATA transaction.
  *
  *     LOCKING:
  *     spin_lock_irqsave(host_set lock)
  */
 
-void ata_bmdma_start_pio (struct ata_queued_cmd *qc)
+void ata_bmdma_setup_pio (struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
        unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
@@ -2458,24 +2530,38 @@ void ata_bmdma_start_pio (struct ata_queued_cmd *qc)
 
        /* issue r/w command */
        ap->ops->exec_command(ap, &qc->tf);
+}
+
+/**
+ *     ata_bmdma_start_pio - Start a PCI IDE BMDMA transaction (PIO)
+ *     @qc: Info associated with this ATA transaction.
+ *
+ *     LOCKING:
+ *     spin_lock_irqsave(host_set lock)
+ */
+
+void ata_bmdma_start_pio (struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+       u8 dmactl;
 
        /* start host DMA transaction */
+       dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
        outb(dmactl | ATA_DMA_START,
             ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
 }
 
 /**
- *     ata_dma_complete -
- *     @ap:
- *     @host_stat:
- *     @done_late:
+ *     ata_dma_complete - Complete an active ATA BMDMA command
+ *     @qc: Command to complete
+ *     @host_stat: BMDMA status register contents
  *
  *     LOCKING:
  */
 
-static void ata_dma_complete(struct ata_port *ap, u8 host_stat,
-                            unsigned int done_late)
+static void ata_dma_complete(struct ata_queued_cmd *qc, u8 host_stat)
 {
+       struct ata_port *ap = qc->ap;
        VPRINTK("ENTER\n");
 
        if (ap->flags & ATA_FLAG_MMIO) {
@@ -2506,8 +2592,7 @@ static void ata_dma_complete(struct ata_port *ap, u8 host_stat,
                ap->id, (u32) host_stat, (u32) ata_chk_status(ap));
 
        /* get drive status; clear intr; complete txn */
-       ata_qc_complete(ata_qc_from_tag(ap, ap->active_tag),
-                       ata_wait_idle(ap), done_late);
+       ata_qc_complete(qc, ata_wait_idle(ap));
 }
 
 /**
@@ -2533,7 +2618,10 @@ inline unsigned int ata_host_intr (struct ata_port *ap,
        unsigned int handled = 0;
 
        switch (qc->tf.protocol) {
+
+       /* BMDMA completion */
        case ATA_PROT_DMA:
+       case ATA_PROT_ATAPI_DMA:
                if (ap->flags & ATA_FLAG_MMIO) {
                        void *mmio = (void *) ap->ioaddr.bmdma_addr;
                        host_stat = readb(mmio + ATA_DMA_STATUS);
@@ -2546,14 +2634,23 @@ inline unsigned int ata_host_intr (struct ata_port *ap,
                        break;
                }
 
-               ata_dma_complete(ap, host_stat, 0);
+               ata_dma_complete(qc, host_stat);
                handled = 1;
                break;
 
-       case ATA_PROT_NODATA:   /* command completion, but no data xfer */
+       /* command completion, but no data xfer */
+       /* FIXME: a shared interrupt _will_ cause a non-data command
+        * to be completed prematurely, with an error.
+        *
+        * This doesn't matter right now, since we aren't sending
+        * non-data commands down this pipe except in development
+        * situations.
+        */
+       case ATA_PROT_ATAPI:
+       case ATA_PROT_NODATA:
                status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
                DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status);
-               ata_qc_complete(qc, status, 0);
+               ata_qc_complete(qc, status);
                handled = 1;
                break;
 
@@ -2574,10 +2671,10 @@ inline unsigned int ata_host_intr (struct ata_port *ap,
 }
 
 /**
- *     ata_interrupt -
- *     @irq:
- *     @dev_instance:
- *     @regs:
+ *     ata_interrupt - Default ATA host interrupt handler
+ *     @irq: irq line
+ *     @dev_instance: pointer to our host information structure
+ *     @regs: unused
  *
  *     LOCKING:
  *
@@ -2603,7 +2700,7 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
                        struct ata_queued_cmd *qc;
 
                        qc = ata_qc_from_tag(ap, ap->active_tag);
-                       if (qc && ((qc->flags & ATA_QCFLAG_POLL) == 0))
+                       if (qc && (!(qc->tf.ctl & ATA_NIEN)))
                                handled += ata_host_intr(ap, qc);
                }
        }
@@ -2613,36 +2710,6 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
        return IRQ_RETVAL(handled);
 }
 
-/**
- *     ata_thread_wake -
- *     @ap:
- *     @thr_state:
- *
- *     LOCKING:
- *     spin_lock_irqsave(host_set lock)
- */
-
-void ata_thread_wake(struct ata_port *ap, unsigned int thr_state)
-{
-       assert(ap->thr_state == THR_IDLE);
-       ap->thr_state = thr_state;
-       up(&ap->thr_sem);
-}
-
-/**
- *     ata_thread_timer -
- *     @opaque:
- *
- *     LOCKING:
- */
-
-static void ata_thread_timer(unsigned long opaque)
-{
-       struct ata_port *ap = (struct ata_port *) opaque;
-
-       up(&ap->thr_sem);
-}
-
 /**
  *     ata_thread_iter -
  *     @ap:
@@ -2666,7 +2733,6 @@ static unsigned long ata_thread_iter(struct ata_port *ap)
                break;
 
        case THR_PROBE_START:
-               down(&ap->sem);
                ap->thr_state = THR_PORT_RESET;
                break;
 
@@ -2685,40 +2751,8 @@ static unsigned long ata_thread_iter(struct ata_port *ap)
                break;
 
        case THR_AWAIT_DEATH:
-               timeout = -1;
-               break;
-
        case THR_IDLE:
-               timeout = 30 * HZ;
-               break;
-
-       case THR_PIO:
-               ata_pio_sector(ap);
-               break;
-
-       case THR_PIO_LAST:
-               ata_pio_complete(ap);
-               break;
-
-       case THR_PIO_POLL:
-       case THR_PIO_LAST_POLL:
-               timeout = ata_pio_poll(ap);
-               break;
-
-       case THR_PIO_TMOUT:
-               printk(KERN_ERR "ata%d: FIXME: THR_PIO_TMOUT\n", /* FIXME */
-                      ap->id);
-               timeout = 11 * HZ;
-               break;
-
-       case THR_PIO_ERR:
-               printk(KERN_ERR "ata%d: FIXME: THR_PIO_ERR\n", /* FIXME */
-                      ap->id);
-               timeout = 11 * HZ;
-               break;
-
-       case THR_PACKET:
-               atapi_cdb_send(ap);
+               timeout = -1;
                break;
 
        default:
@@ -2733,86 +2767,8 @@ static unsigned long ata_thread_iter(struct ata_port *ap)
 }
 
 /**
- *     ata_thread -
- *     @data:
- *
- *     LOCKING:
- *
- *     RETURNS:
- *
- */
-
-static int ata_thread (void *data)
-{
-        struct ata_port *ap = data;
-       long timeout;
-
-       daemonize ("katad-%u", ap->id);
-       allow_signal(SIGTERM);
-
-        while (1) {
-               cond_resched();
-
-               timeout = ata_thread_iter(ap);
-
-                if (signal_pending (current))
-                        flush_signals(current);
-                        
-                if (current->flags & PF_FREEZE)
-                       refrigerator(PF_FREEZE);
-                                                        
-
-                if ((timeout < 0) || (ap->time_to_die))
-                        break;
-
-               /* note sleeping for full timeout not guaranteed (that's ok) */
-               if (timeout) {
-                       mod_timer(&ap->thr_timer, jiffies + timeout);
-                       down_interruptible(&ap->thr_sem);
-
-                       if (signal_pending (current))
-                               flush_signals(current);
-
-                       if (ap->time_to_die)
-                               break;
-               }
-        }
-
-       printk(KERN_DEBUG "ata%u: thread exiting\n", ap->id);
-       ap->thr_pid = -1;
-       del_timer_sync(&ap->thr_timer);
-       complete_and_exit (&ap->thr_exited, 0);
-}
-
-/**
- *     ata_thread_kill - kill per-port kernel thread
- *     @ap: port those thread is to be killed
- *
- *     LOCKING:
- *
- */
-
-static int ata_thread_kill(struct ata_port *ap)
-{
-       int ret = 0;
-
-       if (ap->thr_pid >= 0) {
-               ap->time_to_die = 1;
-               wmb();
-               ret = kill_proc(ap->thr_pid, SIGTERM, 1);
-               if (ret)
-                       printk(KERN_ERR "ata%d: unable to kill kernel thread\n",
-                              ap->id);
-               else
-                       wait_for_completion(&ap->thr_exited);
-       }
-
-       return ret;
-}
-
-/**
- *     atapi_cdb_send - Write CDB bytes to hardware
- *     @ap: Port to which ATAPI device is attached.
+ *     atapi_packet_task - Write CDB bytes to hardware
+ *     @_data: Port to which ATAPI device is attached.
  *
  *     When device has indicated its readiness to accept
  *     a CDB, this function is called.  Send the CDB.
@@ -2824,8 +2780,9 @@ static int ata_thread_kill(struct ata_port *ap)
  *     Kernel thread context (may sleep)
  */
 
-static void atapi_cdb_send(struct ata_port *ap)
+static void atapi_packet_task(void *_data)
 {
+       struct ata_port *ap = _data;
        struct ata_queued_cmd *qc;
        u8 status;
 
@@ -2850,30 +2807,24 @@ static void atapi_cdb_send(struct ata_port *ap)
              qc->scsicmd->cmnd, ap->host->max_cmd_len / 4);
 
        /* if we are DMA'ing, irq handler takes over from here */
-       if (qc->tf.feature == ATAPI_PKT_DMA)
-               goto out;
-
-       /* sleep-wait for BSY to clear */
-       DPRINTK("busy wait 2\n");
-       if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB))
-               goto err_out;
+       if (qc->tf.protocol == ATA_PROT_ATAPI_DMA)
+               ap->ops->bmdma_start(qc);           /* initiate bmdma */
 
-       /* wait for BSY,DRQ to clear */
-       status = ata_wait_idle(ap);
-       if (status & (ATA_BUSY | ATA_DRQ))
-               goto err_out;
+       /* non-data commands are also handled via irq */
+       else if (qc->scsicmd->sc_data_direction == SCSI_DATA_NONE) {
+               /* do nothing */
+       }
 
-       /* transaction completed, indicate such to scsi stack */
-       ata_qc_complete(qc, status, 0);
-       ata_irq_on(ap);
+       /* PIO commands are handled by polling */
+       else {
+               ap->pio_task_state = PIO_ST;
+               queue_work(ata_wq, &ap->pio_task);
+       }
 
-out:
-       ap->thr_state = THR_IDLE;
        return;
 
 err_out:
-       ata_qc_complete(qc, ATA_ERR, 0);
-       goto out;
+       ata_qc_complete(qc, ATA_ERR);
 }
 
 int ata_port_start (struct ata_port *ap)
@@ -2883,7 +2834,7 @@ int ata_port_start (struct ata_port *ap)
        ap->prd = pci_alloc_consistent(pdev, ATA_PRD_TBL_SZ, &ap->prd_dma);
        if (!ap->prd)
                return -ENOMEM;
-       
+
        DPRINTK("prd alloc, virt %p, dma %llx\n", ap->prd, (unsigned long long) ap->prd_dma);
 
        return 0;
@@ -2896,10 +2847,25 @@ void ata_port_stop (struct ata_port *ap)
        pci_free_consistent(pdev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma);
 }
 
+static void ata_probe_task(void *_data)
+{
+       struct ata_port *ap = _data;
+       long timeout;
+
+       timeout = ata_thread_iter(ap);
+       if (timeout < 0)
+               return;
+
+       if (timeout > 0)
+               queue_delayed_work(ata_wq, &ap->probe_task, timeout);
+       else
+               queue_work(ata_wq, &ap->probe_task);
+}
+
 /**
- *     ata_host_remove -
- *     @ap:
- *     @do_unregister:
+ *     ata_host_remove - Unregister SCSI host structure with upper layers
+ *     @ap: Port to unregister
+ *     @do_unregister: 1 if we fully unregister, 0 to just stop the port
  *
  *     LOCKING:
  */
@@ -2913,16 +2879,16 @@ static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister)
        if (do_unregister)
                scsi_remove_host(sh);
 
-       ata_thread_kill(ap);    /* FIXME: check return val */
-
        ap->ops->port_stop(ap);
 }
 
 /**
- *     ata_host_init -
- *     @host:
- *     @ent:
- *     @port_no:
+ *     ata_host_init - Initialize an ata_port structure
+ *     @ap: Structure to initialize
+ *     @host: associated SCSI mid-layer structure
+ *     @host_set: Collection of hosts to which @ap belongs
+ *     @ent: Probe information provided by low-level driver
+ *     @port_no: Port number associated with this ata_port
  *
  *     LOCKING:
  *
@@ -2958,21 +2924,14 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
        ap->active_tag = ATA_TAG_POISON;
        ap->last_ctl = 0xFF;
 
-       /* ata_engine init */
-       ap->eng.flags = 0;
-       INIT_LIST_HEAD(&ap->eng.q);
+       INIT_WORK(&ap->packet_task, atapi_packet_task, ap);
+       INIT_WORK(&ap->pio_task, ata_pio_task, ap);
+       INIT_WORK(&ap->probe_task, ata_probe_task, ap);
 
        for (i = 0; i < ATA_MAX_DEVICES; i++)
                ap->device[i].devno = i;
 
-       init_completion(&ap->thr_exited);
        init_MUTEX_LOCKED(&ap->probe_sem);
-       init_MUTEX_LOCKED(&ap->sem);
-       init_MUTEX_LOCKED(&ap->thr_sem);
-
-       init_timer(&ap->thr_timer);
-       ap->thr_timer.function = ata_thread_timer;
-       ap->thr_timer.data = (unsigned long) ap;
 
 #ifdef ATA_IRQ_TRAP
        ap->stats.unhandled_irq = 1;
@@ -2983,10 +2942,10 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
 }
 
 /**
- *     ata_host_add -
- *     @ent:
- *     @host_set:
- *     @port_no:
+ *     ata_host_add - Attach low-level ATA driver to system
+ *     @ent: Information provided by low-level driver
+ *     @host_set: Collections of ports to which we add
+ *     @port_no: Port number associated with this host
  *
  *     LOCKING:
  *
@@ -3015,18 +2974,8 @@ static struct ata_port * ata_host_add(struct ata_probe_ent *ent,
        if (rc)
                goto err_out;
 
-       ap->thr_pid = kernel_thread(ata_thread, ap, CLONE_FS | CLONE_FILES);
-       if (ap->thr_pid < 0) {
-               printk(KERN_ERR "ata%d: unable to start kernel thread\n",
-                      ap->id);
-               goto err_out_free;
-       }
-
        return ap;
 
-err_out_free:
-       ap->ops->port_stop(ap);
-
 err_out:
        scsi_host_put(host);
        return NULL;
@@ -3106,7 +3055,7 @@ int ata_device_add(struct ata_probe_ent *ent)
                ap = host_set->ports[i];
 
                DPRINTK("ata%u: probe begin\n", ap->id);
-               up(&ap->sem);           /* start probe */
+               queue_work(ata_wq, &ap->probe_task);    /* start probe */
 
                DPRINTK("ata%u: probe-wait begin\n", ap->id);
                down(&ap->probe_sem);   /* wait for end */
@@ -3152,7 +3101,7 @@ err_out:
  *     ata_scsi_release - SCSI layer callback hook for host unload
  *     @host: libata host to be unloaded
  *
- *     Performs all duties necessary to shut down a libata port:
+ *     Performs all duties necessary to shut down a libata port...
  *     Kill port kthread, disable port, and release resources.
  *
  *     LOCKING:
@@ -3177,7 +3126,7 @@ int ata_scsi_release(struct Scsi_Host *host)
 
 /**
  *     ata_std_ports - initialize ioaddr with standard port offsets.
- *     @ioaddr:
+ *     @ioaddr: IO address structure to be initialized
  */
 void ata_std_ports(struct ata_ioports *ioaddr)
 {
@@ -3194,10 +3143,10 @@ void ata_std_ports(struct ata_ioports *ioaddr)
 }
 
 /**
- *     ata_pci_init_one -
- *     @pdev:
- *     @port_info:
- *     @n_ports:
+ *     ata_pci_init_one - Initialize/register PCI IDE host controller
+ *     @pdev: Controller to be initialized
+ *     @port_info: Information from low-level host driver
+ *     @n_ports: Number of ports attached to host controller
  *
  *     LOCKING:
  *     Inherited from PCI layer (may sleep).
@@ -3489,11 +3438,21 @@ int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits)
 
 static int __init ata_init(void)
 {
+       ata_wq = create_workqueue("ata");
+       if (!ata_wq)
+               return -ENOMEM;
+
        printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n");
        return 0;
 }
 
+static void __exit ata_exit(void)
+{
+       destroy_workqueue(ata_wq);
+}
+
 module_init(ata_init);
+module_exit(ata_exit);
 
 /*
  * libata is essentially a library of internal helper functions for
@@ -3512,6 +3471,8 @@ EXPORT_SYMBOL_GPL(ata_tf_load_pio);
 EXPORT_SYMBOL_GPL(ata_tf_load_mmio);
 EXPORT_SYMBOL_GPL(ata_tf_read_pio);
 EXPORT_SYMBOL_GPL(ata_tf_read_mmio);
+EXPORT_SYMBOL_GPL(ata_tf_to_fis);
+EXPORT_SYMBOL_GPL(ata_tf_from_fis);
 EXPORT_SYMBOL_GPL(ata_check_status_pio);
 EXPORT_SYMBOL_GPL(ata_check_status_mmio);
 EXPORT_SYMBOL_GPL(ata_exec_command_pio);
@@ -3520,7 +3481,9 @@ EXPORT_SYMBOL_GPL(ata_port_start);
 EXPORT_SYMBOL_GPL(ata_port_stop);
 EXPORT_SYMBOL_GPL(ata_interrupt);
 EXPORT_SYMBOL_GPL(ata_fill_sg);
+EXPORT_SYMBOL_GPL(ata_bmdma_setup_pio);
 EXPORT_SYMBOL_GPL(ata_bmdma_start_pio);
+EXPORT_SYMBOL_GPL(ata_bmdma_setup_mmio);
 EXPORT_SYMBOL_GPL(ata_bmdma_start_mmio);
 EXPORT_SYMBOL_GPL(ata_port_probe);
 EXPORT_SYMBOL_GPL(sata_phy_reset);
@@ -3533,3 +3496,4 @@ EXPORT_SYMBOL_GPL(ata_scsi_error);
 EXPORT_SYMBOL_GPL(ata_scsi_slave_config);
 EXPORT_SYMBOL_GPL(ata_scsi_release);
 EXPORT_SYMBOL_GPL(ata_host_intr);
+EXPORT_SYMBOL_GPL(ata_dev_id_string);