From: Tejun Heo <htejun@gmail.com>
To: jgarzik@pobox.com, alan@lxorguk.ukuu.org.uk, albertcc@tw.ibm.com,
linux-ide@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 08/14] libata: pass qc around intead of ap during PIO
Date: Sat, 1 Apr 2006 19:48:36 +0900 [thread overview]
Message-ID: <11438885162531-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <11438885151530-git-send-email-htejun@gmail.com>
The current code passes pointer to ap around and repeatedly performs
ata_qc_from_tag() to access the ongoing qc. This is unnatural and
makes EH synchronization cumbersome. Make PIO codes deal with qc
instead of ap.
Signed-off-by: Tejun Heo <htejun@gmail.com>
---
drivers/scsi/libata-core.c | 71 ++++++++++++++++----------------------------
1 files changed, 26 insertions(+), 45 deletions(-)
2a820c9abd25983f2776412030a5ff67f842590e
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index fe66e04..ab7a654 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -3405,7 +3405,7 @@ void ata_poll_qc_complete(struct ata_que
/**
* ata_pio_poll - poll using PIO, depending on current state
- * @ap: the target ata_port
+ * @qc: qc in progress
*
* LOCKING:
* None. (executing in kernel thread context)
@@ -3413,17 +3413,13 @@ void ata_poll_qc_complete(struct ata_que
* RETURNS:
* timeout value to use
*/
-
-static unsigned long ata_pio_poll(struct ata_port *ap)
+static unsigned long ata_pio_poll(struct ata_queued_cmd *qc)
{
- 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;
- qc = ata_qc_from_tag(ap, ap->active_tag);
- WARN_ON(qc == NULL);
-
switch (ap->hsm_task_state) {
case HSM_ST:
case HSM_ST_POLL:
@@ -3457,7 +3453,7 @@ static unsigned long ata_pio_poll(struct
/**
* ata_pio_complete - check if drive is busy or idle
- * @ap: the target ata_port
+ * @qc: qc to complete
*
* LOCKING:
* None. (executing in kernel thread context)
@@ -3465,10 +3461,9 @@ static unsigned long ata_pio_poll(struct
* RETURNS:
* Non-zero if qc completed, zero otherwise.
*/
-
-static int ata_pio_complete (struct ata_port *ap)
+static int ata_pio_complete(struct ata_queued_cmd *qc)
{
- struct ata_queued_cmd *qc;
+ struct ata_port *ap = qc->ap;
u8 drv_stat;
/*
@@ -3489,9 +3484,6 @@ static int ata_pio_complete (struct ata_
}
}
- qc = ata_qc_from_tag(ap, ap->active_tag);
- WARN_ON(qc == NULL);
-
drv_stat = ata_wait_idle(ap);
if (!ata_ok(drv_stat)) {
qc->err_mask |= __ac_err_mask(drv_stat);
@@ -3827,15 +3819,14 @@ err_out:
/**
* ata_pio_block - start PIO on a block
- * @ap: the target ata_port
+ * @qc: qc to transfer block for
*
* LOCKING:
* None. (executing in kernel thread context)
*/
-
-static void ata_pio_block(struct ata_port *ap)
+static void ata_pio_block(struct ata_queued_cmd *qc)
{
- struct ata_queued_cmd *qc;
+ struct ata_port *ap = qc->ap;
u8 status;
/*
@@ -3857,9 +3848,6 @@ static void ata_pio_block(struct ata_por
}
}
- qc = ata_qc_from_tag(ap, ap->active_tag);
- WARN_ON(qc == NULL);
-
/* check error */
if (status & (ATA_ERR | ATA_DF)) {
qc->err_mask |= AC_ERR_DEV;
@@ -3888,12 +3876,9 @@ static void ata_pio_block(struct ata_por
}
}
-static void ata_pio_error(struct ata_port *ap)
+static void ata_pio_error(struct ata_queued_cmd *qc)
{
- struct ata_queued_cmd *qc;
-
- qc = ata_qc_from_tag(ap, ap->active_tag);
- WARN_ON(qc == NULL);
+ struct ata_port *ap = qc->ap;
if (qc->tf.command != ATA_CMD_PACKET)
printk(KERN_WARNING "ata%u: dev %u PIO error\n",
@@ -3911,7 +3896,8 @@ static void ata_pio_error(struct ata_por
static void ata_pio_task(void *_data)
{
- struct ata_port *ap = _data;
+ struct ata_queued_cmd *qc = _data;
+ struct ata_port *ap = qc->ap;
unsigned long timeout;
int qc_completed;
@@ -3924,33 +3910,33 @@ fsm_start:
return;
case HSM_ST:
- ata_pio_block(ap);
+ ata_pio_block(qc);
break;
case HSM_ST_LAST:
- qc_completed = ata_pio_complete(ap);
+ qc_completed = ata_pio_complete(qc);
break;
case HSM_ST_POLL:
case HSM_ST_LAST_POLL:
- timeout = ata_pio_poll(ap);
+ timeout = ata_pio_poll(qc);
break;
case HSM_ST_TMOUT:
case HSM_ST_ERR:
- ata_pio_error(ap);
+ ata_pio_error(qc);
return;
}
if (timeout)
- ata_port_queue_task(ap, ata_pio_task, ap, timeout);
+ ata_port_queue_task(ap, ata_pio_task, qc, timeout);
else if (!qc_completed)
goto fsm_start;
}
/**
* atapi_packet_task - Write CDB bytes to hardware
- * @_data: Port to which ATAPI device is attached.
+ * @_data: qc in progress
*
* When device has indicated its readiness to accept
* a CDB, this function is called. Send the CDB.
@@ -3961,17 +3947,12 @@ fsm_start:
* LOCKING:
* Kernel thread context (may sleep)
*/
-
static void atapi_packet_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;
- qc = ata_qc_from_tag(ap, ap->active_tag);
- WARN_ON(qc == NULL);
- WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE));
-
/* sleep-wait for BSY to clear */
DPRINTK("busy wait\n");
if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) {
@@ -4011,7 +3992,7 @@ static void atapi_packet_task(void *_dat
/* PIO commands are handled by polling */
ap->hsm_task_state = HSM_ST;
- ata_port_queue_task(ap, ata_pio_task, ap, 0);
+ ata_port_queue_task(ap, ata_pio_task, qc, 0);
}
return;
@@ -4317,26 +4298,26 @@ unsigned int ata_qc_issue_prot(struct at
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, ap, 0);
+ ata_port_queue_task(ap, ata_pio_task, qc, 0);
break;
case ATA_PROT_ATAPI:
ata_qc_set_polling(qc);
ata_tf_to_host(ap, &qc->tf);
- ata_port_queue_task(ap, atapi_packet_task, ap, 0);
+ ata_port_queue_task(ap, atapi_packet_task, qc, 0);
break;
case ATA_PROT_ATAPI_NODATA:
ap->flags |= ATA_FLAG_NOINTR;
ata_tf_to_host(ap, &qc->tf);
- ata_port_queue_task(ap, atapi_packet_task, ap, 0);
+ ata_port_queue_task(ap, atapi_packet_task, qc, 0);
break;
case ATA_PROT_ATAPI_DMA:
ap->flags |= ATA_FLAG_NOINTR;
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, ap, 0);
+ ata_port_queue_task(ap, atapi_packet_task, qc, 0);
break;
default:
--
1.2.4
next prev parent reply other threads:[~2006-04-01 10:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-01 10:48 [PATCHSET] libata: prep for new EH Tejun Heo
2006-04-01 10:48 ` [PATCH 01/14] libata: report device number when PIO fails Tejun Heo
2006-04-01 10:48 ` [PATCH 09/14] libata: always generate sense if qc->err_mask is non-zero Tejun Heo
2006-04-01 20:02 ` Jeff Garzik
2006-04-01 10:48 ` [PATCH 06/14] libata: clear ATA_DFLAG_PIO before setting it Tejun Heo
2006-04-01 10:48 ` [PATCH 07/14] libata: add ATA_QCFLAG_IO Tejun Heo
2006-04-01 10:48 ` Tejun Heo [this message]
2006-04-01 10:48 ` [PATCH 03/14] libata: ATA_FLAG_IN_EH is not used, kill it Tejun Heo
2006-04-01 10:48 ` [PATCH 02/14] libata: ata_dev_revalidate() printk update Tejun Heo
2006-04-01 10:48 ` [PATCH 05/14] libata: clear only affected flags during ata_dev_configure() Tejun Heo
2006-04-01 10:48 ` [PATCH 04/14] libata: clean up constants Tejun Heo
2006-04-01 20:02 ` Jeff Garzik
2006-04-01 10:48 ` [PATCH 14/14] libata: make some libata-core routines extern Tejun Heo
2006-04-01 10:48 ` [PATCH 11/14] libata: add @cdb to ata_exec_internal() Tejun Heo
2006-04-01 10:48 ` [PATCH 13/14] libata: separate out libata-eh.c Tejun Heo
2006-04-01 10:48 ` [PATCH 10/14] libata: don't read TF directly from sense generation functions Tejun Heo
2006-04-01 20:05 ` Jeff Garzik
2006-04-01 10:48 ` [PATCH 12/14] libata: dec scmd->retries for qcs with zero err_mask Tejun Heo
2006-04-01 10:51 ` [PATCHSET] libata: prep for new EH Tejun Heo
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=11438885162531-git-send-email-htejun@gmail.com \
--to=htejun@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=albertcc@tw.ibm.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).