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.120, mailfrom: tien.hock.loh@intel.com) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Thu, 09 May 2019 19:41:46 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2019 19:41:46 -0700 X-ExtLoop1: 1 Received: from pg-nx11.altera.com ([10.104.4.26]) by fmsmga004.fm.intel.com with ESMTP; 09 May 2019 19:41:44 -0700 From: "Loh, Tien Hock" To: devel@edk2.groups.io, thloh85@gmail.com Cc: "Tien Hock, Loh" , Leif Lindholm , Ard Biesheuvel Subject: [PATCH v2 1/1] EmbeddedPkg: Fix DwEmmc read/write size in preparing DMA size Date: Fri, 10 May 2019 10:41:25 +0800 Message-Id: <1557456085-176684-1-git-send-email-tien.hock.loh@intel.com> X-Mailer: git-send-email 2.2.2 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 -- v2: - Fix white space issue --- EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c index b57833458f..ec2fa7923b 100644 --- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c +++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c @@ -493,7 +493,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 | @@ -534,8 +537,14 @@ StartDma ( 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.19.0