From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: sachin.agrawal@intel.com) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by groups.io with SMTP; Mon, 23 Sep 2019 04:48:44 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 04:48:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,539,1559545200"; d="scan'208";a="339690570" Received: from sagraw2-desk1.amr.corp.intel.com ([134.134.154.163]) by orsmga004.jf.intel.com with ESMTP; 23 Sep 2019 04:48:43 -0700 From: sachin.agrawal@intel.com To: devel@edk2.groups.io Cc: "Agrawal, Sachin" , Hao A Wu , Ray Ni Subject: [PATCH] MdeModulePkg/UfsPassThru : Fix UFS flag read from Query Resp UPIU Date: Mon, 23 Sep 2019 04:48:17 -0700 Message-Id: <74c3980e787f85e769890c2677b4a0b1ae1e85a8.1569238938.git.sachin.agrawal@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 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: Hao A Wu Cc: Ray Ni Signed-off-by: Sachin Agrawal --- MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c | 5 ++++- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c index e8ef0c2a7a..e450f6f49d 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 0b95e7dddd..93ac958f65 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: -- 2.14.3.windows.1