From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DFB85802AE for ; Thu, 9 Mar 2017 08:55:29 -0800 (PST) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 77F94C04BD27; Thu, 9 Mar 2017 16:55:30 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-228.phx2.redhat.com [10.3.116.228]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v29GtSmQ021137; Thu, 9 Mar 2017 11:55:29 -0500 To: Ard Biesheuvel , edk2-devel@ml01.01.org References: <1489075441-23745-1-git-send-email-ard.biesheuvel@linaro.org> <1489075441-23745-3-git-send-email-ard.biesheuvel@linaro.org> Cc: drjones@redhat.com, leif.lindholm@linaro.org From: Laszlo Ersek Message-ID: Date: Thu, 9 Mar 2017 17:55:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1489075441-23745-3-git-send-email-ard.biesheuvel@linaro.org> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 09 Mar 2017 16:55:30 +0000 (UTC) Subject: Re: [PATCH 2/3] ArmVirtPkg/FdtClientDxe: install DT configuration table at ReadyToBoot X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Mar 2017 16:55:30 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 03/09/17 17:04, Ard Biesheuvel wrote: > Wait for ReadyToBoot to install the FDT configuration table. This allows > any driver to make modifications in the mean time, and will also allow us > to defer the decision of whether to install it in the first place to later > on in the boot. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ard Biesheuvel > --- > ArmVirtPkg/FdtClientDxe/FdtClientDxe.c | 41 ++++++++++++++++---- > ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf | 1 + > 2 files changed, 34 insertions(+), 8 deletions(-) > > diff --git a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c > index 7cc0c44ca12a..0327af5739f2 100644 > --- a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c > +++ b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c > @@ -303,6 +303,30 @@ STATIC FDT_CLIENT_PROTOCOL mFdtClientProtocol = { > GetOrInsertChosenNode, > }; > > +STATIC > +VOID > +EFIAPI > +OnReadyToBoot ( > + EFI_EVENT Event, > + VOID *Context > + ) > +{ > + EFI_STATUS Status; > + > + if (!FeaturePcdGet (PcdPureAcpiBoot)) { > + // > + // Only install the FDT as a configuration table if we want to leave it up > + // to the OS to decide whether it prefers ACPI over DT. > + // > + Status = gBS->InstallConfigurationTable (&gFdtTableGuid, mDeviceTreeBase); > + ASSERT_EFI_ERROR (Status); > + } > + > + gBS->CloseEvent (Event); OK, you didn't forget to close the event. :) > +} > + > +STATIC EFI_EVENT ReadyToBootEvent; This should be called "mReadyToBootEvent". > + > EFI_STATUS > EFIAPI > InitializeFdtClientDxe ( > @@ -330,14 +354,15 @@ InitializeFdtClientDxe ( > > DEBUG ((EFI_D_INFO, "%a: DTB @ 0x%p\n", __FUNCTION__, mDeviceTreeBase)); > > - if (!FeaturePcdGet (PcdPureAcpiBoot)) { > - // > - // Only install the FDT as a configuration table if we want to leave it up > - // to the OS to decide whether it prefers ACPI over DT. > - // > - Status = gBS->InstallConfigurationTable (&gFdtTableGuid, DeviceTreeBase); > - ASSERT_EFI_ERROR (Status); > - } > + Status = gBS->CreateEventEx ( > + EVT_NOTIFY_SIGNAL, > + TPL_CALLBACK, > + OnReadyToBoot, > + NULL, > + &gEfiEventReadyToBootGuid, > + &ReadyToBootEvent > + ); > + ASSERT_EFI_ERROR (Status); I guess it's OK to insist that this succeed. Also, this is done after the assignment to mDeviceTreeBase, so that's good. > > return gBS->InstallProtocolInterface (&ImageHandle, &gFdtClientProtocolGuid, > EFI_NATIVE_INTERFACE, &mFdtClientProtocol); However, if the protocol installation fails for any reason, we exit the driver with an error code, and the driver will be unloaded. We'll have a dangling callback pointer In case of failure, the event should be closed (== CreateEventEx() should be undone). > diff --git a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf > index 3a0cd37040eb..00017727c32c 100644 > --- a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf > +++ b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.inf > @@ -42,6 +42,7 @@ [Protocols] > gFdtClientProtocolGuid ## PRODUCES > > [Guids] > + gEfiEventReadyToBootGuid > gFdtHobGuid > gFdtTableGuid > > For completeness, can you please also #include for gEfiEventReadyToBootGuid's sake, in the C file? (It is already pulled in by something else, but, again, for completenes...) Looks okay to me otherwise. Thanks Laszlo