From: Tony Asleson <tasleson@redhat.com>
To: qemu-devel@nongnu.org, kwolf@redhat.com
Subject: [RFC 4/4] ahci media error reporting
Date: Thu, 19 Sep 2019 14:48:47 -0500 [thread overview]
Message-ID: <20190919194847.18518-5-tasleson@redhat.com> (raw)
In-Reply-To: <20190919194847.18518-1-tasleson@redhat.com>
Initial attempt at returning a media error for ahci. This is certainly
wrong and needs serious improvement.
Signed-off-by: Tony Asleson <tasleson@redhat.com>
---
hw/ide/ahci.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index d45393c019..f487764106 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -36,6 +36,7 @@
#include "hw/ide/internal.h"
#include "hw/ide/pci.h"
#include "ahci_internal.h"
+#include "block/error_inject.h"
#include "trace.h"
@@ -999,6 +1000,22 @@ static void ncq_err(NCQTransferState *ncq_tfs)
ncq_tfs->used = 0;
}
+/*
+ * Figure out correct way to report media error, this is at best a guess
+ * and based on the output of linux kernel, not even remotely close.
+ */
+static void ncq_media_err(NCQTransferState *ncq_tfs, uint64_t err_sector)
+{
+ IDEState *ide_state = &ncq_tfs->drive->port.ifs[0];
+
+ ide_state->error = ECC_ERR;
+ ide_state->status = READY_STAT | ERR_STAT;
+ ncq_tfs->drive->port_regs.scr_err |= (1 << ncq_tfs->tag);
+ ncq_tfs->lba = err_sector;
+ qemu_sglist_destroy(&ncq_tfs->sglist);
+ ncq_tfs->used = 0;
+}
+
static void ncq_finish(NCQTransferState *ncq_tfs)
{
/* If we didn't error out, set our finished bit. Errored commands
@@ -1065,6 +1082,8 @@ static void execute_ncq_command(NCQTransferState *ncq_tfs)
{
AHCIDevice *ad = ncq_tfs->drive;
IDEState *ide_state = &ad->port.ifs[0];
+ uint64_t error_sector = 0;
+ char device_id[32];
int port = ad->port_no;
g_assert(is_ncq(ncq_tfs->cmd));
@@ -1072,6 +1091,14 @@ static void execute_ncq_command(NCQTransferState *ncq_tfs)
switch (ncq_tfs->cmd) {
case READ_FPDMA_QUEUED:
+ sprintf(device_id, "%lu", ide_state->wwn);
+
+ if (error_in_read(device_id, ncq_tfs->lba,
+ ncq_tfs->sector_count, &error_sector)) {
+ ncq_media_err(ncq_tfs, error_sector);
+ return;
+ }
+
trace_execute_ncq_command_read(ad->hba, port, ncq_tfs->tag,
ncq_tfs->sector_count, ncq_tfs->lba);
dma_acct_start(ide_state->blk, &ncq_tfs->acct,
--
2.21.0
next prev parent reply other threads:[~2019-09-19 20:05 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-19 19:48 [RFC 0/4] POC: Generating realistic block errors Tony Asleson
2019-09-19 19:48 ` [RFC 1/4] Add qapi for block error injection Tony Asleson
2019-09-20 9:03 ` Philippe Mathieu-Daudé
2019-09-20 15:17 ` Tony Asleson
2019-09-19 19:48 ` [RFC 2/4] SCSI media error reporting Tony Asleson
2019-09-19 19:48 ` [RFC 3/4] NVMe " Tony Asleson
2019-09-19 19:48 ` Tony Asleson [this message]
2019-09-19 20:43 ` [RFC 4/4] ahci " John Snow
2019-09-19 21:49 ` Tony Asleson
2019-09-20 17:22 ` John Snow
2019-09-20 8:43 ` Kevin Wolf
2019-09-20 16:18 ` John Snow
2019-09-20 19:25 ` Tony Asleson
2019-09-20 19:29 ` John Snow
2019-09-20 8:36 ` [RFC 0/4] POC: Generating realistic block errors Kevin Wolf
2019-09-20 16:41 ` Tony Asleson
2019-09-20 17:08 ` Eric Blake
2019-09-20 19:15 ` Tony Asleson
2019-09-20 18:11 ` Kevin Wolf
2019-09-20 18:55 ` Tony Asleson
2019-09-30 14:54 ` Kevin Wolf
2019-09-20 9:22 ` Stefan Hajnoczi
2019-09-20 17:28 ` Tony Asleson
2019-11-14 15:47 ` Tony Asleson
2019-11-21 10:30 ` Stefan Hajnoczi
2019-11-21 11:12 ` Kevin Wolf
2019-11-26 18:19 ` Tony Asleson
2019-11-26 19:28 ` Kevin Wolf
2019-09-20 9:25 ` Stefan Hajnoczi
2019-09-20 14:41 ` no-reply
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=20190919194847.18518-5-tasleson@redhat.com \
--to=tasleson@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.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).