]> Git Repo - linux.git/commitdiff
Merge branch 'upstream'
authorJeff Garzik <[email protected]>
Wed, 12 Apr 2006 20:54:43 +0000 (16:54 -0400)
committerJeff Garzik <[email protected]>
Wed, 12 Apr 2006 20:54:43 +0000 (16:54 -0400)
1  2 
drivers/scsi/libata-core.c
drivers/scsi/libata-eh.c
drivers/scsi/pdc_adma.c
drivers/scsi/sata_mv.c
drivers/scsi/sata_nv.c
drivers/scsi/sata_promise.c
drivers/scsi/sata_qstor.c
drivers/scsi/sata_sx4.c
drivers/scsi/sata_vsc.c
include/linux/libata.h

index 2b2feb6462a9b4655cec2b38e40d6821be055a02,509178c3700cee365b19626ec4e5b21f48db9f4b..5d38a6cc5736ae6a62de85e5d4ed6f28ee4c8d10
@@@ -1309,19 -1309,11 +1309,19 @@@ static int ata_dev_configure(struct ata
                                       dev->cylinders, dev->heads, dev->sectors);
                }
  
 +              if (dev->id[59] & 0x100) {
 +                      dev->multi_count = dev->id[59] & 0xff;
 +                      DPRINTK("ata%u: dev %u multi count %u\n",
 +                              ap->id, dev->devno, dev->multi_count);
 +              }
 +
                dev->cdb_len = 16;
        }
  
        /* ATAPI-specific feature tests */
        else if (dev->class == ATA_DEV_ATAPI) {
 +              char *cdb_intr_string = "";
 +
                rc = atapi_cdb_len(id);
                if ((rc < 12) || (rc > ATAPI_CDB_LEN)) {
                        printk(KERN_WARNING "ata%u: unsupported CDB len\n", ap->id);
                }
                dev->cdb_len = (unsigned int) rc;
  
 +              if (ata_id_cdb_intr(dev->id)) {
 +                      dev->flags |= ATA_DFLAG_CDB_INTR;
 +                      cdb_intr_string = ", CDB intr";
 +              }
 +
                /* print device info to dmesg */
                if (print_info)
 -                      printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n",
 -                             ap->id, dev->devno, ata_mode_string(xfer_mask));
 +                      printk(KERN_INFO "ata%u: dev %u ATAPI, max %s%s\n",
 +                             ap->id, dev->devno, ata_mode_string(xfer_mask),
 +                             cdb_intr_string);
        }
  
        ap->host->max_cmd_len = 0;
@@@ -1425,12 -1411,9 +1425,9 @@@ static int ata_bus_probe(struct ata_por
        /* read IDENTIFY page and configure devices */
        for (i = 0; i < ATA_MAX_DEVICES; i++) {
                dev = &ap->device[i];
-               dev->class = classes[i];
  
-               if (!tries[i]) {
-                       ata_down_xfermask_limit(ap, dev, 1);
-                       ata_dev_disable(ap, dev);
-               }
+               if (tries[i])
+                       dev->class = classes[i];
  
                if (!ata_dev_enabled(dev))
                        continue;
                                break;
                        }
                rc = 0;
-       } else {
+       } else
                rc = ata_set_mode(ap, &dev);
-               if (rc) {
-                       down_xfermask = 1;
-                       goto fail;
-               }
+       if (rc) {
+               down_xfermask = 1;
+               goto fail;
        }
  
        for (i = 0; i < ATA_MAX_DEVICES; i++)
                        tries[dev->devno] = 0;
        }
  
+       if (!tries[dev->devno]) {
+               ata_down_xfermask_limit(ap, dev, 1);
+               ata_dev_disable(ap, dev);
+       }
        goto retry;
  }
  
@@@ -1750,7 -1738,7 +1752,7 @@@ int ata_set_sata_spd_needed(struct ata_
   *    0 if spd doesn't need to be changed, 1 if spd has been
   *    changed.  -EOPNOTSUPP if SCR registers are inaccessible.
   */
static int ata_set_sata_spd(struct ata_port *ap)
+ int ata_set_sata_spd(struct ata_port *ap)
  {
        u32 scontrol;
  
@@@ -2246,8 -2234,10 +2248,10 @@@ static unsigned int ata_bus_softreset(s
         * the bus shows 0xFF because the odd clown forgets the D7
         * pulldown resistor.
         */
-       if (ata_check_status(ap) == 0xFF)
+       if (ata_check_status(ap) == 0xFF) {
+               printk(KERN_ERR "ata%u: SRST failed (status 0xFF)\n", ap->id);
                return AC_ERR_OTHER;
+       }
  
        ata_bus_post_reset(ap, devmask);
  
@@@ -2383,12 -2373,16 +2387,16 @@@ void ata_std_probeinit(struct ata_port 
        if ((ap->flags & ATA_FLAG_SATA) && ap->ops->scr_read) {
                u32 spd;
  
+               /* set cable type and resume link */
+               ap->cbl = ATA_CBL_SATA;
                sata_phy_resume(ap);
  
+               /* init sata_spd_limit to the current value */
                spd = (scr_read(ap, SCR_CONTROL) & 0xf0) >> 4;
                if (spd)
                        ap->sata_spd_limit &= (1 << spd) - 1;
  
+               /* wait for device */
                if (sata_dev_present(ap))
                        ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT);
        }
  /**
   *    ata_std_softreset - reset host port via ATA SRST
   *    @ap: port to reset
-  *    @verbose: fail verbosely
   *    @classes: resulting classes of attached devices
   *
   *    Reset host port using ATA SRST.  This function is to be used
   *    RETURNS:
   *    0 on success, -errno otherwise.
   */
- int ata_std_softreset(struct ata_port *ap, int verbose, unsigned int *classes)
+ int ata_std_softreset(struct ata_port *ap, unsigned int *classes)
  {
        unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS;
        unsigned int devmask = 0, err_mask;
        DPRINTK("about to softreset, devmask=%x\n", devmask);
        err_mask = ata_bus_softreset(ap, devmask);
        if (err_mask) {
-               if (verbose)
-                       printk(KERN_ERR "ata%u: SRST failed (err_mask=0x%x)\n",
-                              ap->id, err_mask);
-               else
-                       DPRINTK("EXIT, softreset failed (err_mask=0x%x)\n",
-                               err_mask);
+               printk(KERN_ERR "ata%u: SRST failed (err_mask=0x%x)\n",
+                      ap->id, err_mask);
                return -EIO;
        }
  
  /**
   *    sata_std_hardreset - reset host port via SATA phy reset
   *    @ap: port to reset
-  *    @verbose: fail verbosely
   *    @class: resulting class of attached device
   *
   *    SATA phy-reset host port using DET bits of SControl register.
   *    RETURNS:
   *    0 on success, -errno otherwise.
   */
- int sata_std_hardreset(struct ata_port *ap, int verbose, unsigned int *class)
+ int sata_std_hardreset(struct ata_port *ap, unsigned int *class)
  {
        u32 scontrol;
  
        }
  
        if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) {
-               if (verbose)
-                       printk(KERN_ERR "ata%u: COMRESET failed "
-                              "(device not ready)\n", ap->id);
-               else
-                       DPRINTK("EXIT, device not ready\n");
+               printk(KERN_ERR
+                      "ata%u: COMRESET failed (device not ready)\n", ap->id);
                return -EIO;
        }
  
@@@ -2545,10 -2530,6 +2544,6 @@@ void ata_std_postreset(struct ata_port 
  {
        DPRINTK("ENTER\n");
  
-       /* set cable type if it isn't already set */
-       if (ap->cbl == ATA_CBL_NONE && ap->flags & ATA_FLAG_SATA)
-               ap->cbl = ATA_CBL_SATA;
        /* print link status */
        if (ap->cbl == ATA_CBL_SATA)
                sata_print_link_status(ap);
@@@ -2598,7 -2579,7 +2593,7 @@@ int ata_std_probe_reset(struct ata_por
        ata_reset_fn_t hardreset;
  
        hardreset = NULL;
-       if (ap->flags & ATA_FLAG_SATA && ap->ops->scr_read)
+       if (ap->cbl == ATA_CBL_SATA && ap->ops->scr_read)
                hardreset = sata_std_hardreset;
  
        return ata_drive_probe_reset(ap, ata_std_probeinit,
                                     ata_std_postreset, 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 ata_do_reset(struct ata_port *ap, ata_reset_fn_t reset,
+                ata_postreset_fn_t postreset, unsigned int *classes)
  {
        int i, rc;
  
        for (i = 0; i < ATA_MAX_DEVICES; i++)
                classes[i] = ATA_DEV_UNKNOWN;
  
-       rc = reset(ap, verbose, classes);
+       rc = reset(ap, classes);
        if (rc)
                return rc;
  
   *    - If classification is supported, fill classes[] with
   *      recognized class codes.
   *    - If classification is not supported, leave classes[] alone.
-  *    - If verbose is non-zero, print error message on failure;
-  *      otherwise, shut up.
   *
   *    LOCKING:
   *    Kernel thread context (may sleep)
@@@ -2680,7 -2658,7 +2672,7 @@@ int ata_drive_probe_reset(struct ata_po
                probeinit(ap);
  
        if (softreset && !ata_set_sata_spd_needed(ap)) {
-               rc = ata_do_reset(ap, softreset, postreset, 0, classes);
+               rc = ata_do_reset(ap, softreset, postreset, classes);
                if (rc == 0 && classes[0] != ATA_DEV_UNKNOWN)
                        goto done;
                printk(KERN_INFO "ata%u: softreset failed, will try "
                goto done;
  
        while (1) {
-               rc = ata_do_reset(ap, hardreset, postreset, 0, classes);
+               rc = ata_do_reset(ap, hardreset, postreset, classes);
                if (rc == 0) {
                        if (classes[0] != ATA_DEV_UNKNOWN)
                                goto done;
                       ap->id);
                ssleep(5);
  
-               rc = ata_do_reset(ap, softreset, postreset, 0, classes);
+               rc = ata_do_reset(ap, softreset, postreset, classes);
        }
  
   done:
@@@ -3185,15 -3163,6 +3177,15 @@@ int ata_check_atapi_dma(struct ata_queu
        if (ap->ops->check_atapi_dma)
                rc = ap->ops->check_atapi_dma(qc);
  
 +      /* We don't support polling DMA.
 +       * Use PIO if the LLDD handles only interrupts in
 +       * the HSM_ST_LAST state and the ATAPI device
 +       * generates CDB interrupts.
 +       */
 +      if ((ap->flags & ATA_FLAG_PIO_POLLING) &&
 +          (qc->dev->flags & ATA_DFLAG_CDB_INTR))
 +              rc = 1;
 +
        return rc;
  }
  /**
@@@ -3436,11 -3405,111 +3428,11 @@@ void ata_poll_qc_complete(struct ata_qu
        unsigned long flags;
  
        spin_lock_irqsave(&ap->host_set->lock, flags);
 -      ap->flags &= ~ATA_FLAG_NOINTR;
        ata_irq_on(ap);
        ata_qc_complete(qc);
        spin_unlock_irqrestore(&ap->host_set->lock, flags);
  }
  
 -/**
 - *    ata_pio_poll - poll using PIO, depending on current state
 - *    @qc: qc in progress
 - *
 - *    LOCKING:
 - *    None.  (executing in kernel thread context)
 - *
 - *    RETURNS:
 - *    timeout value to use
 - */
 -static unsigned long ata_pio_poll(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;
 -
 -      switch (ap->hsm_task_state) {
 -      case HSM_ST:
 -      case HSM_ST_POLL:
 -              poll_state = HSM_ST_POLL;
 -              reg_state = HSM_ST;
 -              break;
 -      case HSM_ST_LAST:
 -      case HSM_ST_LAST_POLL:
 -              poll_state = HSM_ST_LAST_POLL;
 -              reg_state = HSM_ST_LAST;
 -              break;
 -      default:
 -              BUG();
 -              break;
 -      }
 -
 -      status = ata_chk_status(ap);
 -      if (status & ATA_BUSY) {
 -              if (time_after(jiffies, ap->pio_task_timeout)) {
 -                      qc->err_mask |= AC_ERR_TIMEOUT;
 -                      ap->hsm_task_state = HSM_ST_TMOUT;
 -                      return 0;
 -              }
 -              ap->hsm_task_state = poll_state;
 -              return ATA_SHORT_PAUSE;
 -      }
 -
 -      ap->hsm_task_state = reg_state;
 -      return 0;
 -}
 -
 -/**
 - *    ata_pio_complete - check if drive is busy or idle
 - *    @qc: qc to complete
 - *
 - *    LOCKING:
 - *    None.  (executing in kernel thread context)
 - *
 - *    RETURNS:
 - *    Non-zero if qc completed, zero otherwise.
 - */
 -static int ata_pio_complete(struct ata_queued_cmd *qc)
 -{
 -      struct ata_port *ap = qc->ap;
 -      u8 drv_stat;
 -
 -      /*
 -       * This is purely heuristic.  This is a fast path.  Sometimes when
 -       * we enter, BSY will be cleared in 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
 -       * HSM_ST_POLL state.
 -       */
 -      drv_stat = ata_busy_wait(ap, ATA_BUSY, 10);
 -      if (drv_stat & ATA_BUSY) {
 -              msleep(2);
 -              drv_stat = ata_busy_wait(ap, ATA_BUSY, 10);
 -              if (drv_stat & ATA_BUSY) {
 -                      ap->hsm_task_state = HSM_ST_LAST_POLL;
 -                      ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO;
 -                      return 0;
 -              }
 -      }
 -
 -      drv_stat = ata_wait_idle(ap);
 -      if (!ata_ok(drv_stat)) {
 -              qc->err_mask |= __ac_err_mask(drv_stat);
 -              ap->hsm_task_state = HSM_ST_ERR;
 -              return 0;
 -      }
 -
 -      ap->hsm_task_state = HSM_ST_IDLE;
 -
 -      WARN_ON(qc->err_mask);
 -      ata_poll_qc_complete(qc);
 -
 -      /* another command may start at this point */
 -
 -      return 1;
 -}
 -
 -
  /**
   *    swap_buf_le16 - swap halves of 16-bit words in place
   *    @buf:  Buffer to swap
@@@ -3609,23 -3678,7 +3601,23 @@@ static void ata_pio_sector(struct ata_q
        page = nth_page(page, (offset >> PAGE_SHIFT));
        offset %= PAGE_SIZE;
  
 -      buf = kmap(page) + offset;
 +      DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
 +
 +      if (PageHighMem(page)) {
 +              unsigned long flags;
 +
 +              local_irq_save(flags);
 +              buf = kmap_atomic(page, KM_IRQ0);
 +
 +              /* do the actual data transfer */
 +              ata_data_xfer(ap, buf + offset, ATA_SECT_SIZE, do_write);
 +
 +              kunmap_atomic(buf, KM_IRQ0);
 +              local_irq_restore(flags);
 +      } else {
 +              buf = page_address(page);
 +              ata_data_xfer(ap, buf + offset, ATA_SECT_SIZE, do_write);
 +      }
  
        qc->cursect++;
        qc->cursg_ofs++;
                qc->cursg++;
                qc->cursg_ofs = 0;
        }
 +}
  
 -      DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
 +/**
 + *    ata_pio_sectors - Transfer one or many 512-byte sectors.
 + *    @qc: Command on going
 + *
 + *    Transfer one or many ATA_SECT_SIZE of data from/to the 
 + *    ATA device for the DRQ request.
 + *
 + *    LOCKING:
 + *    Inherited from caller.
 + */
 +
 +static void ata_pio_sectors(struct ata_queued_cmd *qc)
 +{
 +      if (is_multi_taskfile(&qc->tf)) {
 +              /* READ/WRITE MULTIPLE */
 +              unsigned int nsect;
 +
 +              WARN_ON(qc->dev->multi_count == 0);
 +
 +              nsect = min(qc->nsect - qc->cursect, qc->dev->multi_count);
 +              while (nsect--)
 +                      ata_pio_sector(qc);
 +      } else
 +              ata_pio_sector(qc);
 +}
 +
 +/**
 + *    atapi_send_cdb - Write CDB bytes to hardware
 + *    @ap: Port to which ATAPI device is attached.
 + *    @qc: Taskfile currently active
 + *
 + *    When device has indicated its readiness to accept
 + *    a CDB, this function is called.  Send the CDB.
 + *
 + *    LOCKING:
 + *    caller.
 + */
 +
 +static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc)
 +{
 +      /* send SCSI cdb */
 +      DPRINTK("send cdb\n");
 +      WARN_ON(qc->dev->cdb_len < 12);
  
 -      /* do the actual data transfer */
 -      do_write = (qc->tf.flags & ATA_TFLAG_WRITE);
 -      ata_data_xfer(ap, buf, ATA_SECT_SIZE, do_write);
 +      ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1);
 +      ata_altstatus(ap); /* flush */
  
 -      kunmap(page);
 +      switch (qc->tf.protocol) {
 +      case ATA_PROT_ATAPI:
 +              ap->hsm_task_state = HSM_ST;
 +              break;
 +      case ATA_PROT_ATAPI_NODATA:
 +              ap->hsm_task_state = HSM_ST_LAST;
 +              break;
 +      case ATA_PROT_ATAPI_DMA:
 +              ap->hsm_task_state = HSM_ST_LAST;
 +              /* initiate bmdma */
 +              ap->ops->bmdma_start(qc);
 +              break;
 +      }
  }
  
  /**
@@@ -3761,23 -3760,7 +3753,23 @@@ next_sg
        /* don't cross page boundaries */
        count = min(count, (unsigned int)PAGE_SIZE - offset);
  
 -      buf = kmap(page) + offset;
 +      DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
 +
 +      if (PageHighMem(page)) {
 +              unsigned long flags;
 +
 +              local_irq_save(flags);
 +              buf = kmap_atomic(page, KM_IRQ0);
 +
 +              /* do the actual data transfer */
 +              ata_data_xfer(ap, buf + offset, count, do_write);
 +
 +              kunmap_atomic(buf, KM_IRQ0);
 +              local_irq_restore(flags);
 +      } else {
 +              buf = page_address(page);
 +              ata_data_xfer(ap, buf + offset, count, do_write);
 +      }
  
        bytes -= count;
        qc->curbytes += count;
                qc->cursg_ofs = 0;
        }
  
 -      DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
 -
 -      /* do the actual data transfer */
 -      ata_data_xfer(ap, buf, count, do_write);
 -
 -      kunmap(page);
 -
        if (bytes)
                goto next_sg;
  }
@@@ -3824,8 -3814,6 +3816,8 @@@ static void atapi_pio_bytes(struct ata_
        if (do_write != i_write)
                goto err_out;
  
 +      VPRINTK("ata%u: xfering %d bytes\n", ap->id, bytes);
 +
        __atapi_pio_bytes(qc, bytes);
  
        return;
@@@ -3838,294 -3826,187 +3830,294 @@@ err_out
  }
  
  /**
 - *    ata_pio_block - start PIO on a block
 - *    @qc: qc to transfer block for
 + *    ata_hsm_ok_in_wq - Check if the qc can be handled in the workqueue.
 + *    @ap: the target ata_port
 + *    @qc: qc on going
   *
 - *    LOCKING:
 - *    None.  (executing in kernel thread context)
 + *    RETURNS:
 + *    1 if ok in workqueue, 0 otherwise.
   */
 -static void ata_pio_block(struct ata_queued_cmd *qc)
 +
 +static inline int ata_hsm_ok_in_wq(struct ata_port *ap, struct ata_queued_cmd *qc)
  {
 -      struct ata_port *ap = qc->ap;
 -      u8 status;
 +      if (qc->tf.flags & ATA_TFLAG_POLLING)
 +              return 1;
  
 -      /*
 -       * This is purely heuristic.  This is a fast path.
 -       * Sometimes when we enter, BSY will be cleared in
 -       * 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
 -       * HSM_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->hsm_task_state = HSM_ST_POLL;
 -                      ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO;
 -                      return;
 -              }
 -      }
 +      if (ap->hsm_task_state == HSM_ST_FIRST) {
 +              if (qc->tf.protocol == ATA_PROT_PIO &&
 +                  (qc->tf.flags & ATA_TFLAG_WRITE))
 +                  return 1;
  
 -      /* check error */
 -      if (status & (ATA_ERR | ATA_DF)) {
 -              qc->err_mask |= AC_ERR_DEV;
 -              ap->hsm_task_state = HSM_ST_ERR;
 -              return;
 +              if (is_atapi_taskfile(&qc->tf) &&
 +                  !(qc->dev->flags & ATA_DFLAG_CDB_INTR))
 +                      return 1;
        }
  
 -      /* transfer data if any */
 -      if (is_atapi_taskfile(&qc->tf)) {
 -              /* DRQ=0 means no more data to transfer */
 -              if ((status & ATA_DRQ) == 0) {
 -                      ap->hsm_task_state = HSM_ST_LAST;
 -                      return;
 -              }
 +      return 0;
 +}
  
 -              atapi_pio_bytes(qc);
 -      } else {
 -              /* handle BSY=0, DRQ=0 as error */
 -              if ((status & ATA_DRQ) == 0) {
 +/**
 + *    ata_hsm_move - move the HSM to the next state.
 + *    @ap: the target ata_port
 + *    @qc: qc on going
 + *    @status: current device status
 + *    @in_wq: 1 if called from workqueue, 0 otherwise
 + *
 + *    RETURNS:
 + *    1 when poll next status needed, 0 otherwise.
 + */
 +
 +static int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
 +                       u8 status, int in_wq)
 +{
 +      unsigned long flags = 0;
 +      int poll_next;
 +
 +      WARN_ON((qc->flags & ATA_QCFLAG_ACTIVE) == 0);
 +
 +      /* Make sure ata_qc_issue_prot() does not throw things
 +       * like DMA polling into the workqueue. Notice that
 +       * in_wq is not equivalent to (qc->tf.flags & ATA_TFLAG_POLLING).
 +       */
 +      WARN_ON(in_wq != ata_hsm_ok_in_wq(ap, qc));
 +
 +fsm_start:
 +      DPRINTK("ata%u: protocol %d task_state %d (dev_stat 0x%X)\n",
 +              ap->id, qc->tf.protocol, ap->hsm_task_state, status);
 +
 +      switch (ap->hsm_task_state) {
 +      case HSM_ST_FIRST:
 +              /* Send first data block or PACKET CDB */
 +
 +              /* If polling, we will stay in the work queue after
 +               * sending the data. Otherwise, interrupt handler
 +               * takes over after sending the data.
 +               */
 +              poll_next = (qc->tf.flags & ATA_TFLAG_POLLING);
 +
 +              /* check device status */
 +              if (unlikely((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ)) {
 +                      /* Wrong status. Let EH handle this */
                        qc->err_mask |= AC_ERR_HSM;
                        ap->hsm_task_state = HSM_ST_ERR;
 -                      return;
 +                      goto fsm_start;
                }
  
 -              ata_pio_sector(qc);
 -      }
 -}
 +              /* Device should not ask for data transfer (DRQ=1)
 +               * when it finds something wrong.
 +               * We ignore DRQ here and stop the HSM by
 +               * changing hsm_task_state to HSM_ST_ERR and
 +               * let the EH abort the command or reset the device.
 +               */
 +              if (unlikely(status & (ATA_ERR | ATA_DF))) {
 +                      printk(KERN_WARNING "ata%d: DRQ=1 with device error, dev_stat 0x%X\n",
 +                             ap->id, status);
 +                      qc->err_mask |= AC_ERR_DEV;
 +                      ap->hsm_task_state = HSM_ST_ERR;
 +                      goto fsm_start;
 +              }
  
 -static void ata_pio_error(struct ata_queued_cmd *qc)
 -{
 -      struct ata_port *ap = qc->ap;
 +              /* Send the CDB (atapi) or the first data block (ata pio out).
 +               * During the state transition, interrupt handler shouldn't
 +               * be invoked before the data transfer is complete and
 +               * hsm_task_state is changed. Hence, the following locking.
 +               */
 +              if (in_wq)
 +                      spin_lock_irqsave(&ap->host_set->lock, flags);
  
 -      if (qc->tf.command != ATA_CMD_PACKET)
 -              printk(KERN_WARNING "ata%u: dev %u PIO error\n",
 -                     ap->id, qc->dev->devno);
 +              if (qc->tf.protocol == ATA_PROT_PIO) {
 +                      /* PIO data out protocol.
 +                       * send first data block.
 +                       */
  
 -      /* make sure qc->err_mask is available to
 -       * know what's wrong and recover
 -       */
 -      WARN_ON(qc->err_mask == 0);
 +                      /* ata_pio_sectors() might change the state
 +                       * to HSM_ST_LAST. so, the state is changed here
 +                       * before ata_pio_sectors().
 +                       */
 +                      ap->hsm_task_state = HSM_ST;
 +                      ata_pio_sectors(qc);
 +                      ata_altstatus(ap); /* flush */
 +              } else
 +                      /* send CDB */
 +                      atapi_send_cdb(ap, qc);
 +
 +              if (in_wq)
 +                      spin_unlock_irqrestore(&ap->host_set->lock, flags);
 +
 +              /* if polling, ata_pio_task() handles the rest.
 +               * otherwise, interrupt handler takes over from here.
 +               */
 +              break;
  
 -      ap->hsm_task_state = HSM_ST_IDLE;
 +      case HSM_ST:
 +              /* complete command or read/write the data register */
 +              if (qc->tf.protocol == ATA_PROT_ATAPI) {
 +                      /* ATAPI PIO protocol */
 +                      if ((status & ATA_DRQ) == 0) {
 +                              /* no more data to transfer */
 +                              ap->hsm_task_state = HSM_ST_LAST;
 +                              goto fsm_start;
 +                      }
  
 -      ata_poll_qc_complete(qc);
 -}
 +                      /* Device should not ask for data transfer (DRQ=1)
 +                       * when it finds something wrong.
 +                       * We ignore DRQ here and stop the HSM by
 +                       * changing hsm_task_state to HSM_ST_ERR and
 +                       * let the EH abort the command or reset the device.
 +                       */
 +                      if (unlikely(status & (ATA_ERR | ATA_DF))) {
 +                              printk(KERN_WARNING "ata%d: DRQ=1 with device error, dev_stat 0x%X\n",
 +                                     ap->id, status);
 +                              qc->err_mask |= AC_ERR_DEV;
 +                              ap->hsm_task_state = HSM_ST_ERR;
 +                              goto fsm_start;
 +                      }
  
 -static void ata_pio_task(void *_data)
 -{
 -      struct ata_queued_cmd *qc = _data;
 -      struct ata_port *ap = qc->ap;
 -      unsigned long timeout;
 -      int qc_completed;
 +                      atapi_pio_bytes(qc);
  
 -fsm_start:
 -      timeout = 0;
 -      qc_completed = 0;
 +                      if (unlikely(ap->hsm_task_state == HSM_ST_ERR))
 +                              /* bad ireason reported by device */
 +                              goto fsm_start;
  
 -      switch (ap->hsm_task_state) {
 -      case HSM_ST_IDLE:
 -              return;
 +              } else {
 +                      /* ATA PIO protocol */
 +                      if (unlikely((status & ATA_DRQ) == 0)) {
 +                              /* handle BSY=0, DRQ=0 as error */
 +                              qc->err_mask |= AC_ERR_HSM;
 +                              ap->hsm_task_state = HSM_ST_ERR;
 +                              goto fsm_start;
 +                      }
  
 -      case HSM_ST:
 -              ata_pio_block(qc);
 +                      /* For PIO reads, some devices may ask for
 +                       * data transfer (DRQ=1) alone with ERR=1.
 +                       * We respect DRQ here and transfer one
 +                       * block of junk data before changing the
 +                       * hsm_task_state to HSM_ST_ERR.
 +                       *
 +                       * For PIO writes, ERR=1 DRQ=1 doesn't make
 +                       * sense since the data block has been
 +                       * transferred to the device.
 +                       */
 +                      if (unlikely(status & (ATA_ERR | ATA_DF))) {
 +                              /* data might be corrputed */
 +                              qc->err_mask |= AC_ERR_DEV;
 +
 +                              if (!(qc->tf.flags & ATA_TFLAG_WRITE)) {
 +                                      ata_pio_sectors(qc);
 +                                      ata_altstatus(ap);
 +                                      status = ata_wait_idle(ap);
 +                              }
 +
 +                              /* ata_pio_sectors() might change the
 +                               * state to HSM_ST_LAST. so, the state
 +                               * is changed after ata_pio_sectors().
 +                               */
 +                              ap->hsm_task_state = HSM_ST_ERR;
 +                              goto fsm_start;
 +                      }
 +
 +                      ata_pio_sectors(qc);
 +
 +                      if (ap->hsm_task_state == HSM_ST_LAST &&
 +                          (!(qc->tf.flags & ATA_TFLAG_WRITE))) {
 +                              /* all data read */
 +                              ata_altstatus(ap);
 +                              status = ata_wait_idle(ap);
 +                              goto fsm_start;
 +                      }
 +              }
 +
 +              ata_altstatus(ap); /* flush */
 +              poll_next = 1;
                break;
  
        case HSM_ST_LAST:
 -              qc_completed = ata_pio_complete(qc);
 -              break;
 +              if (unlikely(!ata_ok(status))) {
 +                      qc->err_mask |= __ac_err_mask(status);
 +                      ap->hsm_task_state = HSM_ST_ERR;
 +                      goto fsm_start;
 +              }
 +
 +              /* no more data to transfer */
 +              DPRINTK("ata%u: dev %u command complete, drv_stat 0x%x\n",
 +                      ap->id, qc->dev->devno, status);
 +
 +              WARN_ON(qc->err_mask);
  
 -      case HSM_ST_POLL:
 -      case HSM_ST_LAST_POLL:
 -              timeout = ata_pio_poll(qc);
 +              ap->hsm_task_state = HSM_ST_IDLE;
 +
 +              /* complete taskfile transaction */
 +              if (in_wq)
 +                      ata_poll_qc_complete(qc);
 +              else
 +                      ata_qc_complete(qc);
 +
 +              poll_next = 0;
                break;
  
 -      case HSM_ST_TMOUT:
        case HSM_ST_ERR:
 -              ata_pio_error(qc);
 -              return;
 +              if (qc->tf.command != ATA_CMD_PACKET)
 +                      printk(KERN_ERR "ata%u: dev %u command error, drv_stat 0x%x\n",
 +                             ap->id, qc->dev->devno, status);
 +
 +              /* make sure qc->err_mask is available to
 +               * know what's wrong and recover
 +               */
 +              WARN_ON(qc->err_mask == 0);
 +
 +              ap->hsm_task_state = HSM_ST_IDLE;
 +
 +              /* complete taskfile transaction */
 +              if (in_wq)
 +                      ata_poll_qc_complete(qc);
 +              else
 +                      ata_qc_complete(qc);
 +
 +              poll_next = 0;
 +              break;
 +      default:
 +              poll_next = 0;
 +              BUG();
        }
  
 -      if (timeout)
 -              ata_port_queue_task(ap, ata_pio_task, qc, timeout);
 -      else if (!qc_completed)
 -              goto fsm_start;
 +      return poll_next;
  }
  
 -/**
 - *    atapi_packet_task - Write CDB bytes to hardware
 - *    @_data: qc in progress
 - *
 - *    When device has indicated its readiness to accept
 - *    a CDB, this function is called.  Send the CDB.
 - *    If DMA is to be performed, exit immediately.
 - *    Otherwise, we are in polling mode, so poll
 - *    status under operation succeeds or fails.
 - *
 - *    LOCKING:
 - *    Kernel thread context (may sleep)
 - */
 -static void atapi_packet_task(void *_data)
 +static void ata_pio_task(void *_data)
  {
        struct ata_queued_cmd *qc = _data;
        struct ata_port *ap = qc->ap;
        u8 status;
 +      int poll_next;
  
 -      /* sleep-wait for BSY to clear */
 -      DPRINTK("busy wait\n");
 -      if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) {
 -              qc->err_mask |= AC_ERR_TIMEOUT;
 -              goto err_out;
 -      }
 -
 -      /* make sure DRQ is set */
 -      status = ata_chk_status(ap);
 -      if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) {
 -              qc->err_mask |= AC_ERR_HSM;
 -              goto err_out;
 -      }
 -
 -      /* send SCSI cdb */
 -      DPRINTK("send cdb\n");
 -      WARN_ON(qc->dev->cdb_len < 12);
 -
 -      if (qc->tf.protocol == ATA_PROT_ATAPI_DMA ||
 -          qc->tf.protocol == ATA_PROT_ATAPI_NODATA) {
 -              unsigned long flags;
 -
 -              /* Once we're done issuing command and kicking bmdma,
 -               * irq handler takes over.  To not lose irq, we need
 -               * to clear NOINTR flag before sending cdb, but
 -               * interrupt handler shouldn't be invoked before we're
 -               * finished.  Hence, the following locking.
 -               */
 -              spin_lock_irqsave(&ap->host_set->lock, flags);
 -              ap->flags &= ~ATA_FLAG_NOINTR;
 -              ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1);
 -              if (qc->tf.protocol == ATA_PROT_ATAPI_DMA)
 -                      ap->ops->bmdma_start(qc);       /* initiate bmdma */
 -              spin_unlock_irqrestore(&ap->host_set->lock, flags);
 -      } else {
 -              ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1);
 +fsm_start:
 +      WARN_ON(ap->hsm_task_state == HSM_ST_IDLE);
  
 -              /* PIO commands are handled by polling */
 -              ap->hsm_task_state = HSM_ST;
 -              ata_port_queue_task(ap, ata_pio_task, qc, 0);
 +      /*
 +       * This is purely heuristic.  This is a fast path.
 +       * Sometimes when we enter, BSY will be cleared in
 +       * 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, queue delayed work.
 +       */
 +      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) {
 +                      ata_port_queue_task(ap, ata_pio_task, qc, ATA_SHORT_PAUSE);
 +                      return;
 +              }
        }
  
 -      return;
 +      /* move the HSM */
 +      poll_next = ata_hsm_move(ap, qc, status, 1);
  
 -err_out:
 -      ata_poll_qc_complete(qc);
 +      /* another command or interrupt handler
 +       * may be running at this point.
 +       */
 +      if (poll_next)
 +              goto fsm_start;
  }
  
  /**
@@@ -4315,105 -4196,43 +4307,105 @@@ unsigned int ata_qc_issue_prot(struct a
  {
        struct ata_port *ap = qc->ap;
  
 +      /* Use polling pio if the LLD doesn't handle
 +       * interrupt driven pio and atapi CDB interrupt.
 +       */
 +      if (ap->flags & ATA_FLAG_PIO_POLLING) {
 +              switch (qc->tf.protocol) {
 +              case ATA_PROT_PIO:
 +              case ATA_PROT_ATAPI:
 +              case ATA_PROT_ATAPI_NODATA:
 +                      qc->tf.flags |= ATA_TFLAG_POLLING;
 +                      break;
 +              case ATA_PROT_ATAPI_DMA:
 +                      if (qc->dev->flags & ATA_DFLAG_CDB_INTR)
 +                              /* see ata_check_atapi_dma() */
 +                              BUG();
 +                      break;
 +              default:
 +                      break;
 +              }
 +      }
 +
 +      /* select the device */
        ata_dev_select(ap, qc->dev->devno, 1, 0);
  
 +      /* start the command */
        switch (qc->tf.protocol) {
        case ATA_PROT_NODATA:
 +              if (qc->tf.flags & ATA_TFLAG_POLLING)
 +                      ata_qc_set_polling(qc);
 +
                ata_tf_to_host(ap, &qc->tf);
 +              ap->hsm_task_state = HSM_ST_LAST;
 +
 +              if (qc->tf.flags & ATA_TFLAG_POLLING)
 +                      ata_port_queue_task(ap, ata_pio_task, qc, 0);
 +
                break;
  
        case ATA_PROT_DMA:
 +              WARN_ON(qc->tf.flags & ATA_TFLAG_POLLING);
 +
                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 */
 +              ap->hsm_task_state = HSM_ST_LAST;
                break;
  
 -      case ATA_PROT_PIO: /* load tf registers, initiate polling pio */
 -              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, qc, 0);
 -              break;
 +      case ATA_PROT_PIO:
 +              if (qc->tf.flags & ATA_TFLAG_POLLING)
 +                      ata_qc_set_polling(qc);
  
 -      case ATA_PROT_ATAPI:
 -              ata_qc_set_polling(qc);
                ata_tf_to_host(ap, &qc->tf);
 -              ata_port_queue_task(ap, atapi_packet_task, qc, 0);
 +
 +              if (qc->tf.flags & ATA_TFLAG_WRITE) {
 +                      /* PIO data out protocol */
 +                      ap->hsm_task_state = HSM_ST_FIRST;
 +                      ata_port_queue_task(ap, ata_pio_task, qc, 0);
 +
 +                      /* always send first data block using
 +                       * the ata_pio_task() codepath.
 +                       */
 +              } else {
 +                      /* PIO data in protocol */
 +                      ap->hsm_task_state = HSM_ST;
 +
 +                      if (qc->tf.flags & ATA_TFLAG_POLLING)
 +                              ata_port_queue_task(ap, ata_pio_task, qc, 0);
 +
 +                      /* if polling, ata_pio_task() handles the rest.
 +                       * otherwise, interrupt handler takes over from here.
 +                       */
 +              }
 +
                break;
  
 +      case ATA_PROT_ATAPI:
        case ATA_PROT_ATAPI_NODATA:
 -              ap->flags |= ATA_FLAG_NOINTR;
 +              if (qc->tf.flags & ATA_TFLAG_POLLING)
 +                      ata_qc_set_polling(qc);
 +
                ata_tf_to_host(ap, &qc->tf);
 -              ata_port_queue_task(ap, atapi_packet_task, qc, 0);
 +
 +              ap->hsm_task_state = HSM_ST_FIRST;
 +
 +              /* send cdb by polling if no cdb interrupt */
 +              if ((!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) ||
 +                  (qc->tf.flags & ATA_TFLAG_POLLING))
 +                      ata_port_queue_task(ap, ata_pio_task, qc, 0);
                break;
  
        case ATA_PROT_ATAPI_DMA:
 -              ap->flags |= ATA_FLAG_NOINTR;
 +              WARN_ON(qc->tf.flags & ATA_TFLAG_POLLING);
 +
                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, qc, 0);
 +              ap->hsm_task_state = HSM_ST_FIRST;
 +
 +              /* send cdb by polling if no cdb interrupt */
 +              if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR))
 +                      ata_port_queue_task(ap, ata_pio_task, qc, 0);
                break;
  
        default:
  inline unsigned int ata_host_intr (struct ata_port *ap,
                                   struct ata_queued_cmd *qc)
  {
 -      u8 status, host_stat;
 -
 -      switch (qc->tf.protocol) {
 +      u8 status, host_stat = 0;
  
 -      case ATA_PROT_DMA:
 -      case ATA_PROT_ATAPI_DMA:
 -      case ATA_PROT_ATAPI:
 -              /* check status of DMA engine */
 -              host_stat = ap->ops->bmdma_status(ap);
 -              VPRINTK("ata%u: host_stat 0x%X\n", ap->id, host_stat);
 -
 -              /* if it's not our irq... */
 -              if (!(host_stat & ATA_DMA_INTR))
 -                      goto idle_irq;
 -
 -              /* before we do anything else, clear DMA-Start bit */
 -              ap->ops->bmdma_stop(qc);
 +      VPRINTK("ata%u: protocol %d task_state %d\n",
 +              ap->id, qc->tf.protocol, ap->hsm_task_state);
  
 -              /* fall through */
 -
 -      case ATA_PROT_ATAPI_NODATA:
 -      case ATA_PROT_NODATA:
 -              /* check altstatus */
 -              status = ata_altstatus(ap);
 -              if (status & ATA_BUSY)
 -                      goto idle_irq;
 +      /* Check whether we are expecting interrupt in this state */
 +      switch (ap->hsm_task_state) {
 +      case HSM_ST_FIRST:
 +              /* Some pre-ATAPI-4 devices assert INTRQ
 +               * at this state when ready to receive CDB.
 +               */
  
 -              /* check main status, clearing INTRQ */
 -              status = ata_chk_status(ap);
 -              if (unlikely(status & ATA_BUSY))
 +              /* Check the ATA_DFLAG_CDB_INTR flag is enough here.
 +               * The flag was turned on only for atapi devices.
 +               * No need to check is_atapi_taskfile(&qc->tf) again.
 +               */
 +              if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR))
                        goto idle_irq;
 -              DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n",
 -                      ap->id, qc->tf.protocol, status);
 -
 -              /* ack bmdma irq events */
 -              ap->ops->irq_clear(ap);
 -
 -              /* complete taskfile transaction */
 -              qc->err_mask |= ac_err_mask(status);
 -              ata_qc_complete(qc);
                break;
 -
 +      case HSM_ST_LAST:
 +              if (qc->tf.protocol == ATA_PROT_DMA ||
 +                  qc->tf.protocol == ATA_PROT_ATAPI_DMA) {
 +                      /* check status of DMA engine */
 +                      host_stat = ap->ops->bmdma_status(ap);
 +                      VPRINTK("ata%u: host_stat 0x%X\n", ap->id, host_stat);
 +
 +                      /* if it's not our irq... */
 +                      if (!(host_stat & ATA_DMA_INTR))
 +                              goto idle_irq;
 +
 +                      /* before we do anything else, clear DMA-Start bit */
 +                      ap->ops->bmdma_stop(qc);
 +
 +                      if (unlikely(host_stat & ATA_DMA_ERR)) {
 +                              /* error when transfering data to/from memory */
 +                              qc->err_mask |= AC_ERR_HOST_BUS;
 +                              ap->hsm_task_state = HSM_ST_ERR;
 +                      }
 +              }
 +              break;
 +      case HSM_ST:
 +              break;
        default:
                goto idle_irq;
        }
  
 +      /* check altstatus */
 +      status = ata_altstatus(ap);
 +      if (status & ATA_BUSY)
 +              goto idle_irq;
 +
 +      /* check main status, clearing INTRQ */
 +      status = ata_chk_status(ap);
 +      if (unlikely(status & ATA_BUSY))
 +              goto idle_irq;
 +
 +      /* ack bmdma irq events */
 +      ap->ops->irq_clear(ap);
 +
 +      ata_hsm_move(ap, qc, status, 0);
        return 1;       /* irq handled */
  
  idle_irq:
@@@ -4549,11 -4354,11 +4541,11 @@@ irqreturn_t ata_interrupt (int irq, voi
  
                ap = host_set->ports[i];
                if (ap &&
 -                  !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) {
 +                  !(ap->flags & ATA_FLAG_DISABLED)) {
                        struct ata_queued_cmd *qc;
  
                        qc = ata_qc_from_tag(ap, ap->active_tag);
 -                      if (qc && (!(qc->tf.ctl & ATA_NIEN)) &&
 +                      if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) &&
                            (qc->flags & ATA_QCFLAG_ACTIVE))
                                handled |= ata_host_intr(ap, qc);
                }
@@@ -4846,7 -4651,7 +4838,7 @@@ static struct ata_port * ata_host_add(c
  
        host->transportt = &ata_scsi_transport_template;
  
-       ap = (struct ata_port *) &host->hostdata[0];
+       ap = ata_shost_to_port(host);
  
        ata_host_init(ap, host, host_set, ent, port_no);
  
@@@ -5059,7 -4864,7 +5051,7 @@@ void ata_host_set_remove(struct ata_hos
  
  int ata_scsi_release(struct Scsi_Host *host)
  {
-       struct ata_port *ap = (struct ata_port *) &host->hostdata[0];
+       struct ata_port *ap = ata_shost_to_port(host);
        int i;
  
        DPRINTK("ENTER\n");
@@@ -5226,6 -5031,52 +5218,52 @@@ int ata_ratelimit(void
        return rc;
  }
  
+ /**
+  *    ata_wait_register - wait until register value changes
+  *    @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
+  *
+  *    Waiting for some bits of register to change is a common
+  *    operation for ATA controllers.  This function reads 32bit LE
+  *    IO-mapped register @reg and tests for the following condition.
+  *
+  *    (*@reg & mask) != val
+  *
+  *    If the condition is met, it returns; otherwise, the process is
+  *    repeated after @interval_msec until timeout.
+  *
+  *    LOCKING:
+  *    Kernel thread context (may sleep)
+  *
+  *    RETURNS:
+  *    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 timeout;
+       u32 tmp;
+       tmp = ioread32(reg);
+       /* Calculate timeout _after_ the first read to make sure
+        * preceding writes reach the controller before starting to
+        * eat away the timeout.
+        */
+       timeout = jiffies + (timeout_msec * HZ) / 1000;
+       while ((tmp & mask) == val && time_before(jiffies, timeout)) {
+               msleep(interval_msec);
+               tmp = ioread32(reg);
+       }
+       return tmp;
+ }
  /*
   * libata is essentially a library of internal helper functions for
   * low-level ATA host controller drivers.  As such, the API/ABI is
@@@ -5262,6 -5113,7 +5300,7 @@@ EXPORT_SYMBOL_GPL(ata_bmdma_irq_clear)
  EXPORT_SYMBOL_GPL(ata_bmdma_status);
  EXPORT_SYMBOL_GPL(ata_bmdma_stop);
  EXPORT_SYMBOL_GPL(ata_port_probe);
+ EXPORT_SYMBOL_GPL(ata_set_sata_spd);
  EXPORT_SYMBOL_GPL(sata_phy_reset);
  EXPORT_SYMBOL_GPL(__sata_phy_reset);
  EXPORT_SYMBOL_GPL(ata_bus_reset);
@@@ -5276,6 -5128,7 +5315,7 @@@ EXPORT_SYMBOL_GPL(ata_dev_classify)
  EXPORT_SYMBOL_GPL(ata_dev_pair);
  EXPORT_SYMBOL_GPL(ata_port_disable);
  EXPORT_SYMBOL_GPL(ata_ratelimit);
+ EXPORT_SYMBOL_GPL(ata_wait_register);
  EXPORT_SYMBOL_GPL(ata_busy_sleep);
  EXPORT_SYMBOL_GPL(ata_port_queue_task);
  EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
diff --combined drivers/scsi/libata-eh.c
index 9a8eea11b0be30f8aff9437b0d7c3a58226f3ed1,c31b13fd53072da506bdc722c8a311825f28de04..16db62211716d3b9ba5be30687fd80b99d6b8483
@@@ -64,7 -64,7 +64,7 @@@
  enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd)
  {
        struct Scsi_Host *host = cmd->device->host;
-       struct ata_port *ap = (struct ata_port *) &host->hostdata[0];
+       struct ata_port *ap = ata_shost_to_port(host);
        unsigned long flags;
        struct ata_queued_cmd *qc;
        enum scsi_eh_timer_return ret = EH_HANDLED;
@@@ -97,9 -97,9 +97,9 @@@
   *    RETURNS:
   *    Zero.
   */
int ata_scsi_error(struct Scsi_Host *host)
void ata_scsi_error(struct Scsi_Host *host)
  {
-       struct ata_port *ap = (struct ata_port *)&host->hostdata[0];
+       struct ata_port *ap = ata_shost_to_port(host);
  
        DPRINTK("ENTER\n");
  
        scsi_eh_flush_done_q(&ap->eh_done_q);
  
        DPRINTK("EXIT\n");
-       return 0;
  }
  
  /**
@@@ -172,7 -171,7 +171,7 @@@ static void ata_qc_timeout(struct ata_q
                       ap->id, qc->tf.command, drv_stat, host_stat);
  
                /* complete taskfile transaction */
 -              qc->err_mask |= ac_err_mask(drv_stat);
 +              qc->err_mask |= AC_ERR_TIMEOUT;
                break;
        }
  
diff --combined drivers/scsi/pdc_adma.c
index 1fca6f1afa994c15bcc29a2fe801b06dfc371b9d,b9a3c566f8334de06563a13d6e59b59f4d5b904b..a341fa8d3291c90215f413931c74e85627e202a3
@@@ -143,7 -143,6 +143,6 @@@ static struct scsi_host_template adma_a
        .name                   = DRV_NAME,
        .ioctl                  = ata_scsi_ioctl,
        .queuecommand           = ata_scsi_queuecmd,
-       .eh_strategy_handler    = ata_scsi_error,
        .can_queue              = ATA_DEF_QUEUE,
        .this_id                = ATA_SHT_THIS_ID,
        .sg_tablesize           = LIBATA_MAX_PRD,
@@@ -456,13 -455,13 +455,13 @@@ static inline unsigned int adma_intr_pk
                        continue;
                handled = 1;
                adma_enter_reg_mode(ap);
 -              if (ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))
 +              if (ap->flags & ATA_FLAG_DISABLED)
                        continue;
                pp = ap->private_data;
                if (!pp || pp->state != adma_state_pkt)
                        continue;
                qc = ata_qc_from_tag(ap, ap->active_tag);
 -              if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
 +              if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
                        if ((status & (aPERR | aPSD | aUIRQ)))
                                qc->err_mask |= AC_ERR_OTHER;
                        else if (pp->pkt[0] != cDONE)
@@@ -481,13 -480,13 +480,13 @@@ static inline unsigned int adma_intr_mm
        for (port_no = 0; port_no < host_set->n_ports; ++port_no) {
                struct ata_port *ap;
                ap = host_set->ports[port_no];
 -              if (ap && (!(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR)))) {
 +              if (ap && (!(ap->flags & ATA_FLAG_DISABLED))) {
                        struct ata_queued_cmd *qc;
                        struct adma_port_priv *pp = ap->private_data;
                        if (!pp || pp->state != adma_state_mmio)
                                continue;
                        qc = ata_qc_from_tag(ap, ap->active_tag);
 -                      if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
 +                      if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
  
                                /* check main status, clearing INTRQ */
                                u8 status = ata_check_status(ap);
diff --combined drivers/scsi/sata_mv.c
index fd9f2173f0622e3485ddf1aba7f4aded4820c8da,4aabc759fcec2a4775a7345eb60abf3cae2cd8b4..08665ea1e94e6303252756792a92f68fcb6dd257
@@@ -87,7 -87,7 +87,7 @@@ enum 
        MV_FLAG_IRQ_COALESCE    = (1 << 29),  /* IRQ coalescing capability */
        MV_COMMON_FLAGS         = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
                                   ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
 -                                 ATA_FLAG_NO_ATAPI),
 +                                 ATA_FLAG_PIO_POLLING),
        MV_6XXX_FLAGS           = MV_FLAG_IRQ_COALESCE,
  
        CRQB_FLAG_READ          = (1 << 0),
@@@ -378,7 -378,6 +378,6 @@@ static struct scsi_host_template mv_sh
        .name                   = DRV_NAME,
        .ioctl                  = ata_scsi_ioctl,
        .queuecommand           = ata_scsi_queuecmd,
-       .eh_strategy_handler    = ata_scsi_error,
        .can_queue              = MV_USE_Q_DEPTH,
        .this_id                = ATA_SHT_THIS_ID,
        .sg_tablesize           = MV_MAX_SG_CT / 2,
@@@ -1397,7 -1396,7 +1396,7 @@@ static void mv_host_intr(struct ata_hos
                        }
                }
  
 -              if (ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))
 +              if (ap && (ap->flags & ATA_FLAG_DISABLED))
                        continue;
  
                err_mask = ac_err_mask(ata_status);
                                VPRINTK("port %u IRQ found for qc, "
                                        "ata_status 0x%x\n", port,ata_status);
                                /* mark qc status appropriately */
 -                              if (!(qc->tf.ctl & ATA_NIEN)) {
 +                              if (!(qc->tf.flags & ATA_TFLAG_POLLING)) {
                                        qc->err_mask |= err_mask;
                                        ata_qc_complete(qc);
                                }
diff --combined drivers/scsi/sata_nv.c
index 3a0004c3c8b51949769304583b5a749b1b6e3060,3a70875be8bade59877d5efec5102db360e02dbe..70c51088d371f3eb1116b8c0e60e7b0703fd5b82
@@@ -201,7 -201,6 +201,6 @@@ static struct scsi_host_template nv_sh
        .name                   = DRV_NAME,
        .ioctl                  = ata_scsi_ioctl,
        .queuecommand           = ata_scsi_queuecmd,
-       .eh_strategy_handler    = ata_scsi_error,
        .can_queue              = ATA_DEF_QUEUE,
        .this_id                = ATA_SHT_THIS_ID,
        .sg_tablesize           = LIBATA_MAX_PRD,
@@@ -280,11 -279,11 +279,11 @@@ static irqreturn_t nv_interrupt (int ir
  
                ap = host_set->ports[i];
                if (ap &&
 -                  !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) {
 +                  !(ap->flags & ATA_FLAG_DISABLED)) {
                        struct ata_queued_cmd *qc;
  
                        qc = ata_qc_from_tag(ap, ap->active_tag);
 -                      if (qc && (!(qc->tf.ctl & ATA_NIEN)))
 +                      if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
                                handled += ata_host_intr(ap, qc);
                        else
                                // No request pending?  Clear interrupt status
index 03c647cbfb59910dcd798d4b2f18548c59c5f5f6,ddbc0c6dd9fe3887a2e2e0461c08168f002600b6..aaf896a0c63ad38513210ac2ea2372adb0820e43
@@@ -76,8 -76,7 +76,8 @@@ enum 
        PDC_RESET               = (1 << 11), /* HDMA reset */
  
        PDC_COMMON_FLAGS        = ATA_FLAG_NO_LEGACY | ATA_FLAG_SRST |
 -                                ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI,
 +                                ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI |
 +                                ATA_FLAG_PIO_POLLING,
  };
  
  
@@@ -112,7 -111,6 +112,6 @@@ static struct scsi_host_template pdc_at
        .name                   = DRV_NAME,
        .ioctl                  = ata_scsi_ioctl,
        .queuecommand           = ata_scsi_queuecmd,
-       .eh_strategy_handler    = ata_scsi_error,
        .can_queue              = ATA_DEF_QUEUE,
        .this_id                = ATA_SHT_THIS_ID,
        .sg_tablesize           = LIBATA_MAX_PRD,
@@@ -535,11 -533,11 +534,11 @@@ static irqreturn_t pdc_interrupt (int i
                ap = host_set->ports[i];
                tmp = mask & (1 << (i + 1));
                if (tmp && ap &&
 -                  !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) {
 +                  !(ap->flags & ATA_FLAG_DISABLED)) {
                        struct ata_queued_cmd *qc;
  
                        qc = ata_qc_from_tag(ap, ap->active_tag);
 -                      if (qc && (!(qc->tf.ctl & ATA_NIEN)))
 +                      if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
                                handled += pdc_host_intr(ap, qc);
                }
        }
index 1b7a9316810ce76a3e81f4327f4f0fad84f7ef56,259c2dec4e21f6f26ec30654b8d235a52dd01a3c..54283e06070e5455d844e3ecff0b02bec344fddb
@@@ -132,7 -132,6 +132,6 @@@ static struct scsi_host_template qs_ata
        .name                   = DRV_NAME,
        .ioctl                  = ata_scsi_ioctl,
        .queuecommand           = ata_scsi_queuecmd,
-       .eh_strategy_handler    = ata_scsi_error,
        .can_queue              = ATA_DEF_QUEUE,
        .this_id                = ATA_SHT_THIS_ID,
        .sg_tablesize           = QS_MAX_PRD,
@@@ -176,7 -175,7 +175,7 @@@ static const struct ata_port_info qs_po
                .host_flags     = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
                                  ATA_FLAG_SATA_RESET |
                                  //FIXME ATA_FLAG_SRST |
 -                                ATA_FLAG_MMIO,
 +                                ATA_FLAG_MMIO | ATA_FLAG_PIO_POLLING,
                .pio_mask       = 0x10, /* pio4 */
                .udma_mask      = 0x7f, /* udma0-6 */
                .port_ops       = &qs_ata_ops,
@@@ -395,13 -394,14 +394,13 @@@ static inline unsigned int qs_intr_pkt(
                        DPRINTK("SFF=%08x%08x: sCHAN=%u sHST=%d sDST=%02x\n",
                                        sff1, sff0, port_no, sHST, sDST);
                        handled = 1;
 -                      if (ap && !(ap->flags &
 -                                  (ATA_FLAG_DISABLED|ATA_FLAG_NOINTR))) {
 +                      if (ap && !(ap->flags & ATA_FLAG_DISABLED)) {
                                struct ata_queued_cmd *qc;
                                struct qs_port_priv *pp = ap->private_data;
                                if (!pp || pp->state != qs_state_pkt)
                                        continue;
                                qc = ata_qc_from_tag(ap, ap->active_tag);
 -                              if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
 +                              if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
                                        switch (sHST) {
                                        case 0: /* successful CPB */
                                        case 3: /* device error */
@@@ -428,13 -428,13 +427,13 @@@ static inline unsigned int qs_intr_mmio
                struct ata_port *ap;
                ap = host_set->ports[port_no];
                if (ap &&
 -                  !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) {
 +                  !(ap->flags & ATA_FLAG_DISABLED)) {
                        struct ata_queued_cmd *qc;
                        struct qs_port_priv *pp = ap->private_data;
                        if (!pp || pp->state != qs_state_mmio)
                                continue;
                        qc = ata_qc_from_tag(ap, ap->active_tag);
 -                      if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
 +                      if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
  
                                /* check main status, clearing INTRQ */
                                u8 status = ata_check_status(ap);
diff --combined drivers/scsi/sata_sx4.c
index 13dba63f61674e6d2b74b7e6a3d4d2694c232083,a669d0589889576719b960131ea0b3af6308d8b7..4c07ba1f6e62c7cd443af43aa97dfb7c9287a1eb
@@@ -182,7 -182,6 +182,6 @@@ static struct scsi_host_template pdc_sa
        .name                   = DRV_NAME,
        .ioctl                  = ata_scsi_ioctl,
        .queuecommand           = ata_scsi_queuecmd,
-       .eh_strategy_handler    = ata_scsi_error,
        .can_queue              = ATA_DEF_QUEUE,
        .this_id                = ATA_SHT_THIS_ID,
        .sg_tablesize           = LIBATA_MAX_PRD,
@@@ -219,7 -218,7 +218,7 @@@ static const struct ata_port_info pdc_p
                .sht            = &pdc_sata_sht,
                .host_flags     = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
                                  ATA_FLAG_SRST | ATA_FLAG_MMIO |
 -                                ATA_FLAG_NO_ATAPI,
 +                                ATA_FLAG_PIO_POLLING,
                .pio_mask       = 0x1f, /* pio0-4 */
                .mwdma_mask     = 0x07, /* mwdma0-2 */
                .udma_mask      = 0x7f, /* udma0-6 ; FIXME */
@@@ -834,11 -833,11 +833,11 @@@ static irqreturn_t pdc20621_interrupt (
                tmp = mask & (1 << i);
                VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp);
                if (tmp && ap &&
 -                  !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) {
 +                  !(ap->flags & ATA_FLAG_DISABLED)) {
                        struct ata_queued_cmd *qc;
  
                        qc = ata_qc_from_tag(ap, ap->active_tag);
 -                      if (qc && (!(qc->tf.ctl & ATA_NIEN)))
 +                      if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
                                handled += pdc20621_host_intr(ap, qc, (i > 4),
                                                              mmio_base);
                }
diff --combined drivers/scsi/sata_vsc.c
index b7d6a31628c21e25276b7c93672d8b241ac78eaf,9646c39321293f35e8de1250568ab0f1e44323e1..0372be7ff1c924fc5b66a17aa8ab073325c72b34
@@@ -221,21 -221,14 +221,21 @@@ static irqreturn_t vsc_sata_interrupt (
  
                        ap = host_set->ports[i];
  
 -                      if (ap && !(ap->flags &
 -                                  (ATA_FLAG_DISABLED|ATA_FLAG_NOINTR))) {
 +                      if (is_vsc_sata_int_err(i, int_status)) {
 +                              u32 err_status;
 +                              printk(KERN_DEBUG "%s: ignoring interrupt(s)\n", __FUNCTION__);
 +                              err_status = ap ? vsc_sata_scr_read(ap, SCR_ERROR) : 0;
 +                              vsc_sata_scr_write(ap, SCR_ERROR, err_status);
 +                              handled++;
 +                      }
 +
 +                      if (ap && !(ap->flags & ATA_FLAG_DISABLED)) {
                                struct ata_queued_cmd *qc;
  
                                qc = ata_qc_from_tag(ap, ap->active_tag);
 -                              if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
 +                              if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
                                        handled += ata_host_intr(ap, qc);
 -                              else if (is_vsc_sata_int_err(i, int_status)) {
 +                              else if (is_vsc_sata_int_err(i, int_status)) {
                                        /*
                                         * On some chips (i.e. Intel 31244), an error
                                         * interrupt will sneak in at initialization
@@@ -270,7 -263,6 +270,6 @@@ static struct scsi_host_template vsc_sa
        .name                   = DRV_NAME,
        .ioctl                  = ata_scsi_ioctl,
        .queuecommand           = ata_scsi_queuecmd,
-       .eh_strategy_handler    = ata_scsi_error,
        .can_queue              = ATA_DEF_QUEUE,
        .this_id                = ATA_SHT_THIS_ID,
        .sg_tablesize           = LIBATA_MAX_PRD,
diff --combined include/linux/libata.h
index 44d074ff77894bc18aa78b874dff96b31fe1d68e,d35b1e3bb7e0f6c81bf69847431aef77bf3f80a1..bf86ee474533663d0acbb891d0bd4850bc391d1c
@@@ -33,6 -33,7 +33,7 @@@
  #include <asm/io.h>
  #include <linux/ata.h>
  #include <linux/workqueue.h>
+ #include <scsi/scsi_host.h>
  
  /*
   * compile-time options: to be removed as soon as all the drivers are
@@@ -121,7 -122,6 +122,7 @@@ enum 
        /* struct ata_device stuff */
        ATA_DFLAG_LBA           = (1 << 0), /* device supports LBA */
        ATA_DFLAG_LBA48         = (1 << 1), /* device supports LBA48 */
 +      ATA_DFLAG_CDB_INTR      = (1 << 2), /* device asserts INTRQ when ready for CDB */
        ATA_DFLAG_CFG_MASK      = (1 << 8) - 1,
  
        ATA_DFLAG_PIO           = (1 << 8), /* device currently in PIO mode */
        ATA_FLAG_PIO_DMA        = (1 << 7), /* PIO cmds via DMA */
        ATA_FLAG_PIO_LBA48      = (1 << 8), /* Host DMA engine is LBA28 only */
        ATA_FLAG_IRQ_MASK       = (1 << 9), /* Mask IRQ in PIO xfers */
 +      ATA_FLAG_PIO_POLLING    = (1 << 10), /* use polling PIO if LLD
 +                                            * doesn't handle PIO interrupts */
  
 -      ATA_FLAG_NOINTR         = (1 << 16), /* FIXME: Remove this once
 -                                            * proper HSM is in place. */
        ATA_FLAG_DEBUGMSG       = (1 << 17),
        ATA_FLAG_FLUSH_PORT_TASK = (1 << 18), /* flush port task */
  
        ATA_HOST_SIMPLEX        = (1 << 0),     /* Host is simplex, one DMA channel per host_set only */
        
        /* various lengths of time */
 -      ATA_TMOUT_PIO           = 30 * HZ,
        ATA_TMOUT_BOOT          = 30 * HZ,      /* heuristic */
        ATA_TMOUT_BOOT_QUICK    = 7 * HZ,       /* heuristic */
 -      ATA_TMOUT_CDB           = 30 * HZ,
 -      ATA_TMOUT_CDB_QUICK     = 5 * HZ,
        ATA_TMOUT_INTERNAL      = 30 * HZ,
        ATA_TMOUT_INTERNAL_QUICK = 5 * HZ,
  
  };
  
  enum hsm_task_states {
 -      HSM_ST_UNKNOWN,
 -      HSM_ST_IDLE,
 -      HSM_ST_POLL,
 -      HSM_ST_TMOUT,
 -      HSM_ST,
 -      HSM_ST_LAST,
 -      HSM_ST_LAST_POLL,
 -      HSM_ST_ERR,
 +      HSM_ST_UNKNOWN,         /* state unknown */
 +      HSM_ST_IDLE,            /* no command on going */
 +      HSM_ST,                 /* (waiting the device to) transfer data */
 +      HSM_ST_LAST,            /* (waiting the device to) complete command */
 +      HSM_ST_ERR,             /* error */
 +      HSM_ST_FIRST,           /* (waiting the device to)
 +                                 write CDB or first data block */
  };
  
  enum ata_completion_errors {
@@@ -248,7 -252,7 +249,7 @@@ struct ata_queued_cmd
  /* typedefs */
  typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc);
  typedef void (*ata_probeinit_fn_t)(struct ata_port *);
- typedef int (*ata_reset_fn_t)(struct ata_port *, int, unsigned int *);
+ typedef int (*ata_reset_fn_t)(struct ata_port *, unsigned int *);
  typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *);
  
  struct ata_ioports {
@@@ -415,6 -419,7 +416,6 @@@ struct ata_port 
        struct work_struct      port_task;
  
        unsigned int            hsm_task_state;
 -      unsigned long           pio_task_timeout;
  
        u32                     msg_enable;
        struct list_head        eh_done_q;
@@@ -499,15 -504,14 +500,14 @@@ extern void ata_port_probe(struct ata_p
  extern void __sata_phy_reset(struct ata_port *ap);
  extern void sata_phy_reset(struct ata_port *ap);
  extern void ata_bus_reset(struct ata_port *ap);
+ extern int ata_set_sata_spd(struct ata_port *ap);
  extern int ata_drive_probe_reset(struct ata_port *ap,
                        ata_probeinit_fn_t probeinit,
                        ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
                        ata_postreset_fn_t postreset, unsigned int *classes);
  extern void ata_std_probeinit(struct ata_port *ap);
- extern int ata_std_softreset(struct ata_port *ap, int verbose,
-                            unsigned int *classes);
- extern int sata_std_hardreset(struct ata_port *ap, int verbose,
-                             unsigned int *class);
+ extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes);
+ extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class);
  extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes);
  extern int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev,
                              int post_reset);
@@@ -526,6 -530,8 +526,8 @@@ extern void ata_host_set_remove(struct 
  extern int ata_scsi_detect(struct scsi_host_template *sht);
  extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
  extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *));
+ extern void ata_eh_qc_complete(struct ata_queued_cmd *qc);
+ extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
  extern int ata_scsi_release(struct Scsi_Host *host);
  extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
  extern int ata_scsi_device_resume(struct scsi_device *);
@@@ -538,6 -544,9 +540,9 @@@ extern unsigned int ata_busy_sleep(stru
                                   unsigned long timeout);
  extern void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *),
                                void *data, unsigned long delay);
+ extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
+                            unsigned long interval_msec,
+                            unsigned long timeout_msec);
  
  /*
   * Default driver ops implementations
@@@ -631,7 -640,6 +636,6 @@@ extern unsigned long ata_pci_default_fi
  /*
   * EH
   */
- extern int ata_scsi_error(struct Scsi_Host *host);
  extern void ata_eng_timeout(struct ata_port *ap);
  extern void ata_eh_qc_complete(struct ata_queued_cmd *qc);
  extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
@@@ -972,4 -980,9 +976,9 @@@ static inline void ata_pad_free(struct 
        dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma);
  }
  
+ static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
+ {
+       return (struct ata_port *) &host->hostdata[0];
+ }
  #endif /* __LINUX_LIBATA_H__ */
This page took 0.134862 seconds and 4 git commands to generate.