]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Update PciEnumeratorSupport to ignore OptionRom if needed
authorMin Xu <min.m.xu@intel.com>
Thu, 24 Feb 2022 13:50:33 +0000 (21:50 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sat, 2 Apr 2022 10:09:47 +0000 (10:09 +0000)
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429

Function of UpdatePciInfo() in PciEnumeratorSupport.c is used to update
the bar information for those incompatible PCI device. It is the right
place to check if the OptionRom need to be ignored.

According to "Table 20. ACPI 2.0 & 3.0 QWORD Address Space Descriptor
Usage" in PI Spec 1.7, Type-specific flags can be set to 0 when Address
Translation Offset == 6 to skip device option ROM (do not probe option
rom BAR).

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.h

index 9251388bc26836f6422656cf7b5a4b32bb3001e0..509f828b621d07258cb864ab328327fc5d35285e 100644 (file)
@@ -220,8 +220,10 @@ PciSearchDevice (
   )\r
 {\r
   PCI_IO_DEVICE  *PciIoDevice;\r
+  BOOLEAN        IgnoreOptionRom;\r
 \r
-  PciIoDevice = NULL;\r
+  PciIoDevice     = NULL;\r
+  IgnoreOptionRom = FALSE;\r
 \r
   DEBUG ((\r
     DEBUG_INFO,\r
@@ -285,7 +287,7 @@ PciSearchDevice (
   //\r
   // Update the bar information for this PCI device so as to support some specific device\r
   //\r
-  UpdatePciInfo (PciIoDevice);\r
+  UpdatePciInfo (PciIoDevice, &IgnoreOptionRom);\r
 \r
   if (PciIoDevice->DevicePath == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
@@ -295,7 +297,7 @@ PciSearchDevice (
   // Detect this function has option rom\r
   //\r
   if (gFullEnumeration) {\r
-    if (!IS_CARDBUS_BRIDGE (Pci)) {\r
+    if (!IS_CARDBUS_BRIDGE (Pci) && !IgnoreOptionRom) {\r
       GetOpRomInfo (PciIoDevice);\r
     }\r
 \r
@@ -1310,6 +1312,7 @@ DetermineDeviceAttribute (
 \r
   @param PciIoDevice      Input Pci device instance. Output Pci device instance with updated\r
                           Bar information.\r
+  @param IgnoreOptionRom  Output If the option rom of incompatible device need to be ignored.\r
 \r
   @retval EFI_SUCCESS     Successfully updated bar information.\r
   @retval EFI_UNSUPPORTED Given PCI device doesn't belong to incompatible PCI device list.\r
@@ -1317,7 +1320,8 @@ DetermineDeviceAttribute (
 **/\r
 EFI_STATUS\r
 UpdatePciInfo (\r
-  IN OUT PCI_IO_DEVICE  *PciIoDevice\r
+  IN OUT PCI_IO_DEVICE  *PciIoDevice,\r
+  OUT BOOLEAN           *IgnoreOptionRom\r
   )\r
 {\r
   EFI_STATUS                         Status;\r
@@ -1374,6 +1378,17 @@ UpdatePciInfo (
       break;\r
     }\r
 \r
+    //\r
+    // According to "Table 20. ACPI 2.0 & 3.0 QWORD Address Space Descriptor Usage"\r
+    // in PI Spec 1.7, Type-specific flags can be set to 0 when Address Translation\r
+    // Offset == 6 to skip device option ROM (do not probe option rom BAR).\r
+    //\r
+    if (((Ptr->AddrTranslationOffset == PCI_MAX_BAR) && (Ptr->SpecificFlag == 0))) {\r
+      *IgnoreOptionRom = TRUE;\r
+      Ptr++;\r
+      continue;\r
+    }\r
+\r
     for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex++) {\r
       if ((Ptr->AddrTranslationOffset != MAX_UINT64) &&\r
           (Ptr->AddrTranslationOffset != MAX_UINT8) &&\r
index 0ded4bea4f89070a37a693f0c6496b70db727345..7daa6e020d09eefe9df89723bb3c6221f39e94db 100644 (file)
@@ -262,6 +262,7 @@ DetermineDeviceAttribute (
 \r
   @param PciIoDevice      Input Pci device instance. Output Pci device instance with updated\r
                           Bar information.\r
+  @param IgnoreOptionRom  Output If the option rom of incompatible device need to be ignored.\r
 \r
   @retval EFI_SUCCESS     Successfully updated bar information.\r
   @retval EFI_UNSUPPORTED Given PCI device doesn't belong to incompatible PCI device list.\r
@@ -269,7 +270,8 @@ DetermineDeviceAttribute (
 **/\r
 EFI_STATUS\r
 UpdatePciInfo (\r
-  IN OUT PCI_IO_DEVICE  *PciIoDevice\r
+  IN OUT PCI_IO_DEVICE  *PciIoDevice,\r
+  OUT BOOLEAN           *IgnoreOptionRom\r
   );\r
 \r
 /**\r