From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web08.5716.1658481052695481752 for ; Fri, 22 Jul 2022 02:10:53 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=NYDKbwj/; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: foster.nong@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658481052; x=1690017052; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Dbg+vBU6MmuSqWQwp2CPlDdcnEsDTSic5ZpLd3TP+So=; b=NYDKbwj/h7TgASkihbk0vo5s61ZaGGb0MH3gBeaYXUft3nnYf66cMKYk IcXdxzZUV5T/W+t0MCn3s6/LMxqnDVQ/uulhyh2fVMx/s+1zl9wQ2l8Ny yHR4a3n4OhDRsK2iSs3z2YRmL9zSSzRE7xSXivBq5wK2rnDd1sAPGFlSK zpXmamDzyGNrAuvoN26K/JlxSOgF463GvBbrFHNKwOe7XD6TxNmRnuTvb W3vO8mgCOsa2kr1U3I9c05Aq8EsEsIIqPwL2lFNwRlEv6SEo6uui0jwWB /vo7h03a30/WzXD+9hI3lg6Azbnc0Vl1jQVMj5+ZQ9zWnnuKWXXchA030 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10415"; a="351268872" X-IronPort-AV: E=Sophos;i="5.93,185,1654585200"; d="scan'208";a="351268872" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2022 02:10:51 -0700 X-IronPort-AV: E=Sophos;i="5.93,185,1654585200"; d="scan'208";a="657142876" Received: from shwdeopenlab108.ccr.corp.intel.com ([10.239.182.54]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2022 02:10:50 -0700 From: Foster Nong To: devel@edk2.groups.io Cc: Foster Nong Subject: [PATCH 1/1] MdeModulePkg: Enhance bus scan for all root bridge instances Date: Fri, 22 Jul 2022 17:10:26 +0800 Message-Id: <20220722091026.47-1-foster.nong@intel.com> X-Mailer: git-send-email 2.37.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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