From nobody Mon Sep 16 19:48:03 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 1642783792118767.370692451092; Fri, 21 Jan 2022 08:49:52 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 29D0016E4194; Fri, 21 Jan 2022 16:49:48 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 1F53E16E3D81 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:53 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.gmail.com with ESMTPSA id m144sm3198706qke.37.2022.01.21.08.48.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jan 2022 08:48:52 -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=I+UV7q/4V6C2AYowtgm3Rcxp3O18CcAHf5gUk3KTblk=; b=VKKaNRZw7usHQ1etqVMDaZ1eVjRXvFJNV/kTg74Ound61Ar8Gk6loMoZj+bfLQ1L5h /p/bWC4yQmVZTtllE3HifM4ar4kY964z9XXbUPnHzsLpLD5P4/k6yICW7Pw4P5WUhgN1 7SLpmH4OshFjkL14igeZFK/ZCJPPc9N2UXHHs= 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=I+UV7q/4V6C2AYowtgm3Rcxp3O18CcAHf5gUk3KTblk=; b=o27238S4zOIlhXUqJygm23WSBlDkEX7lIJscaFmO1ovzym0VMoSioqzMtYGEnnooSO Gffua/h8Q1Iv6x+k1ZUSB7s/2TerQTSISdBpN7i2AhGQ9MgNasffgA/yn83K9VKQIVJz nmZ0Xh2UUYIQBeewXPuWpBuiOmCEjUSybMllGAFdDWqH5mnqq29XDcUswM6TiBWEiKtI FgMkmczPpPOeqSfWfTXGEVKGsGGljB/j2/VH0rryswksFq9/GughZmRpLPvna1mPVtpY nVDDWe/EJxvAWg1uURuwet0CXQz1qHh+TxCKghvBC+AYUg0L+kQAMNdocxsKmhe5cY+5 riQg== X-Gm-Message-State: AOAM5321/aAL3WHeNIoBjD1hXrFmS8WLlL7MOxdY9LF/0LT9zfjfpO6P t3sCc9GTEbpiMW3YDtXivk5hCaVDdggP6Q== X-Google-Smtp-Source: ABdhPJwbTroy4ULtRl3cRPFD1/q5jwnBcxE2J+kt2RfKq5YmzdwWwdygCw+J8/5P7CqcFWS0iFE62g== X-Received: by 2002:a05:622a:1981:: with SMTP id u1mr3907592qtc.491.1642783732922; Fri, 21 Jan 2022 08:48:52 -0800 (PST) From: Kevin O'Connor To: seabios@seabios.org Date: Fri, 21 Jan 2022 11:48:45 -0500 Message-Id: <20220121164848.2000294-4-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: FSP3C3TC7MRBUMMQJOWYRCQRAKRCCQBH X-Message-ID-Hash: FSP3C3TC7MRBUMMQJOWYRCQRAKRCCQBH 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] [PATCHv2 3/6] 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: 1642783794330100001 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 Reviewed-by: Alexander Graf --- src/hw/nvme-int.h | 1 - src/hw/nvme.c | 46 ++++++++++++++++++++-------------------------- 2 files changed, 20 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 d656e9b..eee7d17 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -498,10 +498,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) @@ -511,31 +514,32 @@ 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; + goto bounce; =20 /* Make sure a full block fits into the last chunk */ if (size & (ns->block_size - 1ULL)) - return 0; + goto bounce; =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; + goto bounce; } =20 - return count; + return nvme_io_xfer(ns, lba, buf, count, write); + +bounce: + /* Use bounce buffer to make transfer */ + return nvme_bounce_xfer(ns, lba, buf, count, write); } =20 static int @@ -736,24 +740,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