MdeModulePkg/PciBusDxe: Install PciEnumerationComplete after PciIo
authorRuiyu Ni <ruiyu.ni@intel.com>
Mon, 22 Jan 2018 06:23:00 +0000 (14:23 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Wed, 24 Jan 2018 03:40:34 +0000 (11:40 +0800)
Per PI spec, the PciEnumerationComplete protocol installation
should be after PciIo installation.
Today's implementation installs the PciEnumerationComplete
after hardware enumeration is completed, but before PciIo
installation.
The change corrects the spec/implementation gap.
The change also benefits certain implementation that depends on
the PciIo handle in PciEnumerationComplete callback.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c

index 3bb5099..c48e3bb 100644 (file)
@@ -360,8 +360,19 @@ PciBusDriverBindingStart (
   //\r
   StartPciDevices (Controller);\r
 \r
-  gFullEnumeration = FALSE;\r
-  return EFI_SUCCESS;\r
+  if (gFullEnumeration) {\r
+    gFullEnumeration = FALSE;\r
+\r
+    Status = gBS->InstallProtocolInterface (\r
+                    &PciRootBridgeIo->ParentHandle,\r
+                    &gEfiPciEnumerationCompleteProtocolGuid,\r
+                    EFI_NATIVE_INTERFACE,\r
+                    NULL\r
+                    );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return Status;\r
 }\r
 \r
 /**\r
index f6aa327..d5d3c07 100644 (file)
@@ -104,16 +104,6 @@ PciEnumerator (
     return Status;\r
   }\r
 \r
-  Status = gBS->InstallProtocolInterface (\r
-                  &HostBridgeHandle,\r
-                  &gEfiPciEnumerationCompleteProtocolGuid,\r
-                  EFI_NATIVE_INTERFACE,\r
-                  NULL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r