From nobody Sat Apr 20 04:07:52 2024 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 1642617985879276.4995642846741; Wed, 19 Jan 2022 10:46:25 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 127B116E3F92; Wed, 19 Jan 2022 18:46:22 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 66F0116E36D3 for ; Wed, 19 Jan 2022 18:45:24 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) for ; Wed, 19 Jan 2022 10:45:24 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.gmail.com with ESMTPSA id h6sm257648qkk.125.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:23 -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=s9+vsAP1a0yZ0ahfaU2tc1IwmGvUXfNxwW8QUlZ+0DE=; b=FuiPmj0dSt+d1dTavXAbjl2knZVyCYofzlftvEiq+5bYJS0COzuFeMvpVqW9rOpomn P0SPLsuddYvM9LYDFEmCDgaF/OaLt3B4JRMOzm3g+inM5Mk5c7RInPv7ReMOFnwJnr25 a4ahRAnCyHpPqN2OKsMCMHufT2pdy/LEbNPKo= 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=s9+vsAP1a0yZ0ahfaU2tc1IwmGvUXfNxwW8QUlZ+0DE=; b=3plS/fJrYrn7WF2c5Ym7teyft10XVI4AgDTAM0zTyl3Fpc9y2nhbdS6el9+yssB6d4 x1xXpg3hVmJwp9j/AGVgethj8UVJRZHJI/VtmHhg4aCuVN5tCLZAmYyDfirlqHyb5XOi XV2mP0I+O2GnKRTn6hZi1RGZMeoj+JWLT5sg+ESJroUtqPwfK0PF9ZH4TKP8mF0EVLUn 7ZMq1NvpF4aeJbjiSqTdNG7/V8pk5sUJKnXvIYPiztCf31LbYbHzgGEenl71ZcmkT+/o Mu6Mszsec5HGL39oxmRBjCCLol9GPW7frmSrX3zADHML255EQe4baPZcsWVOv722T5ai Fyqw== X-Gm-Message-State: AOAM533zNYfp9Pj/UoXwa2Y+gH83UQlmN+EQ6lDohuUykp3Gk6Enqz95 v0Y5lwYwv/5EcaaYEEorK9GCCBafJvwtSg== X-Google-Smtp-Source: ABdhPJxzau6sshmEg+l8cALOlOLJkTcXgYDTMgao9WD7mzsNo8JgGV0ehLoBXheFZWDk1m545lFC0g== X-Received: by 2002:a05:620a:178d:: with SMTP id ay13mr5411816qkb.150.1642617923296; Wed, 19 Jan 2022 10:45:23 -0800 (PST) From: Kevin O'Connor To: seabios@seabios.org Date: Wed, 19 Jan 2022 13:45:12 -0500 Message-Id: <20220119184513.1828156-5-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: 5KEIHTYTMBVKTKYGTE634DG5RUHJOCUQ X-Message-ID-Hash: 5KEIHTYTMBVKTKYGTE634DG5RUHJOCUQ 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 4/5] nvme: Pass prp1 and prp2 directly to nvme_io_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: 1642617987413100001 Content-Type: text/plain; charset="utf-8" When using a prp2 parameter, build it in nvme_prpl_xfer() and pass it directly to nvme_io_xfer(). Signed-off-by: Kevin O'Connor Reviewed-by: Alexander Graf --- src/hw/nvme.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/hw/nvme.c b/src/hw/nvme.c index bafe8bf..3a73784 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -417,33 +417,19 @@ err: /* Reads count sectors into buf. Returns DISK_RET_*. The buffer cannot cro= ss page boundaries. */ static int -nvme_io_xfer(struct nvme_namespace *ns, u64 lba, void *buf, u16 count, - int write) +nvme_io_xfer(struct nvme_namespace *ns, u64 lba, void *prp1, void *prp2, + u16 count, int write) { - u32 buf_addr =3D (u32)buf; - void *prp2; - - if (buf_addr & 0x3) { + if (((u32)prp1 & 0x3) || ((u32)prp2 & 0x3)) { /* Buffer is misaligned */ warn_internalerror(); return -1; } =20 - if ((ns->block_size * count) > (NVME_PAGE_SIZE * 2)) { - /* We need to describe more than 2 pages, rely on PRP List */ - prp2 =3D ns->prpl; - } else if ((ns->block_size * count) > NVME_PAGE_SIZE) { - /* Directly embed the 2nd page if we only need 2 pages */ - prp2 =3D (void *)(long)ns->prpl[0]; - } else { - /* One page is enough, don't expose anything else */ - prp2 =3D NULL; - } - struct nvme_sqe *io_read =3D nvme_get_next_sqe(&ns->ctrl->io_sq, write ? NVME_SQE_OPC_IO_W= RITE : NVME_SQE_OPC_IO_R= EAD, - NULL, buf, prp2); + NULL, prp1, prp2); io_read->nsid =3D ns->ns_id; io_read->dword[10] =3D (u32)lba; io_read->dword[11] =3D (u32)(lba >> 32); @@ -476,7 +462,7 @@ nvme_bounce_xfer(struct nvme_namespace *ns, u64 lba, vo= id *buf, u16 count, if (write) memcpy(ns->dma_buffer, buf, blocks * ns->block_size); =20 - int res =3D nvme_io_xfer(ns, lba, ns->dma_buffer, blocks, write); + int res =3D nvme_io_xfer(ns, lba, ns->dma_buffer, NULL, blocks, write); =20 if (!write && res >=3D 0) memcpy(buf, ns->dma_buffer, res * ns->block_size); @@ -516,7 +502,7 @@ nvme_prpl_xfer(struct nvme_namespace *ns, u64 lba, void= *buf, u16 count, 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)) - return nvme_io_xfer(ns, lba, buf, count, write); + return nvme_io_xfer(ns, lba, buf, NULL, count, write); =20 /* Every request has to be page aligned */ if (base & ~NVME_PAGE_MASK) @@ -536,7 +522,18 @@ nvme_prpl_xfer(struct nvme_namespace *ns, u64 lba, voi= d *buf, u16 count, return nvme_bounce_xfer(ns, lba, buf, count, write); } =20 - return nvme_io_xfer(ns, lba, buf, count, write); + void *prp2; + if ((ns->block_size * count) > (NVME_PAGE_SIZE * 2)) { + /* We need to describe more than 2 pages, rely on PRP List */ + prp2 =3D ns->prpl; + } else if ((ns->block_size * count) > NVME_PAGE_SIZE) { + /* Directly embed the 2nd page if we only need 2 pages */ + prp2 =3D (void *)(long)ns->prpl[0]; + } else { + /* One page is enough, don't expose anything else */ + prp2 =3D NULL; + } + return nvme_io_xfer(ns, lba, buf, prp2, count, write); } =20 static int --=20 2.31.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org