From nobody Mon Feb 9 20:11:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568923523; cv=none; d=zoho.com; s=zohoarc; b=edYKDaWsNSqCcGERw3B5eiFD5NJG4RhKOIHE0w5pD5zmfnfPDcxGQq6LouHc61+N+08WmQHFhaDTyodFnsSdCK5zKzyp5ZBrfC0iQTTMxUMxeq/8QFFwNog3Vud2lgiGlZ8F4eX4hxMFZyCdGYd5vGi28Z9Idc9hW4r4XpNasdc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568923523; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=GNlKdEE4dWRYaByGHy2fDjW0KB9g5+3oIBboKnUlQIs=; b=n5DTojlK+566UZ2vReC4ZPFZb+1rUCvegFFSCB0liXcDvl3+tey2GQlKv151u+Pz8tSWt0PcZ02DcyWnncbXmqQ+2A1fJU56q8Fq/DGdSCimzjR0Mdroi4Y85XYrM5FqvnsfY3rs0AItMo6/ExOwfIQ6sPoDK+GcFrGvdIKfs/8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568923523874951.0085767575785; Thu, 19 Sep 2019 13:05:23 -0700 (PDT) Received: from localhost ([::1]:48288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB2g5-0000PX-7b for importer@patchew.org; Thu, 19 Sep 2019 16:05:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45488) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB2dA-0006FQ-6N for qemu-devel@nongnu.org; Thu, 19 Sep 2019 16:02:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iB2QA-00027N-JA for qemu-devel@nongnu.org; Thu, 19 Sep 2019 15:48:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44528) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iB2QA-00026j-Ds for qemu-devel@nongnu.org; Thu, 19 Sep 2019 15:48:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 77C2230860DF for ; Thu, 19 Sep 2019 19:48:53 +0000 (UTC) Received: from sulaco.redhat.com (ovpn-112-12.phx2.redhat.com [10.3.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC4DF5D6D0; Thu, 19 Sep 2019 19:48:52 +0000 (UTC) From: Tony Asleson 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 Message-Id: <20190919194847.18518-5-tasleson@redhat.com> In-Reply-To: <20190919194847.18518-1-tasleson@redhat.com> References: <20190919194847.18518-1-tasleson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 19 Sep 2019 19:48:53 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Initial attempt at returning a media error for ahci. This is certainly wrong and needs serious improvement. Signed-off-by: Tony Asleson --- 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" =20 #include "trace.h" =20 @@ -999,6 +1000,22 @@ static void ncq_err(NCQTransferState *ncq_tfs) ncq_tfs->used =3D 0; } =20 +/* + * 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 =3D &ncq_tfs->drive->port.ifs[0]; + + ide_state->error =3D ECC_ERR; + ide_state->status =3D READY_STAT | ERR_STAT; + ncq_tfs->drive->port_regs.scr_err |=3D (1 << ncq_tfs->tag); + ncq_tfs->lba =3D err_sector; + qemu_sglist_destroy(&ncq_tfs->sglist); + ncq_tfs->used =3D 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 =3D ncq_tfs->drive; IDEState *ide_state =3D &ad->port.ifs[0]; + uint64_t error_sector =3D 0; + char device_id[32]; int port =3D ad->port_no; =20 g_assert(is_ncq(ncq_tfs->cmd)); @@ -1072,6 +1091,14 @@ static void execute_ncq_command(NCQTransferState *nc= q_tfs) =20 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, --=20 2.21.0