From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from fb.mail.gandi.net (spool8.mail.gandi.net [217.70.178.217]) by nmboxes7-ms7.sd4.0x35.net (Postfix) with ESMTPS id 8029D61930 for ; Tue, 16 Jan 2024 05:26:37 +0000 (UTC) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by fb.mail.gandi.net (Postfix) with ESMTPS id 0DD3860376 for ; Tue, 16 Jan 2024 05:26:36 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ubzNOQhPmgraboHHLGzLkpGwlHoQQLgnHeUKHU05Hj8=; 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=1705382795; v=1; b=dDL0YJVoq/sywJkXLnIXDnv3XaC7+GgaFJfFFRa16FKaEFe6dLaoXKSh3bwQGiCHqTNI7dZc CJrs7PIe6823IoU52U3EUJS6H62cvyubCJt5xBYnvi8koV1FtG/5qeDIaRzyrFJjzC3y4xiaoZb XRHjiYgHjWyY+BvZTk2VmXQo= X-Received: by 127.0.0.2 with SMTP id YW3jYY7687511x7Ibm85iNpg; Mon, 15 Jan 2024 21:26:35 -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.web10.85165.1705334394654893281 for ; Mon, 15 Jan 2024 07:59:54 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-677-78nU2lN9ObaJIBeNYKt3mQ-1; Mon, 15 Jan 2024 10:59:52 -0500 X-MC-Unique: 78nU2lN9ObaJIBeNYKt3mQ-1 X-Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 5394A3813F22 for ; Mon, 15 Jan 2024 15:59:52 +0000 (UTC) X-Received: from dobby.home.kraxel.org (unknown [10.39.193.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 257BF1121306; Mon, 15 Jan 2024 15:59:52 +0000 (UTC) X-Received: by dobby.home.kraxel.org (Postfix, from userid 1000) id D4FFAAC988; Mon, 15 Jan 2024 16:59:48 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: oliver@redhat.com, Gerd Hoffmann Subject: [edk2-devel] [PATCH v2 3/6] OvmfPkg/VirtNorFlashDxe: add a loop for NorFlashWriteBuffer calls. Date: Mon, 15 Jan 2024 16:59:45 +0100 Message-ID: <20240115155948.136499-4-kraxel@redhat.com> In-Reply-To: <20240115155948.136499-1-kraxel@redhat.com> References: <20240115155948.136499-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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: UaG6TgL8j2eknDuhCmwgU0Vvx7686176AA= Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-GND-Status: LEGIT Authentication-Results: fb.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=dDL0YJVo; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (fb.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 --- OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c index 54251633d0ee..67610d6920f7 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; DEBUG ((DEBUG_BLKIO, "NorFlashWriteSingleBlock(Parameters: Lba=%ld, Offset=0x%x, *NumBytes=0x%x, Buffer @ 0x%08x)\n", Lba, Offset, *NumBytes, Buffer)); @@ -620,23 +621,17 @@ NorFlashWriteSingleBlock ( goto Exit; } - Status = 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 = (End - Start) / P30_MAX_BUFFER_SIZE_IN_BYTES; + for (Index = 0; Index < Count; Index++) { Status = NorFlashWriteBuffer ( Instance, - BlockAddress + Start + P30_MAX_BUFFER_SIZE_IN_BYTES, + BlockAddress + Start + Index * P30_MAX_BUFFER_SIZE_IN_BYTES, P30_MAX_BUFFER_SIZE_IN_BYTES, - Instance->ShadowBuffer + P30_MAX_BUFFER_SIZE_IN_BYTES + Instance->ShadowBuffer + Index * P30_MAX_BUFFER_SIZE_IN_BYTES ); + if (EFI_ERROR (Status)) { + goto Exit; + } } Exit: -- 2.43.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113829): https://edk2.groups.io/g/devel/message/113829 Mute This Topic: https://groups.io/mt/103741663/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-