From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web12.2945.1608253777757484423 for ; Thu, 17 Dec 2020 17:09:40 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Fri, 18 Dec 2020 09:09:31 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: , Cc: "'Dandan Bi'" References: <20201217135859.1677-1-ming.tan@intel.com> In-Reply-To: <20201217135859.1677-1-ming.tan@intel.com> Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0gW1BBVENIIHY1XSBNZGVNb2R1bGVQa2cvVW5pdmVyc2FsL1N0YXR1c0NvZGVIYW5kbGVyOiBGaXggYSBidWcgYWJvdXQgbG9nIGxvc3Q=?= Date: Fri, 18 Dec 2020 09:09:35 +0800 Message-ID: <006c01d6d4da$73513830$59f3a890$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQF0vCiA2FoGkk3XFoWjrToDdCaigqrAO7Gg Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Ming: This change uses the accurate point to exit boot service. It is a good enhancement.=20 For the patch, I have one comment that SerialStatusCodeReportWorker() should call mRscHandlerProtocol unregister itself.=20 If there are more than one Status code handlers to be unregistered at = the exit boot service, each handler should unregister itself.=20 Thanks Liming > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: bounce+27952+69130+4905953+8761045@groups.io > =B4=FA=B1=ED Tan, Ming > =B7=A2=CB=CD=CA=B1=BC=E4: 2020=C4=EA12=D4=C217=C8=D5 21:59 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io > =B3=AD=CB=CD: Dandan Bi ; Liming Gao > > =D6=F7=CC=E2: [edk2-devel] [PATCH v5] = MdeModulePkg/Universal/StatusCodeHandler: > Fix a bug about log lost >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3126 >=20 > 1. If use PeiDxeDebugLibReportStatusCode as DebugLib, then some logs > after ExitBootService() will be lost. > 2. The root cause: > 2.1 The original code will register an unregister function > of gEfiEventExitBootServicesGuid, this unregister function will call > EFI_RSC_HANDLER_PROTOCOL->Unregister and does not support log through > serial port. > 2.2 And some other drivers also register call back funtions of > gEfiEventExitBootServicesGuid. > 2.3 Then after the unregister function is called, other call back > functions can't out log if them use RSC as DebugLib. > 3. The DxeMain will report status code EFI_SW_BS_PC_EXIT_BOOT_SERVICES > after notify all the call back functions of > gEfiEventExitBootServicesGuid. > 4. Solution: the StatusCodeHandlerRuntimeDxe.c will not register an > unregister function of gEfiEventExitBootServicesGuid, but unregister = it > after receive the status code of EFI_SW_BS_PC_EXIT_BOOT_SERVICES. >=20 > Cc: Dandan Bi > Cc: Liming Gao > Signed-off-by: Ming Tan > --- > V5: Fix an unused var bug and compile error using GCC. > V4: Fix a spell bug in code comment, change 'a' to 'an' before 'unregister'. > V3: Fix a spell bug in commit message, change 'a' to 'an' before 'unregister'. > V2: Add the REF link in commit message. >=20 > .../RuntimeDxe/SerialStatusCodeWorker.c | 10 ++++++++++ > .../RuntimeDxe/StatusCodeHandlerRuntimeDxe.c | 17 = +---------------- > .../RuntimeDxe/StatusCodeHandlerRuntimeDxe.h | 11 +++++++++++ > 3 files changed, 22 insertions(+), 16 deletions(-) >=20 > diff --git > a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCo > deWorker.c > b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCo > deWorker.c > index 0b98e7ec63..f7ab71e32a 100644 > --- > a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCo > deWorker.c > +++ > b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/SerialStatusCo > deWorker.c > @@ -151,6 +151,16 @@ SerialStatusCodeReportWorker ( > // >=20 > SerialPortWrite ((UINT8 *) Buffer, CharCount); >=20 >=20 >=20 > + // >=20 > + // If register an unregister function of = gEfiEventExitBootServicesGuid, >=20 > + // then some log called in ExitBootServices() will be lost, >=20 > + // so unregister the handler after receive the value of exit boot service. >=20 > + // >=20 > + if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) =3D=3D EFI_PROGRESS_CODE > && >=20 > + Value =3D=3D (EFI_SOFTWARE_EFI_BOOT_SERVICE | > EFI_SW_BS_PC_EXIT_BOOT_SERVICES)) { >=20 > + UnregisterBootTimeHandlers(); >=20 > + } >=20 > + >=20 > return EFI_SUCCESS; >=20 > } >=20 >=20 >=20 > diff --git > a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHa > ndlerRuntimeDxe.c > b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHa > ndlerRuntimeDxe.c > index a8c0fe5b71..2e11c1f4d2 100644 > --- > a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHa > ndlerRuntimeDxe.c > +++ > b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHa > ndlerRuntimeDxe.c > @@ -10,23 +10,17 @@ > #include "StatusCodeHandlerRuntimeDxe.h" >=20 >=20 >=20 > EFI_EVENT mVirtualAddressChangeEvent =3D NULL; >=20 > -static EFI_EVENT mExitBootServicesEvent =3D NULL; >=20 > EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol =3D NULL; >=20 >=20 >=20 > /** >=20 > Unregister status code callback functions only available at boot = time from >=20 > report status code router when exiting boot services. >=20 >=20 >=20 > - @param Event Event whose notification function is being > invoked. >=20 > - @param Context Pointer to the notification function's = context, > which is >=20 > - always zero in current implementation. >=20 > - >=20 > **/ >=20 > VOID >=20 > EFIAPI >=20 > UnregisterBootTimeHandlers ( >=20 > - IN EFI_EVENT Event, >=20 > - IN VOID *Context >=20 > + VOID >=20 > ) >=20 > { >=20 > if (PcdGetBool (PcdStatusCodeUseSerial)) { >=20 > @@ -178,15 +172,6 @@ StatusCodeHandlerRuntimeDxeEntry ( > mRscHandlerProtocol->Register (RtMemoryStatusCodeReportWorker, > TPL_HIGH_LEVEL); >=20 > } >=20 >=20 >=20 > - Status =3D gBS->CreateEventEx ( >=20 > - EVT_NOTIFY_SIGNAL, >=20 > - TPL_NOTIFY, >=20 > - UnregisterBootTimeHandlers, >=20 > - NULL, >=20 > - &gEfiEventExitBootServicesGuid, >=20 > - &mExitBootServicesEvent >=20 > - ); >=20 > - >=20 > Status =3D gBS->CreateEventEx ( >=20 > EVT_NOTIFY_SIGNAL, >=20 > TPL_NOTIFY, >=20 > diff --git > a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHa > ndlerRuntimeDxe.h > b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHa > ndlerRuntimeDxe.h > index fd4689c2d7..f1789dc538 100644 > --- > a/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHa > ndlerRuntimeDxe.h > +++ > b/MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHa > ndlerRuntimeDxe.h > @@ -118,4 +118,15 @@ RtMemoryStatusCodeReportWorker ( > IN EFI_STATUS_CODE_DATA *Data OPTIONAL >=20 > ); >=20 >=20 >=20 > +/** >=20 > + Unregister status code callback functions only available at boot = time from >=20 > + report status code router when exiting boot services. >=20 > + >=20 > +**/ >=20 > +VOID >=20 > +EFIAPI >=20 > +UnregisterBootTimeHandlers ( >=20 > + VOID >=20 > + ); >=20 > + >=20 > #endif >=20 > -- > 2.24.0.windows.2 >=20 >=20 >=20 > -=3D-=3D-=3D-=3D-=3D-=3D > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#69130): = https://edk2.groups.io/g/devel/message/69130 > Mute This Topic: https://groups.io/mt/79036460/4905953 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub > [gaoliming@byosoft.com.cn] > -=3D-=3D-=3D-=3D-=3D-=3D >=20