From nobody Sun Apr 28 13:13:54 2024 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+40305+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+40305+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1557388945; cv=none; d=zoho.com; s=zohoarc; b=hN+FLB+ZoxxhXJOWBYMKq6SwV8E3v2AKP4NKyXeWVfhfi7Fg7Y42thc2CLMqB22BAm6H4zmtYOrAHpluVqk0uhPv20NfIn785tBiiggO1Qg5DYdV80MBWwonVst78W/vRAS5UWrJUhwoElBry+uOQPg8rdslri1I3G7hcsCnya4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557388945; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=It1khST6ohgCXGY9YI6ISVEEQFaio6BYYEnn47fo9K8=; b=l9vRBG0vHkMG3zs7lUnJZWD6Vx18qd1POHNoSKBfZHBuUGtkg0IhZQEwvThnnYp8kDixhwE8KP2h4MZh0V10Qqijd34/5hpvZU4unqQMpYscNOcHhTxEK7g6nF84OV8buZlSAE77s4nRgwHxZT10aYBwpgFtKtTsc24hnnt9Uls= 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+40305+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 1557388945080440.8467483990918; Thu, 9 May 2019 01:02:25 -0700 (PDT) Return-Path: X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by groups.io with SMTP; Thu, 09 May 2019 01:02:23 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2019 01:02:23 -0700 X-ExtLoop1: 1 X-Received: from pg-nx11.altera.com ([10.104.4.26]) by orsmga003.jf.intel.com with ESMTP; 09 May 2019 01:02:21 -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] EmbeddedPkg: Fix DwEmmc SendCommand polling Date: Thu, 9 May 2019 16:02:05 +0800 Message-Id: <1557388925-184479-2-git-send-email-tien.hock.loh@intel.com> In-Reply-To: <1557388925-184479-1-git-send-email-tien.hock.loh@intel.com> References: <1557388925-184479-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=1557388944; bh=5ciP3dmNEq6X7OwE7UCVxCUW8zLgzjtStk3lnAqXWFQ=; h=Cc:Date:From:Reply-To:Subject:To; b=GH9lyFavt0SHFhfyL4e3RQPpGKr2KN/y1+5PNqZml0oHR00Zqi7SXttRdpje04U6TRO 7ZXuQgwsEHG9E6mVoA5ob04T3cV54cqEse2ASd+EPkH+m5B8USz8OXZMKNTWxyXXR0ICt VDNvY9+3+fFjVYRA70p15FpM+vZKOt50Orc= 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 (#40305): https://edk2.groups.io/g/devel/message/40305 Mute This Topic: https://groups.io/mt/31552978/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-