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: command complete, drv_stat 0x%x\n",
+ ap->id, 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: command error, drv_stat 0x%x\n",
+ ap->id, 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)
+ return poll_next;
+}
+
+static void ata_pio_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;
+ int poll_next;
+
+fsm_start:
+ WARN_ON(ap->hsm_task_state == HSM_ST_IDLE);
+
+ qc = ata_qc_from_tag(ap, ap->active_tag);
+ WARN_ON(qc == NULL);
+
+ /*
+ * 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, ap, ATA_SHORT_PAUSE);
+ return;
+ }
+ }
+
+ /* move the HSM */
+ poll_next = ata_hsm_move(ap, qc, status, 1);
+
+ /* another command or interrupt handler
+ * may be running at this point.
+ */
+ if (poll_next)
goto fsm_start;
}
ap = host_set->ports[i];
if (ap &&
- !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
- !(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);
continue;
handled = 1;
adma_enter_reg_mode(ap);
- if (ap->flags & ATA_FLAG_PORT_DISABLED)
- 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)
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_PORT_DISABLED))) {
- 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)
}
}
- if (ap && (ap->flags & ATA_FLAG_PORT_DISABLED))
- if (ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))
++ if (ap && (ap->flags & ATA_FLAG_DISABLED))
continue;
err_mask = ac_err_mask(ata_status);
ap = host_set->ports[i];
if (ap &&
- !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
- !(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);
ap = host_set->ports[i];
tmp = mask & (1 << (i + 1));
if (tmp && ap &&
- !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
- !(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);
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_PORT_DISABLED)) {
- 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)
struct ata_port *ap;
ap = host_set->ports[port_no];
if (ap &&
- !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
- !(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)
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_PORT_DISABLED)) {
- !(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);
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_PORT_DISABLED)) {
++ if (ap && !(ap->flags & ATA_FLAG_DISABLED)) {
struct ata_queued_cmd *qc;
qc = ata_qc_from_tag(ap, ap->active_tag);
ATA_SHT_USE_CLUSTERING = 1,
/* struct ata_device stuff */
- ATA_DFLAG_LBA48 = (1 << 0), /* device supports LBA48 */
- ATA_DFLAG_PIO = (1 << 1), /* device currently in PIO mode */
- ATA_DFLAG_LBA = (1 << 2), /* device supports LBA */
- ATA_DFLAG_CDB_INTR = (1 << 3), /* device asserts INTRQ when ready for CDB */
+ 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_DEV_UNKNOWN = 0, /* unknown device */
ATA_DEV_ATA = 1, /* ATA device */
ATA_DEV_NONE = 5, /* no device */
/* struct ata_port flags */
- ATA_FLAG_SLAVE_POSS = (1 << 1), /* host supports slave dev */
+ ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */
/* (doesn't imply presence) */
- ATA_FLAG_PORT_DISABLED = (1 << 2), /* port is disabled, ignore it */
- ATA_FLAG_SATA = (1 << 3),
- ATA_FLAG_NO_LEGACY = (1 << 4), /* no legacy mode check */
- ATA_FLAG_SRST = (1 << 5), /* (obsolete) use ATA SRST, not E.D.D. */
- ATA_FLAG_MMIO = (1 << 6), /* use MMIO, not PIO */
- ATA_FLAG_SATA_RESET = (1 << 7), /* (obsolete) use COMRESET */
- ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */
- ATA_FLAG_PIO_POLLING = (1 << 9), /* use polling PIO if LLD
- * doesn't handle PIO interrupts */
- ATA_FLAG_DEBUGMSG = (1 << 10),
- ATA_FLAG_NO_ATAPI = (1 << 11), /* No ATAPI support */
-
- ATA_FLAG_SUSPENDED = (1 << 12), /* port is suspended */
-
- ATA_FLAG_PIO_LBA48 = (1 << 13), /* Host DMA engine is LBA28 only */
- ATA_FLAG_IRQ_MASK = (1 << 14), /* Mask IRQ in PIO xfers */
-
- ATA_FLAG_FLUSH_PORT_TASK = (1 << 15), /* Flush port task */
- ATA_FLAG_IN_EH = (1 << 16), /* EH in progress */
-
- ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */
- ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */
- ATA_QCFLAG_SINGLE = (1 << 4), /* no s/g, just a single buffer */
+ ATA_FLAG_SATA = (1 << 1),
+ ATA_FLAG_NO_LEGACY = (1 << 2), /* no legacy mode check */
+ ATA_FLAG_MMIO = (1 << 3), /* use MMIO, not PIO */
+ ATA_FLAG_SRST = (1 << 4), /* (obsolete) use ATA SRST, not E.D.D. */
+ ATA_FLAG_SATA_RESET = (1 << 5), /* (obsolete) use COMRESET */
+ ATA_FLAG_NO_ATAPI = (1 << 6), /* No ATAPI support */
+ 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_FLAG_DISABLED = (1 << 19), /* port is disabled, ignore it */
+ ATA_FLAG_SUSPENDED = (1 << 20), /* port is suspended */
+
+ /* bits 24:31 of ap->flags are reserved for LLDD specific flags */
+
+ /* struct ata_queued_cmd flags */
+ ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */
+ ATA_QCFLAG_SG = (1 << 1), /* have s/g table? */
+ ATA_QCFLAG_SINGLE = (1 << 2), /* no s/g, just a single buffer */
ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE,
- ATA_QCFLAG_EH_SCHEDULED = (1 << 5), /* EH scheduled */
+ ATA_QCFLAG_IO = (1 << 3), /* standard IO command */
+ ATA_QCFLAG_EH_SCHEDULED = (1 << 4), /* EH scheduled */
/* host set flags */
ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */