From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::343; helo=mail-wm1-x343.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DD148211BFCC8 for ; Wed, 30 Jan 2019 09:49:56 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id n190so453883wmd.0 for ; Wed, 30 Jan 2019 09:49:56 -0800 (PST) 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=2YzFPTV6G07KHr1ovXYSehG4+21L7z9x2oLo5LxNBO4=; b=FvPFAEoAqFILHYOP66YllYP4ItzytKHG7XIPkFx2j7VJ3yz84PFLsDRH113whgAHcT x4hcZaOi5DXjiVs0iXtNSy1J312BsNWBTJzlmP4SXKwhtQAI4PexvWMQAYX3GjgLvmDO 96rSCD0hM7texbguyT4LuK+yh/QcpIOtbgsSg= 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=2YzFPTV6G07KHr1ovXYSehG4+21L7z9x2oLo5LxNBO4=; b=C81Bp3SOlhSes/nLz/6DaAjzFk7NdMZFXZ8/YRcQVdw1BZBpsIIx4LJGJE0X6UIFlX K02XGqQc/+qWn0zUqbIMKTCCh4LXzaJI4bwTGrhXnIiMG0hCT/INNgReRskx1Oo5Uv+E s+PUvt/AcYTlfmL4S8JFOZ+a6kIqgNGBBbtKeOtHJVd/YusEM8yemvtuC28SzljF6hcc T+aYiRDQd5/kKzU1H6dzA6C+cARxz3VIW68br252mCN0+QPMnaLBogqHRCxskc3itVqj zs5HCfesRSUo7OlqqyPxoRQAazbvStkwiub/IDDbcglq1KG2CuVte31pSkG9MoyRIvIR NFtg== X-Gm-Message-State: AJcUukfE9wLD8LK3ZtQcayww3zDcYYvXShH8QlCpMSgutSJPxSNsoNuy SdITlqQb6n8F+gZJITV1fGgKpw== X-Google-Smtp-Source: ALg8bN4Zd6krWa2uILcFlIN0PR9LUVUe10bLfOgRWot8MBmbQ4eL78Yt7WntEItw3u2jRJn2rtOb2w== X-Received: by 2002:a1c:a185:: with SMTP id k127mr26033874wme.134.1548870595197; Wed, 30 Jan 2019 09:49:55 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id g16sm2016600wru.41.2019.01.30.09.49.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Jan 2019 09:49:53 -0800 (PST) Date: Wed, 30 Jan 2019 17:49:52 +0000 From: Leif Lindholm To: Meenakshi Aggarwal Cc: ard.biesheuvel@linaro.org, edk2-devel@lists.01.org, jun.nie@linaro.org, haojian.zhuang@linaro.org Message-ID: <20190130174952.aeynrpzdj7glrnym@bivouac.eciton.net> References: <1547644896-7721-1-git-send-email-meenakshi.aggarwal@nxp.com> <1548338718-16247-1-git-send-email-meenakshi.aggarwal@nxp.com> MIME-Version: 1.0 In-Reply-To: <1548338718-16247-1-git-send-email-meenakshi.aggarwal@nxp.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jan 2019 17:49:57 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I updated the subject line to start with EmbeddedPkg: instead. On Thu, Jan 24, 2019 at 07:35:18PM +0530, Meenakshi Aggarwal wrote: > Issue : SD read failure for high capacity cards e.g. 64 GB > i And I dropped the above stray i. Reviewed-by: Leif Lindholm Pushed as b566259c8a. Thanks! > Reason : Command argument value exceeds 32 bit for block number 0x3787FFF > and cant be fit into 32 bit wide SD host controller register. > > Fix : > AccessMode bits [29:30] of OCR is a valid definition to calculate > data address for eMMC cards. > > For SD cards, data address is calculated on the basis of > card capacity status bit[30] of OCR. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Meenakshi Aggarwal > --- > EmbeddedPkg/Universal/MmcDxe/Mmc.h | 2 ++ > EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 21 ++++++++++++++++----- > 2 files changed, 18 insertions(+), 5 deletions(-) > > diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h b/EmbeddedPkg/Universal/MmcDxe/Mmc.h > index a77ba41..62de2c8 100644 > --- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h > +++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.h > @@ -70,6 +70,8 @@ > #define SD_HIGH_SPEED 50000000 > #define SWITCH_CMD_SUCCESS_MASK 0x0f000000 > > +#define SD_CARD_CAPACITY 0x00000002 > + > #define BUSWIDTH_4 4 > > typedef enum { > diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c > index a2b9232..1dea7d3 100644 > --- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c > +++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c > @@ -148,12 +148,23 @@ MmcTransferBlock ( > MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This); > MmcHost = MmcHostInstance->MmcHost; > > - //Set command argument based on the card access mode (Byte mode or Block mode) > - if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) == > - MMC_OCR_ACCESS_SECTOR) { > - CmdArg = Lba; > + if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) { > + //Set command argument based on the card capacity > + //if 0 : SDSC card > + //if 1 : SDXC/SDHC > + if (MmcHostInstance->CardInfo.OCRData.AccessMode & SD_CARD_CAPACITY) { > + CmdArg = Lba; > + } else { > + CmdArg = Lba * This->Media->BlockSize; > + } > } else { > - CmdArg = Lba * This->Media->BlockSize; > + //Set command argument based on the card access mode (Byte mode or Block mode) > + if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) == > + MMC_OCR_ACCESS_SECTOR) { > + CmdArg = Lba; > + } else { > + CmdArg = Lba * This->Media->BlockSize; > + } > } > > Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg); > -- > 1.9.1 >