From: Tejun Heo <tj@kernel.org>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: Robert Hancock <hancockrwd@gmail.com>,
Mark Lord <kernel@teksavvy.com>, Seed <seedrubbish@gmail.com>,
IDE/ATA development list <linux-ide@vger.kernel.org>,
stable@kernel.org
Subject: [PATCH #upstream-fixes] libahci: fix result_tf handling after an ATA PIO data-in command
Date: Thu, 14 Oct 2010 10:53:35 +0200 [thread overview]
Message-ID: <4CB6C50F.60609@kernel.org> (raw)
In-Reply-To: <AANLkTin=QWXcuy6JOi1y26dWH8FG1ji3JewTXu0K=4ri@mail.gmail.com>
ATA devices don't send D2H Reg FIS after an successful ATA PIO data-in
command. The host is supposed to take the E_Status of the preceding
PIO Setup FIS. Update ahci_qc_fill_rtf() such that it takes E_Status
after a successful ATA PIO data-in command.
Without this patch, result_tf for such a command is filled with the
content of the previous D2H Reg FIS which belongs to a previous
command, which can make the command incorrectly seen as failed.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Mark Lord <kernel@teksavvy.com>
Cc: Robert Hancock <hancockrwd@gmail.com>
Cc: stable@kernel.org
---
drivers/ata/ahci.h | 1 +
drivers/ata/libahci.c | 17 ++++++++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index e5fdeeb..d1a0f5b 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -72,6 +72,7 @@ enum {
AHCI_CMD_RESET = (1 << 8),
AHCI_CMD_CLR_BUSY = (1 << 10),
+ RX_FIS_PIO_SETUP = 0x20, /* offset of PIO Setup FIS data */
RX_FIS_D2H_REG = 0x40, /* offset of D2H Register FIS data */
RX_FIS_SDB = 0x58, /* offset of SDB FIS data */
RX_FIS_UNK = 0x60, /* offset of Unknown FIS data */
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 8eea309..0c482a0 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1830,12 +1830,23 @@ static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
{
struct ahci_port_priv *pp = qc->ap->private_data;
- u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
+ u8 *rx_fis = pp->rx_fis;
if (pp->fbs_enabled)
- d2h_fis += qc->dev->link->pmp * AHCI_RX_FIS_SZ;
+ rx_fis += qc->dev->link->pmp * AHCI_RX_FIS_SZ;
+
+ /*
+ * After a successful execution of an ATA PIO data-in command,
+ * the device doesn't send D2H Reg FIS to update the TF and
+ * the host should take Status from E_Status of the preceding
+ * PIO Setup FIS.
+ */
+ if (qc->tf.protocol == ATA_PROT_PIO && qc->dma_dir == DMA_FROM_DEVICE &&
+ !(qc->flags & ATA_QCFLAG_FAILED))
+ qc->result_tf.command = (rx_fis + RX_FIS_PIO_SETUP)[15];
+ else
+ ata_tf_from_fis(rx_fis + RX_FIS_D2H_REG, &qc->result_tf);
- ata_tf_from_fis(d2h_fis, &qc->result_tf);
return true;
}
next prev parent reply other threads:[~2010-10-14 8:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-24 5:34 [BUG] libahci returns stale result tf much of the time Mark Lord
2010-09-24 5:49 ` Seed
2010-09-24 6:27 ` Mark Lord
2010-09-24 7:01 ` Seed
2010-09-24 13:11 ` Mark Lord
2010-09-24 13:24 ` Mark Lord
2010-09-24 23:26 ` Robert Hancock
2010-10-04 9:18 ` Tejun Heo
2010-10-04 17:01 ` Mark Lord
2010-10-04 17:06 ` Mark Lord
2010-10-04 17:31 ` Mark Lord
2010-10-04 18:50 ` Mark Lord
2010-10-04 19:27 ` Jeff Garzik
2010-10-04 19:35 ` Mark Lord
2010-10-04 19:42 ` Jeff Garzik
2010-10-04 19:51 ` Mark Lord
2010-10-05 7:07 ` Tejun Heo
2010-10-05 14:06 ` Mark Lord
2010-10-05 16:06 ` Tejun Heo
2010-10-06 1:00 ` Robert Hancock
2010-10-14 8:53 ` Tejun Heo [this message]
2010-10-14 21:38 ` [PATCH #upstream-fixes] libahci: fix result_tf handling after an ATA PIO data-in command Mark Lord
2010-10-15 0:24 ` Robert Hancock
2010-10-15 8:45 ` Tejun Heo
2010-10-15 22:14 ` Mark Lord
2010-10-15 0:32 ` Robert Hancock
2010-10-15 8:45 ` Tejun Heo
2010-10-15 9:00 ` [PATCH UPDATED " 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=4CB6C50F.60609@kernel.org \
--to=tj@kernel.org \
--cc=hancockrwd@gmail.com \
--cc=jgarzik@pobox.com \
--cc=kernel@teksavvy.com \
--cc=linux-ide@vger.kernel.org \
--cc=seedrubbish@gmail.com \
--cc=stable@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).