From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: tien.hock.loh@intel.com) Received: from mga14.intel.com (mga14.intel.com []) by groups.io with SMTP; Thu, 02 May 2019 20:28:19 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 May 2019 20:28:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,424,1549958400"; d="scan'208";a="167124905" Received: from pg-iccf0195.altera.com ([10.104.4.90]) by fmsmga002.fm.intel.com with ESMTP; 02 May 2019 20:28:17 -0700 From: "Loh, Tien Hock" To: devel@edk2.groups.io, thloh85@gmail.com Cc: "Tien Hock, Loh" , Leif Lindholm , Ard Biesheuvel Subject: [[PATCH v2] 7/7] EmbeddedPkg: Fix DwEmmc driver bugs Date: Fri, 3 May 2019 11:27:03 +0800 Message-Id: <1556854023-5486-8-git-send-email-tien.hock.loh@intel.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1556854023-5486-1-git-send-email-tien.hock.loh@intel.com> References: <1556854023-5486-1-git-send-email-tien.hock.loh@intel.com> From: "Tien Hock, Loh" Add support for reading data that is less than DWEMMC_BLOCK_SIZE, otherwise it would read bigger data than requested and cause errors Signed-off-by: "Tien Hock, Loh" Cc: Leif Lindholm Cc: Ard Biesheuvel --- EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c index c38b5a4..4183ad4 100644 --- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c +++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c @@ -495,7 +495,10 @@ PrepareDmaData ( Cnt = (Length + DWEMMC_DMA_BUF_SIZE - 1) / DWEMMC_DMA_BUF_SIZE; Blks = (Length + DWEMMC_BLOCK_SIZE - 1) / DWEMMC_BLOCK_SIZE; - Length = DWEMMC_BLOCK_SIZE * Blks; + + if(Length >= DWEMMC_BLOCK_SIZE) { + Length = DWEMMC_BLOCK_SIZE * Blks; + } for (Idx = 0; Idx < Cnt; Idx++) { (IdmacDesc + Idx)->Des0 = DWEMMC_IDMAC_DES0_OWN | DWEMMC_IDMAC_DES0_CH | @@ -533,11 +536,18 @@ StartDma ( Data |= DWEMMC_CTRL_INT_EN | DWEMMC_CTRL_DMA_EN | DWEMMC_CTRL_IDMAC_EN; MmioWrite32 (DWEMMC_CTRL, Data); Data = MmioRead32 (DWEMMC_BMOD); + Data |= DWEMMC_IDMAC_ENABLE | DWEMMC_IDMAC_FB; MmioWrite32 (DWEMMC_BMOD, Data); - MmioWrite32 (DWEMMC_BLKSIZ, DWEMMC_BLOCK_SIZE); - MmioWrite32 (DWEMMC_BYTCNT, Length); + if(Length < DWEMMC_BLOCK_SIZE) { + MmioWrite32 (DWEMMC_BLKSIZ, Length); + MmioWrite32 (DWEMMC_BYTCNT, Length); + } + else { + MmioWrite32 (DWEMMC_BLKSIZ, DWEMMC_BLOCK_SIZE); + MmioWrite32 (DWEMMC_BYTCNT, Length); + } } EFI_STATUS -- 2.2.2