public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/2] Install PciEnumerationComplete after PciIo
@ 2018-01-22  6:24 Ruiyu Ni
  2018-01-22  6:24 ` [PATCH 1/2] MdeModulePkg/PciBusDxe: reference gFullEnumeration in one file Ruiyu Ni
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ruiyu Ni @ 2018-01-22  6:24 UTC (permalink / raw)
  To: edk2-devel

The 2nd patch does the real work. 1st patch cleans up the code to
prepare for 2nd patch.

Ruiyu Ni (2):
  MdeModulePkg/PciBusDxe: reference gFullEnumeration in one file
  MdeModulePkg/PciBusDxe: Install PciEnumerationComplete after PciIo

 MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c        | 45 ++++++++++++++++++++---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c | 50 +++-----------------------
 MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.h |  8 +++--
 3 files changed, 50 insertions(+), 53 deletions(-)

-- 
2.15.1.windows.2



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] MdeModulePkg/PciBusDxe: reference gFullEnumeration in one file
  2018-01-22  6:24 [PATCH 0/2] Install PciEnumerationComplete after PciIo Ruiyu Ni
@ 2018-01-22  6:24 ` Ruiyu Ni
  2018-01-22  6:24 ` [PATCH 2/2] MdeModulePkg/PciBusDxe: Install PciEnumerationComplete after PciIo Ruiyu Ni
  2018-01-22 10:53 ` [PATCH 0/2] " Zeng, Star
  2 siblings, 0 replies; 4+ messages in thread
From: Ruiyu Ni @ 2018-01-22  6:24 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng

The patch is just a code cleanup with no functionality impact.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c        | 32 ++++++++++++++++++---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c | 40 ++++----------------------
 MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.h |  8 ++++--
 3 files changed, 38 insertions(+), 42 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
index 950cacc120..3bb5099bd3 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
@@ -8,7 +8,7 @@
   PCI Root Bridges. So it means platform needs install PCI Root Bridge IO protocol for each
   PCI Root Bus and install PCI Host Bridge Resource Allocation Protocol.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -240,8 +240,9 @@ PciBusDriverBindingStart (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath
   )
 {
-  EFI_STATUS                Status;
-  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;
+  EFI_STATUS                      Status;
+  EFI_DEVICE_PATH_PROTOCOL        *ParentDevicePath;
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
 
   //
   // Check RemainingDevicePath validation
@@ -321,12 +322,34 @@ PciBusDriverBindingStart (
     ParentDevicePath
     );
 
+  Status = EFI_SUCCESS;
   //
   // Enumerate the entire host bridge
   // After enumeration, a database that records all the device information will be created
   //
   //
-  Status = PciEnumerator (Controller);
+  if (gFullEnumeration) {
+    //
+    // Get the rootbridge Io protocol to find the host bridge handle
+    //
+    Status = gBS->OpenProtocol (
+                    Controller,
+                    &gEfiPciRootBridgeIoProtocolGuid,
+                    (VOID **) &PciRootBridgeIo,
+                    gPciBusDriverBinding.DriverBindingHandle,
+                    Controller,
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                    );
+
+    if (!EFI_ERROR (Status)) {
+      Status = PciEnumerator (Controller, PciRootBridgeIo->ParentHandle);
+    }
+  } else {
+    //
+    // If PCI bus has already done the full enumeration, never do it again
+    //
+    Status = PciEnumeratorLight (Controller);
+  }
 
   if (EFI_ERROR (Status)) {
     return Status;
@@ -337,6 +360,7 @@ PciBusDriverBindingStart (
   //
   StartPciDevices (Controller);
 
+  gFullEnumeration = FALSE;
   return EFI_SUCCESS;
 }
 
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
index d31144739f..f6aa327493 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
@@ -1,7 +1,7 @@
 /** @file
   PCI eunmeration implementation on entire PCI bus system for PCI Bus module.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
@@ -19,7 +19,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   This routine is used to enumerate entire pci bus system
   in a given platform.
 
-  @param Controller  Parent controller handle.
+  @param Controller          Parent controller handle.
+  @param HostBridgeHandle    Host bridge handle.
 
   @retval EFI_SUCCESS    PCI enumeration finished successfully.
   @retval other          Some error occurred when enumerating the pci bus system.
@@ -27,41 +28,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/
 EFI_STATUS
 PciEnumerator (
-  IN EFI_HANDLE                    Controller
+  IN EFI_HANDLE                    Controller,
+  IN EFI_HANDLE                    HostBridgeHandle
   )
 {
-  EFI_HANDLE                                        HostBridgeHandle;
   EFI_STATUS                                        Status;
   EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL  *PciResAlloc;
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL                   *PciRootBridgeIo;
-
-  //
-  // If PCI bus has already done the full enumeration, never do it again
-  //
-  if (!gFullEnumeration) {
-    return PciEnumeratorLight (Controller);
-  }
-
-  //
-  // Get the rootbridge Io protocol to find the host bridge handle
-  //
-  Status = gBS->OpenProtocol (
-                  Controller,
-                  &gEfiPciRootBridgeIoProtocolGuid,
-                  (VOID **) &PciRootBridgeIo,
-                  gPciBusDriverBinding.DriverBindingHandle,
-                  Controller,
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
-                  );
-
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  //
-  // Get the host bridge handle
-  //
-  HostBridgeHandle = PciRootBridgeIo->ParentHandle;
 
   //
   // Get the pci host bridge resource allocation protocol
@@ -132,8 +104,6 @@ PciEnumerator (
     return Status;
   }
 
-  gFullEnumeration = FALSE;
-
   Status = gBS->InstallProtocolInterface (
                   &HostBridgeHandle,
                   &gEfiPciEnumerationCompleteProtocolGuid,
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.h b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.h
index 46f56618d4..2df1fb0b94 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.h
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.h
@@ -1,7 +1,7 @@
 /** @file
   PCI bus enumeration logic function declaration for PCI bus module.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -21,7 +21,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   This routine is used to enumerate entire pci bus system
   in a given platform.
 
-  @param Controller  Parent controller handle.
+  @param Controller          Parent controller handle.
+  @param HostBridgeHandle    Host bridge handle.
 
   @retval EFI_SUCCESS    PCI enumeration finished successfully.
   @retval other          Some error occurred when enumerating the pci bus system.
@@ -29,7 +30,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/
 EFI_STATUS
 PciEnumerator (
-  IN EFI_HANDLE                    Controller
+  IN EFI_HANDLE                    Controller,
+  IN EFI_HANDLE                    HostBridgeHandle
   );
 
 /**
-- 
2.15.1.windows.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] MdeModulePkg/PciBusDxe: Install PciEnumerationComplete after PciIo
  2018-01-22  6:24 [PATCH 0/2] Install PciEnumerationComplete after PciIo Ruiyu Ni
  2018-01-22  6:24 ` [PATCH 1/2] MdeModulePkg/PciBusDxe: reference gFullEnumeration in one file Ruiyu Ni
@ 2018-01-22  6:24 ` Ruiyu Ni
  2018-01-22 10:53 ` [PATCH 0/2] " Zeng, Star
  2 siblings, 0 replies; 4+ messages in thread
From: Ruiyu Ni @ 2018-01-22  6:24 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng

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>
Cc: Star Zeng <star.zeng@intel.com>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c        | 15 +++++++++++++--
 MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c | 10 ----------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
index 3bb5099bd3..c48e3bba96 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
@@ -360,8 +360,19 @@ PciBusDriverBindingStart (
   //
   StartPciDevices (Controller);
 
-  gFullEnumeration = FALSE;
-  return EFI_SUCCESS;
+  if (gFullEnumeration) {
+    gFullEnumeration = FALSE;
+
+    Status = gBS->InstallProtocolInterface (
+                    &PciRootBridgeIo->ParentHandle,
+                    &gEfiPciEnumerationCompleteProtocolGuid,
+                    EFI_NATIVE_INTERFACE,
+                    NULL
+                    );
+    ASSERT_EFI_ERROR (Status);
+  }
+
+  return Status;
 }
 
 /**
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
index f6aa327493..d5d3c07393 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
@@ -104,16 +104,6 @@ PciEnumerator (
     return Status;
   }
 
-  Status = gBS->InstallProtocolInterface (
-                  &HostBridgeHandle,
-                  &gEfiPciEnumerationCompleteProtocolGuid,
-                  EFI_NATIVE_INTERFACE,
-                  NULL
-                  );
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
   return EFI_SUCCESS;
 }
 
-- 
2.15.1.windows.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Install PciEnumerationComplete after PciIo
  2018-01-22  6:24 [PATCH 0/2] Install PciEnumerationComplete after PciIo Ruiyu Ni
  2018-01-22  6:24 ` [PATCH 1/2] MdeModulePkg/PciBusDxe: reference gFullEnumeration in one file Ruiyu Ni
  2018-01-22  6:24 ` [PATCH 2/2] MdeModulePkg/PciBusDxe: Install PciEnumerationComplete after PciIo Ruiyu Ni
@ 2018-01-22 10:53 ` Zeng, Star
  2 siblings, 0 replies; 4+ messages in thread
From: Zeng, Star @ 2018-01-22 10:53 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Zeng, Star

Reviewed-by: Star Zeng <star.zeng@intel.com>

Thanks,
Star
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Monday, January 22, 2018 2:24 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH 0/2] Install PciEnumerationComplete after PciIo

The 2nd patch does the real work. 1st patch cleans up the code to prepare for 2nd patch.

Ruiyu Ni (2):
  MdeModulePkg/PciBusDxe: reference gFullEnumeration in one file
  MdeModulePkg/PciBusDxe: Install PciEnumerationComplete after PciIo

 MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c        | 45 ++++++++++++++++++++---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c | 50 +++-----------------------  MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.h |  8 +++--
 3 files changed, 50 insertions(+), 53 deletions(-)

--
2.15.1.windows.2

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-22 10:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-22  6:24 [PATCH 0/2] Install PciEnumerationComplete after PciIo Ruiyu Ni
2018-01-22  6:24 ` [PATCH 1/2] MdeModulePkg/PciBusDxe: reference gFullEnumeration in one file Ruiyu Ni
2018-01-22  6:24 ` [PATCH 2/2] MdeModulePkg/PciBusDxe: Install PciEnumerationComplete after PciIo Ruiyu Ni
2018-01-22 10:53 ` [PATCH 0/2] " Zeng, Star

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox