From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=maLYaDI/; spf=pass (domain: linaro.org, ip: 209.85.128.65, mailfrom: leif.lindholm@linaro.org) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by groups.io with SMTP; Tue, 28 May 2019 10:50:54 -0700 Received: by mail-wm1-f65.google.com with SMTP id f204so3948223wme.0 for ; Tue, 28 May 2019 10:50:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sPqpxViUun4Nvl2HahkFkFDWrpKu8Ahg7Sol1vObwCc=; b=maLYaDI/ZD+EJLlm2gHHgpbv2pdtILytWAdMLDADzy44TpXk3srYQSXA/EE+Hn7fLD o65A0yc7IW1AgQCDXkawvsUOmwPUtiELI6d+yICjF5U0RIzO1Iz5vOoVyM1bJX7uyhpx HWOsqaflbMB2VSGIAPW0QxXC9oi/yf25KsJvd03EQjjHyAR59KfXykWtRuzLTBKQc8Ic +wfHStskoEf3vrHRChqnUvFrkIa0zvG3U0uKvtSU6BRe4Q8ZoqMUElyOQYkSGkRL006j VyN09pMrDIinT9JnfM06PztjMvJKDelc4KzgFWHXJnjP4SXsk5F3ktize2EdPAum1zM8 zanQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=sPqpxViUun4Nvl2HahkFkFDWrpKu8Ahg7Sol1vObwCc=; b=cc2FahtV1Ml1dlrT8CXFvZERfoH+ZtScXECzDvOesqyKAfBhG2ep8g3+XubtH+w9Es qcUidprkkOzBSVJ1KurPeUUOiUYp30zc11t/5m8/oFxV8eC2J6SziI6AAFm5/TXsor65 O408fcDVbMNqiA+tDh5hPiYUE4zJQtLr+JuB0zLx3I6fs/m/BLLbgzvU4ETBeroxWqN6 VbWs+bqVLHPBcL1b3jdP3M9ItDs85na7kv1Vxr4fMv3m+QvOulYC2Y0A2QmlWwwQ1dSN Rf0HJPVnkRt5JlTJ9WQQS8bMlyOo/wyt49MBO26cFz7Du0b+fDBmNo5/v+iCYGjfTeA0 Lpvw== X-Gm-Message-State: APjAAAXPmVC0RLi2HBEyZ4TIB27/c5W2ePXjpX7/HgukHEouIP3kQW5/ rjLu3cEfD79IR1X89XgyWWuuNA== X-Google-Smtp-Source: APXvYqxC0zxzwZCet3c+W5f+z2E2iq3wpMODk9DHdJ7DxBm+YLtSEVHHTEHVYLOEYTrMcC8YBCtXjQ== X-Received: by 2002:a1c:254:: with SMTP id 81mr4042468wmc.151.1559065852590; Tue, 28 May 2019 10:50:52 -0700 (PDT) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id 8sm3772308wmf.18.2019.05.28.10.50.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 10:50:51 -0700 (PDT) Date: Tue, 28 May 2019 18:50:50 +0100 From: "Leif Lindholm" To: tien.hock.loh@intel.com Cc: devel@edk2.groups.io, thloh85@gmail.com, Ard Biesheuvel Subject: Re: [PATCH v2 7/7] EmbeddedPkg: Fix DwEmmc read/write size in preparing DMA size Message-ID: <20190528175050.6bmo6n6mcsfk5ch4@bivouac.eciton.net> References: <1558949428-190715-1-git-send-email-tien.hock.loh@intel.com> <1558949428-190715-8-git-send-email-tien.hock.loh@intel.com> MIME-Version: 1.0 In-Reply-To: <1558949428-190715-8-git-send-email-tien.hock.loh@intel.com> User-Agent: NeoMutt/20170113 (1.7.2) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, May 27, 2019 at 05:30:28PM +0800, tien.hock.loh@intel.com wrote: > 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 Drop the version blurb from the commit message. Below --- only. > --- > 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); There is still a duplicated line here > + } > + else { } else { > + MmioWrite32 (DWEMMC_BLKSIZ, DWEMMC_BLOCK_SIZE); > + MmioWrite32 (DWEMMC_BYTCNT, Length); and here > + } Which could be outside of the conditional clause, since it is always executed the same. / Leif > } > > EFI_STATUS > -- > 2.19.0 >