From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-x233.google.com (mail-io0-x233.google.com [IPv6:2607:f8b0:4001:c06::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6D47721A04807 for ; Fri, 31 Mar 2017 05:22:46 -0700 (PDT) Received: by mail-io0-x233.google.com with SMTP id l7so38276255ioe.3 for ; Fri, 31 Mar 2017 05:22:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=zroqTyOWRdhFpgyafFnfpBe4SZFtl5tXVC/g7Fp9sVo=; b=Sxs0rXAecNC59D8EXVSAneyJHVVeSCLiKxS5MEemuCA2LQDld8lQPK3KT8NM4p+jLJ HcvERPblGnuuFaEHIcecx6XbWQcNdsNV+PMsup2aQ2pIn50ZARSidRcRGeYeFaMWjKYF q6sTAmgLEljN1iZy397zunXAdT3M4r+xfdbt8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=zroqTyOWRdhFpgyafFnfpBe4SZFtl5tXVC/g7Fp9sVo=; b=G+5UpSOFBD5PIJDDv++FLfN+9kBebhgDmYPNhoELUiAlbw3oqpW6Hl4Z6SsqZ8e5zB RHXDIBL3768vSCvvsWLRe2Pxfo6N9lMsvkj4Qcd/7MSt3gOUaR9vodGVCyMmxa3zjsVh iBeDG7uVvDEd6ooGtmmWf2cSQhDNcjlMKTr0iKshRKp9uaqQBl81PDN6N4rXHmK8+/F8 o3vFW0xVUPJXKu7Ql6d3I0TzuzXOi6KwZV4ay7+GpibZU/HvsXxErpA5x6C8BqoGv0d2 Jz2BREeLuXQdcub26jV5SV8Bu7SDajJjJSrxnSPSBNjMcNmostZ4uYEdDglYd+2hI4L/ kFwQ== X-Gm-Message-State: AFeK/H09REBGWQ3ptygx5aXsVgDbeNSGSVj18/V1OIE+xhtOZTV6HRV4lL8de5bxQSkD1nOzGRbDLs49+Y60qrr3 X-Received: by 10.107.168.21 with SMTP id r21mr2584136ioe.45.1490962965691; Fri, 31 Mar 2017 05:22:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.10.27 with HTTP; Fri, 31 Mar 2017 05:22:45 -0700 (PDT) In-Reply-To: <3bf58c8c-3582-c668-541f-651dea8bdbb1@redhat.com> References: <20170331105607.3477-1-ard.biesheuvel@linaro.org> <20170331105607.3477-4-ard.biesheuvel@linaro.org> <3bf58c8c-3582-c668-541f-651dea8bdbb1@redhat.com> From: Ard Biesheuvel Date: Fri, 31 Mar 2017 13:22:45 +0100 Message-ID: To: Laszlo Ersek Cc: "edk2-devel@lists.01.org" , Leif Lindholm Subject: Re: [PATCH v2 3/3] EmbeddedPkg/DtPlatformDxe: load platform DTB via new library X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Mar 2017 12:22:46 -0000 Content-Type: text/plain; charset=UTF-8 On 31 March 2017 at 12:39, Laszlo Ersek wrote: > On 03/31/17 12:56, Ard Biesheuvel wrote: >> To give platforms some room to decide which DTB is suitable and where >> to load it from, indirect loading of the DTB image via the new >> DtPlatformDtbLoaderLib library class. > > I think you accidentally the verb in the above sentence :) > 'indirect' was intended as the verb here, but I'll replace it for legibility >> >> Contributed-under: TianoCore Contribution Agreement 1.0 >> Signed-off-by: Ard Biesheuvel >> --- >> EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c | 26 ++++++++++---------- >> EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf | 2 +- >> EmbeddedPkg/EmbeddedPkg.dsc | 2 ++ >> 3 files changed, 16 insertions(+), 14 deletions(-) >> >> diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c >> index 5778633b4985..c75f088a34e5 100644 >> --- a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c >> +++ b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c >> @@ -15,7 +15,7 @@ >> #include >> #include >> #include >> -#include >> +#include >> #include >> #include >> #include >> @@ -114,14 +114,12 @@ DtPlatformDxeEntryPoint ( >> UINTN BufferSize; >> VOID *Dtb; >> UINTN DtbSize; >> - VOID *DtbCopy; >> >> // >> // Check whether a DTB blob is included in the firmware image. >> // > > Please drop this comment; this detail is now abstracted out. > >> Dtb = NULL; >> - Status = GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid, >> - EFI_SECTION_RAW, 0, &Dtb, &DtbSize); >> + Status = DtPlatformLoadDtb (&Dtb, &DtbSize); >> if (EFI_ERROR (Status)) { >> DEBUG ((DEBUG_WARN, "%a: no DTB blob found, defaulting to ACPI\n", >> __FUNCTION__)); > > This can now fail due to out-of-memory in DtPlatformLoadDtb(), so I > suggest printing Status with %r in the debug message. > >> @@ -157,7 +155,7 @@ DtPlatformDxeEntryPoint ( >> EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, >> sizeof (DtAcpiPref), &DtAcpiPref); >> if (EFI_ERROR (Status)) { >> - return Status; >> + goto FreeDtb; >> } >> } >> >> @@ -172,23 +170,18 @@ DtPlatformDxeEntryPoint ( >> DEBUG ((DEBUG_ERROR, >> "%a: failed to install gEdkiiPlatformHasAcpiGuid as a protocol\n", >> __FUNCTION__)); >> - return Status; >> + goto FreeDtb; >> } >> } else if (DtAcpiPref.Pref == DT_ACPI_SELECT_DT) { >> // >> // DT was selected: copy the blob into newly allocated memory and install >> // a reference to it as the FDT configuration table. >> // >> - DtbCopy = AllocateCopyPool (DtbSize, Dtb); >> - if (DtbCopy == NULL) { >> - return EFI_OUT_OF_RESOURCES; >> - } >> - Status = gBS->InstallConfigurationTable (&gFdtTableGuid, DtbCopy); >> + Status = gBS->InstallConfigurationTable (&gFdtTableGuid, Dtb); >> if (EFI_ERROR (Status)) { >> DEBUG ((DEBUG_ERROR, "%a: failed to install FDT configuration table\n", >> __FUNCTION__)); >> - FreePool (DtbCopy); >> - return Status; >> + goto FreeDtb; >> } >> } else { >> ASSERT (FALSE); >> @@ -210,4 +203,11 @@ DtPlatformDxeEntryPoint ( >> // installed in that case. >> // >> return InstallHiiPages (); >> + >> +FreeDtb: >> + if (Dtb != NULL) { >> + FreePool (Dtb); >> + } >> + >> + return Status; >> } >> diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf >> index b73877a6086b..45dfd9088bf0 100644 >> --- a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf >> +++ b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf >> @@ -40,7 +40,7 @@ [Packages] >> [LibraryClasses] >> BaseLib >> DebugLib >> - DxeServicesLib >> + DtPlatformDtbLoaderLib >> HiiLib >> MemoryAllocationLib >> UefiBootServicesTableLib >> diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc >> index 0d5db68631bb..b75678276e8d 100644 >> --- a/EmbeddedPkg/EmbeddedPkg.dsc >> +++ b/EmbeddedPkg/EmbeddedPkg.dsc >> @@ -294,5 +294,7 @@ [Components.common] >> EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf >> EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf >> >> + EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf >> + >> [Components.IA32, Components.X64, Components.IPF, Components.ARM] >> EmbeddedPkg/GdbStub/GdbStub.inf >> > > Please split off the last hunk (for "EmbeddedPkg/EmbeddedPkg.dsc") to a > separate patch. (You might want to make that the first patch in the > series, saying "we forgot this before, but it's needed to build the > driver at all", or some such.) > > With these changes, for both patches: > > Reviewed-by: Laszlo Ersek > > Thanks > Laszlo