From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=203.18.50.4; helo=nat-hk.nvidia.com; envelope-from=ashishsingha@nvidia.com; receiver=edk2-devel@lists.01.org Received: from nat-hk.nvidia.com (nat-hk.nvidia.com [203.18.50.4]) (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 9FFAB21A07096 for ; Sun, 3 Mar 2019 20:08:50 -0800 (PST) Received: from hkpgpgate101.nvidia.com (Not Verified[10.18.92.100]) by nat-hk.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 04 Mar 2019 12:08:48 +0800 Received: from HKMAIL103.nvidia.com ([10.18.16.12]) by hkpgpgate101.nvidia.com (PGP Universal service); Sun, 03 Mar 2019 20:08:48 -0800 X-PGP-Universal: processed; by hkpgpgate101.nvidia.com on Sun, 03 Mar 2019 20:08:48 -0800 Received: from HKMAIL102.nvidia.com (10.18.16.11) by HKMAIL103.nvidia.com (10.18.16.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 4 Mar 2019 04:08:46 +0000 Received: from NAM03-CO1-obe.outbound.protection.outlook.com (104.47.40.56) by HKMAIL102.nvidia.com (10.18.16.11) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Mon, 4 Mar 2019 04:08:46 +0000 Received: from DM6PR12MB3324.namprd12.prod.outlook.com (20.178.31.154) by DM6PR12MB3145.namprd12.prod.outlook.com (20.178.31.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.16; Mon, 4 Mar 2019 04:08:43 +0000 Received: from DM6PR12MB3324.namprd12.prod.outlook.com ([fe80::f8d4:91e2:b81b:3b81]) by DM6PR12MB3324.namprd12.prod.outlook.com ([fe80::f8d4:91e2:b81b:3b81%4]) with mapi id 15.20.1665.019; Mon, 4 Mar 2019 04:08:43 +0000 From: Ashish Singhal To: "Gao, Liming" , "edk2-devel@lists.01.org" CC: "Wu, Hao A" Thread-Topic: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Add V3 64b DMA Support Thread-Index: AQHU0FzaPLjzM8T82kS4lsytC/4gmKX4gYMAgAJbYuA= Date: Mon, 4 Mar 2019 04:08:43 +0000 Message-ID: References: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3F8D40@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <4A89E2EF3DFEDB4C8BFDE51014F606A14E3F8D40@SHSMSX104.ccr.corp.intel.com> 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-04T04:08:42.9403647Z; 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 x-originating-ip: [8.46.90.104] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f6c8df7c-a124-4b69-d0bb-08d6a05717a8 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:DM6PR12MB3145; x-ms-traffictypediagnostic: DM6PR12MB3145: x-ms-exchange-purlcount: 1 x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; DM6PR12MB3145; 23:zDPkuntUlnw+iatyBC1mXVkApT0tD4M8U49GaHz7Y?= =?us-ascii?Q?B3aKjc2qlhAWEguoCjEutkm7qy0BYZheexQP9ZN3iHxJIf1mvlTeTL69fjQK?= =?us-ascii?Q?RBoB6TKb58a5GH0hjjrmPYAem+Hw6JEnzPztFQJm5UDXMzyJkd+igihV8cMb?= =?us-ascii?Q?hS28WxdF29SPPJJYQxJMmI0eVDk/jTE2JG+h7pUDZTGm5WWwAx1TVcna/ooq?= =?us-ascii?Q?Ydc724c2KgspS9AjPZNFpGuq2rYbs2w3s19mPS2mdFiIjtFyPHL2tI7J8CCu?= =?us-ascii?Q?NfLeoxJ9zuECF/ciaPkcncQTI0jjhujMmmJR5tH9Czss5OaIOjswyo//gWlq?= =?us-ascii?Q?0/r9Qn/dk7Yryp/vHNcAhNPlI8P670m/sApWTOv6ZXV2WbDyYZ+/H3jQdlQQ?= =?us-ascii?Q?GUSudSKkbdRUQCn+fxb2ELsumwPCymYfKmp3doO2XorLoa/oMHHfI/gVjUc1?= =?us-ascii?Q?cL9+cl1tzhFhI+rU2Mtz52QC6P7w2mW5lGQjQidsPOcyn2jP+8CDtP0b8dJV?= =?us-ascii?Q?Z+skiO9CXrBFc8sNyj8Fm6rZaDwZV4Pf1B8DeJ7WXC9/+0WuTBrip2yDBlbX?= =?us-ascii?Q?olzaG9EsiBjpFGJVFn0ybvvVxFzXiCxAHNwAKEfBlaWJ2gVT1rmcOf0cngna?= =?us-ascii?Q?YAzTQJTwV4DQc27xwkxMVenJmiRHwCEfXqZmE5Gzr37yY7HRMe8Z72LR/DrL?= =?us-ascii?Q?o3fOE3snv61P3aElDrnQZaK7C2X8YRLN/1nSgLBJ+mbYoZ1jjxfTSPIq2zuE?= =?us-ascii?Q?WGsxMing6yMZcP61FEXBCCwz/jL77COL8q4EdBF4wVFU6MBq6KU294p0NfEN?= =?us-ascii?Q?wA0vZK1wDBeL2ghPm6tiQuUnGWfa+X3fcShafgBsOrPvHFknBXXLisr0hBl6?= =?us-ascii?Q?J7LxJIIrC5UQjAb8scKuuncy6wlftYsYaIdOHvG5P9TWjbHkoal775x+n21r?= =?us-ascii?Q?3ZNjFfZBHHTTTdVEVkUwdU4yJl4u8Pnsjo5aVaX0t4jd9TIPrwwxgJ/rvACP?= =?us-ascii?Q?s3oZ2jDONqlzR4PDV+iClqQ59Ke/8C9bm3AMBx9GQjYnLueaW4llwM6p4GDz?= =?us-ascii?Q?zw6nrkNjpBKT4uGbSuFAEtkBw5Z7fV6hVT2u9ffl8BqD3c8edrd0QD94WAHX?= =?us-ascii?Q?Hq2yMx/n0zs+JjtFebhMz6q4I4AutbKI6BtmOmSkt7dnbiYYs55NQNhew1vt?= =?us-ascii?Q?M65EzTB/cvrQwyk0rVUKlrXDfYyrDUbmfGj+54EYojvzm6azx2uFsXglp0E7?= =?us-ascii?Q?ee1ZT+Kol3moM/uAutB33LnlQB+Fb/HLsPgRssgN5rtd0s1NvpPva6m8pqYm?= =?us-ascii?Q?WL1jolaYzuYbeDhcNoLsmUd8EzmeZkuSYAwQxQ+RGdJz8Dr6qyH2Vqoha8Fj?= =?us-ascii?Q?qjlvng67mVbm/JHSvv0/Y8yZEq5RarxaRE7ap3Owue0cjA/CDE699FnKOUWK?= =?us-ascii?Q?4r0vvRuoYylzQCwypwzHckh4xOysw4=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 09669DB681 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6029001)(396003)(136003)(366004)(376002)(346002)(39850400004)(199004)(189003)(13464003)(316002)(476003)(486006)(186003)(446003)(26005)(110136005)(11346002)(8936002)(3846002)(6116002)(256004)(6346003)(33656002)(305945005)(7736002)(99286004)(74316002)(8676002)(81166006)(81156014)(71200400001)(71190400001)(30864003)(14444005)(19627235002)(66066001)(105586002)(14454004)(2501003)(68736007)(97736004)(52536013)(966005)(478600001)(229853002)(6246003)(7696005)(86362001)(53936002)(2906002)(6506007)(6436002)(25786009)(106356001)(102836004)(76176011)(53946003)(6306002)(55016002)(9686003)(53546011)(4326008)(5660300002)(579004); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB3145; H:DM6PR12MB3324.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) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ashishsingha@nvidia.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 0RDrxSU3GnP3VRNPvM+Ii2ZRno29xx3FGCo1J5AvrXxAtYy83nySuop1o7I/2sB2w7UhojkgYYy3jXiHrMounMAfhVXNIvQ5M4XeLs0zjg0jw/jYJb0HxdMOb3jl99VdizvcPheMRznBfBFIycO3kmZEXmfdHpQFRnbti9HSvmqTIEI8mNELF4JMcH4a26q7uJEwwc5rS3rTOVSmct9nQLnOWxVJPhxgKww4tgbifzHQcMhFmDmSD5nByVo6/FYx3mLRGgPQ6/LKMukdr951wgu+nSR9ejTb6lES+P3qIAzTcEfgNtR/E7p9j1GDhTrE6uuG0h7F9VWwX6UXsGiBrk5XRX42HJJii0/DUt8FylYUI/x/PmtUmOZfCzeuQd0QdnKdDYm3AVlaDZX3k7ZDOxw03Oqy4STHyiuv+2FPASE= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: f6c8df7c-a124-4b69-d0bb-08d6a05717a8 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Mar 2019 04:08:43.8161 (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: DM6PR12MB3145 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1551672528; bh=zIrwpelfSk5n8qUO/AIS7YTmw14rbc2uPl3QchscrVs=; h=X-PGP-Universal:From:To:CC:Subject:Thread-Topic:Thread-Index:Date: Message-ID:References:In-Reply-To:Accept-Language:X-MS-Has-Attach: X-MS-TNEF-Correlator:msip_labels: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:authentication-results: 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:Content-Transfer-Encoding; b=Z3cSIvZEe74D2Xb3gSagu6LPzZ+BX8JFwmeW+WwLds1p8ltRsF0ER0i0IKZFuuHOn nDv6/iMK6DjuTAd7zfn81OXMPxiodtIPs7Tycu/Ke8UD5LTlLcSlEuIcucJSKLJolU dYk1yWdAlUshOLxRv+DhBMaPqU+SScV35vzd59+OJuSyV+lCjgcHqL4GpOTuX2cCFo eau+tRR6phhCy1z34T6rFSInl6reoTA9xywoG0EPgTfB/2/t6KQ8JjW1iqZty+qFYY tknEwFsggJ/yCBVQtRvwFHcvUMSS8hLz1F9GeUBfaRE8uLYQ24y5hH8Tb9I0adiK2a wiN/DO2Sgjoow== 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: Mon, 04 Mar 2019 04:08:51 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Liming, I am OK waiting till the freeze is over. Thanks Ashish -----Original Message----- From: Gao, Liming =20 Sent: Saturday, March 2, 2019 9:01 AM To: Ashish Singhal ; edk2-devel@lists.01.org Cc: Wu, Hao A Subject: RE: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Add V3 64b DMA Su= pport Ashish: =20 This seems a feature. Now, we are in Hard Feature Freeze. So, it will= =20not be added until edk2-stable201903 tag is created at 2019-03-08.=20 Thanks Liming > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of = > Ashish Singhal > Sent: Saturday, March 2, 2019 2:30 AM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Ashish Singhal=20 > > Subject: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Add V3 64b DMA=20 > Support >=20 > Driver was supporting only 32b DMA support for V3 controllers. Add=20 > support for 64b DMA as well for completeness. >=20 > For V4.0 64b support, driver was looking at incorrect capability=20 > register bit. Fix for that is present as well. >=20 > 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(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c=20 > 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 @@ >=20 > It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use. >=20 > - 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=20 > the BSD 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_30= 0 && > + Private->Capability[Slot].SysBus64V3 =3D=3D 0) || > + (Private->ControllerVersion[Slot] =3D=3D SD_MMC_HC_CTRL_VER_40= 0 && > + 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; > } >=20 > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h=20 > 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 @@ >=20 > Provides some data structure definitions used by the SD/MMC host con= troller driver. >=20 > -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=20 > available under the terms and conditions of the BSD 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; >=20 > EFI_EVENT Event; > BOOLEAN Started; > UINT64 Timeout; >=20 > 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=20 > 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 @@ >=20 > It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use. >=20 > - 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=20 > the BSD 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) { > + HostCtrl2 |=3D SD_MMC_HC_26_DATA_LEN_ADMA_EN; > + DEBUG ((DEBUG_INFO, "Enabled V4 26 bit data length ADMA suppor= t\n")); > + } > } > Status =3D SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeo= f (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; >=20 > - 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; >=20 > // > - // 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_CT= RL2, 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 a= lways set to 0) > // > @@ -1445,13 +1444,19 @@ BuildAdmaDescTable ( > DEBUG ((DEBUG_INFO, "The buffer [0x%x] to construct ADMA desc is= =20not 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_CTRL= 2, sizeof(UINT16), > - SD_MMC_HC_26_DATA_LEN_ADMA_EN, SD_MMC_H= C_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=20 > + (Trb->Mode =3D=3D SdMmcAdma64bV4Mode) { > + DescSize =3D sizeof (SD_MMC_HC_ADMA_64_V4_DESC_LINE); } // //=20 > + Configure 26b data length. > + // > + if (Trb->Length =3D=3D SdMmcAdmaLen26b) { > AdmaMaxDataPerLine =3D ADMA_MAX_DATA_PER_LINE_26B; > } >=20 > @@ -1492,7 +1497,7 @@ BuildAdmaDescTable ( > return EFI_OUT_OF_RESOURCES; > } >=20 > - 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 ( >=20 > 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; > } > + > 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 (Re= maining, 16); > } > Trb->Adma32Desc[Index].LowerLength =3D (UINT16)(Remaining &=20 > 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 &= =20MAX_UINT16); > + Trb->Adma64V3Desc[Index].LowerAddress =3D (UINT32)Address; > + Trb->Adma64V3Desc[Index].UpperAddress =3D (UINT32)RShiftU64 (A= ddress, 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 (A= ddress, 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 (R= emaining, 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 & M= AX_UINT16); > - Trb->Adma64Desc[Index].LowerAddress =3D (UINT32)Address; > - Trb->Adma64Desc[Index].UpperAddress =3D (UINT32)RShiftU64 (Add= ress, 32); > + Trb->Adma64V4Desc[Index].LowerLength =3D (UINT16)(Remaining &= =20MAX_UINT16); > + Trb->Adma64V4Desc[Index].LowerAddress =3D (UINT32)Address; > + Trb->Adma64V4Desc[Index].UpperAddress =3D (UINT32)RShiftU64=20 > + (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 (Add= ress, 32); > + Trb->Adma64V4Desc[Index].LowerLength =3D 0; > + Trb->Adma64V4Desc[Index].LowerAddress =3D (UINT32)Address; > + Trb->Adma64V4Desc[Index].UpperAddress =3D (UINT32)RShiftU64=20 > + (Address, 32); > } > } >=20 > @@ -1568,7 +1601,13 @@ BuildAdmaDescTable ( > // > // Set the last descriptor line as end of descriptor table > // > - AddressingMode64 ? (Trb->Adma64Desc[Index].End =3D 1) :=20 > (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; > } >=20 > @@ -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_C= TRL_VER_400) && > + (Private->Capability[Slot].SysBus64V3 =3D=3D 1)) || > + ((Private->ControllerVersion[Slot] >=3D SD_MMC_HC_CTR= L_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[S= lot]); > if (EFI_ERROR (Status)) { > PciIo->Unmap (PciIo, Trb->DataMap); @@ -1719,11 +1771,18 @@=20 > 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_40= 0) { > + Status =3D SdMmcHcCheckMmioSet(PciIo, Trb->Slot, SD_MMC_HC_HOST_CT= RL2, sizeof(UINT16), > + SD_MMC_HC_64_ADDR_EN, SD_MMC_HC_64_AD= DR_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; > + } > } >=20 > SdMmcHcLedOnOff (PciIo, Trb->Slot, TRUE); >=20 > - if (Private->ControllerVersion[Trb->Slot] >=3D SD_MMC_HC_CTRL_VER_40= 0) { > - Status =3D SdMmcHcCheckMmioSet(PciIo, Trb->Slot, SD_MMC_HC_HOST_CT= RL2, 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= =20 > +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_A= DDR, FALSE, sizeof (AdmaAddr), &AdmaAddr); > if (EFI_ERROR (Status)) { > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.h=20 > 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 @@ >=20 > Provides some data structure definitions used by the SD/MMC host con= troller driver. >=20 > -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=20 > available under the terms and conditions of the BSD License @@ -80,16=20 > +80,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXP= RESS OR IMPLIED. >=20 > // > // The transfer modes supported by SD Host Controller -// Simplified=20 > Spec 3.0 Table 1-2 // typedef enum { > SdMmcNoData, > SdMmcPioMode, > SdMmcSdmaMode, > - SdMmcAdmaMode > + SdMmcAdma32bMode, > + SdMmcAdma64bV3Mode, > + SdMmcAdma64bV4Mode > } SD_MMC_HC_TRANSFER_MODE; >=20 > // > +// The ADMA transfer lengths supported by SD Host Controller //=20 > +typedef enum { > + SdMmcAdmaLen16b, > + SdMmcAdmaLen26b > +} SD_MMC_HC_ADMA_LEGTH; > + > +// > // 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; >=20 > #define SD_MMC_SDMA_BOUNDARY 512 * 1024 > #define SD_MMC_SDMA_ROUND_UP(x, n) (((x) + n) & ~(n - 1)) > -- > 2.7.4 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel -------------------------------------------------------------------------= ---------- 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. -------------------------------------------------------------------------= ----------