From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=216.228.121.143; helo=hqemgate14.nvidia.com; envelope-from=ashishsingha@nvidia.com; receiver=edk2-devel@lists.01.org Received: from hqemgate14.nvidia.com (hqemgate14.nvidia.com [216.228.121.143]) (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 39BFE2194D3AE for ; Wed, 6 Mar 2019 15:06:53 -0800 (PST) Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 06 Mar 2019 15:06:52 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 06 Mar 2019 15:06:52 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 06 Mar 2019 15:06:52 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 6 Mar 2019 23:06:51 +0000 Received: from NAM05-DM3-obe.outbound.protection.outlook.com (104.47.49.59) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 6 Mar 2019 23:06:51 +0000 Received: from MN2PR12MB3326.namprd12.prod.outlook.com (20.178.242.204) by MN2PR12MB2959.namprd12.prod.outlook.com (20.179.81.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.17; Wed, 6 Mar 2019 23:06:35 +0000 Received: from MN2PR12MB3326.namprd12.prod.outlook.com ([fe80::888d:c0eb:29f1:3f3e]) by MN2PR12MB3326.namprd12.prod.outlook.com ([fe80::888d:c0eb:29f1:3f3e%4]) with mapi id 15.20.1665.020; Wed, 6 Mar 2019 23:06:35 +0000 From: Ashish Singhal To: "Cohen, Eugene" , "Wu, Hao A" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] MdeModulePkg/SdMmcPciHcDxe: Add V3 64b DMA Support Thread-Index: AQHU0FzaPLjzM8T82kS4lsytC/4gmKX98QaAgAFQUQCAAAA7gA== Date: Wed, 6 Mar 2019 23:06:35 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Enabled=True; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_SiteId=43083d15-7273-40c1-b7db-39efd9ccc17a; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Owner=ashishsingha@nvidia.com; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_SetDate=2019-03-06T23:06:33.6001866Z; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Name=Unrestricted; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Application=Microsoft Azure Information Protection; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Extended_MSFT_Method=Automatic; Sensitivity=Unrestricted authentication-results: spf=none (sender IP is ) smtp.mailfrom=ashishsingha@nvidia.com; x-originating-ip: [216.228.112.22] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9040d041-bcf2-4544-6ae1-08d6a28861a5 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:MN2PR12MB2959; x-ms-traffictypediagnostic: MN2PR12MB2959: x-ms-exchange-purlcount: 1 x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; MN2PR12MB2959; 23:Rj7XBDtQPR4YXAS4S5RwYFGGgivzWo+pBB47cjBqK?= =?us-ascii?Q?Om+L9n7PxYTTpnVAHQ1g6++9Xvy8NlRjsq15v3W09Cpr5xh6PiglxDYI1EXg?= =?us-ascii?Q?M+YKIrpvGgb6n+KOxxvKFJqnNFJSQDHDuXd4dj/Zif7rC+LC732s5LpgpCOq?= =?us-ascii?Q?JPftE5JaEqqq5rdyx/UxtaGV8wF/Iba4bC32VRKNTxAoQUOPYTyOGVRL6tkz?= =?us-ascii?Q?cyqLif6DvLUBA4uHQp3qIJ7izMBBUyXQ+60GEtY/wBQWch2Ct0Adn19pP0vs?= =?us-ascii?Q?GTcLI7qpbKzkuKaeiyS6XS9rhwTR6fhB3As1Qm78HlrdwjR/2CoUf3AK2qaM?= =?us-ascii?Q?Lx8pmksr/fMguQEm+b911HVWC9tzvdgGtvwBmEG4SRWn/pPOSpcuzPZV/6Zn?= =?us-ascii?Q?ffrdu2E4lqLklxFGbOsvcVB9OclIrHOLwFlAIvjCr8EKIeO/K/kZbQUUYGE/?= =?us-ascii?Q?3wUrNz3Btjeg2C7LGpI7zfsmwkFxRt3t2iUa8pDuAIC9ebT6+5WWULl816yH?= =?us-ascii?Q?q4L5zJZJOxxRJy8GzC7Agd95qsQhySt2XDWQ7XMXLznEqN5A0Qx4QusOkUDP?= =?us-ascii?Q?+zK2B1B+MxOcY+qdiW1Dm0ToJgygau3eK/36i4i7+Kmm4EKdjQhIlQzRIVGx?= =?us-ascii?Q?41vSAQdZouYDSQ6INzTVW/qd2AwWtl2bpjI5EgBNuKFUvFoOxePyRPPya8d4?= =?us-ascii?Q?q/176KDgbe36A1IOYyiVhdUgqBiIms8U1MQ0Da7hXy5wA6QQc8XJEQwjEcnu?= =?us-ascii?Q?wccwdXbSAa83BmwOwWIVg3YKQoxaEiu2FDTbeC0nQzluzsfbENHH+ioRVCVG?= =?us-ascii?Q?5dep/3LvZb0MbPu63jKKeFDZi79TZOXK4Oe9PeEGR0hLxruVt+WHBkG19McM?= =?us-ascii?Q?zb6UV17KPdc/gtT7epbznJRCvXkPdMlW3m0jkDcIllMf+dVYw4VJkKOgsM5S?= =?us-ascii?Q?Kaugev1I2DFHp33TfvofqNH1xdJrsYPqbT3FtdlfxZjXxB13Y0mT+DoQLyIu?= =?us-ascii?Q?dJWcqdPOlsErN9iI+26hVWl8AXO5Vq1Jbpd+EZ8TFdTVoWwvr1XdLXK//A1g?= =?us-ascii?Q?Aq32F4THQT+up5l7B9bHN9vmw8DYu8u+UmFawaMEtWaoG9K6APKCF9xM47WR?= =?us-ascii?Q?RxkzRYWjORgAHOJW9NsEy8Xgeve1fbzJFlxpXA2Wngx6F1p/JOSWlIbtMXPj?= =?us-ascii?Q?Arutgi3spRHZLE2v8nOJGEgnW5an26Ww03cFZ/sFov/brvp3z7UqK4YwM2yu?= =?us-ascii?Q?SMEwyHoLqvz+gBT3cvK5ideEebk8yH8ZrMFhAqKRo61b9YG8OHwCin5hIX9B?= =?us-ascii?Q?6+SkqkROmwIjk6PVfgUvaUgt19HEUatzf8PIzzJDUkHZFdYLlHJQVQKjAukp?= =?us-ascii?Q?IiB3UOn7INPS+5HskAnA/BysvdJtYuzUVI862Jufe8lNm1x15qvuhLPe4isS?= =?us-ascii?Q?N/kVsMt+ukuq7Yg9ypXzf+7ZuXjV9c=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0968D37274 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6029001)(376002)(346002)(366004)(39860400002)(136003)(396003)(13464003)(199004)(189003)(14444005)(53946003)(229853002)(9686003)(71200400001)(71190400001)(6306002)(54896002)(236005)(8676002)(110136005)(55016002)(19627235002)(256004)(6436002)(81166006)(81156014)(486006)(7736002)(11346002)(2906002)(66066001)(97736004)(8936002)(9326002)(476003)(316002)(446003)(6246003)(53936002)(478600001)(74316002)(33656002)(186003)(7696005)(966005)(102836004)(105586002)(76176011)(106356001)(790700001)(99286004)(26005)(86362001)(14454004)(2501003)(68736007)(6506007)(53546011)(6116002)(606006)(30864003)(3846002)(5660300002)(52536013)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR12MB2959; H:MN2PR12MB3326.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nvidia.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 2/9kbcUxZ/lyXQe/RWwuuPqdlm5igSAOGYtlV70yL+Soz8aqYIAKXCiQGikQUAcIVfnUXkfPR8tYJKL26UdQWfTTz+qdhWf+7jwt9gIBgpqu3L0VafYWKpSOyyRutsOXd15rySXoVekv2uEyEEpRAuVjMjJ1cYwaopwsZJkCrb6UugbzqncML7j3jk1C9ogXcY9ohUz+eCBLL+V26jHLJ0OKBO0+JvKTeqo4hBk2uRTIDNuif53rY/EAVF3dXpoaEKYWYjaAGKtQciR+pe9hsoIgS0hw2PZ51DMAoRgQdwQmm5ybBB2gv7XyRdyItuJ/7L7vI/nKU/gPrsjELX8yeZusfLc8CqrRHN4XXvKutlyH+U9xaJrDQuvsyQCcNLxNAHx1Txa/kbSP5xrMD8ifvdNWlyHNIu+T1ZhsnWiV6ns= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 9040d041-bcf2-4544-6ae1-08d6a28861a5 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Mar 2019 23:06:35.5485 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB2959 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1551913613; bh=CD40qgk1l7sp1QDvrWIDHkhHSvq3BikVnCcWSgUc+YI=; h=X-PGP-Universal:From:To:Subject:Thread-Topic:Thread-Index:Date: Message-ID:References:In-Reply-To:Accept-Language:X-MS-Has-Attach: X-MS-TNEF-Correlator:msip_labels:authentication-results: x-originating-ip:x-ms-publictraffictype: x-ms-office365-filtering-correlation-id:x-microsoft-antispam: x-ms-traffictypediagnostic:x-ms-exchange-purlcount: x-microsoft-exchange-diagnostics:x-microsoft-antispam-prvs: x-forefront-prvs:x-forefront-antispam-report:received-spf: x-ms-exchange-senderadcheck:x-microsoft-antispam-message-info: MIME-Version:X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-originalarrivaltime: X-MS-Exchange-CrossTenant-fromentityheader: X-MS-Exchange-CrossTenant-id:X-MS-Exchange-CrossTenant-mailboxtype: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg: Content-Language:Content-Type; b=nWR0WOhQtCDQXvmrFnJ5jtEWuqY15r7sqQuwfdgZxwTLduLuvW7DGCOE5o2V8rp1q N0w+KWIQLd+BDd/D+FgrES9QUZjnMbTTVevJ7E0mU5e4f095Wftju2FqA1LnGEf7AX TNI5bcS9+IXQciQ52Ix4BPN/e3PrB96gRVFzpHCNj4pyHDVvuQKzJ5kWyXQZU1bL5T 9Pc0Zrjuhe6nYK5nqJI2GS5NfrMk3pd6bBaNGRiTyy+I8OLucDHQ0Cj47Xmi/hdp+P Km3yrbmN1ow28zGxjTn/2oMjUNGguJi388SsvXVHBHXd5J1VhaMP6bCPwoKcm5/5hs SjXW8oXIV8rIQ== X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [PATCH] MdeModulePkg/SdMmcPciHcDxe: Add V3 64b DMA Support 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, 06 Mar 2019 23:06:53 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Eugene, Thanks for confirming. Can you please validate the v2 patch I sent as wel= l for completeness? Thanks Ashish From: Cohen, Eugene Sent: Wednesday, March 6, 2019 4:05 PM To: Wu, Hao A ; Ashish Singhal ; edk2-devel@lists.01.org Subject: RE: [PATCH] MdeModulePkg/SdMmcPciHcDxe: Add V3 64b DMA Support =20 * I verified the patch on SDHC version 3.00 with 64-bit System Addr= ess =20 * Support. Hope more configurations are available for testing on Eu= gene's =20 * side. This patch works for us. Tested that the V3 64-bit DMA works and verifie= d that addresses above 4GB DMA correctly. Thanks for putting this together. Feel free to add my Tested-By. Eugene From: Wu, Hao A > Sent: Tuesday, March 5, 2019 8:01 PM To: Ashish Singhal >; edk2-devel@lists.01.org Cc: Cohen, Eugene > Subject: RE: [PATCH] MdeModulePkg/SdMmcPciHcDxe: Add V3 64b DMA Support Hi Ashish, One thing to confirm, for the updated checks within SdMmcPciHcDriverBindingStart(): > if ((Private->ControllerVersion[Slot] =3D=3D SD_MMC_HC_CTRL_VER_300 && > Private->Capability[Slot].SysBus64V3 =3D=3D 0) || > (Private->ControllerVersion[Slot] =3D=3D SD_MMC_HC_CTRL_VER_400 && > Private->Capability[Slot].SysBus64V3 =3D=3D 0) || > (Private->ControllerVersion[Slot] >=3D SD_MMC_HC_CTRL_VER_410 && > Private->Capability[Slot].SysBus64V4 =3D=3D 0)) { > Support64BitDma =3D FALSE; > } When the SDHC with version greater than 4.10, the check is only performed= against the 'SysBus64V4' bit. My understanding of the purpose is that: 1. For SDHC with version 4.00, the support of V3 mode and V4 mode of 64-bit System Address are reflect by bit 'SysBus64V3'. Thus, I can infer that the possible support case is both or neither. 2. The spec states that SDHC with version greater than 4.10 divides the V= 3 mode and V4 mode support into 2 bits (SysBus64V3, SysBus64V4) so that the= V3 mode support can be optional. So based on 1 & 2, we do not even bother to check the 'SysBus64V3' bit when HC version >=3D 4.10. Is that right? I verified the patch on SDHC version 3.00 with 64-bit System Address Support. Hope more configurations are available for testing on Eugene's side. Besides, some minor comments below: > -----Original Message----- > From: Ashish Singhal [mailto:ashishsingha@nvidia.com] > Sent: Saturday, March 02, 2019 2:30 AM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A; eugene@hp.com; Ashish Singhal > Subject: [PATCH] MdeModulePkg/SdMmcPciHcDxe: Add V3 64b DMA > Support Please help to add the below Bugzilla tracker for reference: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1583 I have updated the above tracker to match the purpose of the proposed patch. > > Driver was supporting only 32b DMA support for V3 controllers. Add > support for 64b DMA as well for completeness. > > For V4.0 64b support, driver was looking at incorrect capability > register bit. Fix for that is present as well. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ashish Singhal > > --- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 10 +- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h | 6 +- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 199 > ++++++++++++++------- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h | 29 ++- > 4 files changed, 170 insertions(+), 74 deletions(-) > > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > index b474f8d..9b7b88c 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > @@ -6,7 +6,7 @@ > > It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use. > > - Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. > + Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. > Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the B= SD > License > @@ -666,8 +666,12 @@ SdMmcPciHcDriverBindingStart ( > // If any of the slots does not support 64b system bus > // do not enable 64b DMA in the PCI layer. > // > - if (Private->Capability[Slot].SysBus64V3 =3D=3D 0 && > - Private->Capability[Slot].SysBus64V4 =3D=3D 0) { > + if ((Private->ControllerVersion[Slot] =3D=3D SD_MMC_HC_CTRL_VER_300 &= & > + Private->Capability[Slot].SysBus64V3 =3D=3D 0) || > + (Private->ControllerVersion[Slot] =3D=3D SD_MMC_HC_CTRL_VER_400 && > + Private->Capability[Slot].SysBus64V3 =3D=3D 0) || > + (Private->ControllerVersion[Slot] >=3D SD_MMC_HC_CTRL_VER_410 && > + Private->Capability[Slot].SysBus64V4 =3D=3D 0)) { > Support64BitDma =3D FALSE; > } > > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > index 1bb701a..68d8a5c 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > @@ -2,7 +2,7 @@ > > Provides some data structure definitions used by the SD/MMC host > controller driver. > > -Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. > +Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. > Copyright (c) 2015, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the B= SD > License > @@ -145,13 +145,15 @@ typedef struct { > EFI_PHYSICAL_ADDRESS DataPhy; > VOID *DataMap; > SD_MMC_HC_TRANSFER_MODE Mode; > + SD_MMC_HC_ADMA_LEGTH Length; Maybe: SD_MMC_HC_ADMA_LENGTH_MODE AdmaLengthMode; is better to avoid confusion. > > EFI_EVENT Event; > BOOLEAN Started; > UINT64 Timeout; > > SD_MMC_HC_ADMA_32_DESC_LINE *Adma32Desc; > - SD_MMC_HC_ADMA_64_DESC_LINE *Adma64Desc; > + SD_MMC_HC_ADMA_64_V3_DESC_LINE *Adma64V3Desc; > + SD_MMC_HC_ADMA_64_V4_DESC_LINE *Adma64V4Desc; > EFI_PHYSICAL_ADDRESS AdmaDescPhy; > VOID *AdmaMap; > UINT32 AdmaPages; > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > index d73fa10..a6d2395 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > @@ -6,7 +6,7 @@ > > It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use. > > - Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. > + Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. > Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the B= SD > License > @@ -1010,18 +1010,32 @@ SdMmcHcInitV4Enhancements ( > if (ControllerVer >=3D SD_MMC_HC_CTRL_VER_400) { > HostCtrl2 =3D SD_MMC_HC_V4_EN; > // > - // Check if V4 64bit support is available > + // Check if controller version V4.0 > // > - if (Capability.SysBus64V4 !=3D 0) { > - HostCtrl2 |=3D SD_MMC_HC_64_ADDR_EN; > - DEBUG ((DEBUG_INFO, "Enabled V4 64 bit system bus support\n")); > + if (ControllerVer =3D=3D SD_MMC_HC_CTRL_VER_400) { > + // > + // Check if 64bit support is available > + // > + if (Capability.SysBus64V3 !=3D 0) { > + HostCtrl2 |=3D SD_MMC_HC_64_ADDR_EN; > + DEBUG ((DEBUG_INFO, "Enabled V4 64 bit system bus support\n")); > + } > } > // > // Check if controller version V4.10 or higher > // > - if (ControllerVer >=3D SD_MMC_HC_CTRL_VER_410) { > - HostCtrl2 |=3D SD_MMC_HC_26_DATA_LEN_ADMA_EN; > - DEBUG ((DEBUG_INFO, "Enabled V4 26 bit data length ADMA > support\n")); > + else if (ControllerVer >=3D SD_MMC_HC_CTRL_VER_410) { > + // > + // Check if 64bit support is available > + // > + if (Capability.SysBus64V4 !=3D 0) { > + HostCtrl2 |=3D SD_MMC_HC_64_ADDR_EN; > + DEBUG ((DEBUG_INFO, "Enabled V4 64 bit system bus support\n")); > + } > + if (ControllerVer >=3D SD_MMC_HC_CTRL_VER_410) { I think the above 'if' statement can be removed. > + HostCtrl2 |=3D SD_MMC_HC_26_DATA_LEN_ADMA_EN; > + DEBUG ((DEBUG_INFO, "Enabled V4 26 bit data length ADMA > support\n")); > + } > } > Status =3D SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof > (HostCtrl2), &HostCtrl2); > if (EFI_ERROR (Status)) { > @@ -1393,14 +1407,10 @@ BuildAdmaDescTable ( > EFI_PCI_IO_PROTOCOL *PciIo; > EFI_STATUS Status; > UINTN Bytes; > - BOOLEAN AddressingMode64; > - BOOLEAN DataLength26; > UINT32 AdmaMaxDataPerLine; > UINT32 DescSize; > VOID *AdmaDesc; > > - AddressingMode64 =3D FALSE; > - DataLength26 =3D FALSE; > AdmaMaxDataPerLine =3D ADMA_MAX_DATA_PER_LINE_16B; > DescSize =3D sizeof (SD_MMC_HC_ADMA_32_DESC_LINE); > AdmaDesc =3D NULL; > @@ -1410,27 +1420,16 @@ BuildAdmaDescTable ( > PciIo =3D Trb->Private->PciIo; > > // > - // Detect whether 64bit addressing is supported. > - // > - if (ControllerVer >=3D SD_MMC_HC_CTRL_VER_400) { > - Status =3D SdMmcHcCheckMmioSet(PciIo, Trb->Slot, > SD_MMC_HC_HOST_CTRL2, sizeof(UINT16), > - SD_MMC_HC_V4_EN|SD_MMC_HC_64_ADDR_EN, > SD_MMC_HC_V4_EN|SD_MMC_HC_64_ADDR_EN); > - if (!EFI_ERROR (Status)) { > - AddressingMode64 =3D TRUE; > - DescSize =3D sizeof (SD_MMC_HC_ADMA_64_DESC_LINE); > - } > - } > - // > // Check for valid ranges in 32bit ADMA Descriptor Table > // > - if (!AddressingMode64 && > + if ((Trb->Mode =3D=3D SdMmcAdma32bMode) && > ((Data >=3D 0x100000000ul) || ((Data + DataLen) > 0x100000000ul))) { > return EFI_INVALID_PARAMETER; > } > // > // Check address field alignment > // > - if (AddressingMode64) { > + if (Trb->Mode !=3D SdMmcAdma32bMode) { > // > // Address field shall be set on 64-bit boundary (Lower 3-bit is always= =20set > to 0) > // > @@ -1445,13 +1444,19 @@ BuildAdmaDescTable ( > DEBUG ((DEBUG_INFO, "The buffer [0x%x] to construct ADMA desc is not > aligned to 4 bytes boundary!\n", Data)); > } > } > + > // > - // Detect whether 26bit data length is supported. > + // Configure 64b ADMA. > // > - Status =3D SdMmcHcCheckMmioSet(PciIo, Trb->Slot, > SD_MMC_HC_HOST_CTRL2, sizeof(UINT16), > - SD_MMC_HC_26_DATA_LEN_ADMA_EN, > SD_MMC_HC_26_DATA_LEN_ADMA_EN); > - if (!EFI_ERROR (Status)) { > - DataLength26 =3D TRUE; > + if (Trb->Mode =3D=3D SdMmcAdma64bV3Mode) { > + DescSize =3D sizeof (SD_MMC_HC_ADMA_64_V3_DESC_LINE); > + }else if (Trb->Mode =3D=3D SdMmcAdma64bV4Mode) { > + DescSize =3D sizeof (SD_MMC_HC_ADMA_64_V4_DESC_LINE); > + } > + // > + // Configure 26b data length. > + // > + if (Trb->Length =3D=3D SdMmcAdmaLen26b) { > AdmaMaxDataPerLine =3D ADMA_MAX_DATA_PER_LINE_26B; > } > > @@ -1492,7 +1497,7 @@ BuildAdmaDescTable ( > return EFI_OUT_OF_RESOURCES; > } > > - if ((!AddressingMode64) && > + if ((Trb->Mode =3D=3D SdMmcAdma32bMode) && > (UINT64)(UINTN)Trb->AdmaDescPhy > 0x100000000ul) { > // > // The ADMA doesn't support 64bit addressing. > @@ -1511,19 +1516,26 @@ BuildAdmaDescTable ( > > Remaining =3D DataLen; > Address =3D Data; > - if (!AddressingMode64) { > + if (Trb->Mode =3D=3D SdMmcAdma32bMode) { > Trb->Adma32Desc =3D AdmaDesc; > - Trb->Adma64Desc =3D NULL; > + Trb->Adma64V3Desc =3D NULL; > + Trb->Adma64V4Desc =3D NULL; > + } else if (Trb->Mode =3D=3D SdMmcAdma64bV3Mode) { > + Trb->Adma64V3Desc =3D AdmaDesc; > + Trb->Adma32Desc =3D NULL; > + Trb->Adma64V4Desc =3D NULL; > } else { > - Trb->Adma64Desc =3D AdmaDesc; > + Trb->Adma64V4Desc =3D AdmaDesc; > Trb->Adma32Desc =3D NULL; > + Trb->Adma64V3Desc =3D NULL; > } Suggest to remove those NULL assignments to: Trb->Adma32Desc Trb->Adma64Desc Trb->Adma64V3Desc Since in SdMmcCreateTrb(), 'Trb' is allocated by: Trb =3D AllocateZeroPool (sizeof (SD_MMC_HC_TRB)); > + > for (Index =3D 0; Index < Entries; Index++) { > - if (!AddressingMode64) { > + if (Trb->Mode =3D=3D SdMmcAdma32bMode) { > if (Remaining <=3D AdmaMaxDataPerLine) { > Trb->Adma32Desc[Index].Valid =3D 1; > Trb->Adma32Desc[Index].Act =3D 2; > - if (DataLength26) { > + if (Trb->Length =3D=3D SdMmcAdmaLen26b) { > Trb->Adma32Desc[Index].UpperLength =3D (UINT16)RShiftU64 > (Remaining, 16); > } > Trb->Adma32Desc[Index].LowerLength =3D (UINT16)(Remaining & > MAX_UINT16); > @@ -1532,32 +1544,53 @@ BuildAdmaDescTable ( > } else { > Trb->Adma32Desc[Index].Valid =3D 1; > Trb->Adma32Desc[Index].Act =3D 2; > - if (DataLength26) { > + if (Trb->Length =3D=3D SdMmcAdmaLen26b) { > Trb->Adma32Desc[Index].UpperLength =3D 0; > } > Trb->Adma32Desc[Index].LowerLength =3D 0; > Trb->Adma32Desc[Index].Address =3D (UINT32)Address; > } > + } else if (Trb->Mode =3D=3D SdMmcAdma64bV3Mode) { > + if (Remaining <=3D AdmaMaxDataPerLine) { > + Trb->Adma64V3Desc[Index].Valid =3D 1; > + Trb->Adma64V3Desc[Index].Act =3D 2; > + if (Trb->Length =3D=3D SdMmcAdmaLen26b) { > + Trb->Adma64V3Desc[Index].UpperLength =3D (UINT16)RShiftU64 > (Remaining, 16); > + } > + Trb->Adma64V3Desc[Index].LowerLength =3D (UINT16)(Remaining & > MAX_UINT16); > + Trb->Adma64V3Desc[Index].LowerAddress =3D (UINT32)Address; > + Trb->Adma64V3Desc[Index].UpperAddress =3D (UINT32)RShiftU64 > (Address, 32); > + break; > + } else { > + Trb->Adma64V3Desc[Index].Valid =3D 1; > + Trb->Adma64V3Desc[Index].Act =3D 2; > + if (Trb->Length =3D=3D SdMmcAdmaLen26b) { > + Trb->Adma64V3Desc[Index].UpperLength =3D 0; > + } > + Trb->Adma64V3Desc[Index].LowerLength =3D 0; > + Trb->Adma64V3Desc[Index].LowerAddress =3D (UINT32)Address; > + Trb->Adma64V3Desc[Index].UpperAddress =3D (UINT32)RShiftU64 > (Address, 32); > + } > } else { > if (Remaining <=3D AdmaMaxDataPerLine) { > - Trb->Adma64Desc[Index].Valid =3D 1; > - Trb->Adma64Desc[Index].Act =3D 2; > - if (DataLength26) { > - Trb->Adma64Desc[Index].UpperLength =3D (UINT16)RShiftU64 > (Remaining, 16); > + Trb->Adma64V4Desc[Index].Valid =3D 1; > + Trb->Adma64V4Desc[Index].Act =3D 2; > + if (Trb->Length =3D=3D SdMmcAdmaLen26b) { > + Trb->Adma64V4Desc[Index].UpperLength =3D (UINT16)RShiftU64 > (Remaining, 16); > } > - Trb->Adma64Desc[Index].LowerLength =3D (UINT16)(Remaining & > MAX_UINT16); > - Trb->Adma64Desc[Index].LowerAddress =3D (UINT32)Address; > - Trb->Adma64Desc[Index].UpperAddress =3D (UINT32)RShiftU64 (Address, > 32); > + Trb->Adma64V4Desc[Index].LowerLength =3D (UINT16)(Remaining & > MAX_UINT16); > + Trb->Adma64V4Desc[Index].LowerAddress =3D (UINT32)Address; > + Trb->Adma64V4Desc[Index].UpperAddress =3D (UINT32)RShiftU64 > (Address, 32); > break; > } else { > - Trb->Adma64Desc[Index].Valid =3D 1; > - Trb->Adma64Desc[Index].Act =3D 2; > - if (DataLength26) { > - Trb->Adma64Desc[Index].UpperLength =3D 0; > + Trb->Adma64V4Desc[Index].Valid =3D 1; > + Trb->Adma64V4Desc[Index].Act =3D 2; > + if (Trb->Length =3D=3D SdMmcAdmaLen26b) { > + Trb->Adma64V4Desc[Index].UpperLength =3D 0; > } > - Trb->Adma64Desc[Index].LowerLength =3D 0; > - Trb->Adma64Desc[Index].LowerAddress =3D (UINT32)Address; > - Trb->Adma64Desc[Index].UpperAddress =3D (UINT32)RShiftU64 (Address, > 32); > + Trb->Adma64V4Desc[Index].LowerLength =3D 0; > + Trb->Adma64V4Desc[Index].LowerAddress =3D (UINT32)Address; > + Trb->Adma64V4Desc[Index].UpperAddress =3D (UINT32)RShiftU64 > (Address, 32); > } > } > > @@ -1568,7 +1601,13 @@ BuildAdmaDescTable ( > // > // Set the last descriptor line as end of descriptor table > // > - AddressingMode64 ? (Trb->Adma64Desc[Index].End =3D 1) : (Trb- > >Adma32Desc[Index].End =3D 1); > + if (Trb->Mode =3D=3D SdMmcAdma32bMode) { > + Trb->Adma32Desc[Index].End =3D 1; > + } else if (Trb->Mode =3D=3D SdMmcAdma64bV3Mode) { > + Trb->Adma64V3Desc[Index].End =3D 1; > + } else { > + Trb->Adma64V4Desc[Index].End =3D 1; > + } > return EFI_SUCCESS; > } > > @@ -1665,7 +1704,20 @@ SdMmcCreateTrb ( > if (Trb->DataLen =3D=3D 0) { > Trb->Mode =3D SdMmcNoData; > } else if (Private->Capability[Slot].Adma2 !=3D 0) { > - Trb->Mode =3D SdMmcAdmaMode; > + Trb->Mode =3D SdMmcAdma32bMode; > + Trb->Length =3D SdMmcAdmaLen16b; > + if ((Private->ControllerVersion[Slot] =3D=3D SD_MMC_HC_CTRL_VER_300) > && > + (Private->Capability[Slot].SysBus64V3 =3D=3D 1)) { > + Trb->Mode =3D SdMmcAdma64bV3Mode; > + } else if (((Private->ControllerVersion[Slot] =3D=3D > SD_MMC_HC_CTRL_VER_400) && > + (Private->Capability[Slot].SysBus64V3 =3D=3D 1)) || > + ((Private->ControllerVersion[Slot] >=3D SD_MMC_HC_CTRL_VER_410) > && > + (Private->Capability[Slot].SysBus64V4 =3D=3D 1))) { > + Trb->Mode =3D SdMmcAdma64bV4Mode; > + } > + if (Private->ControllerVersion[Slot] >=3D SD_MMC_HC_CTRL_VER_410) { > + Trb->Length =3D SdMmcAdmaLen26b; > + } > Status =3D BuildAdmaDescTable (Trb, Private->ControllerVersion[Slot]); > if (EFI_ERROR (Status)) { > PciIo->Unmap (PciIo, Trb->DataMap); > @@ -1719,11 +1771,18 @@ SdMmcFreeTrb ( > Trb->Adma32Desc > ); > } > - if (Trb->Adma64Desc !=3D NULL) { > + if (Trb->Adma64V3Desc !=3D NULL) { > + PciIo->FreeBuffer ( > + PciIo, > + Trb->AdmaPages, > + Trb->Adma64V3Desc > + ); > + } > + if (Trb->Adma64V4Desc !=3D NULL) { > PciIo->FreeBuffer ( > PciIo, > Trb->AdmaPages, > - Trb->Adma64Desc > + Trb->Adma64V4Desc > ); > } > if (Trb->DataMap !=3D NULL) { > @@ -1891,27 +1950,35 @@ SdMmcExecTrb ( > if (EFI_ERROR (Status)) { > return Status; > } > + > + if (Private->ControllerVersion[Trb->Slot] >=3D SD_MMC_HC_CTRL_VER_400= ) > { > + Status =3D SdMmcHcCheckMmioSet(PciIo, Trb->Slot, > SD_MMC_HC_HOST_CTRL2, sizeof(UINT16), > + SD_MMC_HC_64_ADDR_EN, SD_MMC_HC_64_ADDR_EN); > + if (!EFI_ERROR (Status)) { > + AddressingMode64 =3D TRUE; > + } > + } > + > // > // Set Host Control 1 register DMA Select field > // > - if (Trb->Mode =3D=3D SdMmcAdmaMode) { > + if ((Trb->Mode =3D=3D SdMmcAdma32bMode) || > + (Trb->Mode =3D=3D SdMmcAdma64bV4Mode)) { > HostCtrl1 =3D BIT4; > Status =3D SdMmcHcOrMmio (PciIo, Trb->Slot, SD_MMC_HC_HOST_CTRL1, > sizeof (HostCtrl1), &HostCtrl1); > if (EFI_ERROR (Status)) { > return Status; > } > + } else if (Trb->Mode =3D=3D SdMmcAdma64bV3Mode) { > + HostCtrl1 =3D BIT4|BIT3; > + Status =3D SdMmcHcOrMmio (PciIo, Trb->Slot, SD_MMC_HC_HOST_CTRL1, > sizeof (HostCtrl1), &HostCtrl1); > + if (EFI_ERROR (Status)) { > + return Status; > + } > } > > SdMmcHcLedOnOff (PciIo, Trb->Slot, TRUE); > > - if (Private->ControllerVersion[Trb->Slot] >=3D SD_MMC_HC_CTRL_VER_400= ) > { > - Status =3D SdMmcHcCheckMmioSet(PciIo, Trb->Slot, > SD_MMC_HC_HOST_CTRL2, sizeof(UINT16), > - SD_MMC_HC_V4_EN|SD_MMC_HC_64_ADDR_EN, > SD_MMC_HC_V4_EN|SD_MMC_HC_64_ADDR_EN); > - if (!EFI_ERROR (Status)) { > - AddressingMode64 =3D TRUE; > - } > - } > - > if (Trb->Mode =3D=3D SdMmcSdmaMode) { > if ((!AddressingMode64) && > ((UINT64)(UINTN)Trb->DataPhy >=3D 0x100000000ul)) { > @@ -1929,7 +1996,9 @@ SdMmcExecTrb ( > if (EFI_ERROR (Status)) { > return Status; > } > - } else if (Trb->Mode =3D=3D SdMmcAdmaMode) { > + } else if ((Trb->Mode =3D=3D SdMmcAdma32bMode) || > + (Trb->Mode =3D=3D SdMmcAdma64bV3Mode) || > + (Trb->Mode =3D=3D SdMmcAdma64bV4Mode)) { > AdmaAddr =3D (UINT64)(UINTN)Trb->AdmaDescPhy; > Status =3D SdMmcHcRwMmio (PciIo, Trb->Slot, > SD_MMC_HC_ADMA_SYS_ADDR, FALSE, sizeof (AdmaAddr), &AdmaAddr); > if (EFI_ERROR (Status)) { > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h > index d157f2c..3a05456 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h > @@ -2,7 +2,7 @@ > > Provides some data structure definitions used by the SD/MMC host > controller driver. > > -Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. > +Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. > Copyright (c) 2015, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the B= SD > License > @@ -80,16 +80,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF > ANY KIND, EITHER EXPRESS OR IMPLIED. > > // > // The transfer modes supported by SD Host Controller > -// Simplified Spec 3.0 Table 1-2 > // > typedef enum { > SdMmcNoData, > SdMmcPioMode, > SdMmcSdmaMode, > - SdMmcAdmaMode > + SdMmcAdma32bMode, > + SdMmcAdma64bV3Mode, > + SdMmcAdma64bV4Mode > } SD_MMC_HC_TRANSFER_MODE; > > // > +// The ADMA transfer lengths supported by SD Host Controller > +// > +typedef enum { > + SdMmcAdmaLen16b, > + SdMmcAdmaLen26b > +} SD_MMC_HC_ADMA_LEGTH; Typo 'LEGTH' -> 'LENGTH' Also, how about 'SD_MMC_HC_ADMA_LENGTH_MODE'? Best Regards, Hao Wu > + > +// > // The maximum data length of each descriptor line > // > #define ADMA_MAX_DATA_PER_LINE_16B SIZE_64KB > @@ -122,8 +131,20 @@ typedef struct { > UINT32 LowerLength:16; > UINT32 LowerAddress; > UINT32 UpperAddress; > +} SD_MMC_HC_ADMA_64_V3_DESC_LINE; > + > +typedef struct { > + UINT32 Valid:1; > + UINT32 End:1; > + UINT32 Int:1; > + UINT32 Reserved:1; > + UINT32 Act:2; > + UINT32 UpperLength:10; > + UINT32 LowerLength:16; > + UINT32 LowerAddress; > + UINT32 UpperAddress; > UINT32 Reserved1; > -} SD_MMC_HC_ADMA_64_DESC_LINE; > +} SD_MMC_HC_ADMA_64_V4_DESC_LINE; > > #define SD_MMC_SDMA_BOUNDARY 512 * 1024 > #define SD_MMC_SDMA_ROUND_UP(x, n) (((x) + n) & ~(n - 1)) > -- > 2.7.4 -------------------------------------------------------------------------= ---------- This email message is for the sole use of the intended recipient(s) and m= ay contain confidential information. Any unauthorized review, use, disclosure or di= stribution is prohibited. If you are not the intended recipient, please contact the= =20sender by reply email and destroy all copies of the original message. -------------------------------------------------------------------------= ----------