From: "Laszlo Ersek" <lersek@redhat.com>
To: devel@edk2.groups.io, kraxel@redhat.com
Cc: Ray Ni <ray.ni@intel.com>, Rahul Kumar <rahul1.kumar@intel.com>,
Oliver Steffen <osteffen@redhat.com>
Subject: Re: [edk2-devel] [PATCH v3 6/6] UefiCpuPkg/MpInitLib: return early in GetBspNumber()
Date: Mon, 26 Feb 2024 15:01:25 +0100 [thread overview]
Message-ID: <ea40c283-2d21-78c0-8029-5976c159aaee@redhat.com> (raw)
In-Reply-To: <20240222160106.686484-7-kraxel@redhat.com>
On 2/22/24 17:01, Gerd Hoffmann wrote:
> After finding the BSP Number return the result instead of
> continuing to loop over the remaining processors.
>
> Suggested-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> UefiCpuPkg/Library/MpInitLib/MpLib.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 4b6d6d02b027..2051554207dc 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -1903,15 +1903,13 @@ GetBspNumber (
> )
> {
> UINT32 ApicId;
> - UINT32 BspNumber;
> UINT32 Index;
> CONST MP_HAND_OFF *MpHandOff;
>
> //
> // Get the processor number for the BSP
> //
> - BspNumber = MAX_UINT32;
> - ApicId = GetInitialApicId ();
> + ApicId = GetInitialApicId ();
>
> for (MpHandOff = FirstMpHandOff;
> MpHandOff != NULL;
> @@ -1919,14 +1917,13 @@ GetBspNumber (
> {
> for (Index = 0; Index < MpHandOff->CpuCount; Index++) {
> if (MpHandOff->Info[Index].ApicId == ApicId) {
> - BspNumber = MpHandOff->ProcessorIndex + Index;
> + return MpHandOff->ProcessorIndex + Index;
> }
> }
> }
>
> - ASSERT (BspNumber != MAX_UINT32);
> -
> - return BspNumber;
> + ASSERT (FALSE);
> + return 0;
> }
>
> /**
There's a somewhat sneaky change in here: if we fail to find the BSP,
then (beyond tripping an assert like before) we now return 0, rather
than MAX_UINT32.
However, that's arguably more sensible, even.
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Laszlo
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115965): https://edk2.groups.io/g/devel/message/115965
Mute This Topic: https://groups.io/mt/104510913/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-02-26 14:01 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 16:01 [edk2-devel] [PATCH v3 0/6] UefiCpuPkg/MpInitLib: Add support for multiple MP_HAND_OFF HOBs Gerd Hoffmann
2024-02-22 16:01 ` [edk2-devel] [PATCH v3 1/6] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to GetMpHandOffHob Gerd Hoffmann
2024-02-23 2:35 ` Ni, Ray
2024-02-26 13:42 ` Laszlo Ersek
2024-02-22 16:01 ` [edk2-devel] [PATCH v3 2/6] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to GetBspNumber() Gerd Hoffmann
2024-02-22 16:01 ` [edk2-devel] [PATCH v3 3/6] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to SwitchApContext() Gerd Hoffmann
2024-02-22 16:01 ` [edk2-devel] [PATCH v3 4/6] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to MpInitLibInitialize Gerd Hoffmann
2024-02-26 13:51 ` Laszlo Ersek
2024-02-22 16:01 ` [edk2-devel] [PATCH v3 5/6] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to SaveCpuMpData() Gerd Hoffmann
2024-02-23 2:16 ` Ni, Ray
2024-02-26 13:55 ` Laszlo Ersek
2024-02-26 13:55 ` Laszlo Ersek
2024-02-22 16:01 ` [edk2-devel] [PATCH v3 6/6] UefiCpuPkg/MpInitLib: return early in GetBspNumber() Gerd Hoffmann
2024-02-23 2:33 ` Ni, Ray
2024-02-26 13:59 ` Laszlo Ersek
2024-02-26 14:01 ` Laszlo Ersek [this message]
2024-02-26 15:08 ` [edk2-devel] [PATCH v3 0/6] UefiCpuPkg/MpInitLib: Add support for multiple MP_HAND_OFF HOBs Laszlo Ersek
2024-02-26 15:41 ` Joey Vagedes via groups.io
2024-02-26 16:01 ` Laszlo Ersek
2024-02-26 16:02 ` Laszlo Ersek
2024-02-26 15:19 ` Laszlo Ersek
2024-02-26 22:17 ` Laszlo Ersek
2024-02-27 6:28 ` Ni, Ray
2024-02-27 12:11 ` Laszlo Ersek
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=ea40c283-2d21-78c0-8029-5976c159aaee@redhat.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