diff mbox

[edk2,wave,1,4/5] OvmfPkg: AcpiPlatformDxe: when PCI is enabled, wait for Platform BDS's cue

Message ID 1457959945-29391-5-git-send-email-lersek@redhat.com
State New
Headers show

Commit Message

Laszlo Ersek March 14, 2016, 12:52 p.m. UTC
This patch doesn't change the behavior of AcpiPlatformDxe when
PcdPciDisableBusEnumeration is TRUE -- that is, when the driver runs on
Xen (OvmfPkg and ArmVirtPkg both), or when the driver runs on QEMU as part
of ArmVirtPkg but no PCI host bridge was found by VirtFdtDxe. In these
cases the driver continues to install the ACPI tables immediately.

However, when PcdPciDisableBusEnumeration is FALSE (i.e., when the driver
runs on QEMU as part of OVMF, or as part of ArmVirtPkg and VirtFdtDxe
finds a PCI host bridge), we now delay the ACPI table download from QEMU.
We wait until the Platform BDS tells us that root bridges have been
connected, and PciIo instances are available.

The explanation is in the patch titled

  OvmfPkg: introduce gRootBusesConnectedProtocolGuid

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Marcel Apfelbaum <marcel@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>

---
 OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf          |  2 +-
 OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf |  2 +-
 OvmfPkg/AcpiPlatformDxe/EntryPoint.c                 | 34 +++++++++++---------
 3 files changed, 20 insertions(+), 18 deletions(-)

-- 
1.8.3.1


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox

Patch

diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
index 055f3ad0ee0f..742ad8016c69 100644
--- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
+++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
@@ -53,15 +53,15 @@  [LibraryClasses]
   MemoryAllocationLib
   BaseLib
   DxeServicesTableLib
   OrderedCollectionLib
 
 [Protocols]
   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED
-  gEfiPciEnumerationCompleteProtocolGuid        # PROTOCOL SOMETIMES_CONSUMED
+  gRootBusesConnectedProtocolGuid               # PROTOCOL SOMETIMES_CONSUMED
 
 [Guids]
   gEfiXenInfoGuid
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
diff --git a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf
index 22ce165852f9..5a01de58ed53 100644
--- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf
+++ b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf
@@ -43,14 +43,14 @@  [LibraryClasses]
   OrderedCollectionLib
   QemuFwCfgLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
 
 [Protocols]
   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED
-  gEfiPciEnumerationCompleteProtocolGuid        # PROTOCOL SOMETIMES_CONSUMED
+  gRootBusesConnectedProtocolGuid               # PROTOCOL SOMETIMES_CONSUMED
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
 
 [Depex]
   gEfiAcpiTableProtocolGuid
diff --git a/OvmfPkg/AcpiPlatformDxe/EntryPoint.c b/OvmfPkg/AcpiPlatformDxe/EntryPoint.c
index d713b0d44b1b..dafdf8578265 100644
--- a/OvmfPkg/AcpiPlatformDxe/EntryPoint.c
+++ b/OvmfPkg/AcpiPlatformDxe/EntryPoint.c
@@ -9,15 +9,15 @@ 
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php
 
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
   WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/
 
-#include <Protocol/PciEnumerationComplete.h>
+#include <Protocol/RootBusesConnected.h>
 #include "AcpiPlatform.h"
 
 STATIC
 EFI_ACPI_TABLE_PROTOCOL *
 FindAcpiTableProtocol (
   VOID
   )
@@ -34,22 +34,23 @@  FindAcpiTableProtocol (
   return AcpiTable;
 }
 
 
 STATIC
 VOID
 EFIAPI
-OnPciEnumerated (
+OnRootBusesConnected (
   IN EFI_EVENT Event,
   IN VOID      *Context
   )
 {
   EFI_STATUS Status;
 
-  DEBUG ((EFI_D_INFO, "%a: PCI enumeration complete, installing ACPI tables\n",
+  DEBUG ((EFI_D_INFO,
+    "%a: root buses have been connected, installing ACPI tables\n",
     __FUNCTION__));
   Status = InstallAcpiTables (FindAcpiTableProtocol ());
   if (EFI_ERROR (Status)) {
     DEBUG ((EFI_D_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status));
   }
   gBS->CloseEvent (Event);
 }
@@ -60,57 +61,58 @@  EFIAPI
 AcpiPlatformEntryPoint (
   IN EFI_HANDLE         ImageHandle,
   IN EFI_SYSTEM_TABLE   *SystemTable
   )
 {
   EFI_STATUS Status;
   VOID       *Interface;
-  EFI_EVENT  PciEnumerated;
+  EFI_EVENT  RootBusesConnected;
   VOID       *Registration;
 
   //
   // If the platform doesn't support PCI, or PCI enumeration has been disabled,
   // install the tables at once, and let the entry point's return code reflect
   // the full functionality.
   //
   if (PcdGetBool (PcdPciDisableBusEnumeration)) {
     DEBUG ((EFI_D_INFO, "%a: PCI or its enumeration disabled, installing "
       "ACPI tables\n", __FUNCTION__));
     return InstallAcpiTables (FindAcpiTableProtocol ());
   }
 
   //
-  // Similarly, if PCI enumeration has already completed, install the tables
+  // Similarly, if root buses have already been connected, install the tables
   // immediately.
   //
-  Status = gBS->LocateProtocol (&gEfiPciEnumerationCompleteProtocolGuid,
+  Status = gBS->LocateProtocol (&gRootBusesConnectedProtocolGuid,
                   NULL /* Registration */, &Interface);
   if (!EFI_ERROR (Status)) {
-    DEBUG ((EFI_D_INFO, "%a: PCI enumeration already complete, "
+    DEBUG ((EFI_D_INFO, "%a: root buses already connected, "
       "installing ACPI tables\n", __FUNCTION__));
     return InstallAcpiTables (FindAcpiTableProtocol ());
   }
   ASSERT (Status == EFI_NOT_FOUND);
 
   //
-  // Otherwise, delay installing the ACPI tables until PCI enumeration
-  // completes. The entry point's return status will only reflect the callback
+  // Otherwise, delay installing the ACPI tables until root buses are
+  // connected. The entry point's return status will only reflect the callback
   // setup.
   //
-  Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, OnPciEnumerated,
-                  NULL /* Context */, &PciEnumerated);
+  Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
+                  OnRootBusesConnected, NULL /* Context */,
+                  &RootBusesConnected);
   if (EFI_ERROR (Status)) {
     return Status;
   }
 
-  Status = gBS->RegisterProtocolNotify (
-                  &gEfiPciEnumerationCompleteProtocolGuid, PciEnumerated,
-                  &Registration);
+  Status = gBS->RegisterProtocolNotify (&gRootBusesConnectedProtocolGuid,
+                  RootBusesConnected, &Registration);
   if (EFI_ERROR (Status)) {
-    gBS->CloseEvent (PciEnumerated);
+    gBS->CloseEvent (RootBusesConnected);
   } else {
-    DEBUG ((EFI_D_INFO, "%a: PCI enumeration pending, registered callback\n",
+    DEBUG ((EFI_D_INFO,
+      "%a: waiting for root buses to be connected, registered callback\n",
       __FUNCTION__));
   }
 
   return Status;
 }