public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Foster Nong <foster.nong@intel.com>
To: devel@edk2.groups.io
Cc: Foster Nong <foster.nong@intel.com>
Subject: [PATCH 1/1] MdeModulePkg: Enhance bus scan for all root bridge instances
Date: Fri, 22 Jul 2022 17:10:26 +0800	[thread overview]
Message-ID: <20220722091026.47-1-foster.nong@intel.com> (raw)

Ref:https://bugzilla.tianocore.org/show_bug.cgi?id=4000

Change flow to bus scan all root bridge instances even when any
one root bridge meet bus resource OUT_OF_RESOURCE case.
thus platform handler  of "EfiPciHostBridgeEndBusAllocation" has
an chance to do relative pci bus rebalance to handle this case.

Signed-off-by: Foster Nong <foster.nong@intel.com>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
index 63d149b3b8c0..a89f912de85b 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
@@ -1528,6 +1528,7 @@ PciHostBridgeEnumerator (
   UINT8                              StartBusNumber;
   LIST_ENTRY                         RootBridgeList;
   LIST_ENTRY                         *Link;
+  EFI_STATUS                         RootBridgeEnumerationStatus;
 
   if (FeaturePcdGet (PcdPciBusHotplugDeviceSupport)) {
     InitializeHotPlugSupport ();
@@ -1546,6 +1547,7 @@ PciHostBridgeEnumerator (
 
   DEBUG ((DEBUG_INFO, "PCI Bus First Scanning\n"));
   RootBridgeHandle = NULL;
+  RootBridgeEnumerationStatus = EFI_SUCCESS;
   while (PciResAlloc->GetNextRootBridge (PciResAlloc, &RootBridgeHandle) == EFI_SUCCESS) {
     //
     // if a root bridge instance is found, create root bridge device for it
@@ -1572,7 +1574,7 @@ PciHostBridgeEnumerator (
     }
 
     if (EFI_ERROR (Status)) {
-      return Status;
+      RootBridgeEnumerationStatus = Status;
     }
   }
 
@@ -1581,6 +1583,10 @@ PciHostBridgeEnumerator (
   //
   NotifyPhase (PciResAlloc, EfiPciHostBridgeEndBusAllocation);
 
+  if (EFI_ERROR (RootBridgeEnumerationStatus)) {
+      return RootBridgeEnumerationStatus;
+  }
+
   if ((gPciHotPlugInit != NULL) && FeaturePcdGet (PcdPciBusHotplugDeviceSupport)) {
     //
     // Reset all assigned PCI bus number in all PPB
@@ -1659,7 +1665,7 @@ PciHostBridgeEnumerator (
 
       DestroyRootBridge (RootBridgeDev);
       if (EFI_ERROR (Status)) {
-        return Status;
+        RootBridgeEnumerationStatus = Status;
       }
     }
 
@@ -1667,6 +1673,10 @@ PciHostBridgeEnumerator (
     // Notify the bus allocation phase is to end for the 2nd time
     //
     NotifyPhase (PciResAlloc, EfiPciHostBridgeEndBusAllocation);
+
+    if (EFI_ERROR (RootBridgeEnumerationStatus)) {
+      return RootBridgeEnumerationStatus;
+    }
   }
 
   //
-- 
2.26.2.windows.1


             reply	other threads:[~2022-07-22  9:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-22  9:10 Foster Nong [this message]
2022-07-22 23:48 ` [edk2-devel] [PATCH 1/1] MdeModulePkg: Enhance bus scan for all root bridge instances Michael D Kinney
2022-07-25  8:36   ` Nong, Foster
2022-08-10  7:54 ` Ni, Ray

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=20220722091026.47-1-foster.nong@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