public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU
@ 2018-03-11 15:16 Star Zeng
  2018-03-11 15:16 ` [PATCH 1/3] SourceLevelDebugPkg DebugCommUsb3: Refine some formats Star Zeng
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Star Zeng @ 2018-03-11 15:16 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Jiewen Yao, Ruiyu Ni, Hao Wu

Please get detailed information in the separated patches.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>

Star Zeng (3):
  SourceLevelDebugPkg DebugCommUsb3: Refine some formats
  SourceLevelDebugPkg DebugCommUsb3: Realloc granted DXE DMA buffer
  SourceLevelDebugPkg DebugCommUsb3: Use the Handle from DebugAgentLib

 .../DebugCommunicationLibUsb3Common.c              |  96 +++++-
 .../DebugCommunicationLibUsb3Dxe.c                 | 365 ++++++++++++---------
 .../DebugCommunicationLibUsb3Dxe.inf               |  11 +-
 .../DebugCommunicationLibUsb3Internal.h            |  60 +---
 .../DebugCommunicationLibUsb3Pei.c                 |  50 ++-
 .../DebugCommunicationLibUsb3Pei.inf               |   4 +-
 6 files changed, 332 insertions(+), 254 deletions(-)

--
2.13.3.windows.1



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/3] SourceLevelDebugPkg DebugCommUsb3: Refine some formats
  2018-03-11 15:16 [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU Star Zeng
@ 2018-03-11 15:16 ` Star Zeng
  2018-03-11 15:16 ` [PATCH 2/3] SourceLevelDebugPkg DebugCommUsb3: Realloc granted DXE DMA buffer Star Zeng
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Star Zeng @ 2018-03-11 15:16 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Jiewen Yao, Ruiyu Ni, Hao Wu

Refine some formats and remove some unused prototypes.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 .../DebugCommunicationLibUsb3Common.c              | 10 ++---
 .../DebugCommunicationLibUsb3Dxe.inf               |  6 ++-
 .../DebugCommunicationLibUsb3Internal.h            | 43 ++--------------------
 .../DebugCommunicationLibUsb3Pei.inf               |  2 +-
 4 files changed, 13 insertions(+), 48 deletions(-)

diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Common.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Common.c
index c577df7dea97..e67ff1fe5ca7 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Common.c
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Common.c
@@ -87,8 +87,8 @@ XhcClearR32Bit(
 VOID
 XhcWriteDebugReg (
   IN USB3_DEBUG_PORT_HANDLE  *Handle,
-  IN UINT32                   Offset,
-  IN UINT32                   Data
+  IN UINT32                  Offset,
+  IN UINT32                  Data
   )
 {
   EFI_PHYSICAL_ADDRESS  DebugCapabilityBase;
@@ -111,7 +111,7 @@ XhcWriteDebugReg (
 UINT32
 XhcReadDebugReg (
   IN  USB3_DEBUG_PORT_HANDLE *Handle,
-  IN  UINT32                   Offset
+  IN  UINT32                 Offset
   )
 {
   UINT32                  Data;
@@ -1049,8 +1049,8 @@ DebugPortInitialize (
   }
 
   if (Function != NULL) {
-    Function (Context, UsbDebugPortHandle);
+    Function (Context, (DEBUG_PORT_HANDLE) UsbDebugPortHandle);
   }
 
-  return (DEBUG_PORT_HANDLE)(UINTN)UsbDebugPortHandle;
+  return (DEBUG_PORT_HANDLE) UsbDebugPortHandle;
 }
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.inf b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.inf
index c4e4282c98b4..3af7e7180d37 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.inf
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.inf
@@ -59,8 +59,10 @@ [Pcd]
   gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugPortHandleBufferSize|250   ## SOMETIMES_CONSUMES
 
 [Protocols]
-  gEfiPciIoProtocolGuid                 ## CONSUMES
-  gEdkiiIoMmuProtocolGuid               ## CONSUMES
+   ## NOTIFY
+   ## SOMETIMES_CONSUMES
+  gEfiPciIoProtocolGuid
+  gEdkiiIoMmuProtocolGuid               ## SOMETIMES_CONSUMES
 
 [LibraryClasses]
   BaseLib
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Internal.h b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Internal.h
index 66757dafaebe..961786e2a41f 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Internal.h
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Internal.h
@@ -561,7 +561,7 @@ typedef struct _USB3_DEBUG_PORT_INSTANCE {
 UINT32
 XhcReadDebugReg (
   IN  USB3_DEBUG_PORT_HANDLE    *Handle,
-  IN  UINT32                      Offset
+  IN  UINT32                    Offset
   );
 
 /**
@@ -575,8 +575,8 @@ XhcReadDebugReg (
 VOID
 XhcSetDebugRegBit (
   IN USB3_DEBUG_PORT_HANDLE  *Handle,
-  IN UINT32                   Offset,
-  IN UINT32                   Bit
+  IN UINT32                  Offset,
+  IN UINT32                  Bit
   );
   
 /**
@@ -595,43 +595,6 @@ XhcWriteDebugReg (
   );
 
 /**
-  Discover the USB3 debug device.
-  
-  @param  Handle                Debug port handle.
-  
-  @retval RETURN_SUCCESS        The serial device was initialized.
-  @retval RETURN_DEVICE_ERROR   The serial device could not be initialized.
-
-**/
-RETURN_STATUS
-DiscoverUsb3DebugPort(
-  USB3_DEBUG_PORT_HANDLE  *Handle
-  );
-  
-/**
-  Initialize the Serial Device hardware.
-  
-  @param  Handle            Debug port handle.
-
-  @retval RETURN_SUCCESS    The serial device was initialized successfully.
-  @retval !RETURN_SUCCESS   Error.
-
-**/
-RETURN_STATUS
-InitializeUsb3DebugPort (
-  USB3_DEBUG_PORT_HANDLE  *Handle
-  );
-
-/**
-  Return XHCI MMIO base address.
-
-**/
-EFI_PHYSICAL_ADDRESS
-GetXhciBaseAddress (
-  VOID
-  );
-
-/**
   Verifies if the bit positions specified by a mask are set in a register.
 
   @param[in, out] Register    UNITN register
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.inf b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.inf
index 33074db49a78..4f367622d826 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.inf
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.inf
@@ -41,7 +41,7 @@ [Packages]
 
 [Ppis]
   gEfiPeiMemoryDiscoveredPpiGuid                ## CONSUMES
-  gEdkiiIoMmuPpiGuid                            ## CONSUMES
+  gEdkiiIoMmuPpiGuid                            ## SOMETIMES_CONSUMES
 
 [Pcd]
   # The memory BAR of ehci host controller, in which usb debug feature is enabled.
-- 
2.13.3.windows.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] SourceLevelDebugPkg DebugCommUsb3: Realloc granted DXE DMA buffer
  2018-03-11 15:16 [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU Star Zeng
  2018-03-11 15:16 ` [PATCH 1/3] SourceLevelDebugPkg DebugCommUsb3: Refine some formats Star Zeng
@ 2018-03-11 15:16 ` Star Zeng
  2018-03-11 15:16 ` [PATCH 3/3] SourceLevelDebugPkg DebugCommUsb3: Use the Handle from DebugAgentLib Star Zeng
  2018-03-12  2:09 ` [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU Wu, Hao A
  3 siblings, 0 replies; 9+ messages in thread
From: Star Zeng @ 2018-03-11 15:16 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Jiewen Yao, Ruiyu Ni, Hao Wu

For the case that the USB3 debug port instance and DMA buffers are
from PEI HOB with IOMMU enabled, de8373fa07f8 is to reallocate
the DMA buffers by AllocateAddress with the memory type accessible
by SMM environment.

But reallocating the DMA buffers by AllocateAddress may fail.

Instead, this patch is to reinitialize USB3 debug port with granted
DXE DMA buffer accessible by SMM environment.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 .../DebugCommunicationLibUsb3Dxe.c                 | 246 +++++++++++++--------
 .../DebugCommunicationLibUsb3Dxe.inf               |   3 +
 .../DebugCommunicationLibUsb3Pei.c                 |   2 +-
 3 files changed, 155 insertions(+), 96 deletions(-)

diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c
index 29cec56f39dc..588c9715bd00 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c
@@ -18,11 +18,13 @@
 #include <Library/HobLib.h>
 #include <Protocol/PciIo.h>
 #include <Protocol/IoMmu.h>
+#include <Protocol/DxeSmmReadyToLock.h>
 #include "DebugCommunicationLibUsb3Internal.h"
 
 GUID                        gUsb3DbgGuid =  USB3_DBG_GUID;
 
 USB3_DEBUG_PORT_HANDLE      *mUsb3Instance = NULL;
+EFI_PCI_IO_PROTOCOL         *mUsb3PciIo = NULL;
 
 /**
   Creates a named event that can be signaled.
@@ -85,20 +87,16 @@ Usb3NamedEventListen (
 /**
   USB3 map one DMA buffer.
 
-  @param Instance       Pointer to USB3 debug port instance.
   @param PciIo          Pointer to PciIo for USB3 debug port.
   @param Address        DMA buffer address to be mapped.
   @param NumberOfBytes  Number of bytes to be mapped.
-  @param BackupBuffer   Backup buffer address.
 
 **/
 VOID
 Usb3MapOneDmaBuffer (
-  IN USB3_DEBUG_PORT_HANDLE     *Instance,
   IN EFI_PCI_IO_PROTOCOL        *PciIo,
   IN EFI_PHYSICAL_ADDRESS       Address,
-  IN UINTN                      NumberOfBytes,
-  IN EFI_PHYSICAL_ADDRESS       BackupBuffer
+  IN UINTN                      NumberOfBytes
   )
 {
   EFI_STATUS                    Status;
@@ -117,23 +115,6 @@ Usb3MapOneDmaBuffer (
                     );
   ASSERT_EFI_ERROR (Status);
   ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress));
-  if (Instance->FromHob) {
-    //
-    // Reallocate the DMA buffer by AllocateAddress with
-    // the memory type accessible by SMM.
-    //
-    CopyMem ((VOID *) (UINTN) BackupBuffer, (VOID *) (UINTN) Address, NumberOfBytes);
-    Status = gBS->FreePages (Address, EFI_SIZE_TO_PAGES (NumberOfBytes));
-    ASSERT_EFI_ERROR (Status);
-    Status = gBS->AllocatePages (
-                    AllocateAddress,
-                    EfiACPIMemoryNVS,
-                    EFI_SIZE_TO_PAGES (NumberOfBytes),
-                    &Address
-                    );
-    ASSERT_EFI_ERROR (Status);
-    CopyMem ((VOID *) (UINTN) Address, (VOID *) (UINTN) BackupBuffer, NumberOfBytes);
-  }
 }
 
 /**
@@ -149,99 +130,111 @@ Usb3MapDmaBuffers (
   IN EFI_PCI_IO_PROTOCOL        *PciIo
   )
 {
-  EFI_STATUS                    Status;
-  EDKII_IOMMU_PROTOCOL          *IoMmu;
-  EFI_PHYSICAL_ADDRESS          BackupBuffer;
-  UINTN                         BackupBufferSize;
-
-  IoMmu = NULL;
-  Status = gBS->LocateProtocol (&gEdkiiIoMmuProtocolGuid, NULL, (VOID **) &IoMmu);
-  if (EFI_ERROR (Status) || (IoMmu == NULL)) {
-    //
-    // No need to map the DMA buffers.
-    //
-    return;
-  }
-
-  //
-  // Allocate backup buffer for the case that the USB3
-  // debug port instance and DMA buffers are from PEI HOB.
-  // For this case, the DMA buffers need to be reallocated
-  // by AllocateAddress with the memory type accessible by
-  // SMM.
-  //
-  BackupBufferSize = MAX (XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE * 2 + USB3_DEBUG_PORT_WRITE_MAX_PACKET_SIZE,
-                          MAX (sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER,
-                               MAX (sizeof (TRB_TEMPLATE) * EVENT_RING_TRB_NUMBER,
-                                    MAX (sizeof (EVENT_RING_SEG_TABLE_ENTRY) * ERST_NUMBER,
-                                         MAX (sizeof (XHC_DC_CONTEXT),
-                                              STRING0_DESC_LEN + MANU_DESC_LEN + PRODUCT_DESC_LEN + SERIAL_DESC_LEN)))));
-
-  Status = gBS->AllocatePages (
-                  AllocateAnyPages,
-                  EfiBootServicesData,
-                  EFI_SIZE_TO_PAGES (BackupBufferSize),
-                  &BackupBuffer
-                  );
-  ASSERT_EFI_ERROR (Status);
-
   Usb3MapOneDmaBuffer (
-    Instance,
     PciIo,
     Instance->UrbIn.Data,
-    XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE * 2 + USB3_DEBUG_PORT_WRITE_MAX_PACKET_SIZE,
-    BackupBuffer
+    XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE * 2 + USB3_DEBUG_PORT_WRITE_MAX_PACKET_SIZE
     );
 
   Usb3MapOneDmaBuffer (
-    Instance,
     PciIo,
     Instance->TransferRingIn.RingSeg0,
-    sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER,
-    BackupBuffer
+    sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER
     );
 
   Usb3MapOneDmaBuffer (
-    Instance,
     PciIo,
     Instance->TransferRingOut.RingSeg0,
-    sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER,
-    BackupBuffer
+    sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER
     );
 
   Usb3MapOneDmaBuffer (
-    Instance,
     PciIo,
     Instance->EventRing.EventRingSeg0,
-    sizeof (TRB_TEMPLATE) * EVENT_RING_TRB_NUMBER,
-    BackupBuffer
+    sizeof (TRB_TEMPLATE) * EVENT_RING_TRB_NUMBER
     );
 
   Usb3MapOneDmaBuffer (
-    Instance,
     PciIo,
     Instance->EventRing.ERSTBase,
-    sizeof (EVENT_RING_SEG_TABLE_ENTRY) * ERST_NUMBER,
-    BackupBuffer
+    sizeof (EVENT_RING_SEG_TABLE_ENTRY) * ERST_NUMBER
     );
 
   Usb3MapOneDmaBuffer (
-    Instance,
     PciIo,
     Instance->DebugCapabilityContext,
-    sizeof (XHC_DC_CONTEXT),
-    BackupBuffer
+    sizeof (XHC_DC_CONTEXT)
     );
 
   Usb3MapOneDmaBuffer (
-    Instance,
     PciIo,
     ((XHC_DC_CONTEXT *) (UINTN) Instance->DebugCapabilityContext)->DbcInfoContext.String0DescAddress,
-    STRING0_DESC_LEN + MANU_DESC_LEN + PRODUCT_DESC_LEN + SERIAL_DESC_LEN,
-    BackupBuffer
+    STRING0_DESC_LEN + MANU_DESC_LEN + PRODUCT_DESC_LEN + SERIAL_DESC_LEN
     );
+}
+
+/**
+  Invoke a notification event
 
-  gBS->FreePages (BackupBuffer, EFI_SIZE_TO_PAGES (BackupBufferSize));
+  @param[in] Event              Event whose notification function is being invoked.
+  @param[in] Context            The pointer to the notification function's context,
+                                which is implementation-dependent.
+
+**/
+VOID
+EFIAPI
+Usb3DxeSmmReadyToLockNotify (
+  IN  EFI_EVENT                 Event,
+  IN  VOID                      *Context
+  )
+{
+  ASSERT (mUsb3Instance != NULL);
+
+  DEBUG ((DEBUG_INFO, "%a()\n", __FUNCTION__));
+  mUsb3Instance->InNotify = TRUE;
+
+  //
+  // For the case that the USB3 debug port instance and DMA buffers are
+  // from PEI HOB with IOMMU enabled.
+  // Reinitialize USB3 debug port with granted DXE DMA buffer accessible
+  // by SMM environment.
+  //
+  InitializeUsbDebugHardware (mUsb3Instance);
+
+  //
+  // Wait some time for host to be ready after re-initialization.
+  //
+  MicroSecondDelay (1000000);
+
+  mUsb3Instance->InNotify = FALSE;
+  gBS->CloseEvent (Event);
+}
+
+/**
+  USB3 get IOMMU protocol.
+
+  @return Pointer to IOMMU protocol.
+
+**/
+EDKII_IOMMU_PROTOCOL *
+Usb3GetIoMmu (
+  VOID
+  )
+{
+  EFI_STATUS                Status;
+  EDKII_IOMMU_PROTOCOL      *IoMmu;
+
+  IoMmu = NULL;
+  Status = gBS->LocateProtocol (
+             &gEdkiiIoMmuProtocolGuid,
+             NULL,
+             (VOID **) &IoMmu
+             );
+  if (!EFI_ERROR (Status) && (IoMmu != NULL)) {
+    return IoMmu;
+  }
+
+  return NULL;
 }
 
 /**
@@ -270,8 +263,6 @@ Usb3PciIoNotify (
   UINTN                         PciFunctionNumber;
   UINT32                        PciAddress;
 
-  ASSERT (mUsb3Instance != NULL);
-
   Status = gBS->LocateHandleBuffer (
                   ByProtocol,
                   &gEfiPciIoProtocolGuid,
@@ -296,10 +287,23 @@ Usb3PciIoNotify (
         //
         // Found the PciIo for USB3 debug port.
         //
+        ASSERT (mUsb3Instance != NULL);
         DEBUG ((DEBUG_INFO, "%a()\n", __FUNCTION__));
-        mUsb3Instance->InNotify = TRUE;
-        Usb3MapDmaBuffers (mUsb3Instance, PciIo);
-        mUsb3Instance->InNotify = FALSE;
+        if (Usb3GetIoMmu != NULL) {
+          mUsb3Instance->InNotify = TRUE;
+          Usb3MapDmaBuffers (mUsb3Instance, PciIo);
+          mUsb3Instance->InNotify = FALSE;
+
+          if (mUsb3Instance->FromHob) {
+            mUsb3PciIo = PciIo;
+            Usb3NamedEventListen (
+              &gEfiDxeSmmReadyToLockProtocolGuid,
+              TPL_NOTIFY,
+              Usb3DxeSmmReadyToLockNotify,
+              &Event
+              );
+          }
+        }
         gBS->CloseEvent ((EFI_EVENT) (UINTN) mUsb3Instance->PciIoEvent);
         break;
       }
@@ -334,13 +338,57 @@ GetUsb3DebugPortInstance (
   }
 
 Done:
-  if (Instance != NULL) {
+  if ((Instance != NULL) && (!Instance->InNotify)) {
     DiscoverInitializeUsbDebugPort (Instance);
   }
   return Instance;
 }
 
 /**
+  Allocates pages that are suitable for an OperationBusMasterCommonBuffer or
+  OperationBusMasterCommonBuffer64 mapping.
+
+  @param PciIo                  Pointer to PciIo for USB3 debug port.
+  @param Pages                  The number of pages to allocate.
+  @param Address                A pointer to store the base system memory address of the
+                                allocated range.
+
+  @retval EFI_SUCCESS           The requested memory pages were allocated.
+  @retval EFI_UNSUPPORTED       Attributes is unsupported. The only legal attribute bits are
+                                MEMORY_WRITE_COMBINE and MEMORY_CACHED.
+  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+  @retval EFI_OUT_OF_RESOURCES  The memory pages could not be allocated.
+
+**/
+EFI_STATUS
+Usb3AllocateDmaBuffer (
+  IN EFI_PCI_IO_PROTOCOL    *PciIo,
+  IN UINTN                  Pages,
+  OUT VOID                  **Address
+  )
+{
+  EFI_STATUS            Status;
+
+  *Address = NULL;
+  Status = PciIo->AllocateBuffer (
+                    PciIo,
+                    AllocateAnyPages,
+                    EfiRuntimeServicesData,
+                    Pages,
+                    Address,
+                    0
+                    );
+  if (!EFI_ERROR (Status)) {
+    Usb3MapOneDmaBuffer (
+      PciIo,
+      (EFI_PHYSICAL_ADDRESS) (UINTN) *Address,
+      EFI_PAGES_TO_SIZE (Pages)
+      );
+  }
+  return Status;
+}
+
+/**
   Allocate aligned memory for XHC's usage.
 
   @param  BufferSize      The size, in bytes, of the Buffer.
@@ -360,15 +408,23 @@ AllocateAlignBuffer (
   Buf = NULL;
   
   if (gBS != NULL) {
-    TmpAddr = 0xFFFFFFFF;
-    Status = gBS->AllocatePages (
-               AllocateMaxAddress,
-               EfiACPIMemoryNVS,
-               EFI_SIZE_TO_PAGES (BufferSize),
-               &TmpAddr
-               );
-    if (!EFI_ERROR (Status)) {
-      Buf = (VOID *) (UINTN) TmpAddr;
+    if (mUsb3PciIo != NULL) {
+      Usb3AllocateDmaBuffer (
+        mUsb3PciIo,
+        EFI_SIZE_TO_PAGES (BufferSize),
+        &Buf
+        );
+    } else {
+      TmpAddr = 0xFFFFFFFF;
+      Status = gBS->AllocatePages (
+                      AllocateMaxAddress,
+                      EfiACPIMemoryNVS,
+                      EFI_SIZE_TO_PAGES (BufferSize),
+                      &TmpAddr
+                      );
+      if (!EFI_ERROR (Status)) {
+        Buf = (VOID *) (UINTN) TmpAddr;
+      }
     }
   }
 
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.inf b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.inf
index 3af7e7180d37..9f737b9478a8 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.inf
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.inf
@@ -63,6 +63,9 @@ [Protocols]
    ## SOMETIMES_CONSUMES
   gEfiPciIoProtocolGuid
   gEdkiiIoMmuProtocolGuid               ## SOMETIMES_CONSUMES
+   ## NOTIFY
+   ## SOMETIMES_CONSUMES
+  gEfiDxeSmmReadyToLockProtocolGuid
 
 [LibraryClasses]
   BaseLib
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.c
index 40e9b6406b2e..145113d28dc3 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.c
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.c
@@ -106,7 +106,7 @@ IoMmuAllocateBuffer (
 
   Status = IoMmu->AllocateBuffer (
                     IoMmu,
-                    EfiBootServicesData,
+                    EfiRuntimeServicesData,
                     Pages,
                     HostAddress,
                     0
-- 
2.13.3.windows.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] SourceLevelDebugPkg DebugCommUsb3: Use the Handle from DebugAgentLib
  2018-03-11 15:16 [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU Star Zeng
  2018-03-11 15:16 ` [PATCH 1/3] SourceLevelDebugPkg DebugCommUsb3: Refine some formats Star Zeng
  2018-03-11 15:16 ` [PATCH 2/3] SourceLevelDebugPkg DebugCommUsb3: Realloc granted DXE DMA buffer Star Zeng
@ 2018-03-11 15:16 ` Star Zeng
  2018-03-12  2:09 ` [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU Wu, Hao A
  3 siblings, 0 replies; 9+ messages in thread
From: Star Zeng @ 2018-03-11 15:16 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Jiewen Yao, Ruiyu Ni, Hao Wu

For notifications to get the Instance, de8373fa07f8 was to build
HOB/SystemTable in DebugCommunicationLibUsb3 itself, that works well
at normal boot, but will fail at S3 resume.
At S3 resume, after the code is transferred to PiSmmCpuDxeSmm from
S3Resume2Pei, HOB is still needed to be used for DMA operation, but
PiSmmCpuDxeSmm has no way to get the HOB at S3 resume.

In fact, DebugAgentLib has been managing the instance as Handle in
HOB/SystemTable.
This patch is to use the Handle from DebugAgentLib for the instance
needed in DebugCommunicationLibUsb3.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 .../DebugCommunicationLibUsb3Common.c              |  86 +++++++++--
 .../DebugCommunicationLibUsb3Dxe.c                 | 167 ++++++++++-----------
 .../DebugCommunicationLibUsb3Dxe.inf               |   2 +-
 .../DebugCommunicationLibUsb3Internal.h            |  17 +--
 .../DebugCommunicationLibUsb3Pei.c                 |  48 +++---
 .../DebugCommunicationLibUsb3Pei.inf               |   2 +-
 6 files changed, 188 insertions(+), 134 deletions(-)

diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Common.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Common.c
index e67ff1fe5ca7..740d9f98b41d 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Common.c
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Common.c
@@ -811,6 +811,42 @@ DiscoverInitializeUsbDebugPort (
 }
 
 /**
+  Set USB3 debug instance address.
+
+**/  
+VOID
+SetUsb3DebugPortInstance (
+  IN USB3_DEBUG_PORT_HANDLE     *Instance
+  )
+{
+  EFI_PHYSICAL_ADDRESS          *AddrPtr;
+
+  AddrPtr = GetUsb3DebugPortInstanceAddrPtr ();
+  ASSERT (AddrPtr != NULL);
+  *AddrPtr = (EFI_PHYSICAL_ADDRESS) (UINTN) Instance;
+}
+
+/**
+  Return USB3 debug instance address.
+
+**/  
+USB3_DEBUG_PORT_HANDLE *
+GetUsb3DebugPortInstance (
+  VOID
+  )
+{
+  EFI_PHYSICAL_ADDRESS          *AddrPtr;
+  USB3_DEBUG_PORT_HANDLE        *Instance;
+
+  AddrPtr = GetUsb3DebugPortInstanceAddrPtr ();
+  ASSERT (AddrPtr != NULL);
+
+  Instance = (USB3_DEBUG_PORT_HANDLE *) (UINTN) *AddrPtr;
+
+  return Instance;
+}
+
+/**
   Read data from debug device and save the data in buffer.
 
   Reads NumberOfBytes data bytes from a debug device into the buffer
@@ -844,16 +880,23 @@ DebugPortReadBuffer (
     return 0;
   }
 
-  UsbDebugPortHandle = GetUsb3DebugPortInstance ();
+  if (Handle != NULL) {
+    UsbDebugPortHandle = (USB3_DEBUG_PORT_HANDLE *) Handle;
+    SetUsb3DebugPortInstance (UsbDebugPortHandle);
+  } else {
+    UsbDebugPortHandle = GetUsb3DebugPortInstance ();
+  }
   if (UsbDebugPortHandle == NULL) {
     return 0;
   }
 
-  if (UsbDebugPortHandle->Initialized != USB3DBG_ENABLED) {
+  if (UsbDebugPortHandle->InNotify) {
     return 0;
   }
 
-  if (UsbDebugPortHandle->InNotify) {
+  DiscoverInitializeUsbDebugPort (UsbDebugPortHandle);
+
+  if (UsbDebugPortHandle->Initialized != USB3DBG_ENABLED) {
     return 0;
   }
 
@@ -914,16 +957,23 @@ DebugPortWriteBuffer (
   Sent  = 0;
   Total = 0;
 
-  UsbDebugPortHandle = GetUsb3DebugPortInstance ();
+  if (Handle != NULL) {
+    UsbDebugPortHandle = (USB3_DEBUG_PORT_HANDLE *) Handle;
+    SetUsb3DebugPortInstance (UsbDebugPortHandle);
+  } else {
+    UsbDebugPortHandle = GetUsb3DebugPortInstance ();
+  }
   if (UsbDebugPortHandle == NULL) {
     return 0;
   }
 
-  if (UsbDebugPortHandle->Initialized != USB3DBG_ENABLED) {
+  if (UsbDebugPortHandle->InNotify) {
     return 0;
   }
 
-  if (UsbDebugPortHandle->InNotify) {
+  DiscoverInitializeUsbDebugPort (UsbDebugPortHandle);
+
+  if (UsbDebugPortHandle->Initialized != USB3DBG_ENABLED) {
     return 0;
   }
 
@@ -968,16 +1018,23 @@ DebugPortPollBuffer (
   USB3_DEBUG_PORT_HANDLE     *UsbDebugPortHandle;
   UINTN                     Length;
 
-  UsbDebugPortHandle = GetUsb3DebugPortInstance ();
+  if (Handle != NULL) {
+    UsbDebugPortHandle = (USB3_DEBUG_PORT_HANDLE *) Handle;
+    SetUsb3DebugPortInstance (UsbDebugPortHandle);
+  } else {
+    UsbDebugPortHandle = GetUsb3DebugPortInstance ();
+  }
   if (UsbDebugPortHandle == NULL) {
     return FALSE;
   }
 
-  if (UsbDebugPortHandle->Initialized != USB3DBG_ENABLED) {
+  if (UsbDebugPortHandle->InNotify) {
     return FALSE;
   }
 
-  if (UsbDebugPortHandle->InNotify) {
+  DiscoverInitializeUsbDebugPort (UsbDebugPortHandle);
+
+  if (UsbDebugPortHandle->Initialized != USB3DBG_ENABLED) {
     return FALSE;
   }
 
@@ -1043,11 +1100,22 @@ DebugPortInitialize (
 {
   USB3_DEBUG_PORT_HANDLE    *UsbDebugPortHandle;
 
+  //
+  // Validate the PCD PcdDebugPortHandleBufferSize value 
+  //
+  ASSERT (PcdGet16 (PcdDebugPortHandleBufferSize) == sizeof (USB3_DEBUG_PORT_HANDLE));
+
+  if (Function == NULL && Context != NULL) {
+    SetUsb3DebugPortInstance ((USB3_DEBUG_PORT_HANDLE *) Context);
+    return (DEBUG_PORT_HANDLE) Context;
+  }
   UsbDebugPortHandle = GetUsb3DebugPortInstance ();
   if (UsbDebugPortHandle == NULL) {
     return NULL;
   }
 
+  DiscoverInitializeUsbDebugPort (UsbDebugPortHandle);
+
   if (Function != NULL) {
     Function (Context, (DEBUG_PORT_HANDLE) UsbDebugPortHandle);
   }
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c
index 588c9715bd00..d2f3c56704eb 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.c
@@ -23,7 +23,9 @@
 
 GUID                        gUsb3DbgGuid =  USB3_DBG_GUID;
 
-USB3_DEBUG_PORT_HANDLE      *mUsb3Instance = NULL;
+USB3_DEBUG_PORT_HANDLE      mUsb3Instance = {USB3DBG_UNINITIALIZED};
+EFI_PHYSICAL_ADDRESS        mUsb3InstanceAddr = 0;
+EFI_PHYSICAL_ADDRESS        *mUsb3InstanceAddrPtr = NULL;
 EFI_PCI_IO_PROTOCOL         *mUsb3PciIo = NULL;
 
 /**
@@ -184,14 +186,18 @@ Usb3MapDmaBuffers (
 VOID
 EFIAPI
 Usb3DxeSmmReadyToLockNotify (
-  IN  EFI_EVENT                 Event,
-  IN  VOID                      *Context
+  IN EFI_EVENT                  Event,
+  IN VOID                       *Context
   )
 {
-  ASSERT (mUsb3Instance != NULL);
+  USB3_DEBUG_PORT_HANDLE        *Instance;
 
   DEBUG ((DEBUG_INFO, "%a()\n", __FUNCTION__));
-  mUsb3Instance->InNotify = TRUE;
+
+  Instance = GetUsb3DebugPortInstance ();
+  ASSERT (Instance != NULL);
+
+  Instance->InNotify = TRUE;
 
   //
   // For the case that the USB3 debug port instance and DMA buffers are
@@ -199,14 +205,14 @@ Usb3DxeSmmReadyToLockNotify (
   // Reinitialize USB3 debug port with granted DXE DMA buffer accessible
   // by SMM environment.
   //
-  InitializeUsbDebugHardware (mUsb3Instance);
+  InitializeUsbDebugHardware (Instance);
 
   //
   // Wait some time for host to be ready after re-initialization.
   //
   MicroSecondDelay (1000000);
 
-  mUsb3Instance->InNotify = FALSE;
+  Instance->InNotify = FALSE;
   gBS->CloseEvent (Event);
 }
 
@@ -262,6 +268,8 @@ Usb3PciIoNotify (
   UINTN                         PciDeviceNumber;
   UINTN                         PciFunctionNumber;
   UINT32                        PciAddress;
+  USB3_DEBUG_PORT_HANDLE        *Instance;
+  EFI_EVENT                     SmmReadyToLockEvent;
 
   Status = gBS->LocateHandleBuffer (
                   ByProtocol,
@@ -287,24 +295,27 @@ Usb3PciIoNotify (
         //
         // Found the PciIo for USB3 debug port.
         //
-        ASSERT (mUsb3Instance != NULL);
         DEBUG ((DEBUG_INFO, "%a()\n", __FUNCTION__));
         if (Usb3GetIoMmu != NULL) {
-          mUsb3Instance->InNotify = TRUE;
-          Usb3MapDmaBuffers (mUsb3Instance, PciIo);
-          mUsb3Instance->InNotify = FALSE;
-
-          if (mUsb3Instance->FromHob) {
-            mUsb3PciIo = PciIo;
-            Usb3NamedEventListen (
-              &gEfiDxeSmmReadyToLockProtocolGuid,
-              TPL_NOTIFY,
-              Usb3DxeSmmReadyToLockNotify,
-              &Event
-              );
+          Instance = GetUsb3DebugPortInstance ();
+          ASSERT (Instance != NULL);
+          if (Instance->Ready) {
+            Instance->InNotify = TRUE;
+            Usb3MapDmaBuffers (Instance, PciIo);
+            Instance->InNotify = FALSE;
+
+            if (Instance->FromHob) {
+              mUsb3PciIo = PciIo;
+              Usb3NamedEventListen (
+                &gEfiDxeSmmReadyToLockProtocolGuid,
+                TPL_NOTIFY,
+                Usb3DxeSmmReadyToLockNotify,
+                &SmmReadyToLockEvent
+                );
+            }
           }
         }
-        gBS->CloseEvent ((EFI_EVENT) (UINTN) mUsb3Instance->PciIoEvent);
+        gBS->CloseEvent (Event);
         break;
       }
     }
@@ -314,34 +325,22 @@ Usb3PciIoNotify (
 }
 
 /**
-  Return USB3 debug instance address.
+  Return USB3 debug instance address pointer.
 
 **/  
-USB3_DEBUG_PORT_HANDLE *
-GetUsb3DebugPortInstance (
+EFI_PHYSICAL_ADDRESS *
+GetUsb3DebugPortInstanceAddrPtr (
   VOID
   )
 {
-  USB3_DEBUG_PORT_HANDLE          *Instance;
-  EFI_PEI_HOB_POINTERS            Hob;
-
-  Instance = NULL;
-
-  if (mUsb3Instance != NULL) {
-    Instance = mUsb3Instance;
-    goto Done;
-  }
-
-  Hob.Raw = GetFirstGuidHob (&gUsb3DbgGuid);
-  if (Hob.Raw != NULL) {
-    Instance = GET_GUID_HOB_DATA (Hob.Guid);
-  }
-
-Done:
-  if ((Instance != NULL) && (!Instance->InNotify)) {
-    DiscoverInitializeUsbDebugPort (Instance);
+  if (mUsb3InstanceAddrPtr == NULL) {
+    //
+    // Use the local variables temporarily.
+    //
+    mUsb3InstanceAddr = (EFI_PHYSICAL_ADDRESS) (UINTN) &mUsb3Instance;
+    mUsb3InstanceAddrPtr = &mUsb3InstanceAddr;
   }
-  return Instance;
+  return mUsb3InstanceAddrPtr;
 }
 
 /**
@@ -447,59 +446,50 @@ DebugCommunicationUsb3DxeConstructor (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
-  USB3_DEBUG_PORT_HANDLE        UsbDbg;
+  EFI_PHYSICAL_ADDRESS          *AddrPtr;
   USB3_DEBUG_PORT_HANDLE        *Instance;
   EFI_PHYSICAL_ADDRESS          Address;
   EFI_STATUS                    Status;
   EFI_EVENT                     Event;
 
-  Instance = GetUsb3DebugPortInstance ();
-
-  Status = EfiGetSystemConfigurationTable (&gUsb3DbgGuid, (VOID **) &mUsb3Instance);
-  if (!EFI_ERROR (Status)) {
-    goto Done;
-  }
-
-  if (Instance == NULL) {
+  Status = EfiGetSystemConfigurationTable (&gUsb3DbgGuid, (VOID **) &AddrPtr);
+  if (EFI_ERROR (Status)) {
     //
-    // Initialize USB debug
+    // Instead of using local variables, install system configuration table for
+    // the local instance and the buffer to save instance address pointer.
     //
-    ZeroMem (&UsbDbg, sizeof (UsbDbg));
-    UsbDbg.Initialized = USB3DBG_UNINITIALIZED;
+    Address = SIZE_4GB;
+    Status = gBS->AllocatePages (
+                    AllocateMaxAddress,
+                    EfiACPIMemoryNVS,
+                    EFI_SIZE_TO_PAGES (sizeof (EFI_PHYSICAL_ADDRESS) + sizeof (USB3_DEBUG_PORT_HANDLE)),
+                    &Address
+                    );
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
 
-    DiscoverInitializeUsbDebugPort (&UsbDbg);
+    AddrPtr = (EFI_PHYSICAL_ADDRESS *) (UINTN) Address;
+    ZeroMem (AddrPtr, sizeof (EFI_PHYSICAL_ADDRESS) + sizeof (USB3_DEBUG_PORT_HANDLE));
+    Instance = (USB3_DEBUG_PORT_HANDLE *) (AddrPtr + 1);
+    CopyMem (Instance, &mUsb3Instance, sizeof (USB3_DEBUG_PORT_HANDLE));
+    *AddrPtr = (EFI_PHYSICAL_ADDRESS) (UINTN) Instance;
 
-    Instance = &UsbDbg;
+    Status = gBS->InstallConfigurationTable (&gUsb3DbgGuid, AddrPtr);
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
   }
 
-  //
-  // It is first time to run DXE instance, copy Instance from Hob to ACPINvs.
-  //
-  Address = SIZE_4GB;
-  Status = gBS->AllocatePages (
-                  AllocateMaxAddress,
-                  EfiACPIMemoryNVS,
-                  EFI_SIZE_TO_PAGES (sizeof (USB3_DEBUG_PORT_HANDLE)),
-                  &Address
-                  );
-  if (EFI_ERROR (Status)) {
-    return Status;
+  if (mUsb3InstanceAddrPtr != NULL) {
+    *AddrPtr = *mUsb3InstanceAddrPtr;
   }
+  mUsb3InstanceAddrPtr = AddrPtr;
 
-  CopyMem (
-    (VOID *)(UINTN)Address,
-    Instance,
-    sizeof (USB3_DEBUG_PORT_HANDLE)
-    );
-  mUsb3Instance = (USB3_DEBUG_PORT_HANDLE *)(UINTN)Address;
-
-  Status = gBS->InstallConfigurationTable (&gUsb3DbgGuid, mUsb3Instance);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
+  Instance = GetUsb3DebugPortInstance ();
+  ASSERT (Instance != NULL);
 
-Done:
-  if ((mUsb3Instance != NULL) && mUsb3Instance->Ready && (mUsb3Instance->PciIoEvent == 0)) {
+  if (Instance->PciIoEvent == 0) {
     Status = Usb3NamedEventListen (
                &gEfiPciIoProtocolGuid,
                TPL_NOTIFY,
@@ -507,7 +497,7 @@ Done:
                &Event
                );
     if (!EFI_ERROR (Status)) {
-      mUsb3Instance->PciIoEvent = (EFI_PHYSICAL_ADDRESS) (UINTN) Event;
+      Instance->PciIoEvent = (EFI_PHYSICAL_ADDRESS) (UINTN) Event;
     }
   }
 
@@ -530,12 +520,17 @@ DebugCommunicationUsb3DxeDestructor (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
-  if ((mUsb3Instance != NULL) && (mUsb3Instance->PciIoEvent != 0)) {
+  USB3_DEBUG_PORT_HANDLE        *Instance;
+
+  Instance = GetUsb3DebugPortInstance ();
+  ASSERT (Instance != NULL);
+
+  if (Instance->PciIoEvent != 0) {
     //
     // Close the event created.
     //
-    gBS->CloseEvent ((EFI_EVENT) (UINTN) mUsb3Instance->PciIoEvent);
-    mUsb3Instance->PciIoEvent = 0;
+    gBS->CloseEvent ((EFI_EVENT) (UINTN) Instance->PciIoEvent);
+    Instance->PciIoEvent = 0;
   }
   return EFI_SUCCESS;
 }
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.inf b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.inf
index 9f737b9478a8..683d9572e9f7 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.inf
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Dxe.inf
@@ -56,7 +56,7 @@ [Pcd]
 
   # The value of data buffer size used for USB debug port handle.
   # It should be equal to sizeof (USB3_DEBUG_PORT_HANDLE).
-  gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugPortHandleBufferSize|250   ## SOMETIMES_CONSUMES
+  gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugPortHandleBufferSize|249   ## SOMETIMES_CONSUMES
 
 [Protocols]
    ## NOTIFY
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Internal.h b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Internal.h
index 961786e2a41f..8673dad6c55e 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Internal.h
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Internal.h
@@ -472,11 +472,6 @@ typedef struct _USB3_DEBUG_PORT_INSTANCE {
   BOOLEAN                                 FromHob;
 
   //
-  // IOMMU PPI Notify registered
-  //
-  BOOLEAN                                 PpiNotifyRegistered;
-
-  //
   // Prevent notification being interrupted by debug timer
   //
   BOOLEAN                                 InNotify;
@@ -728,14 +723,12 @@ InitializeUsbDebugHardware (
   );
 
 /**
-  Discover and initialize usb debug port.
-
-  @param Handle                  Debug port handle.
+  Return USB3 debug instance address pointer.
 
-**/
-VOID
-DiscoverInitializeUsbDebugPort (
-  IN USB3_DEBUG_PORT_HANDLE     *Handle
+**/  
+EFI_PHYSICAL_ADDRESS *
+GetUsb3DebugPortInstanceAddrPtr (
+  VOID
   );
 
 /**
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.c
index 145113d28dc3..dfdbfb0b7c2e 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.c
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.c
@@ -45,6 +45,9 @@ Usb3IoMmuPpiNotify (
 
   Instance = GetUsb3DebugPortInstance ();
   ASSERT (Instance != NULL);
+  if (!Instance->Ready) {
+    return EFI_SUCCESS;
+  }
 
   Instance->InNotify = TRUE;
 
@@ -174,49 +177,44 @@ Usb3GetIoMmu (
 }
 
 /**
-  Return USB3 debug instance address.
+  Return USB3 debug instance address pointer.
 
 **/  
-USB3_DEBUG_PORT_HANDLE *
-GetUsb3DebugPortInstance (
+EFI_PHYSICAL_ADDRESS *
+GetUsb3DebugPortInstanceAddrPtr (
   VOID
   )
 {
   USB3_DEBUG_PORT_HANDLE        *Instance;
+  EFI_PHYSICAL_ADDRESS          *AddrPtr;
   EFI_PEI_HOB_POINTERS          Hob;
   EFI_STATUS                    Status;
 
   Hob.Raw = GetFirstGuidHob (&gUsb3DbgGuid);
   if (Hob.Raw == NULL) {
     //
-    // Save Instance into HOB
+    // Build HOB for the local instance and the buffer to save instance address pointer.
+    // Use the local instance in HOB temporarily.
     //
-    Instance = BuildGuidHob (
-                 &gUsb3DbgGuid,
-                 sizeof (USB3_DEBUG_PORT_HANDLE)
-                 );
-    ASSERT (Instance != NULL);
-    ZeroMem (Instance, sizeof (USB3_DEBUG_PORT_HANDLE));
-
+    AddrPtr = BuildGuidHob (
+                &gUsb3DbgGuid,
+                sizeof (EFI_PHYSICAL_ADDRESS) + sizeof (USB3_DEBUG_PORT_HANDLE)
+                );
+    ASSERT (AddrPtr != NULL);
+    ZeroMem (AddrPtr, sizeof (EFI_PHYSICAL_ADDRESS) + sizeof (USB3_DEBUG_PORT_HANDLE));
+    Instance = (USB3_DEBUG_PORT_HANDLE *) (AddrPtr + 1);
+    *AddrPtr = (EFI_PHYSICAL_ADDRESS) (UINTN) Instance;
     Instance->FromHob = TRUE;
     Instance->Initialized = USB3DBG_UNINITIALIZED;
+    if (Usb3GetIoMmu () == NULL) {
+      Status = PeiServicesNotifyPpi (&mUsb3IoMmuPpiNotifyDesc);
+      ASSERT_EFI_ERROR (Status);
+    }
   } else {
-    Instance = GET_GUID_HOB_DATA (Hob.Guid);
-  }
-
-  if (!Instance->InNotify) {
-    DiscoverInitializeUsbDebugPort (Instance);
-  }
-
-  if (Instance->Ready &&
-      !Instance->PpiNotifyRegistered &&
-      (Usb3GetIoMmu () == NULL)) {
-    Status = PeiServicesNotifyPpi (&mUsb3IoMmuPpiNotifyDesc);
-    ASSERT_EFI_ERROR (Status);
-    Instance->PpiNotifyRegistered = TRUE;
+    AddrPtr = GET_GUID_HOB_DATA (Hob.Guid);
   }
 
-  return Instance;
+  return AddrPtr;
 }
 
 /**
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.inf b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.inf
index 4f367622d826..12257bce7da7 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.inf
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.inf
@@ -58,7 +58,7 @@ [Pcd]
 
   # The value of data buffer size used for USB debug port handle.
   # It should be equal to sizeof (USB3_DEBUG_PORT_HANDLE).
-  gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugPortHandleBufferSize|250   ## SOMETIMES_CONSUMES
+  gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugPortHandleBufferSize|249   ## SOMETIMES_CONSUMES
 
 [LibraryClasses]
   BaseLib
-- 
2.13.3.windows.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU
  2018-03-11 15:16 [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU Star Zeng
                   ` (2 preceding siblings ...)
  2018-03-11 15:16 ` [PATCH 3/3] SourceLevelDebugPkg DebugCommUsb3: Use the Handle from DebugAgentLib Star Zeng
@ 2018-03-12  2:09 ` Wu, Hao A
  2018-03-12  2:28   ` Zeng, Star
  3 siblings, 1 reply; 9+ messages in thread
From: Wu, Hao A @ 2018-03-12  2:09 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Yao, Jiewen, Ni, Ruiyu

One minor comment:
For patch 3, within changes in function Usb3PciIoNotify():

Usb3NamedEventListen (
  &gEfiDxeSmmReadyToLockProtocolGuid,
  TPL_NOTIFY,
  Usb3DxeSmmReadyToLockNotify,
  &SmmReadyToLockEvent  <---  Does this change related with patch 2?
  );

Otherwise, for me, patch 2 is storing the event for
DxeSmmReadyToLockProtocol in an event which will be closed right after.


Best Regards,
Hao Wu


> -----Original Message-----
> From: Zeng, Star
> Sent: Sunday, March 11, 2018 11:16 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star; Yao, Jiewen; Ni, Ruiyu; Wu, Hao A
> Subject: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements
> after supporting IOMMU
> 
> Please get detailed information in the separated patches.
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> 
> Star Zeng (3):
>   SourceLevelDebugPkg DebugCommUsb3: Refine some formats
>   SourceLevelDebugPkg DebugCommUsb3: Realloc granted DXE DMA buffer
>   SourceLevelDebugPkg DebugCommUsb3: Use the Handle from DebugAgentLib
> 
>  .../DebugCommunicationLibUsb3Common.c              |  96 +++++-
>  .../DebugCommunicationLibUsb3Dxe.c                 | 365 ++++++++++++---------
>  .../DebugCommunicationLibUsb3Dxe.inf               |  11 +-
>  .../DebugCommunicationLibUsb3Internal.h            |  60 +---
>  .../DebugCommunicationLibUsb3Pei.c                 |  50 ++-
>  .../DebugCommunicationLibUsb3Pei.inf               |   4 +-
>  6 files changed, 332 insertions(+), 254 deletions(-)
> 
> --
> 2.13.3.windows.1



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU
  2018-03-12  2:09 ` [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU Wu, Hao A
@ 2018-03-12  2:28   ` Zeng, Star
  2018-03-12  3:37     ` Zeng, Star
  0 siblings, 1 reply; 9+ messages in thread
From: Zeng, Star @ 2018-03-12  2:28 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Yao, Jiewen, Ni, Ruiyu, Zeng, Star

Hao,

Good catch. :)
It is a mistake when splitting patch.


Thanks,
Star
-----Original Message-----
From: Wu, Hao A 
Sent: Monday, March 12, 2018 10:10 AM
To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
Cc: Yao, Jiewen <jiewen.yao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
Subject: RE: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU

One minor comment:
For patch 3, within changes in function Usb3PciIoNotify():

Usb3NamedEventListen (
  &gEfiDxeSmmReadyToLockProtocolGuid,
  TPL_NOTIFY,
  Usb3DxeSmmReadyToLockNotify,
  &SmmReadyToLockEvent  <---  Does this change related with patch 2?
  );

Otherwise, for me, patch 2 is storing the event for DxeSmmReadyToLockProtocol in an event which will be closed right after.


Best Regards,
Hao Wu


> -----Original Message-----
> From: Zeng, Star
> Sent: Sunday, March 11, 2018 11:16 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star; Yao, Jiewen; Ni, Ruiyu; Wu, Hao A
> Subject: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements 
> after supporting IOMMU
> 
> Please get detailed information in the separated patches.
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> 
> Star Zeng (3):
>   SourceLevelDebugPkg DebugCommUsb3: Refine some formats
>   SourceLevelDebugPkg DebugCommUsb3: Realloc granted DXE DMA buffer
>   SourceLevelDebugPkg DebugCommUsb3: Use the Handle from DebugAgentLib
> 
>  .../DebugCommunicationLibUsb3Common.c              |  96 +++++-
>  .../DebugCommunicationLibUsb3Dxe.c                 | 365 ++++++++++++---------
>  .../DebugCommunicationLibUsb3Dxe.inf               |  11 +-
>  .../DebugCommunicationLibUsb3Internal.h            |  60 +---
>  .../DebugCommunicationLibUsb3Pei.c                 |  50 ++-
>  .../DebugCommunicationLibUsb3Pei.inf               |   4 +-
>  6 files changed, 332 insertions(+), 254 deletions(-)
> 
> --
> 2.13.3.windows.1



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU
  2018-03-12  2:28   ` Zeng, Star
@ 2018-03-12  3:37     ` Zeng, Star
  2018-03-13 12:56       ` Wu, Hao A
  0 siblings, 1 reply; 9+ messages in thread
From: Zeng, Star @ 2018-03-12  3:37 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Yao, Jiewen, Ni, Ruiyu, Zeng, Star

I have handled the mistake at https://github.com/lzeng14/edk2/tree/DebugCommUsb3AfterIOMMUV2_WIP.

If you need, I can resend V2 patch. :)

Thanks,
Star
-----Original Message-----
From: Zeng, Star 
Sent: Monday, March 12, 2018 10:28 AM
To: Wu, Hao A <hao.a.wu@intel.com>; edk2-devel@lists.01.org
Cc: Yao, Jiewen <jiewen.yao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Zeng, Star <star.zeng@intel.com>
Subject: RE: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU

Hao,

Good catch. :)
It is a mistake when splitting patch.


Thanks,
Star
-----Original Message-----
From: Wu, Hao A
Sent: Monday, March 12, 2018 10:10 AM
To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
Cc: Yao, Jiewen <jiewen.yao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
Subject: RE: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU

One minor comment:
For patch 3, within changes in function Usb3PciIoNotify():

Usb3NamedEventListen (
  &gEfiDxeSmmReadyToLockProtocolGuid,
  TPL_NOTIFY,
  Usb3DxeSmmReadyToLockNotify,
  &SmmReadyToLockEvent  <---  Does this change related with patch 2?
  );

Otherwise, for me, patch 2 is storing the event for DxeSmmReadyToLockProtocol in an event which will be closed right after.


Best Regards,
Hao Wu


> -----Original Message-----
> From: Zeng, Star
> Sent: Sunday, March 11, 2018 11:16 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star; Yao, Jiewen; Ni, Ruiyu; Wu, Hao A
> Subject: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements 
> after supporting IOMMU
> 
> Please get detailed information in the separated patches.
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> 
> Star Zeng (3):
>   SourceLevelDebugPkg DebugCommUsb3: Refine some formats
>   SourceLevelDebugPkg DebugCommUsb3: Realloc granted DXE DMA buffer
>   SourceLevelDebugPkg DebugCommUsb3: Use the Handle from DebugAgentLib
> 
>  .../DebugCommunicationLibUsb3Common.c              |  96 +++++-
>  .../DebugCommunicationLibUsb3Dxe.c                 | 365 ++++++++++++---------
>  .../DebugCommunicationLibUsb3Dxe.inf               |  11 +-
>  .../DebugCommunicationLibUsb3Internal.h            |  60 +---
>  .../DebugCommunicationLibUsb3Pei.c                 |  50 ++-
>  .../DebugCommunicationLibUsb3Pei.inf               |   4 +-
>  6 files changed, 332 insertions(+), 254 deletions(-)
> 
> --
> 2.13.3.windows.1



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU
  2018-03-12  3:37     ` Zeng, Star
@ 2018-03-13 12:56       ` Wu, Hao A
  2018-03-13 12:58         ` Zeng, Star
  0 siblings, 1 reply; 9+ messages in thread
From: Wu, Hao A @ 2018-03-13 12:56 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Yao, Jiewen, Ni, Ruiyu

> -----Original Message-----
> From: Zeng, Star
> Sent: Monday, March 12, 2018 11:37 AM
> To: Wu, Hao A; edk2-devel@lists.01.org
> Cc: Yao, Jiewen; Ni, Ruiyu; Zeng, Star
> Subject: RE: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3:
> Enhancements after supporting IOMMU
> 
> I have handled the mistake at
> https://github.com/lzeng14/edk2/tree/DebugCommUsb3AfterIOMMUV2_WIP.
> 
> If you need, I can resend V2 patch. :)

Another comment for patch 2, also within function Usb3PciIoNotify():
if (Usb3GetIoMmu != NULL) {
                ^^^
should be:
if (Usb3GetIoMmu () != NULL) {

With that typo fixed, the 2nd commit on the above link seems good to me.
And for the series,
Reviewed-by: Hao Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu

> 
> Thanks,
> Star
> -----Original Message-----
> From: Zeng, Star
> Sent: Monday, March 12, 2018 10:28 AM
> To: Wu, Hao A <hao.a.wu@intel.com>; edk2-devel@lists.01.org
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>; Zeng,
> Star <star.zeng@intel.com>
> Subject: RE: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3:
> Enhancements after supporting IOMMU
> 
> Hao,
> 
> Good catch. :)
> It is a mistake when splitting patch.
> 
> 
> Thanks,
> Star
> -----Original Message-----
> From: Wu, Hao A
> Sent: Monday, March 12, 2018 10:10 AM
> To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: RE: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3:
> Enhancements after supporting IOMMU
> 
> One minor comment:
> For patch 3, within changes in function Usb3PciIoNotify():
> 
> Usb3NamedEventListen (
>   &gEfiDxeSmmReadyToLockProtocolGuid,
>   TPL_NOTIFY,
>   Usb3DxeSmmReadyToLockNotify,
>   &SmmReadyToLockEvent  <---  Does this change related with patch 2?
>   );
> 
> Otherwise, for me, patch 2 is storing the event for
> DxeSmmReadyToLockProtocol in an event which will be closed right after.
> 
> 
> Best Regards,
> Hao Wu
> 
> 
> > -----Original Message-----
> > From: Zeng, Star
> > Sent: Sunday, March 11, 2018 11:16 PM
> > To: edk2-devel@lists.01.org
> > Cc: Zeng, Star; Yao, Jiewen; Ni, Ruiyu; Wu, Hao A
> > Subject: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements
> > after supporting IOMMU
> >
> > Please get detailed information in the separated patches.
> >
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> > Cc: Hao Wu <hao.a.wu@intel.com>
> >
> > Star Zeng (3):
> >   SourceLevelDebugPkg DebugCommUsb3: Refine some formats
> >   SourceLevelDebugPkg DebugCommUsb3: Realloc granted DXE DMA buffer
> >   SourceLevelDebugPkg DebugCommUsb3: Use the Handle from
> DebugAgentLib
> >
> >  .../DebugCommunicationLibUsb3Common.c              |  96 +++++-
> >  .../DebugCommunicationLibUsb3Dxe.c                 | 365 ++++++++++++---------
> >  .../DebugCommunicationLibUsb3Dxe.inf               |  11 +-
> >  .../DebugCommunicationLibUsb3Internal.h            |  60 +---
> >  .../DebugCommunicationLibUsb3Pei.c                 |  50 ++-
> >  .../DebugCommunicationLibUsb3Pei.inf               |   4 +-
> >  6 files changed, 332 insertions(+), 254 deletions(-)
> >
> > --
> > 2.13.3.windows.1



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU
  2018-03-13 12:56       ` Wu, Hao A
@ 2018-03-13 12:58         ` Zeng, Star
  0 siblings, 0 replies; 9+ messages in thread
From: Zeng, Star @ 2018-03-13 12:58 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Yao, Jiewen, Ni, Ruiyu, Zeng, Star

Good finding.
The typo has been fixed in local.
Thanks very much.

Star
-----Original Message-----
From: Wu, Hao A 
Sent: Tuesday, March 13, 2018 8:56 PM
To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
Cc: Yao, Jiewen <jiewen.yao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
Subject: RE: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU

> -----Original Message-----
> From: Zeng, Star
> Sent: Monday, March 12, 2018 11:37 AM
> To: Wu, Hao A; edk2-devel@lists.01.org
> Cc: Yao, Jiewen; Ni, Ruiyu; Zeng, Star
> Subject: RE: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3:
> Enhancements after supporting IOMMU
> 
> I have handled the mistake at
> https://github.com/lzeng14/edk2/tree/DebugCommUsb3AfterIOMMUV2_WIP.
> 
> If you need, I can resend V2 patch. :)

Another comment for patch 2, also within function Usb3PciIoNotify():
if (Usb3GetIoMmu != NULL) {
                ^^^
should be:
if (Usb3GetIoMmu () != NULL) {

With that typo fixed, the 2nd commit on the above link seems good to me.
And for the series,
Reviewed-by: Hao Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu

> 
> Thanks,
> Star
> -----Original Message-----
> From: Zeng, Star
> Sent: Monday, March 12, 2018 10:28 AM
> To: Wu, Hao A <hao.a.wu@intel.com>; edk2-devel@lists.01.org
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Ni, Ruiyu 
> <ruiyu.ni@intel.com>; Zeng, Star <star.zeng@intel.com>
> Subject: RE: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3:
> Enhancements after supporting IOMMU
> 
> Hao,
> 
> Good catch. :)
> It is a mistake when splitting patch.
> 
> 
> Thanks,
> Star
> -----Original Message-----
> From: Wu, Hao A
> Sent: Monday, March 12, 2018 10:10 AM
> To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: RE: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3:
> Enhancements after supporting IOMMU
> 
> One minor comment:
> For patch 3, within changes in function Usb3PciIoNotify():
> 
> Usb3NamedEventListen (
>   &gEfiDxeSmmReadyToLockProtocolGuid,
>   TPL_NOTIFY,
>   Usb3DxeSmmReadyToLockNotify,
>   &SmmReadyToLockEvent  <---  Does this change related with patch 2?
>   );
> 
> Otherwise, for me, patch 2 is storing the event for 
> DxeSmmReadyToLockProtocol in an event which will be closed right after.
> 
> 
> Best Regards,
> Hao Wu
> 
> 
> > -----Original Message-----
> > From: Zeng, Star
> > Sent: Sunday, March 11, 2018 11:16 PM
> > To: edk2-devel@lists.01.org
> > Cc: Zeng, Star; Yao, Jiewen; Ni, Ruiyu; Wu, Hao A
> > Subject: [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements 
> > after supporting IOMMU
> >
> > Please get detailed information in the separated patches.
> >
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> > Cc: Hao Wu <hao.a.wu@intel.com>
> >
> > Star Zeng (3):
> >   SourceLevelDebugPkg DebugCommUsb3: Refine some formats
> >   SourceLevelDebugPkg DebugCommUsb3: Realloc granted DXE DMA buffer
> >   SourceLevelDebugPkg DebugCommUsb3: Use the Handle from
> DebugAgentLib
> >
> >  .../DebugCommunicationLibUsb3Common.c              |  96 +++++-
> >  .../DebugCommunicationLibUsb3Dxe.c                 | 365 ++++++++++++---------
> >  .../DebugCommunicationLibUsb3Dxe.inf               |  11 +-
> >  .../DebugCommunicationLibUsb3Internal.h            |  60 +---
> >  .../DebugCommunicationLibUsb3Pei.c                 |  50 ++-
> >  .../DebugCommunicationLibUsb3Pei.inf               |   4 +-
> >  6 files changed, 332 insertions(+), 254 deletions(-)
> >
> > --
> > 2.13.3.windows.1



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-03-13 12:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-11 15:16 [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU Star Zeng
2018-03-11 15:16 ` [PATCH 1/3] SourceLevelDebugPkg DebugCommUsb3: Refine some formats Star Zeng
2018-03-11 15:16 ` [PATCH 2/3] SourceLevelDebugPkg DebugCommUsb3: Realloc granted DXE DMA buffer Star Zeng
2018-03-11 15:16 ` [PATCH 3/3] SourceLevelDebugPkg DebugCommUsb3: Use the Handle from DebugAgentLib Star Zeng
2018-03-12  2:09 ` [PATCH 0/3] SouceLevelDebugPkg DebugCommUsb3: Enhancements after supporting IOMMU Wu, Hao A
2018-03-12  2:28   ` Zeng, Star
2018-03-12  3:37     ` Zeng, Star
2018-03-13 12:56       ` Wu, Hao A
2018-03-13 12:58         ` Zeng, Star

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox