From d945390d5f154cb6664308846736e65e1f59099d Mon Sep 17 00:00:00 2001 From: Feng Tian Date: Tue, 18 Oct 2016 13:17:56 +0800 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 Reviewed-by: Hao Wu --- MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c | 7 ++++++- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c index 68800570cb..7e90ecf8e0 100644 --- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -329,6 +329,11 @@ UfsInitUtpPrdt ( 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; } diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 26986cbf26..3bd6dade90 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -2,7 +2,7 @@ UfsPassThruDxe driver is used to produce EFI_EXT_SCSI_PASS_THRU protocol interface for upper layer application to execute UFS-supported SCSI cmds. - Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -400,6 +400,11 @@ UfsInitUtpPrdt ( 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.39.5