]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg/VirtFdtDxe: drop PCI host bridge handling
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 8 Apr 2016 09:45:02 +0000 (11:45 +0200)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 12 Apr 2016 16:26:47 +0000 (18:26 +0200)
Now that the PCI host bridge driver parses the DT node that describes
the PCI host bridge directly via the FDT client protocol, we can drop the
handling from VirtFdtDxe completely.

This means some PCI related PCDs are no longer set, such as PcdPciBusMin,
PcdPciBusMax, PcdPciIoBase, PcdPciIoSize, PcdPciIoTranslation,
PcdPciMmio32Base and PcdPciMmio32Size. Since these PCDs are specific to
ARM (and declared in ArmPlatformPkg), and not used anywhere else by the
ArmVirtPkg platforms, we can simply stop populating them, and drop all
references to them.

It also means that we can no longer rely on PcdPciDisableBusEnumeration
to be set before it is consumed by PciBusDxe and QemuFwCfgAcpiPlatformDxe,
so make those depend on FdtPciPcdProducerLib explicitly via NULL library
class resolution.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
ArmVirtPkg/ArmVirtQemu.dsc
ArmVirtPkg/ArmVirtQemuKernel.dsc
ArmVirtPkg/ArmVirtXen.dsc
ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.c
ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.inf

index f2eccf8cca63aaf99858638a4208d197c9805479..c42092f54163ff7873cbebcb68c986912c3d4d5f 100644 (file)
   ## PL031 RealTimeClock\r
   gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x0\r
 \r
-  gArmPlatformTokenSpaceGuid.PcdPciBusMin|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciBusMax|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciIoBase|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciIoSize|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciIoTranslation|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciMmio32Base|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciMmio32Size|0x0\r
-\r
   # set PcdPciExpressBaseAddress to MAX_UINT64, which signifies that this\r
   # PCD and PcdPciDisableBusEnumeration above have not been assigned yet\r
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xFFFFFFFFFFFFFFFF\r
   # PCI support\r
   #\r
   ArmVirtPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf\r
-  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf\r
+  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {\r
+    <LibraryClasses>\r
+      NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf\r
+  }\r
   OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf\r
   OvmfPkg/Virtio10Dxe/Virtio10.inf\r
 \r
   # ACPI Support\r
   #\r
   MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf\r
-  OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf\r
+  OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf {\r
+    <LibraryClasses>\r
+      NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf\r
+  }\r
index 107627e6a6f484ae7bdaffd42fe3464f9cc02661..2cbeced695f95cadd387e339df5e23e8a4b49d0d 100644 (file)
   ## PL031 RealTimeClock\r
   gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x0\r
 \r
-  gArmPlatformTokenSpaceGuid.PcdPciBusMin|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciBusMax|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciIoBase|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciIoSize|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciIoTranslation|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciMmio32Base|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciMmio32Size|0x0\r
-\r
   # set PcdPciExpressBaseAddress to MAX_UINT64, which signifies that this\r
   # PCD and PcdPciDisableBusEnumeration above have not been assigned yet\r
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xFFFFFFFFFFFFFFFF\r
   # ACPI Support\r
   #\r
   MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf\r
-  OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf\r
+  OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf {\r
+    <LibraryClasses>\r
+      NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf\r
+  }\r
 \r
   #\r
   # PCI support\r
   #\r
   ArmVirtPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf\r
-  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf\r
+  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {\r
+    <LibraryClasses>\r
+      NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf\r
+  }\r
   OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf\r
   OvmfPkg/Virtio10Dxe/Virtio10.inf\r
 \r
index d5057bb4632609182a7f36e44d38c6973cd72f4d..112dc8ed33df9d52519ace88c10657afea389e0c 100644 (file)
   gArmTokenSpaceGuid.PcdFvBaseAddress|0x0\r
 \r
 [PcdsDynamicDefault.common]\r
-  ## If TRUE, OvmfPkg/AcpiPlatformDxe will not wait for PCI\r
-  #  enumeration to complete before installing ACPI tables.\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE\r
 \r
   gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|0x0\r
   gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|0x0\r
   ## PL031 RealTimeClock\r
   gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x0\r
 \r
-  gArmPlatformTokenSpaceGuid.PcdPciBusMin|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciBusMax|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciIoBase|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciIoSize|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciIoTranslation|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciMmio32Base|0x0\r
-  gArmPlatformTokenSpaceGuid.PcdPciMmio32Size|0x0\r
-  gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0x0\r
-\r
   gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|3\r
 \r
 ################################################################################\r
index 0a47092e35ce5d5ba983d9dfe7ba241706ed0a70..31e0ca7db8b480c90bfb048f5cb23b04e756cb7c 100644 (file)
@@ -45,7 +45,6 @@ typedef enum {
   PropertyTypeRtc,\r
   PropertyTypeVirtio,\r
   PropertyTypeUart,\r
-  PropertyTypePciHost,\r
   PropertyTypeXen,\r
 } PROPERTY_TYPE;\r
 \r
@@ -58,7 +57,6 @@ STATIC CONST PROPERTY CompatibleProperties[] = {
   { PropertyTypeRtc,     "arm,pl031"             },\r
   { PropertyTypeVirtio,  "virtio,mmio"           },\r
   { PropertyTypeUart,    "arm,pl011"             },\r
-  { PropertyTypePciHost, "pci-host-ecam-generic" },\r
   { PropertyTypeXen,     "xen,xen"               },\r
   { PropertyTypeUnknown, ""                      }\r
 };\r
@@ -88,176 +86,6 @@ GetTypeFromNode (
   return PropertyTypeUnknown;\r
 }\r
 \r
-//\r
-// We expect the "ranges" property of "pci-host-ecam-generic" to consist of\r
-// records like this.\r
-//\r
-#pragma pack (1)\r
-typedef struct {\r
-  UINT32 Type;\r
-  UINT64 ChildBase;\r
-  UINT64 CpuBase;\r
-  UINT64 Size;\r
-} DTB_PCI_HOST_RANGE_RECORD;\r
-#pragma pack ()\r
-\r
-#define DTB_PCI_HOST_RANGE_RELOCATABLE  BIT31\r
-#define DTB_PCI_HOST_RANGE_PREFETCHABLE BIT30\r
-#define DTB_PCI_HOST_RANGE_ALIASED      BIT29\r
-#define DTB_PCI_HOST_RANGE_MMIO32       BIT25\r
-#define DTB_PCI_HOST_RANGE_MMIO64       (BIT25 | BIT24)\r
-#define DTB_PCI_HOST_RANGE_IO           BIT24\r
-#define DTB_PCI_HOST_RANGE_TYPEMASK     (BIT31 | BIT30 | BIT29 | BIT25 | BIT24)\r
-\r
-/**\r
-  Process the device tree node describing the generic PCI host controller.\r
-\r
-  param[in] DeviceTreeBase  Pointer to the device tree.\r
-\r
-  param[in] Node            Offset of the device tree node whose "compatible"\r
-                            property is "pci-host-ecam-generic".\r
-\r
-  param[in] RegProp         Pointer to the "reg" property of Node. The caller\r
-                            is responsible for ensuring that the size of the\r
-                            property is 4 UINT32 cells.\r
-\r
-  @retval EFI_SUCCESS         Parsing successful, properties parsed from Node\r
-                              have been stored in dynamic PCDs.\r
-\r
-  @retval EFI_PROTOCOL_ERROR  Parsing failed. PCDs are left unchanged.\r
-**/\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-ProcessPciHost (\r
-  IN CONST VOID *DeviceTreeBase,\r
-  IN INT32      Node,\r
-  IN CONST VOID *RegProp\r
-  )\r
-{\r
-  UINT64     ConfigBase, ConfigSize;\r
-  CONST VOID *Prop;\r
-  INT32      Len;\r
-  UINT32     BusMin, BusMax;\r
-  UINT32     RecordIdx;\r
-  UINT64     IoBase, IoSize, IoTranslation;\r
-  UINT64     MmioBase, MmioSize, MmioTranslation;\r
-\r
-  //\r
-  // Fetch the ECAM window.\r
-  //\r
-  ConfigBase = fdt64_to_cpu (((CONST UINT64 *)RegProp)[0]);\r
-  ConfigSize = fdt64_to_cpu (((CONST UINT64 *)RegProp)[1]);\r
-\r
-  //\r
-  // Fetch the bus range (note: inclusive).\r
-  //\r
-  Prop = fdt_getprop (DeviceTreeBase, Node, "bus-range", &Len);\r
-  if (Prop == NULL || Len != 2 * sizeof(UINT32)) {\r
-    DEBUG ((EFI_D_ERROR, "%a: 'bus-range' not found or invalid\n",\r
-      __FUNCTION__));\r
-    return EFI_PROTOCOL_ERROR;\r
-  }\r
-  BusMin = fdt32_to_cpu (((CONST UINT32 *)Prop)[0]);\r
-  BusMax = fdt32_to_cpu (((CONST UINT32 *)Prop)[1]);\r
-\r
-  //\r
-  // Sanity check: the config space must accommodate all 4K register bytes of\r
-  // all 8 functions of all 32 devices of all buses.\r
-  //\r
-  if (BusMax < BusMin || BusMax - BusMin == MAX_UINT32 ||\r
-      DivU64x32 (ConfigSize, SIZE_4KB * 8 * 32) < BusMax - BusMin + 1) {\r
-    DEBUG ((EFI_D_ERROR, "%a: invalid 'bus-range' and/or 'reg'\n",\r
-      __FUNCTION__));\r
-    return EFI_PROTOCOL_ERROR;\r
-  }\r
-\r
-  //\r
-  // Iterate over "ranges".\r
-  //\r
-  Prop = fdt_getprop (DeviceTreeBase, Node, "ranges", &Len);\r
-  if (Prop == NULL || Len == 0 ||\r
-      Len % sizeof (DTB_PCI_HOST_RANGE_RECORD) != 0) {\r
-    DEBUG ((EFI_D_ERROR, "%a: 'ranges' not found or invalid\n", __FUNCTION__));\r
-    return EFI_PROTOCOL_ERROR;\r
-  }\r
-\r
-  //\r
-  // IoBase, IoTranslation, MmioBase and MmioTranslation are initialized only\r
-  // in order to suppress '-Werror=maybe-uninitialized' warnings *incorrectly*\r
-  // emitted by some gcc versions.\r
-  //\r
-  IoBase = 0;\r
-  IoTranslation = 0;\r
-  MmioBase = 0;\r
-  MmioTranslation = 0;\r
-\r
-  //\r
-  // IoSize and MmioSize are initialized to zero because the logic below\r
-  // requires it.\r
-  //\r
-  IoSize = 0;\r
-  MmioSize = 0;\r
-  for (RecordIdx = 0; RecordIdx < Len / sizeof (DTB_PCI_HOST_RANGE_RECORD);\r
-       ++RecordIdx) {\r
-    CONST DTB_PCI_HOST_RANGE_RECORD *Record;\r
-\r
-    Record = (CONST DTB_PCI_HOST_RANGE_RECORD *)Prop + RecordIdx;\r
-    switch (fdt32_to_cpu (Record->Type) & DTB_PCI_HOST_RANGE_TYPEMASK) {\r
-    case DTB_PCI_HOST_RANGE_IO:\r
-      IoBase = fdt64_to_cpu (Record->ChildBase);\r
-      IoSize = fdt64_to_cpu (Record->Size);\r
-      IoTranslation = fdt64_to_cpu (Record->CpuBase) - IoBase;\r
-      break;\r
-\r
-    case DTB_PCI_HOST_RANGE_MMIO32:\r
-      MmioBase = fdt64_to_cpu (Record->ChildBase);\r
-      MmioSize = fdt64_to_cpu (Record->Size);\r
-      MmioTranslation = fdt64_to_cpu (Record->CpuBase) - MmioBase;\r
-\r
-      if (MmioBase > MAX_UINT32 || MmioSize > MAX_UINT32 ||\r
-          MmioBase + MmioSize > SIZE_4GB) {\r
-        DEBUG ((EFI_D_ERROR, "%a: MMIO32 space invalid\n", __FUNCTION__));\r
-        return EFI_PROTOCOL_ERROR;\r
-      }\r
-\r
-      if (MmioTranslation != 0) {\r
-        DEBUG ((EFI_D_ERROR, "%a: unsupported nonzero MMIO32 translation "\r
-          "0x%Lx\n", __FUNCTION__, MmioTranslation));\r
-        return EFI_UNSUPPORTED;\r
-      }\r
-\r
-      break;\r
-    }\r
-  }\r
-  if (IoSize == 0 || MmioSize == 0) {\r
-    DEBUG ((EFI_D_ERROR, "%a: %a space empty\n", __FUNCTION__,\r
-      (IoSize == 0) ? "IO" : "MMIO32"));\r
-    return EFI_PROTOCOL_ERROR;\r
-  }\r
-\r
-  PcdSet64 (PcdPciExpressBaseAddress, ConfigBase);\r
-\r
-  PcdSet32 (PcdPciBusMin, BusMin);\r
-  PcdSet32 (PcdPciBusMax, BusMax);\r
-\r
-  PcdSet64 (PcdPciIoBase,        IoBase);\r
-  PcdSet64 (PcdPciIoSize,        IoSize);\r
-  PcdSet64 (PcdPciIoTranslation, IoTranslation);\r
-\r
-  PcdSet32 (PcdPciMmio32Base, (UINT32)MmioBase);\r
-  PcdSet32 (PcdPciMmio32Size, (UINT32)MmioSize);\r
-\r
-  PcdSetBool (PcdPciDisableBusEnumeration, FALSE);\r
-\r
-  DEBUG ((EFI_D_INFO, "%a: Config[0x%Lx+0x%Lx) Bus[0x%x..0x%x] "\r
-    "Io[0x%Lx+0x%Lx)@0x%Lx Mem[0x%Lx+0x%Lx)@0x%Lx\n", __FUNCTION__, ConfigBase,\r
-    ConfigSize, BusMin, BusMax, IoBase, IoSize, IoTranslation, MmioBase,\r
-    MmioSize, MmioTranslation));\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
 EFI_STATUS\r
 EFIAPI\r
 InitializeVirtFdtDxe (\r
@@ -277,7 +105,6 @@ InitializeVirtFdtDxe (
   VIRTIO_TRANSPORT_DEVICE_PATH   *DevicePath;\r
   EFI_HANDLE                     Handle;\r
   UINT64                         RegBase;\r
-  BOOLEAN                        HavePci;\r
 \r
   Hob = GetFirstGuidHob(&gFdtHobGuid);\r
   if (Hob == NULL || GET_GUID_HOB_DATA_SIZE (Hob) != sizeof (UINT64)) {\r
@@ -293,7 +120,6 @@ InitializeVirtFdtDxe (
   DEBUG ((EFI_D_INFO, "%a: DTB @ 0x%p\n", __FUNCTION__, DeviceTreeBase));\r
 \r
   RtcNode = -1;\r
-  HavePci = FALSE;\r
   //\r
   // Now enumerate the nodes and install peripherals that we are interested in,\r
   // i.e., GIC, RTC and virtio MMIO nodes\r
@@ -323,13 +149,6 @@ InitializeVirtFdtDxe (
     ASSERT (RegProp != NULL);\r
 \r
     switch (PropType) {\r
-    case PropertyTypePciHost:\r
-      ASSERT (Len == 2 * sizeof (UINT64));\r
-      Status = ProcessPciHost (DeviceTreeBase, Node, RegProp);\r
-      ASSERT_EFI_ERROR (Status);\r
-      HavePci = TRUE;\r
-      break;\r
-\r
     case PropertyTypeVirtio:\r
       ASSERT (Len == 16);\r
       //\r
@@ -433,28 +252,6 @@ InitializeVirtFdtDxe (
           "disabled") != 0) {\r
       DEBUG ((EFI_D_WARN, "Failed to set PL031 status to 'disabled'\n"));\r
     }\r
-\r
-    if (HavePci) {\r
-      //\r
-      // Set the /chosen/linux,pci-probe-only property to 1, so that the PCI\r
-      // setup we will perform in the firmware is honored by the Linux OS,\r
-      // rather than torn down and done from scratch. This is generally a more\r
-      // sensible approach, and aligns with what ACPI based OSes do in general.\r
-      //\r
-      // In case we are exposing an emulated VGA PCI device to the guest, which\r
-      // may subsequently get exposed via the Graphics Output protocol and\r
-      // driven as an efifb by Linux, we need this setting to prevent the\r
-      // framebuffer from becoming unresponsive.\r
-      //\r
-      Node = fdt_path_offset (DeviceTreeBase, "/chosen");\r
-      if (Node < 0) {\r
-        Node = fdt_add_subnode (DeviceTreeBase, 0, "/chosen");\r
-      }\r
-      if (Node < 0 ||\r
-          fdt_setprop_u32 (DeviceTreeBase, Node, "linux,pci-probe-only", 1) < 0) {\r
-        DEBUG ((EFI_D_WARN, "Failed to set /chosen/linux,pci-probe-only property\n"));\r
-      }\r
-    }\r
   }\r
   return EFI_SUCCESS;\r
 }\r
index 6c8ba68599ae82986184559f9ae270fd6a59b06b..8ebce337747f85ad643f8c7877ca39a71cc63a8a 100644 (file)
 \r
 [Pcd]\r
   gArmPlatformTokenSpaceGuid.PcdPL031RtcBase\r
-  gArmPlatformTokenSpaceGuid.PcdPciBusMin\r
-  gArmPlatformTokenSpaceGuid.PcdPciBusMax\r
-  gArmPlatformTokenSpaceGuid.PcdPciIoBase\r
-  gArmPlatformTokenSpaceGuid.PcdPciIoSize\r
-  gArmPlatformTokenSpaceGuid.PcdPciIoTranslation\r
-  gArmPlatformTokenSpaceGuid.PcdPciMmio32Base\r
-  gArmPlatformTokenSpaceGuid.PcdPciMmio32Size\r
-  gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration\r
 \r
 [FeaturePcd]\r
   gArmVirtTokenSpaceGuid.PcdPureAcpiBoot\r