From nobody Thu Apr 25 06:26:30 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 1642619508227642.9875340086289; Wed, 19 Jan 2022 11:11:48 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 05EFD16E3F96; Wed, 19 Jan 2022 19:11:43 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 10B8016E36D3 for ; Wed, 19 Jan 2022 19:11:27 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) for ; Wed, 19 Jan 2022 11:11:26 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.gmail.com with ESMTPSA id m14sm200518qtx.44.2022.01.19.11.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 11:11:25 -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:mime-version :content-transfer-encoding; bh=uaioRibTWS7EsEB8GKWbXj5jqAw9ejR/z3WhHRpZVDw=; b=XcJeSB0xs+3C2MpLjSIpOIfV6A2NitfxmmDL5LgJJngXFSyJyoy/DG52kgAQ739vjO cKkVffwPAlxEhEeLzlU97l0bBdIHOr415od9h3kEyDvnj+PMToJ7mmzmnQqc+Wd3GrGI Z0tG9mneqJA+sfqipVKBzVrB4SlOyOA2kvNIA= 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:mime-version :content-transfer-encoding; bh=uaioRibTWS7EsEB8GKWbXj5jqAw9ejR/z3WhHRpZVDw=; b=Fqhsnw4QPWEQdwJ9LQ3AJwU6ffT+itUS+lp6o/nropAqWepjY84ODAXs4uAjuMlrCD mRzWLCSV082IAKbGBdXcXauyxqDHcKzwsLPb3I8umewWFHDz5kfHCG6psIm7CmPDOvjA njoCwffL9L62HPphBUhcnQEc25TESoJamG0NJXRThoQyOg31j0ENVEGD+tYz1MGUsqFl VZOXn9vUtXhm94ClTdxdTAilaWcayyWt9DtoXtIwnLQpRphakQlA3whrMAiuei+sHAkO DmaWUc0GNFSU8vEcHr+GcYkiWlmngEO5OIFT8t+7BDvznw86EXNnVEDcqkxXgexUj/wz TvNQ== X-Gm-Message-State: AOAM532OCkdEHeAXvnZAPF+5OZAwrtmd2U1eC6WdxvWtIFmPWMOt6cKW k0ef40qqflKXq57WUNAdnBbhLfQx8Dmmtg== X-Google-Smtp-Source: ABdhPJyzXlc40HX9S8KXOSIAGwLeNIY0iUx2IuEhLvbxaFgM6RupUd1Z5+LXCVDLBqtTb8P6enaRHw== X-Received: by 2002:a05:620a:2916:: with SMTP id m22mr13217158qkp.27.1642619485834; Wed, 19 Jan 2022 11:11:25 -0800 (PST) From: Kevin O'Connor To: seabios@seabios.org Date: Wed, 19 Jan 2022 14:11:21 -0500 Message-Id: <20220119191121.1830274-1-kevin@koconnor.net> MIME-Version: 1.0 X-Spam-Level: * Message-ID-Hash: U4HMLI7MLK3SHRCB7N5H23TZNA7PY4RL X-Message-ID-Hash: U4HMLI7MLK3SHRCB7N5H23TZNA7PY4RL 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] [PATCH] nvme: Only allocate one dma bounce buffer for all nvme drives 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: 1642619509114100001 Content-Type: text/plain; charset="utf-8" There is no need to create multiple dma bounce buffers as the BIOS disk code isn't reentrant capable. Signed-off-by: Kevin O'Connor Reviewed-by: Alexander Graf --- This is a minor cleanup on top of the previous nvme code series. -Kevin ---=20 src/hw/nvme-int.h | 3 --- src/hw/nvme.c | 14 +++++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/hw/nvme-int.h b/src/hw/nvme-int.h index f0d717d..f9c807e 100644 --- a/src/hw/nvme-int.h +++ b/src/hw/nvme-int.h @@ -117,9 +117,6 @@ struct nvme_namespace { u32 block_size; u32 metadata_size; u32 max_req_size; - - /* Page aligned buffer of size NVME_PAGE_SIZE. */ - char *dma_buffer; }; =20 /* Data structures for NVMe admin identify commands */ diff --git a/src/hw/nvme.c b/src/hw/nvme.c index 39b9138..0ba981c 100644 --- a/src/hw/nvme.c +++ b/src/hw/nvme.c @@ -20,6 +20,9 @@ #include "nvme.h" #include "nvme-int.h" =20 +// Page aligned "dma bounce buffer" of size NVME_PAGE_SIZE in high memory +static void *nvme_dma_buffer; + static void * zalloc_page_aligned(struct zone_s *zone, u32 size) { @@ -294,7 +297,8 @@ nvme_probe_ns(struct nvme_ctrl *ctrl, u32 ns_idx, u8 md= ts) ns->max_req_size =3D -1U; } =20 - ns->dma_buffer =3D zalloc_page_aligned(&ZoneHigh, NVME_PAGE_SIZE); + if (!nvme_dma_buffer) + nvme_dma_buffer =3D zalloc_page_aligned(&ZoneHigh, NVME_PAGE_SIZE); =20 char *desc =3D znprintf(MAXDESCSIZE, "NVMe NS %u: %llu MiB (%llu %u-by= te " "blocks + %u-byte metadata)", @@ -460,12 +464,12 @@ nvme_bounce_xfer(struct nvme_namespace *ns, u64 lba, = void *buf, u16 count, u16 blocks =3D count < max_blocks ? count : max_blocks; =20 if (write) - memcpy(ns->dma_buffer, buf, blocks * ns->block_size); + memcpy(nvme_dma_buffer, buf, blocks * ns->block_size); =20 - int res =3D nvme_io_xfer(ns, lba, ns->dma_buffer, NULL, blocks, write); + int res =3D nvme_io_xfer(ns, lba, nvme_dma_buffer, NULL, blocks, write= ); =20 if (!write && res >=3D 0) - memcpy(buf, ns->dma_buffer, res * ns->block_size); + memcpy(buf, nvme_dma_buffer, res * ns->block_size); =20 return res; } @@ -499,7 +503,7 @@ nvme_prpl_xfer(struct nvme_namespace *ns, u64 lba, void= *buf, u16 count, if ((ns->block_size * count) > (NVME_PAGE_SIZE * 2)) { /* We need to describe more than 2 pages, build PRP List */ u32 prpl_len =3D 0; - u64 *prpl =3D (void*)ns->dma_buffer; + u64 *prpl =3D nvme_dma_buffer; int first_page =3D 1; for (; size > 0; base +=3D NVME_PAGE_SIZE, size -=3D NVME_PAGE_SIZ= E) { if (first_page) { --=20 2.31.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org