]> err.no Git - linux-2.6/blobdiff - drivers/scsi/libata-core.c
Merge branch 'master'
[linux-2.6] / drivers / scsi / libata-core.c
index 00018705582bb3231474408b3a619fbc41d46c68..3387fe35c54f4f1620caf6acfbdb83a8de59a3ef 100644 (file)
@@ -65,10 +65,6 @@ static unsigned int ata_dev_init_params(struct ata_port *ap,
                                        struct ata_device *dev,
                                        u16 heads,
                                        u16 sectors);
-static int ata_down_xfermask_limit(struct ata_port *ap, struct ata_device *dev,
-                                  int force_pio0);
-static int ata_down_sata_spd_limit(struct ata_port *ap);
-static int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev);
 static unsigned int ata_dev_set_xfermode(struct ata_port *ap,
                                         struct ata_device *dev);
 static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev);
@@ -80,6 +76,10 @@ int atapi_enabled = 1;
 module_param(atapi_enabled, int, 0444);
 MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)");
 
+int atapi_dmadir = 0;
+module_param(atapi_dmadir, int, 0444);
+MODULE_PARM_DESC(atapi_dmadir, "Enable ATAPI DMADIR bridge support (0=off, 1=on)");
+
 int libata_fua = 0;
 module_param_named(fua, libata_fua, int, 0444);
 MODULE_PARM_DESC(fua, "FUA support (0=off, 1=on)");
@@ -412,7 +412,7 @@ static const char *sata_spd_string(unsigned int spd)
        return spd_str[spd - 1];
 }
 
-static void ata_dev_disable(struct ata_port *ap, struct ata_device *dev)
+void ata_dev_disable(struct ata_port *ap, struct ata_device *dev)
 {
        if (ata_dev_enabled(dev)) {
                printk(KERN_WARNING "ata%u: dev %u disabled\n",
@@ -964,6 +964,7 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc)
  *     @ap: Port to which the command is sent
  *     @dev: Device to which the command is sent
  *     @tf: Taskfile registers for the command and the result
+ *     @cdb: CDB for packet command
  *     @dma_dir: Data tranfer direction of the command
  *     @buf: Data buffer of the command
  *     @buflen: Length of data buffer
@@ -978,10 +979,9 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc)
  *     None.  Should be called with kernel context, might sleep.
  */
 
-static unsigned
-ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
-                 struct ata_taskfile *tf,
-                 int dma_dir, void *buf, unsigned int buflen)
+unsigned ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
+                          struct ata_taskfile *tf, const u8 *cdb,
+                          int dma_dir, void *buf, unsigned int buflen)
 {
        u8 command = tf->command;
        struct ata_queued_cmd *qc;
@@ -995,6 +995,8 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
        BUG_ON(qc == NULL);
 
        qc->tf = *tf;
+       if (cdb)
+               memcpy(qc->cdb, cdb, ATAPI_CDB_LEN);
        qc->dma_dir = dma_dir;
        if (dma_dir != DMA_NONE) {
                ata_sg_init_one(qc, buf, buflen);
@@ -1045,7 +1047,7 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
         *
         * Kill the following code as soon as those drivers are fixed.
         */
-       if (ap->flags & ATA_FLAG_PORT_DISABLED) {
+       if (ap->flags & ATA_FLAG_DISABLED) {
                err_mask |= AC_ERR_SYSTEM;
                ata_port_probe(ap);
        }
@@ -1144,7 +1146,7 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev,
 
        tf.protocol = ATA_PROT_PIO;
 
-       err_mask = ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE,
+       err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_FROM_DEVICE,
                                     id, sizeof(id[0]) * ATA_ID_WORDS);
        if (err_mask) {
                rc = -EIO;
@@ -1241,7 +1243,7 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev,
                       id[84], id[85], id[86], id[87], id[88]);
 
        /* initialize to-be-configured parameters */
-       dev->flags = 0;
+       dev->flags &= ~ATA_DFLAG_CFG_MASK;
        dev->max_sectors = 0;
        dev->cdb_len = 0;
        dev->n_sectors = 0;
@@ -1395,7 +1397,7 @@ static int ata_bus_probe(struct ata_port *ap)
        } else {
                ap->ops->phy_reset(ap);
 
-               if (!(ap->flags & ATA_FLAG_PORT_DISABLED))
+               if (!(ap->flags & ATA_FLAG_DISABLED))
                        for (i = 0; i < ATA_MAX_DEVICES; i++)
                                classes[i] = ap->device[i].class;
 
@@ -1491,7 +1493,7 @@ static int ata_bus_probe(struct ata_port *ap)
 
 void ata_port_probe(struct ata_port *ap)
 {
-       ap->flags &= ~ATA_FLAG_PORT_DISABLED;
+       ap->flags &= ~ATA_FLAG_DISABLED;
 }
 
 /**
@@ -1505,20 +1507,23 @@ void ata_port_probe(struct ata_port *ap)
  */
 static void sata_print_link_status(struct ata_port *ap)
 {
-       u32 sstatus, tmp;
+       u32 sstatus, scontrol, tmp;
 
        if (!ap->ops->scr_read)
                return;
 
        sstatus = scr_read(ap, SCR_STATUS);
+       scontrol = scr_read(ap, SCR_CONTROL);
 
        if (sata_dev_present(ap)) {
                tmp = (sstatus >> 4) & 0xf;
-               printk(KERN_INFO "ata%u: SATA link up %s (SStatus %X)\n",
-                      ap->id, sata_spd_string(tmp), sstatus);
+               printk(KERN_INFO
+                      "ata%u: SATA link up %s (SStatus %X SControl %X)\n",
+                      ap->id, sata_spd_string(tmp), sstatus, scontrol);
        } else {
-               printk(KERN_INFO "ata%u: SATA link down (SStatus %X)\n",
-                      ap->id, sstatus);
+               printk(KERN_INFO
+                      "ata%u: SATA link down (SStatus %X SControl %X)\n",
+                      ap->id, sstatus, scontrol);
        }
 }
 
@@ -1565,7 +1570,7 @@ void __sata_phy_reset(struct ata_port *ap)
        else
                ata_port_disable(ap);
 
-       if (ap->flags & ATA_FLAG_PORT_DISABLED)
+       if (ap->flags & ATA_FLAG_DISABLED)
                return;
 
        if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) {
@@ -1590,7 +1595,7 @@ void __sata_phy_reset(struct ata_port *ap)
 void sata_phy_reset(struct ata_port *ap)
 {
        __sata_phy_reset(ap);
-       if (ap->flags & ATA_FLAG_PORT_DISABLED)
+       if (ap->flags & ATA_FLAG_DISABLED)
                return;
        ata_bus_reset(ap);
 }
@@ -1629,7 +1634,7 @@ void ata_port_disable(struct ata_port *ap)
 {
        ap->device[0].class = ATA_DEV_NONE;
        ap->device[1].class = ATA_DEV_NONE;
-       ap->flags |= ATA_FLAG_PORT_DISABLED;
+       ap->flags |= ATA_FLAG_DISABLED;
 }
 
 /**
@@ -1646,7 +1651,7 @@ void ata_port_disable(struct ata_port *ap)
  *     RETURNS:
  *     0 on success, negative errno on failure
  */
-static int ata_down_sata_spd_limit(struct ata_port *ap)
+int ata_down_sata_spd_limit(struct ata_port *ap)
 {
        u32 spd, mask;
        int highbit;
@@ -1706,7 +1711,7 @@ static int __ata_set_sata_spd_needed(struct ata_port *ap, u32 *scontrol)
  *     RETURNS:
  *     1 if SATA spd configuration is needed, 0 otherwise.
  */
-static int ata_set_sata_spd_needed(struct ata_port *ap)
+int ata_set_sata_spd_needed(struct ata_port *ap)
 {
        u32 scontrol;
 
@@ -1910,8 +1915,8 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed,
  *     RETURNS:
  *     0 on success, negative errno on failure
  */
-static int ata_down_xfermask_limit(struct ata_port *ap, struct ata_device *dev,
-                                  int force_pio0)
+int ata_down_xfermask_limit(struct ata_port *ap, struct ata_device *dev,
+                           int force_pio0)
 {
        unsigned long xfer_mask;
        int highbit;
@@ -1949,6 +1954,7 @@ static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev)
        unsigned int err_mask;
        int rc;
 
+       dev->flags &= ~ATA_DFLAG_PIO;
        if (dev->xfer_shift == ATA_SHIFT_PIO)
                dev->flags |= ATA_DFLAG_PIO;
 
@@ -1961,12 +1967,8 @@ static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev)
        }
 
        rc = ata_dev_revalidate(ap, dev, 0);
-       if (rc) {
-               printk(KERN_ERR
-                      "ata%u: failed to revalidate after set xfermode\n",
-                      ap->id);
+       if (rc)
                return rc;
-       }
 
        DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n",
                dev->xfer_shift, (int)dev->xfer_mode);
@@ -1992,7 +1994,7 @@ static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev)
  *     RETURNS:
  *     0 on success, negative errno otherwise
  */
-static int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
+int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
 {
        struct ata_device *dev;
        int i, rc = 0, used_dma = 0, found = 0;
@@ -2255,7 +2257,7 @@ static unsigned int ata_bus_softreset(struct ata_port *ap,
  *     Obtains host_set lock.
  *
  *     SIDE EFFECTS:
- *     Sets ATA_FLAG_PORT_DISABLED if bus reset fails.
+ *     Sets ATA_FLAG_DISABLED if bus reset fails.
  */
 
 void ata_bus_reset(struct ata_port *ap)
@@ -2590,9 +2592,9 @@ int ata_std_probe_reset(struct ata_port *ap, unsigned int *classes)
                                     ata_std_postreset, classes);
 }
 
-static int ata_do_reset(struct ata_port *ap,
-                       ata_reset_fn_t reset, ata_postreset_fn_t postreset,
-                       int verbose, unsigned int *classes)
+int ata_do_reset(struct ata_port *ap,
+                ata_reset_fn_t reset, ata_postreset_fn_t postreset,
+                int verbose, unsigned int *classes)
 {
        int i, rc;
 
@@ -2786,15 +2788,14 @@ static int ata_dev_same_device(struct ata_port *ap, struct ata_device *dev,
 int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev,
                       int post_reset)
 {
-       unsigned int class;
-       u16 *id;
+       unsigned int class = dev->class;
+       u16 *id = NULL;
        int rc;
 
-       if (!ata_dev_enabled(dev))
-               return -ENODEV;
-
-       class = dev->class;
-       id = NULL;
+       if (!ata_dev_enabled(dev)) {
+               rc = -ENODEV;
+               goto fail;
+       }
 
        /* allocate & read ID data */
        rc = ata_dev_read_id(ap, dev, &class, post_reset, &id);
@@ -2811,7 +2812,9 @@ int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev,
        dev->id = id;
 
        /* configure device according to the new ID */
-       return ata_dev_configure(ap, dev, 0);
+       rc = ata_dev_configure(ap, dev, 0);
+       if (rc == 0)
+               return 0;
 
  fail:
        printk(KERN_ERR "ata%u: dev %u revalidation failed (errno=%d)\n",
@@ -2990,7 +2993,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_port *ap,
        tf.protocol = ATA_PROT_NODATA;
        tf.nsect = dev->xfer_mode;
 
-       err_mask = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0);
+       err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0);
 
        DPRINTK("EXIT, err_mask=%x\n", err_mask);
        return err_mask;
@@ -3030,7 +3033,7 @@ static unsigned int ata_dev_init_params(struct ata_port *ap,
        tf.nsect = sectors;
        tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */
 
-       err_mask = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0);
+       err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0);
 
        DPRINTK("EXIT, err_mask=%x\n", err_mask);
        return err_mask;
@@ -3418,7 +3421,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc)
 
 /**
  *     ata_pio_poll - poll using PIO, depending on current state
- *     @ap: the target ata_port
+ *     @qc: qc in progress
  *
  *     LOCKING:
  *     None.  (executing in kernel thread context)
@@ -3426,17 +3429,13 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc)
  *     RETURNS:
  *     timeout value to use
  */
-
-static unsigned long ata_pio_poll(struct ata_port *ap)
+static unsigned long ata_pio_poll(struct ata_queued_cmd *qc)
 {
-       struct ata_queued_cmd *qc;
+       struct ata_port *ap = qc->ap;
        u8 status;
        unsigned int poll_state = HSM_ST_UNKNOWN;
        unsigned int reg_state = HSM_ST_UNKNOWN;
 
-       qc = ata_qc_from_tag(ap, ap->active_tag);
-       WARN_ON(qc == NULL);
-
        switch (ap->hsm_task_state) {
        case HSM_ST:
        case HSM_ST_POLL:
@@ -3470,7 +3469,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
 
 /**
  *     ata_pio_complete - check if drive is busy or idle
- *     @ap: the target ata_port
+ *     @qc: qc to complete
  *
  *     LOCKING:
  *     None.  (executing in kernel thread context)
@@ -3478,10 +3477,9 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
  *     RETURNS:
  *     Non-zero if qc completed, zero otherwise.
  */
-
-static int ata_pio_complete (struct ata_port *ap)
+static int ata_pio_complete(struct ata_queued_cmd *qc)
 {
-       struct ata_queued_cmd *qc;
+       struct ata_port *ap = qc->ap;
        u8 drv_stat;
 
        /*
@@ -3502,9 +3500,6 @@ static int ata_pio_complete (struct ata_port *ap)
                }
        }
 
-       qc = ata_qc_from_tag(ap, ap->active_tag);
-       WARN_ON(qc == NULL);
-
        drv_stat = ata_wait_idle(ap);
        if (!ata_ok(drv_stat)) {
                qc->err_mask |= __ac_err_mask(drv_stat);
@@ -3840,15 +3835,14 @@ err_out:
 
 /**
  *     ata_pio_block - start PIO on a block
- *     @ap: the target ata_port
+ *     @qc: qc to transfer block for
  *
  *     LOCKING:
  *     None.  (executing in kernel thread context)
  */
-
-static void ata_pio_block(struct ata_port *ap)
+static void ata_pio_block(struct ata_queued_cmd *qc)
 {
-       struct ata_queued_cmd *qc;
+       struct ata_port *ap = qc->ap;
        u8 status;
 
        /*
@@ -3870,9 +3864,6 @@ static void ata_pio_block(struct ata_port *ap)
                }
        }
 
-       qc = ata_qc_from_tag(ap, ap->active_tag);
-       WARN_ON(qc == NULL);
-
        /* check error */
        if (status & (ATA_ERR | ATA_DF)) {
                qc->err_mask |= AC_ERR_DEV;
@@ -3901,15 +3892,13 @@ static void ata_pio_block(struct ata_port *ap)
        }
 }
 
-static void ata_pio_error(struct ata_port *ap)
+static void ata_pio_error(struct ata_queued_cmd *qc)
 {
-       struct ata_queued_cmd *qc;
-
-       qc = ata_qc_from_tag(ap, ap->active_tag);
-       WARN_ON(qc == NULL);
+       struct ata_port *ap = qc->ap;
 
        if (qc->tf.command != ATA_CMD_PACKET)
-               printk(KERN_WARNING "ata%u: PIO error\n", ap->id);
+               printk(KERN_WARNING "ata%u: dev %u PIO error\n",
+                      ap->id, qc->dev->devno);
 
        /* make sure qc->err_mask is available to
         * know what's wrong and recover
@@ -3923,7 +3912,8 @@ static void ata_pio_error(struct ata_port *ap)
 
 static void ata_pio_task(void *_data)
 {
-       struct ata_port *ap = _data;
+       struct ata_queued_cmd *qc = _data;
+       struct ata_port *ap = qc->ap;
        unsigned long timeout;
        int qc_completed;
 
@@ -3936,33 +3926,33 @@ fsm_start:
                return;
 
        case HSM_ST:
-               ata_pio_block(ap);
+               ata_pio_block(qc);
                break;
 
        case HSM_ST_LAST:
-               qc_completed = ata_pio_complete(ap);
+               qc_completed = ata_pio_complete(qc);
                break;
 
        case HSM_ST_POLL:
        case HSM_ST_LAST_POLL:
-               timeout = ata_pio_poll(ap);
+               timeout = ata_pio_poll(qc);
                break;
 
        case HSM_ST_TMOUT:
        case HSM_ST_ERR:
-               ata_pio_error(ap);
+               ata_pio_error(qc);
                return;
        }
 
        if (timeout)
-               ata_port_queue_task(ap, ata_pio_task, ap, timeout);
+               ata_port_queue_task(ap, ata_pio_task, qc, timeout);
        else if (!qc_completed)
                goto fsm_start;
 }
 
 /**
  *     atapi_packet_task - Write CDB bytes to hardware
- *     @_data: Port to which ATAPI device is attached.
+ *     @_data: qc in progress
  *
  *     When device has indicated its readiness to accept
  *     a CDB, this function is called.  Send the CDB.
@@ -3973,17 +3963,12 @@ fsm_start:
  *     LOCKING:
  *     Kernel thread context (may sleep)
  */
-
 static void atapi_packet_task(void *_data)
 {
-       struct ata_port *ap = _data;
-       struct ata_queued_cmd *qc;
+       struct ata_queued_cmd *qc = _data;
+       struct ata_port *ap = qc->ap;
        u8 status;
 
-       qc = ata_qc_from_tag(ap, ap->active_tag);
-       WARN_ON(qc == NULL);
-       WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE));
-
        /* sleep-wait for BSY to clear */
        DPRINTK("busy wait\n");
        if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) {
@@ -4023,7 +4008,7 @@ static void atapi_packet_task(void *_data)
 
                /* PIO commands are handled by polling */
                ap->hsm_task_state = HSM_ST;
-               ata_port_queue_task(ap, ata_pio_task, ap, 0);
+               ata_port_queue_task(ap, ata_pio_task, qc, 0);
        }
 
        return;
@@ -4032,99 +4017,6 @@ err_out:
        ata_poll_qc_complete(qc);
 }
 
-/**
- *     ata_qc_timeout - Handle timeout of queued command
- *     @qc: Command that timed out
- *
- *     Some part of the kernel (currently, only the SCSI layer)
- *     has noticed that the active command on port @ap has not
- *     completed after a specified length of time.  Handle this
- *     condition by disabling DMA (if necessary) and completing
- *     transactions, with error if necessary.
- *
- *     This also handles the case of the "lost interrupt", where
- *     for some reason (possibly hardware bug, possibly driver bug)
- *     an interrupt was not delivered to the driver, even though the
- *     transaction completed successfully.
- *
- *     LOCKING:
- *     Inherited from SCSI layer (none, can sleep)
- */
-
-static void ata_qc_timeout(struct ata_queued_cmd *qc)
-{
-       struct ata_port *ap = qc->ap;
-       struct ata_host_set *host_set = ap->host_set;
-       u8 host_stat = 0, drv_stat;
-       unsigned long flags;
-
-       DPRINTK("ENTER\n");
-
-       ap->hsm_task_state = HSM_ST_IDLE;
-
-       spin_lock_irqsave(&host_set->lock, flags);
-
-       switch (qc->tf.protocol) {
-
-       case ATA_PROT_DMA:
-       case ATA_PROT_ATAPI_DMA:
-               host_stat = ap->ops->bmdma_status(ap);
-
-               /* before we do anything else, clear DMA-Start bit */
-               ap->ops->bmdma_stop(qc);
-
-               /* fall through */
-
-       default:
-               ata_altstatus(ap);
-               drv_stat = ata_chk_status(ap);
-
-               /* ack bmdma irq events */
-               ap->ops->irq_clear(ap);
-
-               printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x host_stat 0x%x\n",
-                      ap->id, qc->tf.command, drv_stat, host_stat);
-
-               /* complete taskfile transaction */
-               qc->err_mask |= ac_err_mask(drv_stat);
-               break;
-       }
-
-       spin_unlock_irqrestore(&host_set->lock, flags);
-
-       ata_eh_qc_complete(qc);
-
-       DPRINTK("EXIT\n");
-}
-
-/**
- *     ata_eng_timeout - Handle timeout of queued command
- *     @ap: Port on which timed-out command is active
- *
- *     Some part of the kernel (currently, only the SCSI layer)
- *     has noticed that the active command on port @ap has not
- *     completed after a specified length of time.  Handle this
- *     condition by disabling DMA (if necessary) and completing
- *     transactions, with error if necessary.
- *
- *     This also handles the case of the "lost interrupt", where
- *     for some reason (possibly hardware bug, possibly driver bug)
- *     an interrupt was not delivered to the driver, even though the
- *     transaction completed successfully.
- *
- *     LOCKING:
- *     Inherited from SCSI layer (none, can sleep)
- */
-
-void ata_eng_timeout(struct ata_port *ap)
-{
-       DPRINTK("ENTER\n");
-
-       ata_qc_timeout(ata_qc_from_tag(ap, ap->active_tag));
-
-       DPRINTK("EXIT\n");
-}
-
 /**
  *     ata_qc_new - Request an available ATA command, for queueing
  *     @ap: Port associated with device @dev
@@ -4329,26 +4221,26 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
                ata_qc_set_polling(qc);
                ata_tf_to_host(ap, &qc->tf);
                ap->hsm_task_state = HSM_ST;
-               ata_port_queue_task(ap, ata_pio_task, ap, 0);
+               ata_port_queue_task(ap, ata_pio_task, qc, 0);
                break;
 
        case ATA_PROT_ATAPI:
                ata_qc_set_polling(qc);
                ata_tf_to_host(ap, &qc->tf);
-               ata_port_queue_task(ap, atapi_packet_task, ap, 0);
+               ata_port_queue_task(ap, atapi_packet_task, qc, 0);
                break;
 
        case ATA_PROT_ATAPI_NODATA:
                ap->flags |= ATA_FLAG_NOINTR;
                ata_tf_to_host(ap, &qc->tf);
-               ata_port_queue_task(ap, atapi_packet_task, ap, 0);
+               ata_port_queue_task(ap, atapi_packet_task, qc, 0);
                break;
 
        case ATA_PROT_ATAPI_DMA:
                ap->flags |= ATA_FLAG_NOINTR;
                ap->ops->tf_load(ap, &qc->tf);   /* load tf registers */
                ap->ops->bmdma_setup(qc);           /* set up bmdma */
-               ata_port_queue_task(ap, atapi_packet_task, ap, 0);
+               ata_port_queue_task(ap, atapi_packet_task, qc, 0);
                break;
 
        default:
@@ -4470,7 +4362,7 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
 
                ap = host_set->ports[i];
                if (ap &&
-                   !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) {
+                   !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) {
                        struct ata_queued_cmd *qc;
 
                        qc = ata_qc_from_tag(ap, ap->active_tag);
@@ -4502,7 +4394,7 @@ static int ata_do_simple_cmd(struct ata_port *ap, struct ata_device *dev,
        tf.flags |= ATA_TFLAG_DEVICE;
        tf.protocol = ATA_PROT_NODATA;
 
-       err = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0);
+       err = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0);
        if (err)
                printk(KERN_ERR "%s: ata command failed: %d\n",
                                __FUNCTION__, err);
@@ -4691,7 +4583,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
        host->unique_id = ata_unique_id++;
        host->max_cmd_len = 12;
 
-       ap->flags = ATA_FLAG_PORT_DISABLED;
+       ap->flags = ATA_FLAG_DISABLED;
        ap->id = host->unique_id;
        ap->host = host;
        ap->ctl = ATA_DEVCTL_OBS;
@@ -5162,7 +5054,6 @@ EXPORT_SYMBOL_GPL(ata_sg_init);
 EXPORT_SYMBOL_GPL(ata_sg_init_one);
 EXPORT_SYMBOL_GPL(__ata_qc_complete);
 EXPORT_SYMBOL_GPL(ata_qc_issue_prot);
-EXPORT_SYMBOL_GPL(ata_eng_timeout);
 EXPORT_SYMBOL_GPL(ata_tf_load);
 EXPORT_SYMBOL_GPL(ata_tf_read);
 EXPORT_SYMBOL_GPL(ata_noop_dev_select);
@@ -5202,15 +5093,12 @@ EXPORT_SYMBOL_GPL(ata_busy_sleep);
 EXPORT_SYMBOL_GPL(ata_port_queue_task);
 EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
 EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);
-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_id_string);
 EXPORT_SYMBOL_GPL(ata_id_c_string);
 EXPORT_SYMBOL_GPL(ata_scsi_simulate);
-EXPORT_SYMBOL_GPL(ata_eh_qc_complete);
-EXPORT_SYMBOL_GPL(ata_eh_qc_retry);
 
 EXPORT_SYMBOL_GPL(ata_pio_need_iordy);
 EXPORT_SYMBOL_GPL(ata_timing_compute);
@@ -5232,3 +5120,8 @@ EXPORT_SYMBOL_GPL(ata_device_suspend);
 EXPORT_SYMBOL_GPL(ata_device_resume);
 EXPORT_SYMBOL_GPL(ata_scsi_device_suspend);
 EXPORT_SYMBOL_GPL(ata_scsi_device_resume);
+
+EXPORT_SYMBOL_GPL(ata_scsi_error);
+EXPORT_SYMBOL_GPL(ata_eng_timeout);
+EXPORT_SYMBOL_GPL(ata_eh_qc_complete);
+EXPORT_SYMBOL_GPL(ata_eh_qc_retry);