]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/EhciDxe: enable 64-bit PCI DMA
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 5 Sep 2016 08:51:16 +0000 (09:51 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 6 Sep 2016 14:40:49 +0000 (15:40 +0100)
PCI controller drivers must set the EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE
attribute if the controller supports 64-bit DMA addressing.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Feng Tian <feng.tian@Intel.com>
MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h
MdeModulePkg/Bus/Pci/EhciDxe/EhciSched.c

index 4e9e05f0e43134403c89557f84488381721eafe9..c7a6a400cff241ccbcfe6d83e330e169a11b676a 100644 (file)
@@ -89,7 +89,7 @@ EhcGetCapability (
 \r
   *MaxSpeed       = EFI_USB_SPEED_HIGH;\r
   *PortNumber     = (UINT8) (Ehc->HcStructParams & HCSP_NPORTS);\r
-  *Is64BitCapable = (UINT8) (Ehc->HcCapParams & HCCP_64BIT);\r
+  *Is64BitCapable = (UINT8) Ehc->Support64BitDma;\r
 \r
   DEBUG ((EFI_D_INFO, "EhcGetCapability: %d ports, 64 bit %d\n", *PortNumber, *Is64BitCapable));\r
 \r
@@ -1877,6 +1877,26 @@ EhcDriverBindingStart (
     goto CLOSE_PCIIO;\r
   }\r
 \r
+  //\r
+  // Enable 64-bit DMA support in the PCI layer if this controller\r
+  // supports it.\r
+  //\r
+  if (EHC_BIT_IS_SET (Ehc->HcCapParams, HCCP_64BIT)) {\r
+    Status = PciIo->Attributes (\r
+                      PciIo,\r
+                      EfiPciIoAttributeOperationEnable,\r
+                      EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE,\r
+                      NULL\r
+                      );\r
+    if (!EFI_ERROR (Status)) {\r
+      Ehc->Support64BitDma = TRUE;\r
+    } else {\r
+      DEBUG ((EFI_D_WARN,\r
+        "%a: failed to enable 64-bit DMA on 64-bit capable controller @ %p (%r)\n",\r
+        __FUNCTION__, Controller, Status));\r
+    }\r
+  }\r
+\r
   Status = gBS->InstallProtocolInterface (\r
                   &Controller,\r
                   &gEfiUsb2HcProtocolGuid,\r
index 7177658092c302ebd03a28ebcb2d3362664eb89b..be81bde40d9b7110185c6dd7e72e8825c344ac8a 100644 (file)
@@ -173,6 +173,8 @@ struct _USB2_HC_DEV {
   UINT16                    DebugPortOffset; // The offset of debug port mmio register\r
   UINT8                     DebugPortBarNum; // The bar number of debug port mmio register\r
   UINT8                     DebugPortNum;    // The port number of usb debug port\r
+\r
+  BOOLEAN                   Support64BitDma; // Whether 64 bit DMA may be used with this device\r
 };\r
 \r
 \r
index 5594e6699ea648052a2be683dc46dba6d0c3aa68..036c00b32b4006e6130f27bb0d75c708c2829ca5 100644 (file)
@@ -178,7 +178,7 @@ EhcInitSched (
   //\r
   Ehc->MemPool = UsbHcInitMemPool (\r
                    PciIo,\r
-                   EHC_BIT_IS_SET (Ehc->HcCapParams, HCCP_64BIT),\r
+                   Ehc->Support64BitDma,\r
                    EHC_HIGH_32BIT (PhyAddr)\r
                    );\r
 \r