From nobody Sun Dec 7 08:41:24 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 1642617974831197.05680726000844; Wed, 19 Jan 2022 10:46:14 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 2027916E3F90; Wed, 19 Jan 2022 18:46:11 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 890FD16E36D3 for ; Wed, 19 Jan 2022 18:45:23 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) for ; Wed, 19 Jan 2022 10:45:23 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.gmail.com with ESMTPSA id s126sm245250qke.135.2022.01.19.10.45.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 10:45:22 -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=hoG29dW98WNHLfPSddiy8h/kCG/PcL4XfsZJYjN8p6A=; b=RZ30ZzqfLx5yvKAXvSI0h7r9eUlfxkkyCtuMBoNS+V/Ert2d4tR78Xwoj9uFNvjOY0 O8W4+42OwYYCfdid9dbhslOTXm1e03JplN8tfb+LqZtmGUQOvx7XTYE2IBOGOCoyV09y 7DRjjLKEL3bb0tdRo4gwfS8v9kFT0BAMzdj/k= 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=hoG29dW98WNHLfPSddiy8h/kCG/PcL4XfsZJYjN8p6A=; b=iZbiRUuQzW9xw2WfSbhAU8wCj4stkxm/0PR3TPw8cA/dTEWxyBcjyNgWkzFZL2ZygS ebXeJJoWIls4aqiBHOE0g7dxqTmGXUejUwOd6I7QmwFd/eKBhxgBNebtMfD8lYVmeRqY L5saq00Z6MDMy5+Xkhv8fww7nAhYqYUaCtUsCSpOOvodk7jEaUB6AOZrQQAxtuiqTYkM ha0HxGAiFcEyXQtTYTMcq6oHmI1+gtkBKCSnABdwSyfjJ5xtm9JwvZDLavqn9oHSAcro PCkEMpoQlrSP/AnnALJ84RE8kosiahY3nVPTjZytM+2hZcie8sBd0h8zk3a5NNox5NDU 78QA== X-Gm-Message-State: AOAM530tcIYe8BUn8feWPgGN+WKLmFmEu85GPwqCAkYPGVCCZovMtKSO Hq6MLB67MMXiEhhQziNLVdBFwKP+897Evw== X-Google-Smtp-Source: ABdhPJzb15+8kfD0DtWCk6g9fRt/rOOhDFaNO4n9agyT3q9srZfvXjjOTCYG+9G9lYNL5I0fjlv5pA== X-Received: by 2002:a05:620a:1987:: with SMTP id bm7mr18676737qkb.450.1642617922407; Wed, 19 Jan 2022 10:45:22 -0800 (PST) From: Kevin O'Connor To: seabios@seabios.org Date: Wed, 19 Jan 2022 13:45:11 -0500 Message-Id: <20220119184513.1828156-4-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: TG3JPZNYE62RXKZ6TI2JXZWVYR6PXUKC X-Message-ID-Hash: TG3JPZNYE62RXKZ6TI2JXZWVYR6PXUKC 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 3/5] nvme: Convert nvme_build_prpl() to nvme_prpl_xfer() 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: 1642617976900100001 Content-Type: text/plain; charset="utf-8" Rename nvme_build_prpl() to nvme_prpl_xfer() and directly invoke nvme_io_xfer() or nvme_bounce_xfer() from that function. Signed-off-by: Kevin O'Connor --- src/hw/nvme-int.h | 1 - src/hw/nvme.c | 42 ++++++++++++++++-------------------------- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/hw/nvme-int.h b/src/hw/nvme-int.h index a4c1555..9564c17 100644 --- a/src/hw/nvme-int.h +++ b/src/hw/nvme-int.h @@ -125,7 +125,6 @@ struct nvme_namespace { =20 /* Page List */ u32 prpl_len; - void *prp1; u64 prpl[NVME_MAX_PRPL_ENTRIES]; }; =20 diff --git a/src/hw/nvme.c b/src/hw/nvme.c index fd7c1d0..bafe8bf 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -499,10 +499,13 @@ static int nvme_add_prpl(struct nvme_namespace *ns, u= 64 base) return 0; } =20 -static int nvme_build_prpl(struct nvme_namespace *ns, void *op_buf, u16 co= unt) +// Transfer data using page list (if applicable) +static int +nvme_prpl_xfer(struct nvme_namespace *ns, u64 lba, void *buf, u16 count, + int write) { int first_page =3D 1; - u32 base =3D (long)op_buf; + u32 base =3D (long)buf; s32 size; =20 if (count > ns->max_req_size) @@ -512,31 +515,28 @@ static int nvme_build_prpl(struct nvme_namespace *ns,= void *op_buf, u16 count) =20 size =3D count * ns->block_size; /* Special case for transfers that fit into PRP1, but are unaligned */ - if (((size + (base & ~NVME_PAGE_MASK)) <=3D NVME_PAGE_SIZE)) { - ns->prp1 =3D op_buf; - return count; - } + if (((size + (base & ~NVME_PAGE_MASK)) <=3D NVME_PAGE_SIZE)) + return nvme_io_xfer(ns, lba, buf, count, write); =20 /* Every request has to be page aligned */ if (base & ~NVME_PAGE_MASK) - return 0; + return nvme_bounce_xfer(ns, lba, buf, count, write); =20 /* Make sure a full block fits into the last chunk */ if (size & (ns->block_size - 1ULL)) - return 0; + return nvme_bounce_xfer(ns, lba, buf, count, write); =20 for (; size > 0; base +=3D NVME_PAGE_SIZE, size -=3D NVME_PAGE_SIZE) { if (first_page) { /* First page is special */ - ns->prp1 =3D (void*)base; first_page =3D 0; continue; } if (nvme_add_prpl(ns, base)) - return 0; + return nvme_bounce_xfer(ns, lba, buf, count, write); } =20 - return count; + return nvme_io_xfer(ns, lba, buf, count, write); } =20 static int @@ -737,24 +737,14 @@ nvme_scan(void) static int nvme_cmd_readwrite(struct nvme_namespace *ns, struct disk_op_s *op, int wr= ite) { - u16 i, blocks; - + int i; 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; - - blocks =3D nvme_build_prpl(ns, op_buf, blocks_remaining); - if (blocks) { - int res =3D nvme_io_xfer(ns, op->lba + i, ns->prp1, blocks, wr= ite); - if (res < 0) - return DISK_RET_EBADTRACK; - } else { - int res =3D nvme_bounce_xfer(ns, op->lba + i, op_buf, blocks, = write); - if (res < 0) - return DISK_RET_EBADTRACK; - blocks =3D res; - } - + int blocks =3D nvme_prpl_xfer(ns, op->lba + i, op_buf, + blocks_remaining, write); + if (blocks < 0) + return DISK_RET_EBADTRACK; i +=3D blocks; } =20 --=20 2.31.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org