From nobody Wed Nov 12 20:47:17 2025 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 ARC-Seal: i=1; a=rsa-sha256; t=1573475530; cv=none; d=zoho.com; s=zohoarc; b=mfg58zup9fg7bJaEsftYv3nGqT5pgdLnKbf0QGEvjnRvK9qDbihJVgwX9h33k++ptCYaHrSoJo1apY7cH3pj8wrJ1ap04wL2Sw8sXtWi44A/cNt+DwJmkLdba2gOo1O/pRhnZYd5Qgypj7LjXEB/7Dgs8qfyRjubwOrEW2126Bg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573475530; h=Content-Transfer-Encoding:Cc: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; bh=uEd14UYU7pOCXFmHEb5PXYLNA3h7AIuuWV+4E86c+js=; b=UWq0jYnvH0Hj5qG7drWGFAIKTqKpfej0t2aqpeB+pcNiW+rfQjz5PKxSrUJPGheFhNOvnO2I2p72Yq+lvsBF+Z61OzamAZWbZsvGBqUuOE9koElBAG4Hx4wLmxP3yIDhQRxLYL3iQwMrLTtXzboWzeUTs6yBFLrU1EAZe5C/71I= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1573475530421647.1393094947217; Mon, 11 Nov 2019 04:32:10 -0800 (PST) Received: from localhost ([::1]:51838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iU8rX-0005Ms-Se for importer@patchew.org; Mon, 11 Nov 2019 07:32:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36920) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iU8li-0007ca-84 for qemu-devel@nongnu.org; Mon, 11 Nov 2019 07:26:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iU8lh-0003Rv-0r for qemu-devel@nongnu.org; Mon, 11 Nov 2019 07:26:06 -0500 Received: from charlie.dont.surf ([128.199.63.193]:52200) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iU8ld-0003Oa-GW; Mon, 11 Nov 2019 07:26:01 -0500 Received: from apples.localdomain (unknown [194.62.217.57]) by charlie.dont.surf (Postfix) with ESMTPSA id 714AABFAE9; Mon, 11 Nov 2019 12:26:00 +0000 (UTC) From: Klaus Jensen To: qemu-block@nongnu.org Subject: [PATCH v3 10/21] nvme: add logging to error information log page Date: Mon, 11 Nov 2019 13:25:34 +0100 Message-Id: <20191111122545.252478-11-its@irrelevant.dk> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111122545.252478-1-its@irrelevant.dk> References: <20191111122545.252478-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 128.199.63.193 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: , Cc: Kevin Wolf , Javier Gonzalez , qemu-devel@nongnu.org, Max Reitz , Ross Lagerwall , Paul Durrant , Keith Busch , Stephen Bates Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This adds the nvme_set_error_page function which allows errors to be written to the error information log page. The functionality is largely unused in the device, but with this in place we can at least try to push new contributions to use it. NOTE: In violation of the specification the Error Count field is *not* retained across power off conditions because the device currently has no place to store this kind of persistent state. Cribbed from Keith's qemu-nvme tree. Signed-off-by: Klaus Jensen --- hw/block/nvme.c | 22 ++++++++++++++++++++-- hw/block/nvme.h | 2 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index f1a9b2cf5cbd..47f7c5cfcff9 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -161,6 +161,22 @@ static void nvme_irq_deassert(NvmeCtrl *n, NvmeCQueue = *cq) } } =20 +static void nvme_set_error_page(NvmeCtrl *n, uint16_t sqid, uint16_t cid, + uint16_t status, uint16_t location, uint64_t lba, uint32_t nsid) +{ + NvmeErrorLog *elp; + + elp =3D &n->elpes[n->elp_index]; + elp->error_count =3D n->error_count++; + elp->sqid =3D sqid; + elp->cid =3D cid; + elp->status_field =3D status; + elp->param_error_location =3D location; + elp->lba =3D lba; + elp->nsid =3D nsid; + n->elp_index =3D (n->elp_index + 1) % n->params.elpe; +} + static uint16_t nvme_map_prp(QEMUSGList *qsg, QEMUIOVector *iov, uint64_t = prp1, uint64_t prp2, uint32_t len, NvmeCtrl *n) { @@ -386,7 +402,9 @@ static void nvme_rw_cb(void *opaque, int ret) req->status =3D NVME_SUCCESS; } else { block_acct_failed(blk_get_stats(n->conf.blk), &req->acct); - req->status =3D NVME_INTERNAL_DEV_ERROR; + nvme_set_error_page(n, sq->sqid, cpu_to_le16(req->cid), + NVME_INTERNAL_DEV_ERROR, 0, 0, 1); + req->status =3D NVME_INTERNAL_DEV_ERROR | NVME_MORE; } if (req->has_sg) { qemu_sglist_destroy(&req->qsg); @@ -677,7 +695,7 @@ static uint16_t nvme_smart_info(NvmeCtrl *n, NvmeCmd *c= md, uint8_t rae, smart.host_read_commands[0] =3D cpu_to_le64(read_commands); smart.host_write_commands[0] =3D cpu_to_le64(write_commands); =20 - smart.number_of_error_log_entries[0] =3D cpu_to_le64(0); + smart.number_of_error_log_entries[0] =3D cpu_to_le64(n->error_count); smart.temperature[0] =3D n->temperature & 0xff; smart.temperature[1] =3D (n->temperature >> 8) & 0xff; =20 diff --git a/hw/block/nvme.h b/hw/block/nvme.h index 3fc36f577b46..d74b0e0f9b2c 100644 --- a/hw/block/nvme.h +++ b/hw/block/nvme.h @@ -100,6 +100,8 @@ typedef struct NvmeCtrl { uint64_t timestamp_set_qemu_clock_ms; /* QEMU clock time */ uint64_t starttime_ms; uint16_t temperature; + uint8_t elp_index; + uint64_t error_count; =20 QEMUTimer *aer_timer; uint8_t aer_mask; --=20 2.24.0