From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.107.0.70; helo=eur02-am5-obe.outbound.protection.outlook.com; envelope-from=meenakshi.aggarwal@nxp.com; receiver=edk2-devel@lists.01.org Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00070.outbound.protection.outlook.com [40.107.0.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E9345211BD61E for ; Tue, 29 Jan 2019 20:26:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m8+bFvH7c5JJg75j2ZbMdMLtg5KUqWM6y0Hkr9f1axE=; b=SZBVlOyM4+AVhmIRnnT8yUI4Wx/S2Jb4V+U3MQCYK8CztvaP+QD+I7wg4rNdPj/0mcmF/Zc3/rJH1I5F/OGRCrJNfTX98rN9SgAJ+5xv4KsrClH90FY868Z9EUBV0dlUlq61a1I/n9S0mBKyzxRZr/2GtFQZrwP+avNyMpSBMeM= Received: from VI1PR04MB4685.eurprd04.prod.outlook.com (20.177.56.77) by VI1PR04MB5872.eurprd04.prod.outlook.com (20.178.205.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1580.17; Wed, 30 Jan 2019 04:26:37 +0000 Received: from VI1PR04MB4685.eurprd04.prod.outlook.com ([fe80::f14a:c19b:b324:7d63]) by VI1PR04MB4685.eurprd04.prod.outlook.com ([fe80::f14a:c19b:b324:7d63%4]) with mapi id 15.20.1580.017; Wed, 30 Jan 2019 04:26:37 +0000 From: Meenakshi Aggarwal To: "ard.biesheuvel@linaro.org" , "leif.lindholm@linaro.org" , "edk2-devel@lists.01.org" , "jun.nie@linaro.org" , "haojian.zhuang@linaro.org" Thread-Topic: [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation. Thread-Index: AQHUs72LHw56wKfsjUevWhp7SeSNk6XFsqIQgAGN0lA= Date: Wed, 30 Jan 2019 04:26:36 +0000 Message-ID: References: <1547644896-7721-1-git-send-email-meenakshi.aggarwal@nxp.com> <1548338718-16247-1-git-send-email-meenakshi.aggarwal@nxp.com> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=meenakshi.aggarwal@nxp.com; x-originating-ip: [92.120.0.3] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR04MB5872; 6:sExGuJ5wZC380QVvNQXJFJjeNjpwG7SjVFwXlGqsnB7MRSGXxArQDUhzJLCeWznyzwaJHTrtLyg7e2zgQBEwnl2LQ/nK2yqGCr5xsCZ1Krfqe1NBHShIfRP2CrB0PFPIL2b/kMX0sNc4rdMGTwBEC7TTD2y4Qr/eWD1p8hycTyXAl6EaNG867HOmhDwPyblVM52jbIiDwwUcX2w/umlEzITOW4M3C45FfpXnbHqQ9IV0A/k35jTe2tQGlb/Kdt6cscMv/620zPNtjFabUWP3NS0A+Afx8CywTl+k6pwuG9F8kNBrjKGCjc11Znb0Rjqz93VPzhMepOXqRpzaDxYSkeMBiMB9Aqxb3gpho6Q0g33Vs5qOB0GDWLGgK2rFWJko/w71P+myX4lP9Fd0T8A3NhInoI+uU8QXc9DWGA77yp5SEooYKUCB5I33X2VS1lvzOVi50gFThxpDu7QtG7uSeg==; 5:47UAMX6SACekpRNlKpH2Kx4AL7hvdruVtTKqYm7QQtbuBuQDnRHhMFvOoNVFjkE1zA8Orlt6p0+MQzDUN3XpzptJOdU0Oz/4J5uzbp2z3dEw1udwNSRZntlwrsojqFtIq/gw+3D6KocNv7H/F6ZeFhD8Isx8+gDCR5ijr9v91y70xyBuQxEnE7Qmy/6sTK7Nd6Vb+ivMmMDx6cd+RkyjKg==; 7:LPU1D45sNc6GHa/WYNMrV5DtoPCkmiDdcSBwv3V1ghyZ+qlt5BtEyerA+UzdZGNaTMyJM1C2aVFJTukwEEk4ZSM8VJRuTptBTt9McmjziBPKdOWZfrfLLxBjjr5sfNLPbInUhpaKOwIhjfqyb5uotA== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 4b8f064b-ade4-4c38-e858-08d6866b1fac x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB5872; x-ms-traffictypediagnostic: VI1PR04MB5872: x-microsoft-antispam-prvs: x-forefront-prvs: 0933E9FD8D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(366004)(376002)(136003)(396003)(39860400002)(189003)(199004)(13464003)(55016002)(9686003)(6506007)(106356001)(71200400001)(71190400001)(8676002)(81156014)(86362001)(81166006)(105586002)(316002)(110136005)(229853002)(53936002)(33656002)(14454004)(53546011)(68736007)(97736004)(26005)(6116002)(478600001)(3846002)(102836004)(186003)(305945005)(25786009)(476003)(6436002)(2201001)(2501003)(74316002)(76176011)(8936002)(66066001)(2906002)(14444005)(256004)(446003)(11346002)(44832011)(7736002)(486006)(99286004)(6246003)(7696005); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB5872; H:VI1PR04MB4685.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: ZA5QGd2WIxTCcVZwbK2u3mqpaeYbtTmymUei+Os2ZL5mSXheg44mqIbOXCBOwu51UUlktI1bt4iENAviMKuijGL8J1cbJOw+WO5eN17jNy3pnnYOjCj+ut5PMfMjX3pyn422jBvj0c1Zb9lGiCmYi/2yHOtBeZ+/c1Pd9ulKh3GTuYt4UzguU/lA6GZidQdh39OiqJ24Luh4uH11TPMtEtBb4HLDVwfozlHIdKGXUfyaiFbXqdYiyI1BfZu4+zZiCHRE8YjmAGOUdqGs34brAoCQG4V0t6V3YFbXmABIYsdPNzPUVhrbUSP3p7hUjeXJ5RndxQJcVm1oHCbPsZT1j9U8o7iDEF/thfsp566OKF/vkkkGkLRYmF6RQFXNl2L0xsH0qrr0fc1jlw8Nr1VDyJZQ35zMJUw5zq8CEUsfwNQ= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b8f064b-ade4-4c38-e858-08d6866b1fac X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jan 2019 04:26:36.9210 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5872 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 04:26:41 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Any comments? > -----Original Message----- > From: Meenakshi Aggarwal > Sent: Tuesday, January 29, 2019 10:13 AM > To: Meenakshi Aggarwal ; > ard.biesheuvel@linaro.org; leif.lindholm@linaro.org; edk2-devel@lists.01.= org; > jun.nie@linaro.org; haojian.zhuang@linaro.org > Subject: RE: [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W > operation. >=20 > Hi, >=20 > Please share review comments. >=20 > Thanks, > Meenakshi >=20 > > -----Original Message----- > > From: Meenakshi Aggarwal > > Sent: Thursday, January 24, 2019 7:35 PM > > To: ard.biesheuvel@linaro.org; leif.lindholm@linaro.org; edk2- > > devel@lists.01.org; jun.nie@linaro.org; haojian.zhuang@linaro.org > > Cc: Meenakshi Aggarwal > > Subject: [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W > > operation. > > > > Issue : SD read failure for high capacity cards e.g. 64 GB i 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 =3D MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This); > > MmcHost =3D 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) =3D=3D > > - MMC_OCR_ACCESS_SECTOR) { > > - CmdArg =3D Lba; > > + if (MmcHostInstance->CardInfo.CardType !=3D 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 =3D Lba; > > + } else { > > + CmdArg =3D Lba * This->Media->BlockSize; > > + } > > } else { > > - CmdArg =3D 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) =3D=3D > > + MMC_OCR_ACCESS_SECTOR) { > > + CmdArg =3D Lba; > > + } else { > > + CmdArg =3D Lba * This->Media->BlockSize; > > + } > > } > > > > Status =3D MmcHost->SendCommand (MmcHost, Cmd, CmdArg); > > -- > > 1.9.1