From nobody Wed Jun 10 08:36:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+113919+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113919+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1705425075; cv=none; d=zohomail.com; s=zohoarc; b=ERAAcSEcMotFarMersqbn3niga4MrnzxChTluyAcw6End5JCLzXvoRZNaMvcjQEBB6HBT+EZkjTCSYC8xB2L/p4e5RijJO+wwaUPq5G5NjGvYprCPst0f5DCwJZ0glrPhxVXihlE8qU4e9YJelzTfVzb/kel4EtY+qwAv/P6ENs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705425075; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=dpjBVM2/noyqQSVAITd9ma25/B7hdOiwTqxAjEx5Cfo=; b=G7DG1HmsnfTy7oLcplWmTLZfI1EgkaPDDWUmN/VDcRc9SGwgBjpoiXaTQJlPcxr1YWdh6Cvz/cEi/dca/HsYdIxtR7y1YHFk+gy1gpv38207+sJINkWbMDvAgWclqf+a9AmX0Q+R4evkWZ0GP1O8EP6KCN0GP1NULlvL8nqDJ+E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113919+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1705425075650864.2894165929827; Tue, 16 Jan 2024 09:11:15 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=AmW7ymeH0CY8mbhVHkXP+NsG9XAffegfq4aapEbJE94=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1705425075; v=1; b=IxFobcjjtzjF5etRxXRA7B76+gKrlcrUWpJIiB57XXwD3yxGMv8VsqWzCKVbh/isu2Qag7Bz bOgdIfLVeBHtzmUXVb2K6gAGM0YQuiIaXN9Ig8fm3xwBYJisc8M0+hejv8VIF0dccPlTWqz7Bqi RccUCyZoZEexXzY0+uyPpftk= X-Received: by 127.0.0.2 with SMTP id IMyfYY1788612xIWwn3cM7p0; Tue, 16 Jan 2024 09:11:15 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.22113.1705425073076131665 for ; Tue, 16 Jan 2024 09:11:13 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-1-zc9Qp-5uPjKZDLcZMVJ_Pg-1; Tue, 16 Jan 2024 12:11:09 -0500 X-MC-Unique: zc9Qp-5uPjKZDLcZMVJ_Pg-1 X-Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 401A4102B627 for ; Tue, 16 Jan 2024 17:11:09 +0000 (UTC) X-Received: from dobby.home.kraxel.org (unknown [10.39.192.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0362AC15E6C; Tue, 16 Jan 2024 17:11:09 +0000 (UTC) X-Received: by dobby.home.kraxel.org (Postfix, from userid 1000) id 61AA4AEDBE; Tue, 16 Jan 2024 18:11:05 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: oliver@redhat.com, Gerd Hoffmann , Laszlo Ersek Subject: [edk2-devel] [PATCH v3 3/6] OvmfPkg/VirtNorFlashDxe: add a loop for NorFlashWriteBuffer calls. Date: Tue, 16 Jan 2024 18:11:02 +0100 Message-ID: <20240116171105.37831-4-kraxel@redhat.com> In-Reply-To: <20240116171105.37831-1-kraxel@redhat.com> References: <20240116171105.37831-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ADVsip8tO6k5uISWlZvtygh2x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1705425077338100017 Content-Type: text/plain; charset="utf-8"; x-default="true" Replace the two NorFlashWriteBuffer() calls with a loop containing a single NorFlashWriteBuffer() call. With the changes in place the code is able to handle updates larger than two P30_MAX_BUFFER_SIZE_IN_BYTES blocks, even though the patch does not actually change the size limit. Signed-off-by: Gerd Hoffmann Reviewed-by: Laszlo Ersek --- OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashD= xe/VirtNorFlash.c index 88a4d2c23fc0..3d1343b381bc 100644 --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c @@ -521,6 +521,7 @@ NorFlashWriteSingleBlock ( UINTN BlockAddress; UINT8 *OrigData; UINTN Start, End; + UINT32 Index, Count; =20 DEBUG ((DEBUG_BLKIO, "NorFlashWriteSingleBlock(Parameters: Lba=3D%ld, Of= fset=3D0x%x, *NumBytes=3D0x%x, Buffer @ 0x%08x)\n", Lba, Offset, *NumBytes,= Buffer)); =20 @@ -621,23 +622,17 @@ NorFlashWriteSingleBlock ( goto Exit; } =20 - Status =3D NorFlashWriteBuffer ( - Instance, - BlockAddress + Start, - P30_MAX_BUFFER_SIZE_IN_BYTES, - Instance->ShadowBuffer - ); - if (EFI_ERROR (Status)) { - goto Exit; - } - - if ((End - Start) > P30_MAX_BUFFER_SIZE_IN_BYTES) { + Count =3D (End - Start) / P30_MAX_BUFFER_SIZE_IN_BYTES; + for (Index =3D 0; Index < Count; Index++) { Status =3D NorFlashWriteBuffer ( Instance, - BlockAddress + Start + P30_MAX_BUFFER_SIZE_IN_BYTES, + BlockAddress + Start + Index * P30_MAX_BUFFER_SIZE_IN_BYT= ES, P30_MAX_BUFFER_SIZE_IN_BYTES, - Instance->ShadowBuffer + P30_MAX_BUFFER_SIZE_IN_BYTES + Instance->ShadowBuffer + Index * P30_MAX_BUFFER_SIZE_IN_B= YTES ); + if (EFI_ERROR (Status)) { + goto Exit; + } } =20 Exit: --=20 2.43.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113919): https://edk2.groups.io/g/devel/message/113919 Mute This Topic: https://groups.io/mt/103766777/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-