From nobody Mon Dec 8 03:30:10 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=koconnor.net Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1642617951564154.23228888716994; Wed, 19 Jan 2022 10:45:51 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id A917916E3F8C; Wed, 19 Jan 2022 18:45:47 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 2732D16E36D3 for ; Wed, 19 Jan 2022 18:45:22 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) for ; Wed, 19 Jan 2022 10:45:21 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.gmail.com with ESMTPSA id h21sm188289qth.16.2022.01.19.10.45.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 10:45:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=koconnor.net; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=s5ccvKtIo8BNaxWm83/EuJ4Egqkl3WJMxhnuuoFPDAk=; b=EAHtH3QN85B139ES24NQjjz+UMdIChfWDHGrnEcT7fgWkHbEqL5kCQ78wtrZdcdd82 wyN9h0iEG9OJ0JbAQagU9e7M6Wo3kUyV60lTAKmp7fC3K71K7FXuNSZR5yCIN03lITD+ +kYsttR9T3V9DdzBzekuFUmlYWa+12gWW7pm0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s5ccvKtIo8BNaxWm83/EuJ4Egqkl3WJMxhnuuoFPDAk=; b=EbprigWucw6qsWnmk2+p1n79mdPb+FuSRAHltl1Kuxkpz+IcODAZ1WGfVlrOC3F+in kGOdHQ/qnGus4TuY1K4h3NIQ/cKJ2VrEy6oaSDWIiU0TWVhQCjd2BCvmNq1tiLu02571 y5y4E9z4CHX2LIgjU9zeIh9zMz//Cqg1K4kBrkDLWP54ALJ8BY2l+/zV4YT8gnMr2mRB ZYu8Q2bO8AN6VwvqJohnJXsMJB58htgZ0iJjMn5tx4EreFUp8OgUOjFP+ekqfTiijT5d S3xV4nkILX/LPj3oM31yMy5f78eURadBmv2CSQelUP/HLojWu1A3nAvB1U7oymu6azRF wQzg== X-Gm-Message-State: AOAM532CUS/AsEHscmoRDJr1UG6AjFbK31EhuXAbse+nwOplMmqX+FXl I+oGQHFYIthuf/TeX9etJJQliCY+IcuvCw== X-Google-Smtp-Source: ABdhPJzxsaHyOI0kD+ygu2IGy2d9wxyt8RXxCpbj9YZFAcJxiUTGu7ODr7+RzYKMoM8kffgoFl/zvA== X-Received: by 2002:a05:6214:5288:: with SMTP id kj8mr28930181qvb.101.1642617920927; Wed, 19 Jan 2022 10:45:20 -0800 (PST) From: Kevin O'Connor To: seabios@seabios.org Date: Wed, 19 Jan 2022 13:45:09 -0500 Message-Id: <20220119184513.1828156-2-kevin@koconnor.net> In-Reply-To: <20220119184513.1828156-1-kevin@koconnor.net> References: <20220119184513.1828156-1-kevin@koconnor.net> MIME-Version: 1.0 X-Spam-Level: ** Message-ID-Hash: ERRL7PLGQVGGBGUFC33UDMJXRYWXHQ5K X-Message-ID-Hash: ERRL7PLGQVGGBGUFC33UDMJXRYWXHQ5K X-MailFrom: kevin@koconnor.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.5rc1 Precedence: list Subject: [SeaBIOS] [PATCH 1/5] nvme: Rework nvme_io_readwrite() to return -1 on error List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: --- X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1642617952598100001 Content-Type: text/plain; charset="utf-8" Rename nvme_io_readwrite() to nvme_io_xfer() and change it so it implements the debugging dprintf() and it returns -1 on an error. Signed-off-by: Kevin O'Connor Reviewed-by: Alexander Graf --- src/hw/nvme.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/hw/nvme.c b/src/hw/nvme.c index f035fa2..a97501b 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -417,8 +417,8 @@ err: /* Reads count sectors into buf. Returns DISK_RET_*. The buffer cannot cro= ss page boundaries. */ static int -nvme_io_readwrite(struct nvme_namespace *ns, u64 lba, char *buf, u16 count, - int write) +nvme_io_xfer(struct nvme_namespace *ns, u64 lba, void *buf, u16 count, + int write) { u32 buf_addr =3D (u32)buf; void *prp2; @@ -426,7 +426,7 @@ nvme_io_readwrite(struct nvme_namespace *ns, u64 lba, c= har *buf, u16 count, if (buf_addr & 0x3) { /* Buffer is misaligned */ warn_internalerror(); - return DISK_RET_EBADTRACK; + return -1; } =20 if ((ns->block_size * count) > (NVME_PAGE_SIZE * 2)) { @@ -457,10 +457,12 @@ nvme_io_readwrite(struct nvme_namespace *ns, u64 lba,= char *buf, u16 count, dprintf(2, "read io: %08x %08x %08x %08x\n", cqe.dword[0], cqe.dword[1], cqe.dword[2], cqe.dword[3]); =20 - return DISK_RET_EBADTRACK; + return -1; } =20 - return DISK_RET_SUCCESS; + dprintf(5, "ns %u %s lba %llu+%u\n", ns->ns_id, write ? "write" : "rea= d", + lba, count); + return count; } =20 static void nvme_reset_prpl(struct nvme_namespace *ns) @@ -716,20 +718,18 @@ nvme_scan(void) static int nvme_cmd_readwrite(struct nvme_namespace *ns, struct disk_op_s *op, int wr= ite) { - int res =3D DISK_RET_SUCCESS; u16 const max_blocks =3D NVME_PAGE_SIZE / ns->block_size; u16 i, blocks; =20 - for (i =3D 0; i < op->count && res =3D=3D DISK_RET_SUCCESS;) { + for (i =3D 0; i < op->count;) { u16 blocks_remaining =3D op->count - i; char *op_buf =3D op->buf_fl + i * ns->block_size; =20 blocks =3D nvme_build_prpl(ns, op_buf, blocks_remaining); if (blocks) { - res =3D nvme_io_readwrite(ns, op->lba + i, ns->prp1, blocks, w= rite); - dprintf(5, "ns %u %s lba %llu+%u: %d\n", ns->ns_id, write ? "w= rite" - : "r= ead", - op->lba, blocks, res); + int res =3D nvme_io_xfer(ns, op->lba + i, ns->prp1, blocks, wr= ite); + if (res < 0) + return DISK_RET_EBADTRACK; } else { blocks =3D blocks_remaining < max_blocks ? blocks_remaining : max_blocks; @@ -738,12 +738,12 @@ nvme_cmd_readwrite(struct nvme_namespace *ns, struct = disk_op_s *op, int write) memcpy(ns->dma_buffer, op_buf, blocks * ns->block_size); } =20 - res =3D nvme_io_readwrite(ns, op->lba + i, ns->dma_buffer, blo= cks, write); - dprintf(5, "ns %u %s lba %llu+%u: %d\n", ns->ns_id, write ? "w= rite" - : "r= ead", - op->lba + i, blocks, res); + int res =3D nvme_io_xfer(ns, op->lba + i, ns->dma_buffer, + blocks, write); + if (res < 0) + return DISK_RET_EBADTRACK; =20 - if (!write && res =3D=3D DISK_RET_SUCCESS) { + if (!write) { memcpy(op_buf, ns->dma_buffer, blocks * ns->block_size); } } @@ -751,7 +751,7 @@ nvme_cmd_readwrite(struct nvme_namespace *ns, struct di= sk_op_s *op, int write) i +=3D blocks; } =20 - return res; + return DISK_RET_SUCCESS; } =20 int --=20 2.31.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org