Re: [edk2] [patch] MdeModulePkg/Ufs: ensure the DBC field of UTP PRDT is dword-aligned

2016-10-18 Thread Wu, Hao A
The patch is good to me. Please update the copyright info before checkin.
Reviewed-by: Hao Wu 

Best Regards,
Hao Wu

> -Original Message-
> From: Tian, Feng
> Sent: Tuesday, October 18, 2016 1:19 PM
> To: Wu, Hao A
> Cc: edk2-devel@lists.01.org
> Subject: [patch] MdeModulePkg/Ufs: ensure the DBC field of UTP PRDT is
> dword-aligned
> 
> According to UFS Host Controller Spec(JESD223), the bits 1:0 of this
> DataByteCount field shall be 11b to indicate Dword granularity.
> 
> But the size of UFS Request Sense Data Response defined in UFS Spec
> (JESD220C) is 18 which is not Dword aligned, we would have to round
> down to the multiple of 4 to fill the DBC field to avoid bring issue
> on some UFS HCs.
> 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Feng Tian 
> ---
>  MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
> b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
> index 26986cb..a854264 100644
> --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
> +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
> @@ -399,6 +399,11 @@ UfsInitUtpPrdt (
>UINT32 RemainingLen;
>UINT8  *Remaining;
>UINTN  PrdtNumber;
> +
> +  if ((BufferSize & (BIT0 | BIT1)) != 0) {
> +BufferSize &= ~(BIT0 | BIT1);
> +DEBUG ((EFI_D_WARN, "UfsInitUtpPrdt: The BufferSize [%d] is not dword-
> aligned!\n", BufferSize));
> +  }
> 
>if (BufferSize == 0) {
>  return EFI_SUCCESS;
> --
> 2.7.1.windows.2

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [patch] MdeModulePkg/Ufs: ensure the DBC field of UTP PRDT is dword-aligned

2016-10-17 Thread Feng Tian
According to UFS Host Controller Spec(JESD223), the bits 1:0 of this
DataByteCount field shall be 11b to indicate Dword granularity.

But the size of UFS Request Sense Data Response defined in UFS Spec
(JESD220C) is 18 which is not Dword aligned, we would have to round
down to the multiple of 4 to fill the DBC field to avoid bring issue
on some UFS HCs.

Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian 
---
 MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c 
b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index 26986cb..a854264 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -399,6 +399,11 @@ UfsInitUtpPrdt (
   UINT32 RemainingLen;
   UINT8  *Remaining;
   UINTN  PrdtNumber;
+  
+  if ((BufferSize & (BIT0 | BIT1)) != 0) {
+BufferSize &= ~(BIT0 | BIT1);
+DEBUG ((EFI_D_WARN, "UfsInitUtpPrdt: The BufferSize [%d] is not 
dword-aligned!\n", BufferSize));
+  }
 
   if (BufferSize == 0) {
 return EFI_SUCCESS;
-- 
2.7.1.windows.2

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel