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 6FCA6941625 for ; Tue, 14 Nov 2023 08:24:29 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=/uIaYUOLcTb80fn6l3bYt5xSdBq5vlsu8LWzV8kCQUE=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1699950268; v=1; b=F3AUvKv/BNbDiIAyb472ffmP0hy5i/0tPEAUd9axlft62eHTgD4Dh+525DjmZIlJzqWt3jBO M/iD9c5kl0PyNM49wg+Yo2mtY4UydWLTMi+LXWgmqbdTgMlo/WgTDnEDaFdh9McOojm7YzCifjW boBT9qmRspUY3Kpw/DMIGIks= X-Received: by 127.0.0.2 with SMTP id E9OUYY7687511xP23TwCB3q0; Tue, 14 Nov 2023 00:24:28 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.8601.1699950266821232588 for ; Tue, 14 Nov 2023 00:24:27 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="454901978" X-IronPort-AV: E=Sophos;i="6.03,301,1694761200"; d="scan'208";a="454901978" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 00:24:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="888176889" X-IronPort-AV: E=Sophos;i="6.03,301,1694761200"; d="scan'208";a="888176889" X-Received: from gaocheng-desk.ccr.corp.intel.com ([10.239.154.170]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 00:24:22 -0800 From: "Gao" To: devel@edk2.groups.io Cc: Gao Cheng , Liming Gao , Ray Ni Subject: [edk2-devel] [PATCH] MdeModulePkg/Variable: Merge variable header + data update into one step Date: Tue, 14 Nov 2023 16:23:53 +0800 Message-ID: <475e7d21da7f9a54d4841d1efe78c1e587c6b931.1699949356.git.gao.cheng@intel.com> MIME-Version: 1.0 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,gao.cheng@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 6D6cMv27oPODtxHWap2Tc8jpx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="F3AUvKv/"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4597 When creating a new variable, skip marking VAR_HEADER_VALID_ONLY so that variable header + data update can be merged into one flash write. This will greatly reduce the time taken for updating a variable and thus increase performance. Removing VAR_HEADER_VALID_ONLY marking doesn't have any function impact since it's not used by current code to detect variable header + data corruption. Cc: Liming Gao Cc: Ray Ni Signed-off-by: Gao Cheng --- .../Universal/Variable/RuntimeDxe/Variable.c | 45 ++----------------- 1 file changed, 4 insertions(+), 41 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 7a1331255b..3c360481f4 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -2168,11 +2168,9 @@ UpdateVariable ( if (!mVariableModuleGlobal->VariableGlobal.EmuNvMode) { // - // Four steps - // 1. Write variable header - // 2. Set variable state to header valid - // 3. Write variable data - // 4. Set variable state to valid + // Two steps + // 1. Write variable header and data + // 2. Set variable state to valid // // // Step 1: @@ -2183,7 +2181,7 @@ UpdateVariable ( TRUE, Fvb, mVariableModuleGlobal->NonVolatileLastVariableOffset, - (UINT32)GetVariableHeaderSize (AuthFormat), + (UINT32)VarSize, (UINT8 *)NextVariable ); @@ -2194,41 +2192,6 @@ UpdateVariable ( // // Step 2: // - NextVariable->State = VAR_HEADER_VALID_ONLY; - Status = UpdateVariableStore ( - &mVariableModuleGlobal->VariableGlobal, - FALSE, - TRUE, - Fvb, - mVariableModuleGlobal->NonVolatileLastVariableOffset + OFFSET_OF (VARIABLE_HEADER, State), - sizeof (UINT8), - &NextVariable->State - ); - - if (EFI_ERROR (Status)) { - goto Done; - } - - // - // Step 3: - // - Status = UpdateVariableStore ( - &mVariableModuleGlobal->VariableGlobal, - FALSE, - TRUE, - Fvb, - mVariableModuleGlobal->NonVolatileLastVariableOffset + GetVariableHeaderSize (AuthFormat), - (UINT32)(VarSize - GetVariableHeaderSize (AuthFormat)), - (UINT8 *)NextVariable + GetVariableHeaderSize (AuthFormat) - ); - - if (EFI_ERROR (Status)) { - goto Done; - } - - // - // Step 4: - // NextVariable->State = VAR_ADDED; Status = UpdateVariableStore ( &mVariableModuleGlobal->VariableGlobal, -- 2.42.0.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111193): https://edk2.groups.io/g/devel/message/111193 Mute This Topic: https://groups.io/mt/102579876/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-