]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Ufs: ensure the DBC field of UTP PRDT is dword-aligned
authorFeng Tian <feng.tian@intel.com>
Tue, 18 Oct 2016 05:17:56 +0000 (13:17 +0800)
committerFeng Tian <feng.tian@intel.com>
Wed, 9 Nov 2016 07:30:10 +0000 (15:30 +0800)
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 <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c
MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c

index 68800570cb0c182a2e72882c3bdc286774b6ac2f..7e90ecf8e0198eef193d5de4ab3b17a47bdad867 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-  Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2016, 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
@@ -329,6 +329,11 @@ UfsInitUtpPrdt (
   UINT8      *Remaining;\r
   UINTN      PrdtNumber;\r
 \r
+  if ((BufferSize & (BIT0 | BIT1)) != 0) {\r
+    BufferSize &= ~(BIT0 | BIT1);\r
+    DEBUG ((EFI_D_WARN, "UfsInitUtpPrdt: The BufferSize [%d] is not dword-aligned!\n", BufferSize));\r
+  }\r
+\r
   if (BufferSize == 0) {\r
     return EFI_SUCCESS;\r
   }\r
index 26986cbf26dcaf52d4ca9d0c4a988ec6506ecc37..3bd6dade907c23cd7f7cdaf22efff619f0b69757 100644 (file)
@@ -2,7 +2,7 @@
   UfsPassThruDxe driver is used to produce EFI_EXT_SCSI_PASS_THRU protocol interface\r
   for upper layer application to execute UFS-supported SCSI cmds.\r
 \r
-  Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2016, 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
@@ -400,6 +400,11 @@ UfsInitUtpPrdt (
   UINT8      *Remaining;\r
   UINTN      PrdtNumber;\r
 \r
+  if ((BufferSize & (BIT0 | BIT1)) != 0) {\r
+    BufferSize &= ~(BIT0 | BIT1);\r
+    DEBUG ((EFI_D_WARN, "UfsInitUtpPrdt: The BufferSize [%d] is not dword-aligned!\n", BufferSize));\r
+  }\r
+\r
   if (BufferSize == 0) {\r
     return EFI_SUCCESS;\r
   }\r