[edk2] [PATCH V2 0/6] SourceLevelDebugPkg DebugUsb3: Re-Support IOMMU

Star Zeng posted 6 patches 6 years, 9 months ago
Failed in applying to current master (apply log)
.../DebugCommunicationLibUsb3Common.c              | 110 +++++-
.../DebugCommunicationLibUsb3Dxe.c                 | 375 ++++++++++++---------
.../DebugCommunicationLibUsb3Dxe.inf               |  11 +-
.../DebugCommunicationLibUsb3Internal.h            |  60 +---
.../DebugCommunicationLibUsb3Pei.c                 |  50 ++-
.../DebugCommunicationLibUsb3Pei.inf               |   4 +-
6 files changed, 351 insertions(+), 259 deletions(-)
[edk2] [PATCH V2 0/6] SourceLevelDebugPkg DebugUsb3: Re-Support IOMMU
Posted by Star Zeng 6 years, 9 months ago
The patch series is also at
https://github.com/lzeng14/edk2 DebugCommUsb3AfterIOMMUV2 branch.

Based on the feedbacks from Ray and Hao.
It is V2 of
https://lists.01.org/pipermail/edk2-devel/2018-March/022586.html.
It has no essential difference with V1 about the final code, but
re-arranges the patches to revert old IOMMU support patches and
then re-support IOMMU.

de8373fa07f87ca735139bb86c51e2c29fb1d956 could not handle two cases.
1. For the case that the USB3 debug port instance and DMA buffers are
from PEI HOB with IOMMU enabled, it was to reallocate the DMA buffers
by AllocateAddress with the memory type accessible by SMM environment.
But reallocating the DMA buffers by AllocateAddress may fail.

2. 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.

The patch is to re-support IOMMU.
For PEI, allocate granted DMA buffer from IOMMU PPI, register IOMMU PPI
notification to reinitialize hardware with granted DMA buffer if IOMMU
PPI is not present yet.
For DXE, map DMA buffer by PciIo in PciIo notification for early DXE,
and register DxeSmmReadyToLock notification to reinitialize hardware
with granted DXE DMA buffer accessible by SMM environment for late DXE.

DebugAgentLib has been managing the instance as Handle in
HOB/SystemTable. The Handle(instance) from DebugAgentLib can be used
directly in DebugCommunicationLibUsb3. Then DebugCommunicationLibUsb3
could get consistent Handle(instance) from DebugAgentLib.

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

Star Zeng (6):
  Revert "DebugUsb3: Check mUsb3Instance before dereferencing it"
  Revert "DebugUsb3: Fix GCC build failures"
  Revert "DebugUsb3: Support IOMMU"
  SourceLevelDebugPkg DebugUsb3: Re-Fix GCC build failures
  SourceLevelDebugPkg DebugCommUsb3: Refine some formats/comments
  SourceLevelDebugPkg DebugUsb3: Re-Support IOMMU

 .../DebugCommunicationLibUsb3Common.c              | 110 +++++-
 .../DebugCommunicationLibUsb3Dxe.c                 | 375 ++++++++++++---------
 .../DebugCommunicationLibUsb3Dxe.inf               |  11 +-
 .../DebugCommunicationLibUsb3Internal.h            |  60 +---
 .../DebugCommunicationLibUsb3Pei.c                 |  50 ++-
 .../DebugCommunicationLibUsb3Pei.inf               |   4 +-
 6 files changed, 351 insertions(+), 259 deletions(-)

-- 
2.7.0.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH V2 0/6] SourceLevelDebugPkg DebugUsb3: Re-Support IOMMU
Posted by Ni, Ruiyu 6 years, 9 months ago
On 3/14/2018 5:33 PM, Star Zeng wrote:
> The patch series is also at
> https://github.com/lzeng14/edk2 DebugCommUsb3AfterIOMMUV2 branch.
> 
> Based on the feedbacks from Ray and Hao.
> It is V2 of
> https://lists.01.org/pipermail/edk2-devel/2018-March/022586.html.
> It has no essential difference with V1 about the final code, but
> re-arranges the patches to revert old IOMMU support patches and
> then re-support IOMMU.
> 
> de8373fa07f87ca735139bb86c51e2c29fb1d956 could not handle two cases.
> 1. For the case that the USB3 debug port instance and DMA buffers are
> from PEI HOB with IOMMU enabled, it was to reallocate the DMA buffers
> by AllocateAddress with the memory type accessible by SMM environment.
> But reallocating the DMA buffers by AllocateAddress may fail.
> 
> 2. 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.
> 
> The patch is to re-support IOMMU.
> For PEI, allocate granted DMA buffer from IOMMU PPI, register IOMMU PPI
> notification to reinitialize hardware with granted DMA buffer if IOMMU
> PPI is not present yet.
> For DXE, map DMA buffer by PciIo in PciIo notification for early DXE,
> and register DxeSmmReadyToLock notification to reinitialize hardware
> with granted DXE DMA buffer accessible by SMM environment for late DXE.
> 
> DebugAgentLib has been managing the instance as Handle in
> HOB/SystemTable. The Handle(instance) from DebugAgentLib can be used
> directly in DebugCommunicationLibUsb3. Then DebugCommunicationLibUsb3
> could get consistent Handle(instance) from DebugAgentLib.
> 
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> 
> Star Zeng (6):
>    Revert "DebugUsb3: Check mUsb3Instance before dereferencing it"
>    Revert "DebugUsb3: Fix GCC build failures"
>    Revert "DebugUsb3: Support IOMMU"
>    SourceLevelDebugPkg DebugUsb3: Re-Fix GCC build failures
>    SourceLevelDebugPkg DebugCommUsb3: Refine some formats/comments
>    SourceLevelDebugPkg DebugUsb3: Re-Support IOMMU
> 
>   .../DebugCommunicationLibUsb3Common.c              | 110 +++++-
>   .../DebugCommunicationLibUsb3Dxe.c                 | 375 ++++++++++++---------
>   .../DebugCommunicationLibUsb3Dxe.inf               |  11 +-
>   .../DebugCommunicationLibUsb3Internal.h            |  60 +---
>   .../DebugCommunicationLibUsb3Pei.c                 |  50 ++-
>   .../DebugCommunicationLibUsb3Pei.inf               |   4 +-
>   6 files changed, 351 insertions(+), 259 deletions(-)
> 
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

-- 
Thanks,
Ray
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH V2 0/6] SourceLevelDebugPkg DebugUsb3: Re-Support IOMMU
Posted by Wu, Hao A 6 years, 9 months ago
The series is good to me.
Reviewed-by: Hao Wu <hao.a.wu@intel.com>


Best Regards,
Hao Wu


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Star
> Zeng
> Sent: Wednesday, March 14, 2018 5:34 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu; Wu, Hao A; Zeng, Star
> Subject: [edk2] [PATCH V2 0/6] SourceLevelDebugPkg DebugUsb3: Re-Support
> IOMMU
> 
> The patch series is also at
> https://github.com/lzeng14/edk2 DebugCommUsb3AfterIOMMUV2 branch.
> 
> Based on the feedbacks from Ray and Hao.
> It is V2 of
> https://lists.01.org/pipermail/edk2-devel/2018-March/022586.html.
> It has no essential difference with V1 about the final code, but
> re-arranges the patches to revert old IOMMU support patches and
> then re-support IOMMU.
> 
> de8373fa07f87ca735139bb86c51e2c29fb1d956 could not handle two cases.
> 1. For the case that the USB3 debug port instance and DMA buffers are
> from PEI HOB with IOMMU enabled, it was to reallocate the DMA buffers
> by AllocateAddress with the memory type accessible by SMM environment.
> But reallocating the DMA buffers by AllocateAddress may fail.
> 
> 2. 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.
> 
> The patch is to re-support IOMMU.
> For PEI, allocate granted DMA buffer from IOMMU PPI, register IOMMU PPI
> notification to reinitialize hardware with granted DMA buffer if IOMMU
> PPI is not present yet.
> For DXE, map DMA buffer by PciIo in PciIo notification for early DXE,
> and register DxeSmmReadyToLock notification to reinitialize hardware
> with granted DXE DMA buffer accessible by SMM environment for late DXE.
> 
> DebugAgentLib has been managing the instance as Handle in
> HOB/SystemTable. The Handle(instance) from DebugAgentLib can be used
> directly in DebugCommunicationLibUsb3. Then DebugCommunicationLibUsb3
> could get consistent Handle(instance) from DebugAgentLib.
> 
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> 
> Star Zeng (6):
>   Revert "DebugUsb3: Check mUsb3Instance before dereferencing it"
>   Revert "DebugUsb3: Fix GCC build failures"
>   Revert "DebugUsb3: Support IOMMU"
>   SourceLevelDebugPkg DebugUsb3: Re-Fix GCC build failures
>   SourceLevelDebugPkg DebugCommUsb3: Refine some formats/comments
>   SourceLevelDebugPkg DebugUsb3: Re-Support IOMMU
> 
>  .../DebugCommunicationLibUsb3Common.c              | 110 +++++-
>  .../DebugCommunicationLibUsb3Dxe.c                 | 375 ++++++++++++---------
>  .../DebugCommunicationLibUsb3Dxe.inf               |  11 +-
>  .../DebugCommunicationLibUsb3Internal.h            |  60 +---
>  .../DebugCommunicationLibUsb3Pei.c                 |  50 ++-
>  .../DebugCommunicationLibUsb3Pei.inf               |   4 +-
>  6 files changed, 351 insertions(+), 259 deletions(-)
> 
> --
> 2.7.0.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel