public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Yuanhao Xie" <yuanhao.xie@intel.com>
To: "Ni, Ray" <ray.ni@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	"Dong, Eric" <eric.dong@intel.com>,
	"Kumar, Rahul R" <rahul.r.kumar@intel.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Subject: Re: [Patch V3 5/5] UefiCpuPkg: Eliminate the second INIT-SIPI-SIPI sequence.
Date: Wed, 28 Jun 2023 08:52:28 +0000	[thread overview]
Message-ID: <CO1PR11MB5026E704DEF5D61A98644794F024A@CO1PR11MB5026.namprd11.prod.outlook.com> (raw)
In-Reply-To: <MN6PR11MB82447ACD8D36AFAD9F33882C8C27A@MN6PR11MB8244.namprd11.prod.outlook.com>

Hi Ray,

Please check V4 patch series.
Thanks for the feedbacks.

Yuanhao


> +      OriginalValue         = InterlockedCompareExchange32 (
> +                                (UINT32 *)ApStartupSignalBuffer,
> +                                MP_HAND_OFF_SIGNAL,
> +                                0
> +                                );
> +      if (OriginalValue == MP_HAND_OFF_SIGNAL) {
> +        SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateReady);
> +      }

1. I don't think InterlockedCompareExchange32() is needed. But it's consistent with the following code. Ok to me.
A: I keep this in V4 patch series.

> +
>        InterlockedCompareExchange32 (
>          (UINT32 *)ApStartupSignalBuffer,
>          WAKEUP_AP_SIGNAL,
> @@ -887,6 +897,32 @@ ApWakeupFunction (
>    }
>  }
> 

> +DxeApEntryPoint (
> +  CPU_MP_DATA  *CpuMpData
> +  )
> +{
> +  UINTN  ProcessorNumber;
> +
> +  GetProcessorNumber (CpuMpData, &ProcessorNumber);  
> + InterlockedIncrement ((UINT32 *)&CpuMpData->FinishedCount);  
> + RestoreVolatileRegisters (&CpuMpData->CpuData[0].VolatileRegisters, 
> + FALSE);  PlaceAPInMwaitLoopOrRunLoop (
> +    CpuMpData->ApLoopMode,
> +    CpuMpData->CpuData[ProcessorNumber].StartupApSignal,
> +    CpuMpData->ApTargetCState
> +    );

2. CpuMpData->ApLoopMode is set to PcdGet8 (PcdCpuApLoopMode) in DXE phase.
     It's possible that when building the Dxe instance of the library, PcdCpuApLoopMode is ApInHltLoop.
     Then above code should not expect the CpuMpData->ApLoopMode is either MwaitLoop or RunLoop.
     But, if the CPU runs here, PcdCpuApLoopMode in PEI phase should not be APInHltLoop.
     So the question becomes: Shall MpInitLib support different PcdCpuApLoopMode values?
     I prefer no for keeping the configuration simple.
     Then, can you please add an assertion before calling SwitchApContext()? (see comments below)

A: I added assertion in V4 patch series.

> +    if (MpHandOff->WaitLoopExecutionMode == sizeof (VOID *)) {

3. can you add "ASSERT (CpuMpData->ApLoopMode != APInHltLoop)" here?

> +      //
> +      // In scenarios where both the PEI and DXE phases run in the same
> +      // execution mode (32bit or 64bit), the BSP triggers
> +      // a start-up signal during the DXE phase to wake up the APs. This causes any
> +      // APs that are currently in a loop on the memory prepared during the PEI
> +      // phase to awaken and run the SwitchContextPerAp procedure. 
> + This
> procedure
> +      // enables the APs to switch to a different memory section and continue their
> +      // looping process there.
> +      //
> +      CpuMpData->FinishedCount = 0;
> +      CpuMpData->InitFlag      = ApInitDone;
> +      SaveCpuMpData (CpuMpData);
> +      SwitchApContext (MpHandOff);
> +      ASSERT (CpuMpData->FinishedCount == (CpuMpData->CpuCount - 1));


      reply	other threads:[~2023-06-28  8:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26  5:57 [Patch V3 0/5] Eliminate the second INIT-SIPI-SIPI sequence Yuanhao Xie
2023-06-26  5:57 ` [Patch V3 1/5] UefiCpuPkg: Refactor the logic for placing APs in HltLoop Yuanhao Xie
2023-06-26  9:10   ` Ni, Ray
2023-06-26  5:57 ` [Patch V3 2/5] UefiCpuPkg: Refactor the logic for placing APs in Mwait/Runloop Yuanhao Xie
2023-06-26  9:10   ` Ni, Ray
2023-06-26  5:57 ` [Patch V3 3/5] UefiCpuPkg: Create MpHandOff Yuanhao Xie
2023-06-26  9:28   ` Ni, Ray
2023-06-28  8:57     ` Yuanhao Xie
2023-06-26  5:57 ` [Patch V3 4/5] UefiCpuPkg: ApWakeupFunction directly use CpuMpData Yuanhao Xie
2023-06-26  9:36   ` Ni, Ray
2023-06-26  5:57 ` [Patch V3 5/5] UefiCpuPkg: Eliminate the second INIT-SIPI-SIPI sequence Yuanhao Xie
2023-06-27  5:51   ` Ni, Ray
2023-06-28  8:52     ` Yuanhao Xie [this message]

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=CO1PR11MB5026E704DEF5D61A98644794F024A@CO1PR11MB5026.namprd11.prod.outlook.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