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=j7xBuC1I; spf=pass (domain: linaro.org, ip: 209.85.208.195, mailfrom: haojian.zhuang@linaro.org) Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by groups.io with SMTP; Thu, 30 May 2019 00:06:04 -0700 Received: by mail-lj1-f195.google.com with SMTP id h19so5007743ljj.4 for ; Thu, 30 May 2019 00:06:03 -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=ruxJWqmP7Az4TG3oO3Fq8T5X9tJIcUDajGkKdk6vwPE=; b=j7xBuC1IkgzYyQje5u91w3HbOhOqooHNZ/WD2F22EWiMIp1SbmNZhszSdMmiTKgsZx TE3k5GC8kDZ7o6PIXAf3YNFmkLVSqqNqLAeNybs9ZE3DgRgpcROJfIp3YffgdqFt2yf1 jcJE2D12QR4C0wCFLKHrJdTNnpbN57VzNCV5qGIfGVAuPj3oyp9DYBO/iv4NEL+zAffX n1Z1ryEYkYGUOVek//I6nRq133Atu01WV/6+HZCmWtwp/29Jo5txB2Oo8Exj+G1AyGkY VEA3lzgVf+8Rp8w0Ll9ZtgDXLEV9ZPILETEr/xq0obHcCcHWgBHotVQyumEhUhGm9OMr fcVw== 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=ruxJWqmP7Az4TG3oO3Fq8T5X9tJIcUDajGkKdk6vwPE=; b=AnH4BC4ua871K7bYPB+wnFYQ/Wa1Jn5GFjJzEk9tF6dq6VrlC1Iz5uP5tMFR+FzPmn esMSN9GUbFIgCpeS1cWnB9w7oqKw0g/C5TjHfd1sCvYZyEzr99xf7ypoccqGc9g0QJFA u66JdH5JFd5Yab4r4f2jEsmf/mxZJhB51i65Cbv9ewsjtLXJ8SKcpFD4RevN9GnZEmS4 OSYQt5zld478QU3e2eoWXfNwQM0e8qsandLOK5BttaX8mXKfkb/3OqcWYXxnb0F7LyLI JQvvUAFZyyhZ7Pnr+uhmHX3UL/0M1qwD9cYQUKMdU1xaszqrbE9h1SUC2OuBZCuhhWkn oCnQ== X-Gm-Message-State: APjAAAUHZ4s39sY376s6DO+Wo/PUf11nuub2jIaplTUemHmSh6epyVYY zxIjSrBf/AMoDn0GC4c3LwiY4A== X-Google-Smtp-Source: APXvYqy24CTA6VZUn7TVmxNw+ow39pHnf0XOE/Ow5yCY70YBvV3GCSykbiHyvQtiiigLCrukU8Rykg== X-Received: by 2002:a2e:9106:: with SMTP id m6mr1175341ljg.164.1559199962363; Thu, 30 May 2019 00:06:02 -0700 (PDT) Return-Path: Received: from gmail.com ([58.32.38.16]) by smtp.gmail.com with ESMTPSA id n26sm347079lfi.90.2019.05.30.00.05.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 May 2019 00:06:01 -0700 (PDT) Date: Thu, 30 May 2019 15:05:55 +0800 From: Haojian Zhuang To: Leif Lindholm Cc: tien.hock.loh@intel.com, devel@edk2.groups.io, thloh85@gmail.com, Ard Biesheuvel Subject: Re: [PATCH v2 6/7] EmbeddedPkg: Fix DwEmmc SendCommand polling Message-ID: <20190530070553.GB18524@gmail.com> References: <1558949428-190715-1-git-send-email-tien.hock.loh@intel.com> <1558949428-190715-7-git-send-email-tien.hock.loh@intel.com> <20190528180409.xqqigzdyk4e2oamt@bivouac.eciton.net> MIME-Version: 1.0 In-Reply-To: <20190528180409.xqqigzdyk4e2oamt@bivouac.eciton.net> User-Agent: Mutt/1.9.4 (2018-02-28) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, May 28, 2019 at 07:04:09PM +0100, Leif Lindholm wrote: > +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? I'm not in the loop, so I missed the patch series. The patch series can't work on my platform for the eMMC. Although a variable is created to identify whether it's a SD or eMMC device, it doesn't identify the eMMC device by the right way. So the eMMC device isn't initialized successfully on my platform. 1. Since MMC framework could identify whether it's eMMC device or SD device, we need to make device driver gets this kind of information from the MMC framework. And we need to support multiple eMMC/SD instances in MMC framework. 2. I sent a patch series to support both eMMC device and SD device before. https://edk2.groups.io/g/devel/message/28572 && https://edk2.groups.io/g/devel/message/28615 Maybe it's missed. Could you help to review that patch series? Best Regards Haojian > > 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 > >