From 656563e32c3f1dfdc35b3944305ece1c5dfeade5 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sun, 20 Nov 2005 03:36:45 -0500 Subject: [libata] Print out SATA speed, if link is up Make the SATA phy probe messages a bit more informative. Note this only applies to drivers that use __sata_phy_reset(), which excludes some drivers. --- drivers/scsi/libata-core.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 665ae79e1fd..9f27e8d0e77 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -1444,11 +1444,23 @@ void __sata_phy_reset(struct ata_port *ap) } while (time_before(jiffies, timeout)); /* TODO: phy layer with polling, timeouts, etc. */ - if (sata_dev_present(ap)) + sstatus = scr_read(ap, SCR_STATUS); + if (sata_dev_present(ap)) { + const char *speed; + u32 tmp; + + tmp = (sstatus >> 4) & 0xf; + if (tmp & (1 << 0)) + speed = "1.5"; + else if (tmp & (1 << 1)) + speed = "3.0"; + else + speed = ""; + printk(KERN_INFO "ata%u: SATA link up %s Gbps (SStatus %X)\n", + ap->id, speed, sstatus); ata_port_probe(ap); - else { - sstatus = scr_read(ap, SCR_STATUS); - printk(KERN_INFO "ata%u: no device found (phy stat %08x)\n", + } else { + printk(KERN_INFO "ata%u: SATA link down (SStatus %X)\n", ap->id, sstatus); ata_port_disable(ap); } -- cgit v1.2.3 From 98ac62defe529d04a192688f40d801a2d8fbcf98 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Mon, 28 Nov 2005 10:06:23 +0100 Subject: [PATCH] mark several libata datastructures const Hi, the patch below marks several libata (and libata-driver) structures const so that they end up in the .rodata segment and don't false-share cachelines with things that get dirtied often. Signed-off-by: Arjan van de Ven Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 9f27e8d0e77..11ed6fa2709 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -605,7 +605,7 @@ void ata_rwcmd_protocol(struct ata_queued_cmd *qc) tf->command = ata_rw_cmds[index + lba48 + write]; } -static const char * xfer_mode_str[] = { +static const char * const xfer_mode_str[] = { "UDMA/16", "UDMA/25", "UDMA/33", @@ -2083,7 +2083,7 @@ static void ata_pr_blacklisted(const struct ata_port *ap, ap->id, dev->devno); } -static const char * ata_dma_blacklist [] = { +static const char * const ata_dma_blacklist [] = { "WDC AC11000H", "WDC AC22100H", "WDC AC32500H", -- cgit v1.2.3 From c14b8331ec4843e4f2b67a4d847a0d812a50e43c Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Mon, 5 Dec 2005 15:36:08 +0800 Subject: [PATCH] libata: minor patch before moving err_mask - add qc to ata_pio_poll() - reorder the initialization of qc in ata_pio_complete() Signed-off-by: Albert Lee =================== Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 11ed6fa2709..0a959566f96 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -2802,10 +2802,14 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) static unsigned long ata_pio_poll(struct ata_port *ap) { + struct ata_queued_cmd *qc; 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); + assert(qc != NULL); + switch (ap->hsm_task_state) { case HSM_ST: case HSM_ST_POLL: @@ -2870,15 +2874,15 @@ static int ata_pio_complete (struct ata_port *ap) } } + qc = ata_qc_from_tag(ap, ap->active_tag); + assert(qc != NULL); + drv_stat = ata_wait_idle(ap); if (!ata_ok(drv_stat)) { ap->hsm_task_state = HSM_ST_ERR; return 0; } - qc = ata_qc_from_tag(ap, ap->active_tag); - assert(qc != NULL); - ap->hsm_task_state = HSM_ST_IDLE; ata_poll_qc_complete(qc, 0); -- cgit v1.2.3 From a22e2eb0710798009b8e696ae911aef745089dd6 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Mon, 5 Dec 2005 15:38:02 +0800 Subject: [PATCH] libata: move err_mask to ata_queued_cmd - remove err_mask from the parameter list of the complete functions - move err_mask to ata_queued_cmd - initialize qc->err_mask when needed - for each function call to ata_qc_complete(), replace the err_mask parameter with qc->err_mask. Signed-off-by: Albert Lee =============== Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 0a959566f96..f56b4daf418 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -1053,9 +1053,9 @@ static int ata_qc_wait_err(struct ata_queued_cmd *qc, if (wait_for_completion_timeout(wait, 30 * HZ) < 1) { /* timeout handling */ - unsigned int err_mask = ac_err_mask(ata_chk_status(qc->ap)); + qc->err_mask |= ac_err_mask(ata_chk_status(qc->ap)); - if (!err_mask) { + if (!qc->err_mask) { printk(KERN_WARNING "ata%u: slow completion (cmd %x)\n", qc->ap->id, qc->tf.command); } else { @@ -1064,7 +1064,7 @@ static int ata_qc_wait_err(struct ata_queued_cmd *qc, rc = -EIO; } - ata_qc_complete(qc, err_mask); + ata_qc_complete(qc); } return rc; @@ -1175,6 +1175,7 @@ retry: qc->cursg_ofs = 0; qc->cursect = 0; qc->nsect = 1; + qc->err_mask = 0; goto retry; } } @@ -2777,7 +2778,7 @@ skip_map: * None. (grabs host lock) */ -void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) +void ata_poll_qc_complete(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; unsigned long flags; @@ -2785,7 +2786,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) spin_lock_irqsave(&ap->host_set->lock, flags); ap->flags &= ~ATA_FLAG_NOINTR; ata_irq_on(ap); - ata_qc_complete(qc, err_mask); + ata_qc_complete(qc); spin_unlock_irqrestore(&ap->host_set->lock, flags); } @@ -2885,7 +2886,8 @@ static int ata_pio_complete (struct ata_port *ap) ap->hsm_task_state = HSM_ST_IDLE; - ata_poll_qc_complete(qc, 0); + assert(qc->err_mask == 0); + ata_poll_qc_complete(qc); /* another command may start at this point */ @@ -3261,7 +3263,8 @@ static void ata_pio_error(struct ata_port *ap) ap->hsm_task_state = HSM_ST_IDLE; - ata_poll_qc_complete(qc, AC_ERR_ATA_BUS); + qc->err_mask |= AC_ERR_ATA_BUS; + ata_poll_qc_complete(qc); } static void ata_pio_task(void *_data) @@ -3363,7 +3366,8 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc) ap->id, qc->tf.command, drv_stat, host_stat); /* complete taskfile transaction */ - ata_qc_complete(qc, ac_err_mask(drv_stat)); + qc->err_mask |= ac_err_mask(drv_stat); + ata_qc_complete(qc); break; } @@ -3462,7 +3466,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, return qc; } -int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask) +int ata_qc_complete_noop(struct ata_queued_cmd *qc) { return 0; } @@ -3521,7 +3525,7 @@ void ata_qc_free(struct ata_queued_cmd *qc) * spin_lock_irqsave(host_set lock) */ -void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) +void ata_qc_complete(struct ata_queued_cmd *qc) { int rc; @@ -3538,7 +3542,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) qc->flags &= ~ATA_QCFLAG_ACTIVE; /* call completion callback */ - rc = qc->complete_fn(qc, err_mask); + rc = qc->complete_fn(qc); /* if callback indicates not to complete command (non-zero), * return immediately @@ -3976,7 +3980,8 @@ inline unsigned int ata_host_intr (struct ata_port *ap, ap->ops->irq_clear(ap); /* complete taskfile transaction */ - ata_qc_complete(qc, ac_err_mask(status)); + qc->err_mask |= ac_err_mask(status); + ata_qc_complete(qc); break; default: @@ -4111,7 +4116,8 @@ static void atapi_packet_task(void *_data) err_out_status: status = ata_chk_status(ap); err_out: - ata_poll_qc_complete(qc, __ac_err_mask(status)); + qc->err_mask |= __ac_err_mask(status); + ata_poll_qc_complete(qc); } -- cgit v1.2.3 From 1c8489840e6b080e810e588423c1b6dd5913cf18 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Mon, 5 Dec 2005 15:40:15 +0800 Subject: [PATCH] libata: determine the err_mask when the error is found - move "qc->err_mask |= AC_ERR_ATA_BUS" to where the error is found - add "assert(qc->err_mask)" to ata_pio_error() to make sure qc->err_mask was available when we enter the error state Signed-off-by: Albert Lee ============ Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index f56b4daf418..cc003f2c6d9 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -2830,6 +2830,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap) status = ata_chk_status(ap); if (status & ATA_BUSY) { if (time_after(jiffies, ap->pio_task_timeout)) { + qc->err_mask |= AC_ERR_ATA_BUS; ap->hsm_task_state = HSM_ST_TMOUT; return 0; } @@ -2880,6 +2881,7 @@ static int ata_pio_complete (struct ata_port *ap) 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; } @@ -3195,6 +3197,7 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc) err_out: printk(KERN_INFO "ata%u: dev %u: ATAPI check failed\n", ap->id, dev->devno); + qc->err_mask |= AC_ERR_ATA_BUS; ap->hsm_task_state = HSM_ST_ERR; } @@ -3244,6 +3247,7 @@ static void ata_pio_block(struct ata_port *ap) } else { /* handle BSY=0, DRQ=0 as error */ if ((status & ATA_DRQ) == 0) { + qc->err_mask |= AC_ERR_ATA_BUS; ap->hsm_task_state = HSM_ST_ERR; return; } @@ -3261,9 +3265,13 @@ static void ata_pio_error(struct ata_port *ap) qc = ata_qc_from_tag(ap, ap->active_tag); assert(qc != NULL); + /* make sure qc->err_mask is available to + * know what's wrong and recover + */ + assert(qc->err_mask); + ap->hsm_task_state = HSM_ST_IDLE; - qc->err_mask |= AC_ERR_ATA_BUS; ata_poll_qc_complete(qc); } -- cgit v1.2.3 From d8fe452b3e8e9ea6d62a3d116a092999fabae407 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Mon, 5 Dec 2005 15:42:17 +0800 Subject: [PATCH] libata: determine the err_mask directly in atapi_packet_task() - set qc->err_mask directly when we found the error - remove the code to determine err_mask from device status Signed-off-by: Albert Lee ============ Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index cc003f2c6d9..b3aedb03346 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -4083,13 +4083,17 @@ static void atapi_packet_task(void *_data) /* sleep-wait for BSY to clear */ DPRINTK("busy wait\n"); - if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) - goto err_out_status; + if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) { + qc->err_mask |= AC_ERR_ATA_BUS; + goto err_out; + } /* make sure DRQ is set */ status = ata_chk_status(ap); - if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) + if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) { + qc->err_mask |= AC_ERR_ATA_BUS; goto err_out; + } /* send SCSI cdb */ DPRINTK("send cdb\n"); @@ -4121,10 +4125,7 @@ static void atapi_packet_task(void *_data) return; -err_out_status: - status = ata_chk_status(ap); err_out: - qc->err_mask |= __ac_err_mask(status); ata_poll_qc_complete(qc); } -- cgit v1.2.3 From fe79e683ccdb29c13b3e0d18507474b4e2d9aab6 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Tue, 6 Dec 2005 11:34:59 +0800 Subject: [PATCH] libata: err_mask misc fix 1. ata_pio_complete(): It seems unnecessary to wait for the clearing of the DRQ bit. (Waiting for BSY=0 should be enough. ata_ok() also checks the correctness of the status bits later.) 2. ata_pio_block(): - added error checking, before transfering data. - minor comments fix Signed-off-by: Albert Lee ============ Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index b3aedb03346..e4c400756b2 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -2865,11 +2865,11 @@ static int ata_pio_complete (struct ata_port *ap) * msecs, then chk-status again. If still busy, fall back to * HSM_ST_POLL state. */ - drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10); - if (drv_stat & (ATA_BUSY | ATA_DRQ)) { + drv_stat = ata_busy_wait(ap, ATA_BUSY, 10); + if (drv_stat & ATA_BUSY) { msleep(2); - drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10); - if (drv_stat & (ATA_BUSY | ATA_DRQ)) { + 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; @@ -3236,8 +3236,16 @@ static void ata_pio_block(struct ata_port *ap) qc = ata_qc_from_tag(ap, ap->active_tag); assert(qc != NULL); + /* check error */ + if (status & (ATA_ERR | ATA_DF)) { + qc->err_mask |= AC_ERR_DEV; + ap->hsm_task_state = HSM_ST_ERR; + return; + } + + /* transfer data if any */ if (is_atapi_taskfile(&qc->tf)) { - /* no more data to transfer or unsupported ATAPI command */ + /* DRQ=0 means no more data to transfer */ if ((status & ATA_DRQ) == 0) { ap->hsm_task_state = HSM_ST_LAST; return; -- cgit v1.2.3 From a2a7a662f80d8b7f2295a36de1f9b033ed0b910c Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 13 Dec 2005 14:48:31 +0900 Subject: [PATCH] libata: implement ata_exec_internal() This patch implements ata_exec_internal() function which performs libata internal command execution. Previously, this was done by each user by manually initializing a qc, issueing it, waiting for its completion and handling errors. In addition to obvious code factoring, using ata_exec_internal() fixes the following bugs. * qc not freed on issue failure * ap->qactive clearing could race with the next internal command * race between timeout handling and irq * ignoring error condition not represented in tf->status Also, qc & hardware are not accessed anymore once it's completed, making internal commands more conformant with general semantics. ata_exec_internal() also makes it easy to issue internal commands from multiple threads if that becomes necessary. This patch only implements ata_exec_internal(). A following patch will convert all users. Signed-off-by: Tejun Heo -- Jeff, all patches have been regenerated against upstream branch as of today. (575ab52a218e4ff0667a6cbd972c3af443ee8713) Also, I took out a debug printk from ata_exec_internal (don't know how that one got left there). Other than that, all patches are identical to the previous posting. Thanks. :-) Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index a0060cf31e0..de80abeab06 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -1046,6 +1046,105 @@ static unsigned int ata_pio_modes(const struct ata_device *adev) return modes; } +struct ata_exec_internal_arg { + unsigned int err_mask; + struct ata_taskfile *tf; + struct completion *waiting; +}; + +int ata_qc_complete_internal(struct ata_queued_cmd *qc) +{ + struct ata_exec_internal_arg *arg = qc->private_data; + struct completion *waiting = arg->waiting; + + if (!(qc->err_mask & ~AC_ERR_DEV)) + qc->ap->ops->tf_read(qc->ap, arg->tf); + arg->err_mask = qc->err_mask; + arg->waiting = NULL; + complete(waiting); + + return 0; +} + +/** + * ata_exec_internal - execute libata internal command + * @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 + * @dma_dir: Data tranfer direction of the command + * @buf: Data buffer of the command + * @buflen: Length of data buffer + * + * Executes libata internal command with timeout. @tf contains + * command on entry and result on return. Timeout and error + * conditions are reported via return value. No recovery action + * is taken after a command times out. It's caller's duty to + * clean up after timeout. + * + * LOCKING: + * 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) +{ + u8 command = tf->command; + struct ata_queued_cmd *qc; + DECLARE_COMPLETION(wait); + unsigned long flags; + struct ata_exec_internal_arg arg; + + spin_lock_irqsave(&ap->host_set->lock, flags); + + qc = ata_qc_new_init(ap, dev); + BUG_ON(qc == NULL); + + qc->tf = *tf; + qc->dma_dir = dma_dir; + if (dma_dir != DMA_NONE) { + ata_sg_init_one(qc, buf, buflen); + qc->nsect = buflen / ATA_SECT_SIZE; + } + + arg.waiting = &wait; + arg.tf = tf; + qc->private_data = &arg; + qc->complete_fn = ata_qc_complete_internal; + + if (ata_qc_issue(qc)) + goto issue_fail; + + spin_unlock_irqrestore(&ap->host_set->lock, flags); + + if (!wait_for_completion_timeout(&wait, ATA_TMOUT_INTERNAL)) { + spin_lock_irqsave(&ap->host_set->lock, flags); + + /* We're racing with irq here. If we lose, the + * following test prevents us from completing the qc + * again. If completion irq occurs after here but + * before the caller cleans up, it will result in a + * spurious interrupt. We can live with that. + */ + if (arg.waiting) { + qc->err_mask = AC_ERR_OTHER; + ata_qc_complete(qc); + printk(KERN_WARNING "ata%u: qc timeout (cmd 0x%x)\n", + ap->id, command); + } + + spin_unlock_irqrestore(&ap->host_set->lock, flags); + } + + return arg.err_mask; + + issue_fail: + ata_qc_free(qc); + spin_unlock_irqrestore(&ap->host_set->lock, flags); + return AC_ERR_OTHER; +} + static int ata_qc_wait_err(struct ata_queued_cmd *qc, struct completion *wait) { -- cgit v1.2.3 From a012370322eafee642369784ff71afe81f5a8592 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 13 Dec 2005 14:49:31 +0900 Subject: [PATCH] libata: use ata_exec_internal() This patch converts all users of libata internal commands to use ata_exec_internal(). Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 145 ++++++++++++++------------------------------- 1 file changed, 44 insertions(+), 101 deletions(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index de80abeab06..01070366bb1 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -1198,9 +1198,8 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) u16 tmp; unsigned long xfer_modes; unsigned int using_edd; - DECLARE_COMPLETION(wait); - struct ata_queued_cmd *qc; - unsigned long flags; + struct ata_taskfile tf; + unsigned int err_mask; int rc; if (!ata_dev_present(dev)) { @@ -1221,40 +1220,26 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) ata_dev_select(ap, device, 1, 1); /* select device 0/1 */ - qc = ata_qc_new_init(ap, dev); - BUG_ON(qc == NULL); - - ata_sg_init_one(qc, dev->id, sizeof(dev->id)); - qc->dma_dir = DMA_FROM_DEVICE; - qc->tf.protocol = ATA_PROT_PIO; - qc->nsect = 1; - retry: + ata_tf_init(ap, &tf, device); + if (dev->class == ATA_DEV_ATA) { - qc->tf.command = ATA_CMD_ID_ATA; + tf.command = ATA_CMD_ID_ATA; DPRINTK("do ATA identify\n"); } else { - qc->tf.command = ATA_CMD_ID_ATAPI; + tf.command = ATA_CMD_ID_ATAPI; DPRINTK("do ATAPI identify\n"); } - qc->waiting = &wait; - qc->complete_fn = ata_qc_complete_noop; - - spin_lock_irqsave(&ap->host_set->lock, flags); - rc = ata_qc_issue(qc); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + tf.protocol = ATA_PROT_PIO; - if (rc) - goto err_out; - else - ata_qc_wait_err(qc, &wait); + err_mask = ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE, + dev->id, sizeof(dev->id)); - spin_lock_irqsave(&ap->host_set->lock, flags); - ap->ops->tf_read(ap, &qc->tf); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + if (err_mask) { + if (err_mask & ~AC_ERR_DEV) + goto err_out; - if (qc->tf.command & ATA_ERR) { /* * arg! EDD works for all test cases, but seems to return * the ATA signature for some ATAPI devices. Until the @@ -1267,14 +1252,9 @@ retry: * to have this problem. */ if ((using_edd) && (dev->class == ATA_DEV_ATA)) { - u8 err = qc->tf.feature; + u8 err = tf.feature; if (err & ATA_ABORTED) { dev->class = ATA_DEV_ATAPI; - qc->cursg = 0; - qc->cursg_ofs = 0; - qc->cursect = 0; - qc->nsect = 1; - qc->err_mask = 0; goto retry; } } @@ -2378,34 +2358,23 @@ static int ata_choose_xfer_mode(const struct ata_port *ap, static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) { - DECLARE_COMPLETION(wait); - struct ata_queued_cmd *qc; - int rc; - unsigned long flags; + struct ata_taskfile tf; /* set up set-features taskfile */ DPRINTK("set features - xfer mode\n"); - qc = ata_qc_new_init(ap, dev); - BUG_ON(qc == NULL); - - qc->tf.command = ATA_CMD_SET_FEATURES; - qc->tf.feature = SETFEATURES_XFER; - qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; - qc->tf.protocol = ATA_PROT_NODATA; - qc->tf.nsect = dev->xfer_mode; - - qc->waiting = &wait; - qc->complete_fn = ata_qc_complete_noop; - - spin_lock_irqsave(&ap->host_set->lock, flags); - rc = ata_qc_issue(qc); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + ata_tf_init(ap, &tf, dev->devno); + tf.command = ATA_CMD_SET_FEATURES; + tf.feature = SETFEATURES_XFER; + tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; + tf.protocol = ATA_PROT_NODATA; + tf.nsect = dev->xfer_mode; - if (rc) + if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) { + printk(KERN_ERR "ata%u: failed to set xfermode, disabled\n", + ap->id); ata_port_disable(ap); - else - ata_qc_wait_err(qc, &wait); + } DPRINTK("EXIT\n"); } @@ -2420,41 +2389,25 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev) { - DECLARE_COMPLETION(wait); - struct ata_queued_cmd *qc; - unsigned long flags; - int rc; - - qc = ata_qc_new_init(ap, dev); - BUG_ON(qc == NULL); + struct ata_taskfile tf; - ata_sg_init_one(qc, dev->id, sizeof(dev->id)); - qc->dma_dir = DMA_FROM_DEVICE; + ata_tf_init(ap, &tf, dev->devno); if (dev->class == ATA_DEV_ATA) { - qc->tf.command = ATA_CMD_ID_ATA; + tf.command = ATA_CMD_ID_ATA; DPRINTK("do ATA identify\n"); } else { - qc->tf.command = ATA_CMD_ID_ATAPI; + tf.command = ATA_CMD_ID_ATAPI; DPRINTK("do ATAPI identify\n"); } - qc->tf.flags |= ATA_TFLAG_DEVICE; - qc->tf.protocol = ATA_PROT_PIO; - qc->nsect = 1; - - qc->waiting = &wait; - qc->complete_fn = ata_qc_complete_noop; - - spin_lock_irqsave(&ap->host_set->lock, flags); - rc = ata_qc_issue(qc); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + tf.flags |= ATA_TFLAG_DEVICE; + tf.protocol = ATA_PROT_PIO; - if (rc) + if (ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE, + dev->id, sizeof(dev->id))) goto err_out; - ata_qc_wait_err(qc, &wait); - swap_buf_le16(dev->id, ATA_ID_WORDS); ata_dump_id(dev); @@ -2463,6 +2416,7 @@ static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev) return; err_out: + printk(KERN_ERR "ata%u: failed to reread ID, disabled\n", ap->id); ata_port_disable(ap); } @@ -2476,10 +2430,7 @@ err_out: static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev) { - DECLARE_COMPLETION(wait); - struct ata_queued_cmd *qc; - int rc; - unsigned long flags; + struct ata_taskfile tf; u16 sectors = dev->id[6]; u16 heads = dev->id[3]; @@ -2490,26 +2441,18 @@ static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev) /* set up init dev params taskfile */ DPRINTK("init dev params \n"); - qc = ata_qc_new_init(ap, dev); - BUG_ON(qc == NULL); - - qc->tf.command = ATA_CMD_INIT_DEV_PARAMS; - qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; - qc->tf.protocol = ATA_PROT_NODATA; - qc->tf.nsect = sectors; - qc->tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ - - qc->waiting = &wait; - qc->complete_fn = ata_qc_complete_noop; - - spin_lock_irqsave(&ap->host_set->lock, flags); - rc = ata_qc_issue(qc); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + ata_tf_init(ap, &tf, dev->devno); + tf.command = ATA_CMD_INIT_DEV_PARAMS; + tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; + tf.protocol = ATA_PROT_NODATA; + tf.nsect = sectors; + tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ - if (rc) + if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) { + printk(KERN_ERR "ata%u: failed to init parameters, disabled\n", + ap->id); ata_port_disable(ap); - else - ata_qc_wait_err(qc, &wait); + } DPRINTK("EXIT\n"); } -- cgit v1.2.3 From 82033adf0a4b26eb0c0c90e224848431e2a59bc6 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 13 Dec 2005 14:50:38 +0900 Subject: [PATCH] libata: remove unused functions There is no user of ata_qc_wait_err() and ata_qc_complete_noop() after ata_exec_internal() changes. Remove unused functions. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 01070366bb1..1c4dbf3e981 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -1145,30 +1145,6 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev, return AC_ERR_OTHER; } -static int ata_qc_wait_err(struct ata_queued_cmd *qc, - struct completion *wait) -{ - int rc = 0; - - if (wait_for_completion_timeout(wait, 30 * HZ) < 1) { - /* timeout handling */ - qc->err_mask |= ac_err_mask(ata_chk_status(qc->ap)); - - if (!qc->err_mask) { - printk(KERN_WARNING "ata%u: slow completion (cmd %x)\n", - qc->ap->id, qc->tf.command); - } else { - printk(KERN_WARNING "ata%u: qc timeout (cmd %x)\n", - qc->ap->id, qc->tf.command); - rc = -EIO; - } - - ata_qc_complete(qc); - } - - return rc; -} - /** * ata_dev_identify - obtain IDENTIFY x DEVICE page * @ap: port on which device we wish to probe resides @@ -3524,11 +3500,6 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, return qc; } -int ata_qc_complete_noop(struct ata_queued_cmd *qc) -{ - return 0; -} - static void __ata_qc_complete(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; -- cgit v1.2.3 From b5632303401c231bf270ef36f1013e52caf4caf9 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 13 Dec 2005 14:51:25 +0900 Subject: [PATCH] libata: remove unused qc->waiting There is no user of qc->waiting left after ata_exec_internal() changes. Kill the field. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 1c4dbf3e981..9ea10258791 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -3503,7 +3503,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, static void __ata_qc_complete(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; - unsigned int tag, do_clear = 0; + unsigned int tag; qc->flags = 0; tag = qc->tag; @@ -3511,17 +3511,8 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc) if (tag == ap->active_tag) ap->active_tag = ATA_TAG_POISON; qc->tag = ATA_TAG_POISON; - do_clear = 1; - } - - if (qc->waiting) { - struct completion *waiting = qc->waiting; - qc->waiting = NULL; - complete(waiting); - } - - if (likely(do_clear)) clear_bit(tag, &ap->qactive); + } } /** @@ -3537,7 +3528,6 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc) void ata_qc_free(struct ata_queued_cmd *qc) { assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ - assert(qc->waiting == NULL); /* nothing should be waiting */ __ata_qc_complete(qc); } -- cgit v1.2.3