From c16eee92d4b2e872f21645f7a4a04bbfb2a92d75 Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Thu, 15 Jun 2017 15:15:59 +0800 Subject: [PATCH] MdeModulePkg/Ufs: Set 'Data Segment Length' field for Write Descriptor According to the Universal Flash Storage (UFS) Version 2.1 (JESD220C) spec Section 10.7.8.5, the DATA SEGMENT LENGTH field of the UPIU shall also be set to number of descriptor bytes to write. The origin codes miss the above operation. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: Star Zeng --- MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c | 3 +++ MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c index 1ef6c8878b..9c72c1dede 100644 --- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c @@ -407,6 +407,9 @@ UfsInitQueryRequestUpiu ( if (Opcode == UtpQueryFuncOpcodeWrDesc) { CopyMem (QueryReq + 1, Data, DataSize); + + SwapLittleEndianToBigEndian ((UINT8*)&DataSize, sizeof (UINT16)); + QueryReq->DataSegLen = (UINT16)DataSize; } return EFI_SUCCESS; diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 5fa635523a..4b7df74501 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -478,6 +478,9 @@ UfsInitQueryRequestUpiu ( if (Opcode == UtpQueryFuncOpcodeWrDesc) { CopyMem (QueryReq + 1, Data, DataSize); + + SwapLittleEndianToBigEndian ((UINT8*)&DataSize, sizeof (UINT16)); + QueryReq->DataSegLen = (UINT16)DataSize; } return EFI_SUCCESS;