On 07/08/15 02:38, Jordan Justen wrote: > On 2015-07-07 08:09:23, Laszlo Ersek wrote: >> QEMU provides an fw_cfg file called "etc/extra-pci-roots", containing a > > How long were the extra roots in qemu without the fw_cfg entry?
Not at all. Please see QEMU commit 2118196bb. That patch, adding the fw_cfg file, is an integral part of Marcel's patch series that implements the QEMU feature. OVMF support required twelve more QEMU patches from me. See their list in: https://bugzilla.redhat.com/show_bug.cgi?id=1193080#c12 https://bugzilla.redhat.com/show_bug.cgi?id=1193080#c11 But both Marcel's feature patches (one of which is 2118196bb), and my tweaks for OVMF, will be part of QEMU v2.4.0. > That's a leading question for, what if we only were to only scan for > the roots if the fw_cfg entry is present? That's exactly what the patch does. (Apologies if the commit message is not fully precise on this.) Please see the code that I'm marking below. > > Does seabios scan up to 255 if the fw_cfg entry is not found? It does not, please see seabios commit 5cc7eece. And we're actually following suit, please see below. > -Jordan > >> little-endian UINT64 value that exposes the number of extra root buses. We >> can use this value to terminate the scan as soon as we find the last extra >> root bus. >> >> Cc: Jordan Justen <jordan.l.jus...@intel.com> >> Contributed-under: TianoCore Contribution Agreement 1.0 >> Signed-off-by: Laszlo Ersek <ler...@redhat.com> >> Regression-tested-by: Gabriel Somlo <so...@cmu.edu> >> --- >> >> Notes: >> v2: >> - %Lu is available now in format strings, for printing UINT64 values in >> decimal >> >> OvmfPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf | 2 ++ >> OvmfPkg/PciHostBridgeDxe/PciHostBridge.c | 22 +++++++++++++++++++- >> 2 files changed, 23 insertions(+), 1 deletion(-) >> >> diff --git a/OvmfPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf >> b/OvmfPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf >> index 40f4c3c..ca760b5 100644 >> --- a/OvmfPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf >> +++ b/OvmfPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf >> @@ -26,6 +26,7 @@ [Defines] >> >> [Packages] >> MdePkg/MdePkg.dec >> + OvmfPkg/OvmfPkg.dec >> >> [LibraryClasses] >> UefiDriverEntryPoint >> @@ -39,6 +40,7 @@ [LibraryClasses] >> DevicePathLib >> IoLib >> PciLib >> + QemuFwCfgLib >> >> [Sources] >> PciHostBridge.c >> diff --git a/OvmfPkg/PciHostBridgeDxe/PciHostBridge.c >> b/OvmfPkg/PciHostBridgeDxe/PciHostBridge.c >> index 3486644..efef2ed 100644 >> --- a/OvmfPkg/PciHostBridgeDxe/PciHostBridge.c >> +++ b/OvmfPkg/PciHostBridgeDxe/PciHostBridge.c >> @@ -15,6 +15,8 @@ >> >> **/ >> >> +#include <Library/QemuFwCfgLib.h> >> + >> #include "PciHostBridge.h" >> >> STATIC >> @@ -207,6 +209,9 @@ InitializePciHostBridge ( >> ) >> { >> EFI_STATUS Status; >> + FIRMWARE_CONFIG_ITEM FwCfgItem; >> + UINTN FwCfgSize; >> + UINT64 ExtraRootBridgesLeft; >> UINTN LastRootBridgeNumber; >> UINTN RootBridgeNumber; >> PCI_HOST_BRIDGE_INSTANCE *HostBridge; >> @@ -237,6 +242,20 @@ InitializePciHostBridge ( >> } >> >> // >> + // QEMU provides the number of extra root buses, shortening the exhaustive >> + // search below. If there is no hint, the feature is missing. >> + // >> + Status = QemuFwCfgFindFile ("etc/extra-pci-roots", &FwCfgItem, >> &FwCfgSize); >> + if (EFI_ERROR (Status) || FwCfgSize != sizeof ExtraRootBridgesLeft) { >> + ExtraRootBridgesLeft = 0; If QemuFwCfgFindFile() doesn't find the fw_cfg file, then it returns NOT_FOUND. That will set ExtraRootBridgesLeft to zero, and then: >> + } else { >> + QemuFwCfgSelectItem (FwCfgItem); >> + QemuFwCfgReadBytes (FwCfgSize, &ExtraRootBridgesLeft); >> + DEBUG ((EFI_D_INFO, "%a: %Lu extra root buses reported by QEMU\n", >> + __FUNCTION__, ExtraRootBridgesLeft)); >> + } >> + >> + // >> // The "main" root bus is always there. >> // >> LastRootBridgeNumber = 0; >> @@ -247,7 +266,7 @@ InitializePciHostBridge ( >> // alive. >> // >> for (RootBridgeNumber = 1; >> - RootBridgeNumber < 256; >> + RootBridgeNumber < 256 && ExtraRootBridgesLeft > 0; this condition here will prevent the loop body from executing even once. See also the comment a bit higher up: "If there is no hint, the feature is missing.". ... If you are otherwise okay with this patch, I can append a remark like this to the commit message, before committing the set: If the "etc/extra-pci-roots" fw_cfg file is absent, then no extra root buses are available, and we skip the scan altogether. Thanks! Laszlo >> ++RootBridgeNumber) { >> UINTN Device; >> >> @@ -271,6 +290,7 @@ InitializePciHostBridge ( >> } >> InsertTailList (&HostBridge->Head, &RootBus->Link); >> LastRootBridgeNumber = RootBridgeNumber; >> + --ExtraRootBridgesLeft; >> } >> } >> >> -- >> 1.8.3.1 >> >> ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel