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=TsB1Nu1o; spf=pass (domain: linaro.org, ip: 209.85.128.66, mailfrom: leif.lindholm@linaro.org) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by groups.io with SMTP; Tue, 28 May 2019 11:04:14 -0700 Received: by mail-wm1-f66.google.com with SMTP id u78so3972663wmu.5 for ; Tue, 28 May 2019 11:04:13 -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=eRR1yM6gLeJPHD3qTbtXl/iT9dPoHkSiqXiW3f9TMqg=; b=TsB1Nu1oJfiEtw4fskjwLD7Hs/490J4dGszpL4QTQxkeQCjZKu5XPO7xkRl1rUF9tx rWpqBIOC0s2CCIbDVFlHtBngSdM8DR8Zsa2jj5M0694TBWhzbeBdK66SPc+4Bj5K6f/7 OOgu8vXohk8m8oIhu/soBQv1xXUPg3tTazhFKhwSPVRKwFx8E1FfSXrBrcn3GtMhvnTi x3rp89jPG6JfDhHwSy6XURM4KiASUk5mIFE2n+6Bj3wssLfbSednxIn7MOicqWxXDIan QQbme7MwQiY73O+G9j3l6cY80d3P/b92Qn18ovMCU/QOvW7xK69DYV0raBC0hBZByMcG A1fw== 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=eRR1yM6gLeJPHD3qTbtXl/iT9dPoHkSiqXiW3f9TMqg=; b=kDfFDhyoOm3FpoAvn9TQaQBRR5IE0J8CCWHYsRiMV7vazNbuJq8Nh0lVAm/vPcjbVU rEJn2PFtiZFd5BC4VTPr5Dwbq9OYpBJ9hO6/qTRdJBoBIWRwGKuCtvtsXyb03pLFM+ZD NApi5iR0KdCOkjmKtODeEVIdiimE/xKZh488bYEWOu1aLRSpqTmPlxmW5TKn2OYHW0cL ZG5Bt2ms9tbe2b60WLChJW4PG7gQ0kwJ5Hd3enmPXzFo/IUE1NWyOipPObamm25CgJgC b0P2TXi+NiEL3ngRlFPMNfNBC5RPGUsYkVlKxEeDA5RhZXA153GNqm/CPHGiyIF9empY vw+A== X-Gm-Message-State: APjAAAXLRRRx+vkHoYV6Bu2+wovgW5++z8Vn/shJ1NdwJO9A3E5J1qxm CSBmrs0lNIp1EWihrqW2d608fQ== X-Google-Smtp-Source: APXvYqysphX7bAKHppYnpX9jyITDtH4GDR18ZgXoyfMpKj0WGuMCEgBg030zbPitmyu3JkpKWKblwg== X-Received: by 2002:a1c:b782:: with SMTP id h124mr4110219wmf.20.1559066652187; Tue, 28 May 2019 11:04:12 -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 m17sm1951695wmc.6.2019.05.28.11.04.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 11:04:11 -0700 (PDT) Date: Tue, 28 May 2019 19:04:09 +0100 From: "Leif Lindholm" To: tien.hock.loh@intel.com, Haojian Zhuang Cc: devel@edk2.groups.io, thloh85@gmail.com, Ard Biesheuvel Subject: Re: [PATCH v2 6/7] EmbeddedPkg: Fix DwEmmc SendCommand polling Message-ID: <20190528180409.xqqigzdyk4e2oamt@bivouac.eciton.net> References: <1558949428-190715-1-git-send-email-tien.hock.loh@intel.com> <1558949428-190715-7-git-send-email-tien.hock.loh@intel.com> MIME-Version: 1.0 In-Reply-To: <1558949428-190715-7-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 +Haojian, Haojian - since you are the original author, can you comment on the delays? Are these silicon bug workarounds (so we need to add a Pcd), or does these changes work on your platforms too? Regards, Leif On Mon, May 27, 2019 at 05:30:27PM +0800, tien.hock.loh@intel.com wrote: > From: "Tien Hock, Loh" > > Change SendCommand polling mode to remove unnecessary delay, and check > for transfer done only when block data is to be read/write. This would > also increase performance slightly. > > Signed-off-by: "Tien Hock, Loh" > Cc: Leif Lindholm > Cc: Ard Biesheuvel > --- > EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c | 43 +++++++++++++++----- > 1 file changed, 33 insertions(+), 10 deletions(-) > > diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c > index c6c8e04917..b57833458f 100644 > --- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c > +++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c > @@ -286,16 +286,13 @@ SendCommand ( > DWEMMC_INT_RCRC | DWEMMC_INT_RE; > ErrMask |= DWEMMC_INT_DCRC | DWEMMC_INT_DRT | DWEMMC_INT_SBE; > do { > - MicroSecondDelay(500); > Data = MmioRead32 (DWEMMC_RINTSTS); > - > - if (Data & ErrMask) { > - return EFI_DEVICE_ERROR; > - } > - if (Data & DWEMMC_INT_DTO) { // Transfer Done > - break; > - } > } while (!(Data & DWEMMC_INT_CMD_DONE)); > + > + if (Data & ErrMask) { > + return EFI_DEVICE_ERROR; > + } > + > return EFI_SUCCESS; > } > > @@ -550,8 +547,9 @@ DwEmmcReadBlockData ( > ) > { > EFI_STATUS Status; > - UINT32 DescPages, CountPerPage, Count; > + UINT32 DescPages, CountPerPage, Count, ErrMask; > EFI_TPL Tpl; > + UINTN Rintsts = 0; > > Tpl = gBS->RaiseTPL (TPL_NOTIFY); > > @@ -574,6 +572,18 @@ DwEmmcReadBlockData ( > DEBUG ((DEBUG_ERROR, "Failed to read data, mDwEmmcCommand:%x, mDwEmmcArgument:%x, Status:%r\n", mDwEmmcCommand, mDwEmmcArgument, Status)); > goto out; > } > + > + while(!((MmioRead32(DWEMMC_RINTSTS) & (DWEMMC_INT_DTO)))) { > + Rintsts = MmioRead32 (DWEMMC_RINTSTS); > + } > + ErrMask = DWEMMC_INT_EBE | DWEMMC_INT_HLE | DWEMMC_INT_RTO | > + DWEMMC_INT_RCRC | DWEMMC_INT_RE | DWEMMC_INT_DCRC | > + DWEMMC_INT_DRT | DWEMMC_INT_SBE; > + > + if (Rintsts & ErrMask) { > + Status = EFI_DEVICE_ERROR; > + goto out; > + } > out: > // Restore Tpl > gBS->RestoreTPL (Tpl); > @@ -589,8 +599,9 @@ DwEmmcWriteBlockData ( > ) > { > EFI_STATUS Status; > - UINT32 DescPages, CountPerPage, Count; > + UINT32 DescPages, CountPerPage, Count, ErrMask; > EFI_TPL Tpl; > + UINTN Rintsts = 0; > > Tpl = gBS->RaiseTPL (TPL_NOTIFY); > > @@ -613,6 +624,18 @@ DwEmmcWriteBlockData ( > DEBUG ((DEBUG_ERROR, "Failed to write data, mDwEmmcCommand:%x, mDwEmmcArgument:%x, Status:%r\n", mDwEmmcCommand, mDwEmmcArgument, Status)); > goto out; > } > + > + while(!((MmioRead32(DWEMMC_RINTSTS) & (DWEMMC_INT_DTO)))) { > + Rintsts = MmioRead32 (DWEMMC_RINTSTS); > + } > + ErrMask = DWEMMC_INT_EBE | DWEMMC_INT_HLE | DWEMMC_INT_RTO | > + DWEMMC_INT_RCRC | DWEMMC_INT_RE | DWEMMC_INT_DCRC | > + DWEMMC_INT_DRT | DWEMMC_INT_SBE; > + > + if (Rintsts & ErrMask) { > + Status = EFI_DEVICE_ERROR; > + goto out; > + } > out: > // Restore Tpl > gBS->RestoreTPL (Tpl); > -- > 2.19.0 >