From cd70b1a71d30d0fff4c549a309682fdf127aaae6 Mon Sep 17 00:00:00 2001 From: "Agrawal, Sachin" Date: Mon, 23 Sep 2019 19:48:17 +0800 Subject: MdeModulePkg/Ufs: Fix UFS flag read from Query Resp UPIU As per UFS spec, flag value is stored in the 'last byte' of value field. Existing code is attempting to read first byte. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2208 Test: Verified the Fix by sending command to set fPowerOnWPEn flag and then reading it to verify the set value. Cc: Ray Ni Signed-off-by: Sachin Agrawal Reviewed-by: Hao A Wu --- MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c | 5 ++++- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c index e8ef0c2..e450f6f 100644 --- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c @@ -977,7 +977,10 @@ UfsRwFlags ( } if (Trd->Ocs == 0) { - *Value = (UINT8)QueryResp->Tsf.Value; + // + // The 'FLAG VALUE' field is at byte offset 3 of QueryResp->Tsf.Value + // + *Value = *((UINT8*)&(QueryResp->Tsf.Value) + 3); } else { Status = EFI_DEVICE_ERROR; } diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 0b95e7d..93ac958 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -863,7 +863,10 @@ UfsGetReturnDataFromQueryResponse ( case UtpQueryFuncOpcodeSetFlag: case UtpQueryFuncOpcodeClrFlag: case UtpQueryFuncOpcodeTogFlag: - CopyMem (Packet->DataBuffer, &QueryResp->Tsf.Value, sizeof (UINT8)); + // + // The 'FLAG VALUE' field is at byte offset 3 of QueryResp->Tsf.Value + // + *((UINT8*)(Packet->DataBuffer)) = *((UINT8*)&(QueryResp->Tsf.Value) + 3); break; case UtpQueryFuncOpcodeRdAttr: case UtpQueryFuncOpcodeWrAttr: -- cgit v1.1