From: Jeff Garzik Date: Sun, 2 Apr 2006 14:30:40 +0000 (-0400) Subject: Merge branch 'upstream' X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=029f5468b5b5f93a09bf90326fdcb9124079658d;p=linux-beck.git Merge branch 'upstream' Conflicts: drivers/scsi/libata-core.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 --- 029f5468b5b5f93a09bf90326fdcb9124079658d diff --cc drivers/scsi/libata-core.c index 597e9e8bcd2c,8beba3cd9a56..9de48dd4234a --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@@ -3785,94 -3923,23 +4033,94 @@@ fsm_start 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; } @@@ -4392,7 -4355,7 +4640,7 @@@ irqreturn_t ata_interrupt (int irq, voi 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); diff --cc drivers/scsi/pdc_adma.c index ff4fec96271b,d64073dd028f..a4dcb4352206 --- a/drivers/scsi/pdc_adma.c +++ b/drivers/scsi/pdc_adma.c @@@ -456,7 -456,7 +456,7 @@@ static inline unsigned int adma_intr_pk 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) @@@ -481,7 -481,7 +481,7 @@@ 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_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) diff --cc drivers/scsi/sata_mv.c index dc54f294fac8,e9152f850003..fd9f2173f062 --- a/drivers/scsi/sata_mv.c +++ b/drivers/scsi/sata_mv.c @@@ -1397,7 -1397,7 +1397,7 @@@ static void mv_host_intr(struct ata_hos } } - 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); diff --cc drivers/scsi/sata_nv.c index 8a99c3827426,72721ac482d8..be38f328a479 --- a/drivers/scsi/sata_nv.c +++ b/drivers/scsi/sata_nv.c @@@ -280,7 -280,7 +280,7 @@@ static irqreturn_t nv_interrupt (int ir 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); diff --cc drivers/scsi/sata_promise.c index cf0eeba47eb6,9557c7aa45e0..322525d84907 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c @@@ -535,7 -534,7 +535,7 @@@ static irqreturn_t pdc_interrupt (int i 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); diff --cc drivers/scsi/sata_qstor.c index a547c1272a5e,8ef042a09448..f86858962fbe --- a/drivers/scsi/sata_qstor.c +++ b/drivers/scsi/sata_qstor.c @@@ -395,7 -395,8 +395,7 @@@ 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_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) @@@ -428,7 -429,7 +428,7 @@@ static inline unsigned int qs_intr_mmio 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) diff --cc drivers/scsi/sata_sx4.c index 2d6b091a9eaf,3af28ef76fd9..45c78c399bfd --- a/drivers/scsi/sata_sx4.c +++ b/drivers/scsi/sata_sx4.c @@@ -834,7 -834,7 +834,7 @@@ 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_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); diff --cc drivers/scsi/sata_vsc.c index 5af6d5f9f4bd,cecc1f76256b..b7d6a31628c2 --- a/drivers/scsi/sata_vsc.c +++ b/drivers/scsi/sata_vsc.c @@@ -221,15 -221,8 +221,15 @@@ 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_PORT_DISABLED)) { ++ if (ap && !(ap->flags & ATA_FLAG_DISABLED)) { struct ata_queued_cmd *qc; qc = ata_qc_from_tag(ap, ap->active_tag); diff --cc include/linux/libata.h index b0171e9accc4,75bdee09c307..cc6cc08e8010 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@@ -120,10 -120,11 +120,12 @@@ enum 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 */ @@@ -133,33 -134,35 +135,35 @@@ 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 */