]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: exit pci function loops early if device is not multi-function
authorJoseph Shifflett <joseph.shifflett@hpe.com>
Tue, 6 Oct 2015 20:55:31 +0000 (20:55 +0000)
committerlersek <lersek@Edk2>
Tue, 6 Oct 2015 20:55:31 +0000 (20:55 +0000)
When looping through all PCI functions, code should not look for functions
1-7 if function 0 is not present or if function 0 indicates the device is
not multifunction.  Prior to this fix the code would use stale data in a
buffer to determine if a device is multifunction even if function 0 is not
present.  This fixes a code bug and provides very small performance
improvements.

PCI 2.3 Specification states: They [multifunction devices] are also
required to always implement function 0 in the device. Implementing other
functions is optional and may be assigned in any order.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Joseph Shifflett <joseph.shifflett@hpe.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18574 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c
MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c

index 732914313607ec2d44f72e745b6a977abe206c4b..597c0834e0f50606287f15fd5c2cf8833bed160c 100644 (file)
@@ -2,6 +2,7 @@
   PCI eunmeration implementation on entire PCI bus system for PCI Bus module.\r
 \r
 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -407,6 +408,13 @@ PciAssignBusNumber (
                 Func\r
                 );\r
 \r
+      if (EFI_ERROR (Status) && Func == 0) {\r
+        //\r
+        // go to next device if there is no Function 0\r
+        //\r
+        break;\r
+      }\r
+\r
       if (!EFI_ERROR (Status)   &&\r
           (IS_PCI_BRIDGE (&Pci) || IS_CARDBUS_BRIDGE (&Pci))) {\r
 \r
index f46025e2f61c54f3b32b4a3cd45792c5a0e072da..f7aea4fd80c8423723e4c3db7bf54f5442f1bdfd 100644 (file)
@@ -2,6 +2,7 @@
   PCI emumeration support functions implementation for PCI Bus module.\r
 \r
 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -119,6 +120,14 @@ PciPciDeviceInfoCollector (
                  (UINT8) Device,\r
                  (UINT8) Func\r
                  );\r
+\r
+      if (EFI_ERROR (Status) && Func == 0) {\r
+        //\r
+        // go to next device if there is no Function 0\r
+        //\r
+        break;\r
+      }\r
+\r
       if (!EFI_ERROR (Status)) {\r
 \r
         //\r
@@ -2597,6 +2606,13 @@ ResetAllPpbBusNumber (
                  Func\r
                  );\r
 \r
+      if (EFI_ERROR (Status) && Func == 0) {\r
+        //\r
+        // go to next device if there is no Function 0\r
+        //\r
+        break;\r
+      }\r
+\r
       if (!EFI_ERROR (Status) && (IS_PCI_BRIDGE (&Pci))) {\r
 \r
         Register  = 0;\r
index b3d91a8d3037ee43f85f060211d78a3d27567c9e..3e275e34ecebe4c998d18cf05184e373120494c6 100644 (file)
@@ -2,6 +2,7 @@
   Internal library implementation for PCI Bus module.\r
 \r
 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -1022,6 +1023,13 @@ PciScanBus (
                 Func\r
                 );\r
 \r
+      if (EFI_ERROR (Status) && Func == 0) {\r
+        //\r
+        // go to next device if there is no Function 0\r
+        //\r
+        break;\r
+      }\r
+\r
       if (EFI_ERROR (Status)) {\r
         continue;\r
       }\r