From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 847291A1E3B for ; Mon, 17 Oct 2016 22:20:10 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP; 17 Oct 2016 22:20:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,508,1473145200"; d="scan'208";a="1055357067" Received: from shwdeftian.ccr.corp.intel.com ([10.239.158.36]) by fmsmga001.fm.intel.com with ESMTP; 17 Oct 2016 22:20:09 -0700 From: Feng Tian To: hao.a.wu@intel.com Cc: edk2-devel@lists.01.org Date: Tue, 18 Oct 2016 13:18:43 +0800 Message-Id: <0fd6e31790f23ea8ad162df1fbc7ceb325770dcf.1476767885.git.feng.tian@intel.com> X-Mailer: git-send-email 2.7.1.windows.2 Subject: [patch] MdeModulePkg/Ufs: ensure the DBC field of UTP PRDT is dword-aligned X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Oct 2016 05:20:10 -0000 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 --- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 26986cb..a854264 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -399,6 +399,11 @@ UfsInitUtpPrdt ( UINT32 RemainingLen; 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.7.1.windows.2