From nobody Mon Sep 16 19:37:26 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 16427838049681004.3205968993769; Fri, 21 Jan 2022 08:50:04 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 145F716E4196; Fri, 21 Jan 2022 16:50:00 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id D7C5516E3D81 for ; Fri, 21 Jan 2022 16:48:54 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) for ; Fri, 21 Jan 2022 08:48:54 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.gmail.com with ESMTPSA id de15sm3278112qkb.4.2022.01.21.08.48.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jan 2022 08:48:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=koconnor.net; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8K2XFJDza5yFFi0J5mpeJJRR4n4W6t719sA2FYfGxQE=; b=b5SrFXUcsTJWqcwr8h69jesYY6Rnry8iZuAh4ErqrUD5B99n5zFxjPfPRazE8EEkA6 OXqLqiGPkrD9jBHEs62xVgiALrYohxf8ZroatKLiD/wPuT8Kqha4+WzmvWbxQHsCeeSc NWGhWyPTm9I6IP4+VmUrzJZ1a0yJfSMMSArMo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8K2XFJDza5yFFi0J5mpeJJRR4n4W6t719sA2FYfGxQE=; b=MlnQv7mrwFo/E9NVrsmJGFn8C4lGUrVNWpelG+NfgfhPSV3HaTZKY1bV6K0849TxZl x0D4HEmZbk0enhWlck+vtoEdW22lPQBeWmiLF8C8vArm52NfqzxqL65YDrJZvMzt3rvg KwtzRVhCQElZycgdsDfzjphEIvdlAcEuVwZhKINfT7BfA6785F3vQUa6xrKY3jlCceyt q43MCErniehE+GYRM0bLRxuZmMHMCvuHHmoAUt9hpuvRS6uvCOT86/DxEhLsUfi4Bo3x Z8citnbiK9iKSGPwTCnjQgIwViyvkki84p1gpgjGiohkTlL3oGesFqdh/489+2iK99H/ x6Ew== X-Gm-Message-State: AOAM532XtWKi1dyQKaYRF3kDtEL7KlY66mbYTDf1Xs2MUqpkcpwAZPLs 0u6zLivcU/GzcYHoC5cCbgXAkHuf28eJjg== X-Google-Smtp-Source: ABdhPJzmV0s/6Up+251viZFrXSFI7k46B1xO+5CgnG7ggzqyDDE/0uP9GX0hNkb1TIhjFcJX61pXUg== X-Received: by 2002:a05:6214:20aa:: with SMTP id 10mr4567763qvd.40.1642783733788; Fri, 21 Jan 2022 08:48:53 -0800 (PST) From: Kevin O'Connor To: seabios@seabios.org Date: Fri, 21 Jan 2022 11:48:46 -0500 Message-Id: <20220121164848.2000294-5-kevin@koconnor.net> In-Reply-To: <20220121164848.2000294-1-kevin@koconnor.net> References: <20220121164848.2000294-1-kevin@koconnor.net> MIME-Version: 1.0 X-Spam-Level: *** Message-ID-Hash: MHJYOAVTLMMHAIOFYUWTLSV27HVYXTTM X-Message-ID-Hash: MHJYOAVTLMMHAIOFYUWTLSV27HVYXTTM 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 CC: Alexander Graf X-Mailman-Version: 3.3.5rc1 Precedence: list Subject: [SeaBIOS] [PATCHv2 4/6] 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: 1642783806658100001 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 eee7d17..20976fc 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -416,33 +416,19 @@ err: =20 /* Reads count sectors into buf. The buffer cannot cross 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); @@ -475,7 +461,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); @@ -515,7 +501,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) @@ -535,7 +521,18 @@ nvme_prpl_xfer(struct nvme_namespace *ns, u64 lba, voi= d *buf, u16 count, goto bounce; } =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 bounce: /* Use bounce buffer to make transfer */ --=20 2.31.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org