public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Dong, Eric" <eric.dong@intel.com>
To: "Yao, Jiewen" <jiewen.yao@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Ni, Ruiyu" <ruiyu.ni@intel.com>
Subject: Re: [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished.
Date: Wed, 11 Oct 2017 08:24:46 +0000	[thread overview]
Message-ID: <ED077930C258884BBCB450DB737E66224AA1398C@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503A9D9CB0@shsmsx102.ccr.corp.intel.com>

Jiewen,

Yes, it will always install new protocol and may cause run out of memory. I have updated code to uninstall this protocol right after install it. please check the V3 patch which fix your two comments.

Thanks,
Eric

-----Original Message-----
From: Yao, Jiewen 
Sent: Wednesday, October 11, 2017 3:13 PM
To: Dong, Eric <eric.dong@intel.com>; edk2-devel@lists.01.org
Cc: Ni, Ruiyu <ruiyu.ni@intel.com>
Subject: RE: [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished.

I have a question for below:

> +  SmmHandle = NULL;
> +  Status = SmmInstallProtocolInterface (
> +             &SmmHandle,
> +             &gEdkiiSmmEndOfS3ResumeProtocolGuid,
> +             EFI_NATIVE_INTERFACE,
> +             NULL
> +             );

A platform may do S3 multiple times. What happen if the SmmInstallProtocolInterface() called twice?
Will the system has 2 handle and 2 protocol?

Thank you
Yao Jiewen

> -----Original Message-----
> From: Dong, Eric
> Sent: Wednesday, October 11, 2017 1:32 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when 
> S3 resume finished.
> 
> Install EdkiiSmmEndOfS3ResumeProtocol when S3 resume finished.
> S3ResumePei will send S3 resume finished event to SmmCore through 
> communication buffer.
> 
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
>  MdeModulePkg/Core/PiSmmCore/PiSmmCore.c   | 55
> +++++++++++++++++++++++++++----
>  MdeModulePkg/Core/PiSmmCore/PiSmmCore.h   | 24 ++++++++++++++
>  MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf |  1 +
>  3 files changed, 73 insertions(+), 7 deletions(-)
> 
> diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
> b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
> index 9e4390e..aa44933 100644
> --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
> +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
> @@ -75,13 +75,14 @@ BOOLEAN  mInLegacyBoot = FALSE;  // Table of SMI 
> Handlers that are registered by the SMM Core when it is initialized  
> //  SMM_CORE_SMI_HANDLERS  mSmmCoreSmiHandlers[] = {
> -  { SmmDriverDispatchHandler,   &gEfiEventDxeDispatchGuid,
> NULL, TRUE  },
> -  { SmmReadyToLockHandler,      &gEfiDxeSmmReadyToLockProtocolGuid,
> NULL, TRUE },
> -  { SmmLegacyBootHandler,       &gEfiEventLegacyBootGuid,
> NULL, FALSE },
> -  { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid,     NULL,
> FALSE },
> -  { SmmReadyToBootHandler,      &gEfiEventReadyToBootGuid,
> NULL, FALSE },
> -  { SmmEndOfDxeHandler,         &gEfiEndOfDxeEventGroupGuid,
> NULL, TRUE },
> -  { NULL,                       NULL,
> NULL, FALSE }
> +  { SmmDriverDispatchHandler,   &gEfiEventDxeDispatchGuid,
> NULL, TRUE  },
> +  { SmmReadyToLockHandler,      &gEfiDxeSmmReadyToLockProtocolGuid,
> NULL, TRUE },
> +  { SmmLegacyBootHandler,       &gEfiEventLegacyBootGuid,
> NULL, FALSE },
> +  { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid,      NULL,
> FALSE },
> +  { SmmReadyToBootHandler,      &gEfiEventReadyToBootGuid,
> NULL, FALSE },
> +  { SmmEndOfDxeHandler,         &gEfiEndOfDxeEventGroupGuid,
> NULL, TRUE },
> +  { SmmEndOfS3ResumeHandler,
> &gEdkiiSmmEndOfS3ResumeProtocolGuid, NULL, FALSE },
> +  { NULL,                       NULL,
> NULL, FALSE }
>  };
> 
>  UINTN                           mFullSmramRangeCount;
> @@ -383,6 +384,46 @@ SmmEndOfDxeHandler (  }
> 
>  /**
> +  Software SMI handler that is called when the EndOfS3Resume event is
> trigged.
> +  This function installs the SMM EndOfS3Resume Protocol so SMM 
> + Drivers are
> informed that
> +  S3 resume has finished.
> +
> +  @param  DispatchHandle  The unique handle assigned to this handler 
> + by
> SmiHandlerRegister().
> +  @param  Context         Points to an optional handler context which was
> specified when the handler was registered.
> +  @param  CommBuffer      A pointer to a collection of data in memory
> that will
> +                          be conveyed from a non-SMM environment into
> an SMM environment.
> +  @param  CommBufferSize  The size of the CommBuffer.
> +
> +  @return Status Code
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +SmmEndOfS3ResumeHandler (
> +  IN     EFI_HANDLE  DispatchHandle,
> +  IN     CONST VOID  *Context,        OPTIONAL
> +  IN OUT VOID        *CommBuffer,     OPTIONAL
> +  IN OUT UINTN       *CommBufferSize  OPTIONAL
> +  )
> +{
> +  EFI_STATUS  Status;
> +  EFI_HANDLE  SmmHandle;
> +
> +  DEBUG ((EFI_D_INFO, "SmmEndOfS3ResumeHandler\n"));
> +  //
> +  // Install SMM EndOfDxe protocol
> +  //
> +  SmmHandle = NULL;
> +  Status = SmmInstallProtocolInterface (
> +             &SmmHandle,
> +             &gEdkiiSmmEndOfS3ResumeProtocolGuid,
> +             EFI_NATIVE_INTERFACE,
> +             NULL
> +             );
> +  return Status;
> +}
> +
> +/**
>    Determine if two buffers overlap in memory.
> 
>    @param[in] Buff1  Pointer to first buffer diff --git 
> a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
> b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
> index b6f815c..6cc824b 100644
> --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
> +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
> @@ -32,6 +32,7 @@
>  #include <Protocol/SmmExitBootServices.h>  #include 
> <Protocol/SmmLegacyBoot.h>  #include <Protocol/SmmReadyToBoot.h>
> +#include <Protocol/SmmEndOfS3Resume.h>
> 
>  #include <Guid/Apriori.h>
>  #include <Guid/EventGroup.h>
> @@ -802,6 +803,29 @@ SmmReadyToBootHandler (
>    );
> 
>  /**
> +  Software SMI handler that is called when the EndOfS3Resume event is
> trigged.
> +  This function installs the SMM EndOfS3Resume Protocol so SMM 
> + Drivers are
> informed that
> +  S3 resume has finished.
> +
> +  @param  DispatchHandle  The unique handle assigned to this handler 
> + by
> SmiHandlerRegister().
> +  @param  Context         Points to an optional handler context which was
> specified when the handler was registered.
> +  @param  CommBuffer      A pointer to a collection of data in memory
> that will
> +                          be conveyed from a non-SMM environment into
> an SMM environment.
> +  @param  CommBufferSize  The size of the CommBuffer.
> +
> +  @return Status Code
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +SmmEndOfS3ResumeHandler (
> +  IN     EFI_HANDLE  DispatchHandle,
> +  IN     CONST VOID  *Context,        OPTIONAL
> +  IN OUT VOID        *CommBuffer,     OPTIONAL
> +  IN OUT UINTN       *CommBufferSize  OPTIONAL
> +  );
> +
> +/**
>    Place holder function until all the SMM System Table Service are available.
> 
>    @param  Arg1                   Undefined
> diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
> b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
> index 95e34bd..a724189 100644
> --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
> +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
> @@ -79,6 +79,7 @@
>    gEdkiiSmmExitBootServicesProtocolGuid         ##
> SOMETIMES_PRODUCES
>    gEdkiiSmmLegacyBootProtocolGuid               ##
> SOMETIMES_PRODUCES
>    gEdkiiSmmReadyToBootProtocolGuid              ## PRODUCES
> +  gEdkiiSmmEndOfS3ResumeProtocolGuid            ##
> SOMETIMES_PRODUCES
> 
>    gEfiSmmSwDispatch2ProtocolGuid                ##
> SOMETIMES_CONSUMES
>    gEfiSmmSxDispatch2ProtocolGuid                ##
> SOMETIMES_CONSUMES
> --
> 2.7.0.windows.1



  reply	other threads:[~2017-10-11  8:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11  5:31 [Patch v2 0/3] Add SmmEndOfS3Resume event Eric Dong
2017-10-11  5:31 ` [Patch v2 1/3] MdeModulePkg/SmmEndOfS3Resume.h: Add new protocol definition Eric Dong
2017-10-11  5:31 ` [Patch v2 2/3] UefiCpuPkg/S3Resume2Pei: Send S3 resume finished event to SmmCore Eric Dong
2017-10-11  6:25   ` Yao, Jiewen
2017-10-11  6:28     ` Dong, Eric
2017-10-11  5:31 ` [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished Eric Dong
2017-10-11  7:13   ` Yao, Jiewen
2017-10-11  8:24     ` Dong, Eric [this message]
2017-10-11  7:09 ` [Patch v2 0/3] Add SmmEndOfS3Resume event Ni, Ruiyu

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=ED077930C258884BBCB450DB737E66224AA1398C@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