From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 87CB4D81164 for ; Tue, 16 Jan 2024 12:59:27 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=I+W5qb9SYwfWLEXSXXddIvIBb2MZcLLBRiAul7iv3rE=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1705409966; v=1; b=o9ZrY3C6U1cu/UMB17KHZuwd3yvwjmLtMgomAmpWD8oNy//U4zg9XGIQX3ZHAk3c9GMl9cC4 ssOU/y2z73yM2IN3fsfo6Lp9EwG7GjA0KW+61ZFmwjSH8jl4a0wwZpk1ePPpYtgUnTYfDLbSN+P HsBBHyOKet7KhB2B9YUSKQ/0= X-Received: by 127.0.0.2 with SMTP id 2dZ0YY7687511xhTQe8mwC2q; Tue, 16 Jan 2024 04:59:26 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.12877.1705409965687822074 for ; Tue, 16 Jan 2024 04:59:25 -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-18-zm62gZzkOnKkUItWnj9MPg-1; Tue, 16 Jan 2024 07:59:23 -0500 X-MC-Unique: zm62gZzkOnKkUItWnj9MPg-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 0E7341025881 for ; Tue, 16 Jan 2024 12:59:23 +0000 (UTC) X-Received: from [10.39.194.248] (unknown [10.39.194.248]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 77B08C15E6C; Tue, 16 Jan 2024 12:59:22 +0000 (UTC) Message-ID: <975804c8-6958-d567-1af4-71d7e657f521@redhat.com> Date: Tue, 16 Jan 2024 13:59:21 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v2 4/6] OvmfPkg/VirtNorFlashDxe: allow larger writes without block erase To: devel@edk2.groups.io, kraxel@redhat.com Cc: oliver@redhat.com References: <20240115155948.136499-1-kraxel@redhat.com> <20240115155948.136499-5-kraxel@redhat.com> From: "Laszlo Ersek" In-Reply-To: <20240115155948.136499-5-kraxel@redhat.com> 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 7YPrcPRAoN4vgiH7R0Mp2BXzx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=o9ZrY3C6; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none) On 1/15/24 16:59, Gerd Hoffmann wrote: > Raise the limit for writes without block erase from two to four > P30_MAX_BUFFER_SIZE_IN_BYTES blocks. With this in place almost all efi > variable updates are handled without block erase. With the old limit > some variable updates (with device paths) took the block erase code > path. >=20 > Signed-off-by: Gerd Hoffmann > --- > OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c | 18 ++++++++++-------- > 1 file changed, 10 insertions(+), 8 deletions(-) >=20 > diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c b/OvmfPkg/VirtNorFlas= hDxe/VirtNorFlash.c > index 67610d6920f7..d80e9f0a2f3a 100644 > --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c > +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlash.c > @@ -550,13 +550,15 @@ NorFlashWriteSingleBlock ( > return EFI_BAD_BUFFER_SIZE; > } > =20 > - // Pick P30_MAX_BUFFER_SIZE_IN_BYTES (=3D=3D 128 bytes) as a good star= t for word > - // operations as opposed to erasing the block and writing the data reg= ardless > - // if an erase is really needed. It looks like most individual NV var= iable > - // writes are smaller than 128 bytes. > - // To avoid pathological cases were a 2 byte write is disregarded beca= use it > - // occurs right at a 128 byte buffered write alignment boundary, permi= t up to > - // twice the max buffer size, and perform two writes if needed. > + // Pick 4 * P30_MAX_BUFFER_SIZE_IN_BYTES (=3D=3D 512 bytes) as a good > + // start for word operations as opposed to erasing the block and > + // writing the data regardless if an erase is really needed. > + // > + // Many NV variable updates are small enough for a a single > + // P30_MAX_BUFFER_SIZE_IN_BYTES block write. In case the update is > + // larger than a single block, or the update crosses a > + // P30_MAX_BUFFER_SIZE_IN_BYTES boundary (as shown in the diagram > + // below), or both, we might have to write two or more blocks. > // > // 0 128 256 > // [----------------|----------------] > @@ -577,7 +579,7 @@ NorFlashWriteSingleBlock ( > Start =3D Offset & ~BOUNDARY_OF_32_WORDS; > End =3D ALIGN_VALUE (Offset + *NumBytes, P30_MAX_BUFFER_SIZE_IN_BYTE= S); > =20 > - if ((End - Start) <=3D (2 * P30_MAX_BUFFER_SIZE_IN_BYTES)) { > + if ((End - Start) <=3D (4 * P30_MAX_BUFFER_SIZE_IN_BYTES)) { > // Check to see if we need to erase before programming the data into= NOR. > // If the destination bits are only changing from 1s to 0s we can ju= st write. > // After a block is erased all bits in the block is set to 1. Reviewed-by: Laszlo Ersek -=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 (#113895): https://edk2.groups.io/g/devel/message/113895 Mute This Topic: https://groups.io/mt/103741664/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-