]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/PciBusDxe: Enable Bus Master on P2P bridges on demand
authorRuiyu Ni <ruiyu.ni@intel.com>
Wed, 16 Aug 2017 17:26:49 +0000 (10:26 -0700)
committerRuiyu Ni <ruiyu.ni@intel.com>
Thu, 28 Sep 2017 04:54:53 +0000 (12:54 +0800)
The patch dynamically enables Bus Master on P2P bridges only
when requested by a device driver through PciIo.Attribute() to enable
the Bus Master.

Signed-off-by: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c

index c0227fa2b69635bf3d440e714f52a63554df2867..359b9ded6d6c6ae6d6ba6da29454dafd73aa2978 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Supporting functions implementaion for PCI devices management.\r
 \r
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<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
@@ -711,7 +711,12 @@ StartPciDevicesOnBridge (
                              0,\r
                              &Supports\r
                              );\r
-        Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
+        //\r
+        // By default every bridge's IO and MMIO spaces are enabled.\r
+        // Bridge's Bus Master will be enabled when any device behind it requests\r
+        // to enable Bus Master.\r
+        //\r
+        Supports &= (UINT64) (EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY);\r
         PciIoDevice->PciIo.Attributes (\r
                              &(PciIoDevice->PciIo),\r
                              EfiPciIoAttributeOperationEnable,\r
@@ -763,7 +768,12 @@ StartPciDevicesOnBridge (
                              0,\r
                              &Supports\r
                              );\r
-        Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
+        //\r
+        // By default every bridge's IO and MMIO spaces are enabled.\r
+        // Bridge's Bus Master will be enabled when any device behind it requests\r
+        // to enable Bus Master.\r
+        //\r
+        Supports &= (UINT64) (EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY);\r
         PciIoDevice->PciIo.Attributes (\r
                              &(PciIoDevice->PciIo),\r
                              EfiPciIoAttributeOperationEnable,\r
index 81171c82d9e21500ceaf25464d78d196904b02b2..f73756a31ecd9dcf40b1011bc85d2083d814ca06 100644 (file)
@@ -1218,11 +1218,12 @@ DetermineDeviceAttribute (
       return Status;\r
     }\r
     //\r
-    // Assume the PCI Root Bridge supports DAC\r
+    // Assume the PCI Root Bridge supports DAC and Bus Master.\r
     //\r
     PciIoDevice->Supports |= (UINT64)(EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE |\r
                               EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM |\r
-                              EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE);\r
+                              EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE |\r
+                              EFI_PCI_IO_ATTRIBUTE_BUS_MASTER);\r
 \r
   } else {\r
 \r
@@ -1233,9 +1234,16 @@ DetermineDeviceAttribute (
     //\r
     Command = EFI_PCI_COMMAND_IO_SPACE     |\r
               EFI_PCI_COMMAND_MEMORY_SPACE |\r
-              EFI_PCI_COMMAND_BUS_MASTER   |\r
               EFI_PCI_COMMAND_VGA_PALETTE_SNOOP;\r
 \r
+    //\r
+    // Per PCI-to-PCI Bridge Architecture all PCI-to-PCI bridges are Bus Master capable.\r
+    // So only test the Bus Master capability for PCI devices.\r
+    //\r
+    if (!IS_PCI_BRIDGE(&PciIoDevice->Pci)) {\r
+      Command |= EFI_PCI_COMMAND_BUS_MASTER;\r
+    }\r
+\r
     BridgeControl = EFI_PCI_BRIDGE_CONTROL_ISA | EFI_PCI_BRIDGE_CONTROL_VGA | EFI_PCI_BRIDGE_CONTROL_VGA_16;\r
 \r
     //\r
@@ -1245,7 +1253,11 @@ DetermineDeviceAttribute (
 \r
     //\r
     // Set the supported attributes for specified PCI device\r
+    // Per PCI-to-PCI Bridge Architecture all PCI-to-PCI bridges are Bus Master capable.\r
     //\r
+    if (IS_PCI_BRIDGE(&PciIoDevice->Pci)) {\r
+      Command |= EFI_PCI_COMMAND_BUS_MASTER;\r
+    }\r
     PciSetDeviceAttribute (PciIoDevice, Command, BridgeControl, EFI_SET_SUPPORTS);\r
 \r
     //\r
index cc7125e4fc3c00f924fc7ea11d482f785219cd14..659f480d712234871485664f6de596412aa0887d 100644 (file)
@@ -1348,7 +1348,8 @@ ModifyRootBridgeAttributes (
   //\r
   Attributes &= ~(UINT64)(EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE |\r
                           EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM |\r
-                          EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE);\r
+                          EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE |\r
+                          EFI_PCI_IO_ATTRIBUTE_BUS_MASTER);\r
 \r
   //\r
   // Record the new attribute of the Root Bridge\r
@@ -1726,12 +1727,11 @@ PciIoAttributes (
   }\r
   //\r
   // The upstream bridge should be also set to revelant attribute\r
-  // expect for IO, Mem and BusMaster\r
+  // expect for IO and Mem\r
   //\r
   UpStreamAttributes = Attributes &\r
                        (~(EFI_PCI_IO_ATTRIBUTE_IO     |\r
-                          EFI_PCI_IO_ATTRIBUTE_MEMORY |\r
-                          EFI_PCI_IO_ATTRIBUTE_BUS_MASTER\r
+                          EFI_PCI_IO_ATTRIBUTE_MEMORY\r
                           )\r
                         );\r
   UpStreamBridge = PciIoDevice->Parent;\r