From: Albert Lee <albertcc@tw.ibm.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: IDE Linux <linux-ide@vger.kernel.org>,
Tejun Heo <htejun@gmail.com>, Doug Maxey <dwm@maxeymade.com>
Subject: [PATCH 3/5] libata-dev: Let ata_hsm_move() work with both irq-pio and polling pio
Date: Mon, 13 Mar 2006 15:45:31 +0800 [thread overview]
Message-ID: <4415231B.1090906@tw.ibm.com> (raw)
In-Reply-To: <4415203F.4070103@tw.ibm.com>
Let ata_hsm_move() work with both irq-pio and polling pio codepath.
Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
---
Changes:
- add a new parameter "in_wq" for polling pio
- add return value "poll_next" to tell polling pio task whether the HSM is finished
- merge code from ata_pio_first_block() to the HSM_ST_FIRST state.
- call ata_poll_qc_complete() if called from the workqueue
--- 02_minor_fix/drivers/scsi/libata-core.c 2006-03-13 12:47:13.000000000 +0800
+++ 03_support_wq/drivers/scsi/libata-core.c 2006-03-13 13:28:05.000000000 +0800
@@ -3770,11 +3770,36 @@ static void ata_pio_error(struct ata_por
ata_poll_qc_complete(qc);
}
-static void ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
- u8 status)
+/**
+ * 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 != ((qc->tf.flags & ATA_TFLAG_POLLING) ||
+ (ap->hsm_task_state == HSM_ST_FIRST &&
+ ((qc->tf.protocol == ATA_PROT_PIO &&
+ (qc->tf.flags & ATA_TFLAG_WRITE)) ||
+ (is_atapi_taskfile(&qc->tf) &&
+ !(qc->dev->flags & ATA_DFLAG_CDB_INTR))))));
+
/* check error */
if (unlikely(status & (ATA_ERR | ATA_DF))) {
qc->err_mask |= AC_ERR_DEV;
@@ -3784,6 +3809,14 @@ static void ata_hsm_move(struct ata_port
fsm_start:
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 */
@@ -3792,8 +3825,36 @@ fsm_start:
goto fsm_start;
}
- atapi_send_cdb(ap, qc);
+ /* 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.protocol == ATA_PROT_PIO) {
+ /* PIO data out protocol.
+ * send first data block.
+ */
+
+ /* 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;
case HSM_ST:
@@ -3833,6 +3894,7 @@ fsm_start:
}
ata_altstatus(ap); /* flush */
+ poll_next = 1;
break;
case HSM_ST_LAST:
@@ -3851,7 +3913,12 @@ fsm_start:
ap->hsm_task_state = HSM_ST_IDLE;
/* complete taskfile transaction */
- ata_qc_complete(qc);
+ if (in_wq)
+ ata_poll_qc_complete(qc);
+ else
+ ata_qc_complete(qc);
+
+ poll_next = 0;
break;
case HSM_ST_ERR:
@@ -3865,12 +3932,20 @@ fsm_start:
WARN_ON(qc->err_mask == 0);
ap->hsm_task_state = HSM_ST_IDLE;
- ata_qc_complete(qc);
+
+ if (in_wq)
+ ata_poll_qc_complete(qc);
+ else
+ ata_qc_complete(qc);
+
+ poll_next = 0;
break;
default:
+ poll_next = 0;
BUG();
}
+ return poll_next;
}
static void ata_pio_task(void *_data)
@@ -4620,7 +4695,7 @@ inline unsigned int ata_host_intr (struc
/* ack bmdma irq events */
ap->ops->irq_clear(ap);
- ata_hsm_move(ap, qc, status);
+ ata_hsm_move(ap, qc, status, 0);
return 1; /* irq handled */
idle_irq:
next prev parent reply other threads:[~2006-03-13 7:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-09 8:41 [PATCH/RFC 0/5] libata-dev: integrate polling pio with irq-pio Albert Lee
2006-03-09 8:45 ` [PATCH/RFC 1/5] libata-dev: Move out the HSM code from ata_host_intr() Albert Lee
2006-03-10 9:18 ` Tejun Heo
2006-03-09 8:49 ` [PATCH/RFC 2/5] libata-dev: Minor fix for ata_hsm_move() to work with ata_host_intr() Albert Lee
2006-03-10 9:22 ` Tejun Heo
2006-03-09 8:51 ` [PATCH/RFC 3/5] libata-dev: Let ata_hsm_move() work with both irq-pio and polling pio Albert Lee
2006-03-10 9:31 ` Tejun Heo
2006-03-10 13:52 ` Albert Lee
2006-03-10 17:32 ` Tejun Heo
2006-03-09 8:54 ` [PATCH/RFC 4/5] libata-dev: Convert ata_pio_task() to use the new ata_hsm_move() Albert Lee
2006-03-10 9:35 ` Tejun Heo
2006-03-10 14:25 ` Albert Lee
2006-03-09 8:56 ` [PATCH/RFC 5/5] libata-dev: Cleanup unused enums/functions Albert Lee
2006-03-10 9:38 ` [PATCH/RFC 0/5] libata-dev: integrate polling pio with irq-pio Tejun Heo
2006-03-12 0:37 ` Jeff Garzik
2006-03-13 7:33 ` [PATCH 0/5] libata-dev: integrate polling pio with irq-pio (respin) Albert Lee
2006-03-13 7:37 ` [PATCH 1/5] libata-dev: Move out the HSM code from ata_host_intr() Albert Lee
2006-03-13 7:41 ` [PATCH 2/5] libata-dev: Minor fix for ata_hsm_move() to work with ata_host_intr() Albert Lee
2006-03-13 7:45 ` Albert Lee [this message]
2006-03-13 7:55 ` [PATCH 3/5] libata-dev: Let ata_hsm_move() work with both irq-pio and polling pio Jeff Garzik
2006-03-13 8:42 ` [PATCH 1/1] libata-dev: Make the the in_wq check as an inline function Albert Lee
2006-03-13 8:56 ` Jeff Garzik
2006-03-13 7:47 ` [PATCH 4/5] libata-dev: Convert ata_pio_task() to use the new ata_hsm_move() Albert Lee
2006-03-13 7:49 ` [PATCH 5/5] libata-dev: Cleanup unused enums/functions Albert Lee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4415231B.1090906@tw.ibm.com \
--to=albertcc@tw.ibm.com \
--cc=albertl@mail.com \
--cc=dwm@maxeymade.com \
--cc=htejun@gmail.com \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).