From nobody Sat Feb 7 06:55:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+41414+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41414+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1558949519; cv=none; d=zoho.com; s=zohoarc; b=KQJVLfPgtXLnuvZ9PGYkTzRsGvXdTx1zBPZ93Esz/ov1DDecfUt7yx4tC4WXrrlsDoxLuPByMEoy6Vh1cpUmj2nhYjncG41fttBwyZQfK5FWHLLmhWusxuudkfjU3+6mpWPo04TYX0sBJb1q3NGhg288lZi0dCSDLKPCNnZ612c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558949519; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=do53iHMeD0J9ibeSm+N5uso0e9ku/t2BMc9B7tEtOiY=; b=f93jEUnjpGvRWw+QfnWG9ksP2rDezZERIIvo3NTT3dXNp4SV8r97hza19plFRSpNAhCW28w4qdaWROx/1k5jEYjMJgHBPR1x62oPWY+B+0/Nk+TtyrR2HfyeldID7E+KxvWtYU7PpTlSCAiFWvVQMuxYYEg2EI5+32I3e1oTb2w= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41414+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1558949519842839.5347304011545; Mon, 27 May 2019 02:31:59 -0700 (PDT) Return-Path: X-Received: from mga02.intel.com (mga02.intel.com []) by groups.io with SMTP; Mon, 27 May 2019 02:31:59 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 May 2019 02:31:58 -0700 X-ExtLoop1: 1 X-Received: from pg-nx11.altera.com ([10.104.4.26]) by orsmga008.jf.intel.com with ESMTP; 27 May 2019 02:31:57 -0700 From: "Loh, Tien Hock" To: devel@edk2.groups.io, thloh85@gmail.com Cc: "Tien Hock, Loh" , Leif Lindholm , Ard Biesheuvel Subject: [edk2-devel] [PATCH v2 6/7] EmbeddedPkg: Fix DwEmmc SendCommand polling Date: Mon, 27 May 2019 17:30:27 +0800 Message-Id: <1558949428-190715-7-git-send-email-tien.hock.loh@intel.com> In-Reply-To: <1558949428-190715-1-git-send-email-tien.hock.loh@intel.com> References: <1558949428-190715-1-git-send-email-tien.hock.loh@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,tien.hock.loh@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1558949519; bh=MsLmil7qFePJnGydeDFc7QNeqCfkwZH+lfc0gTt1wjU=; h=Cc:Date:From:Reply-To:Subject:To; b=wAuYMiXfDJA9p963xThh2XtrIZp+DxahcNEWIgcAm3ytzUmxstkqRVXu/cvxvDEklaz d7vYAs9sz8/3z+kJAHGvogWIikn5znbSfgM3xnk++IhhxnZVgJqAqs0tQq6t1mOK0cIYw DaNF2DIVUTg5tgO88+vPgCvSaI03ujAms3U= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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/Driver= s/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 |=3D DWEMMC_INT_DCRC | DWEMMC_INT_DRT | DWEMMC_INT_SBE; do { - MicroSecondDelay(500); Data =3D 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; } =20 @@ -550,8 +547,9 @@ DwEmmcReadBlockData ( ) { EFI_STATUS Status; - UINT32 DescPages, CountPerPage, Count; + UINT32 DescPages, CountPerPage, Count, ErrMask; EFI_TPL Tpl; + UINTN Rintsts =3D 0; =20 Tpl =3D gBS->RaiseTPL (TPL_NOTIFY); =20 @@ -574,6 +572,18 @@ DwEmmcReadBlockData ( DEBUG ((DEBUG_ERROR, "Failed to read data, mDwEmmcCommand:%x, mDwEmmcA= rgument:%x, Status:%r\n", mDwEmmcCommand, mDwEmmcArgument, Status)); goto out; } + + while(!((MmioRead32(DWEMMC_RINTSTS) & (DWEMMC_INT_DTO)))) { + Rintsts =3D MmioRead32 (DWEMMC_RINTSTS); + } + ErrMask =3D 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 =3D 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 =3D 0; =20 Tpl =3D gBS->RaiseTPL (TPL_NOTIFY); =20 @@ -613,6 +624,18 @@ DwEmmcWriteBlockData ( DEBUG ((DEBUG_ERROR, "Failed to write data, mDwEmmcCommand:%x, mDwEmmc= Argument:%x, Status:%r\n", mDwEmmcCommand, mDwEmmcArgument, Status)); goto out; } + + while(!((MmioRead32(DWEMMC_RINTSTS) & (DWEMMC_INT_DTO)))) { + Rintsts =3D MmioRead32 (DWEMMC_RINTSTS); + } + ErrMask =3D 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 =3D EFI_DEVICE_ERROR; + goto out; + } out: // Restore Tpl gBS->RestoreTPL (Tpl); --=20 2.19.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#41414): https://edk2.groups.io/g/devel/message/41414 Mute This Topic: https://groups.io/mt/31807965/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-