From: "Laszlo Ersek" <lersek@redhat.com>
To: devel@edk2.groups.io, ard.biesheuvel@arm.com
Cc: Dandan Bi <dandan.bi@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>,
Jian J Wang <jian.j.wang@intel.com>,
Hao A Wu <hao.a.wu@intel.com>,
Sami Mujawar <sami.mujawar@arm.com>,
Leif Lindholm <leif@nuviainc.com>
Subject: Re: [edk2-devel] [PATCH 3/3] MdeModulePkg/AcpiTableDxe: use pool allocation for RSDP if possible
Date: Mon, 19 Oct 2020 22:13:40 +0200 [thread overview]
Message-ID: <e80ad242-6eef-1a3e-9ec8-45fdfae6b7aa@redhat.com> (raw)
In-Reply-To: <20201016154923.21260-4-ard.biesheuvel@arm.com>
On 10/16/20 17:49, Ard Biesheuvel wrote:
> Use a pool allocation for the RSDP ACPI root pointer structure if no
> memory limit is in effect that forces us to use page based allocation,
> which may be wasteful if they get rounded up to 64 KB as is the case
> on AArch64.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
> ---
> MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 30 ++++++++++++++------
> 1 file changed, 21 insertions(+), 9 deletions(-)
>
> diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> index 22f49a8489e7..fb939aa00f49 100644
> --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c
> @@ -1737,19 +1737,26 @@ AcpiTableAcpiTableConstructor (
> RsdpTableSize += sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER);
> }
>
> - PageAddress = 0xFFFFFFFF;
> - Status = gBS->AllocatePages (
> - mAcpiTableAllocType,
> - EfiACPIReclaimMemory,
> - EFI_SIZE_TO_PAGES (RsdpTableSize),
> - &PageAddress
> - );
> + if (mAcpiTableAllocType != AllocateAnyPages) {
> + PageAddress = 0xFFFFFFFF;
> + Status = gBS->AllocatePages (
> + mAcpiTableAllocType,
> + EfiACPIReclaimMemory,
> + EFI_SIZE_TO_PAGES (RsdpTableSize),
> + &PageAddress
> + );
> + Pointer = (UINT8 *)(UINTN)PageAddress;
(1) (same as earlier) please check for success before assigning the pointer
> + } else {
> + Status = gBS->AllocatePool (
> + EfiACPIReclaimMemory,
> + RsdpTableSize,
> + (VOID **)&Pointer);
(2) (same as earlier) style: please break off the closing paren, or
condense all the arguments.
Looks OK other than these.
Thanks
Laszlo
> + }
>
> if (EFI_ERROR (Status)) {
> return EFI_OUT_OF_RESOURCES;
> }
>
> - Pointer = (UINT8 *) (UINTN) PageAddress;
> ZeroMem (Pointer, RsdpTableSize);
>
> AcpiTableInstance->Rsdp1 = (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) Pointer;
> @@ -1797,7 +1804,12 @@ AcpiTableAcpiTableConstructor (
> }
>
> if (EFI_ERROR (Status)) {
> - gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)AcpiTableInstance->Rsdp1, EFI_SIZE_TO_PAGES (RsdpTableSize));
> + if (mAcpiTableAllocType != AllocateAnyPages) {
> + gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)AcpiTableInstance->Rsdp1,
> + EFI_SIZE_TO_PAGES (RsdpTableSize));
> + } else {
> + gBS->FreePool (AcpiTableInstance->Rsdp1);
> + }
> return EFI_OUT_OF_RESOURCES;
> }
>
>
next prev parent reply other threads:[~2020-10-19 20:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-16 15:49 [PATCH 0/3] MdeModulePkg: use pool allocations for ACPI tables Ard Biesheuvel
2020-10-16 15:49 ` [PATCH 1/3] MdeModulePkg/AcpiTableDxe: use pool allocations when possible Ard Biesheuvel
2020-10-19 19:47 ` [edk2-devel] " Laszlo Ersek
2020-10-22 2:01 ` 回复: " gaoliming
2020-10-22 12:55 ` Ard Biesheuvel
2020-10-26 1:35 ` 回复: " gaoliming
2020-10-26 6:25 ` Laszlo Ersek
2020-10-26 7:42 ` Ard Biesheuvel
2020-10-27 8:45 ` 回复: " gaoliming
2020-10-27 9:05 ` Ard Biesheuvel
2020-10-27 11:07 ` Laszlo Ersek
2020-10-16 15:49 ` [PATCH 2/3] MdeModulePkg/AcpiTableDxe: use pool allocation for RSDT/XSDT if possible Ard Biesheuvel
2020-10-19 20:06 ` [edk2-devel] " Laszlo Ersek
2020-10-19 20:11 ` Laszlo Ersek
2020-10-16 15:49 ` [PATCH 3/3] MdeModulePkg/AcpiTableDxe: use pool allocation for RSDP " Ard Biesheuvel
2020-10-19 20:13 ` Laszlo Ersek [this message]
2020-10-19 1:28 ` FW: [PATCH 0/3] MdeModulePkg: use pool allocations for ACPI tables Wu, Hao A
2020-10-19 1:59 ` Wu, Hao A
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=e80ad242-6eef-1a3e-9ec8-45fdfae6b7aa@redhat.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