public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Shao, Ming" <ming.shao@intel.com>
To: "Ni, Ruiyu" <ruiyu.ni@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Shao, Ming" <ming.shao@intel.com>
Subject: Re: [PATCH] UefiCpuPkg/MtrrLib: Add comments to recommend to use batch-set API
Date: Mon, 22 Jan 2018 09:13:41 +0000	[thread overview]
Message-ID: <0D32B2537B667F42AD320D616D521AF738A402DC@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20180118061359.351852-1-ruiyu.ni@intel.com>

Reviewed-by Shao Ming <ming.shao@intel.com>

-Ming

-----Original Message-----
From: Ni, Ruiyu 
Sent: Thursday, January 18, 2018 2:14 PM
To: edk2-devel@lists.01.org
Cc: Shao, Ming <ming.shao@intel.com>
Subject: [PATCH] UefiCpuPkg/MtrrLib: Add comments to recommend to use batch-set API

MtrrSetMemoryAttributesInMtrrSettings() is a batch-set API.
When setting multiple ranges of memory attributes, the single-set API (MtrrSetMemoryAttributeInMtrrSettings and MtrrSetMemoryAttribute) may fail, but batch-set API may succeed.
Add comments to recommend caller to use batch-set API when setting multiple ranges.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Ming Shao <ming.shao@intel.com>
---
 UefiCpuPkg/Include/Library/MtrrLib.h | 10 ++++++++++  UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/UefiCpuPkg/Include/Library/MtrrLib.h b/UefiCpuPkg/Include/Library/MtrrLib.h
index d56f1057e1..f82c27ea0c 100644
--- a/UefiCpuPkg/Include/Library/MtrrLib.h
+++ b/UefiCpuPkg/Include/Library/MtrrLib.h
@@ -157,6 +157,11 @@ GetFirmwareVariableMtrrCount (
   @retval RETURN_OUT_OF_RESOURCES   There are not enough system resources to
                                     modify the attributes of the memory
                                     resource range.
+                                    Multiple memory range attributes setting by calling this API multiple
+                                    times may fail with status RETURN_OUT_OF_RESOURCES. It may not mean
+                                    the number of CPU MTRRs are too small to set such memory attributes.
+                                    Pass the multiple memory range attributes to one call of
+                                    MtrrSetMemoryAttributesInMtrrSettings() may succeed.
   @retval RETURN_BUFFER_TOO_SMALL   The fixed internal scratch buffer is too small for MTRR calculation.
                                     Caller should use MtrrSetMemoryAttributesInMtrrSettings() to specify
                                     external scratch buffer.
@@ -354,6 +359,11 @@ MtrrGetDefaultMemoryType (
                                     BaseAddress and Length cannot be modified.
   @retval RETURN_OUT_OF_RESOURCES   There are not enough system resources to modify the attributes of
                                     the memory resource range.
+                                    Multiple memory range attributes setting by calling this API multiple
+                                    times may fail with status RETURN_OUT_OF_RESOURCES. It may not mean
+                                    the number of CPU MTRRs are too small to set such memory attributes.
+                                    Pass the multiple memory range attributes to one call of
+                                    MtrrSetMemoryAttributesInMtrrSettings() may succeed.
   @retval RETURN_BUFFER_TOO_SMALL   The fixed internal scratch buffer is too small for MTRR calculation.
                                     Caller should use MtrrSetMemoryAttributesInMtrrSettings() to specify
                                     external scratch buffer.
diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
index 2496d08ad4..dfce9a996b 100644
--- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
+++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
@@ -2513,6 +2513,11 @@ Exit:
                                     BaseAddress and Length cannot be modified.
   @retval RETURN_OUT_OF_RESOURCES   There are not enough system resources to modify the attributes of
                                     the memory resource range.
+                                    Multiple memory range attributes setting by calling this API multiple
+                                    times may fail with status RETURN_OUT_OF_RESOURCES. It may not mean
+                                    the number of CPU MTRRs are too small to set such memory attributes.
+                                    Pass the multiple memory range attributes to one call of
+                                    MtrrSetMemoryAttributesInMtrrSettings() may succeed.
   @retval RETURN_BUFFER_TOO_SMALL   The fixed internal scratch buffer is too small for MTRR calculation.
                                     Caller should use MtrrSetMemoryAttributesInMtrrSettings() to specify
                                     external scratch buffer.
@@ -2561,6 +2566,11 @@ MtrrSetMemoryAttributeInMtrrSettings (
   @retval RETURN_OUT_OF_RESOURCES   There are not enough system resources to
                                     modify the attributes of the memory
                                     resource range.
+                                    Multiple memory range attributes setting by calling this API multiple
+                                    times may fail with status RETURN_OUT_OF_RESOURCES. It may not mean
+                                    the number of CPU MTRRs are too small to set such memory attributes.
+                                    Pass the multiple memory range attributes to one call of
+                                    MtrrSetMemoryAttributesInMtrrSettings() may succeed.
   @retval RETURN_BUFFER_TOO_SMALL   The fixed internal scratch buffer is too small for MTRR calculation.
                                     Caller should use MtrrSetMemoryAttributesInMtrrSettings() to specify
                                     external scratch buffer.
--
2.15.1.windows.2



      reply	other threads:[~2018-01-22  9:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-18  6:13 [PATCH] UefiCpuPkg/MtrrLib: Add comments to recommend to use batch-set API Ruiyu Ni
2018-01-22  9:13 ` Shao, Ming [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0D32B2537B667F42AD320D616D521AF738A402DC@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox