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 B92E5211CD9A4 for ; Thu, 28 Feb 2019 13:27:40 -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 ; Fri, 01 Mar 2019 05:27:38 +0800 Received: from HKMAIL101.nvidia.com ([10.18.16.10]) by hkpgpgate101.nvidia.com (PGP Universal service); Thu, 28 Feb 2019 13:27:38 -0800 X-PGP-Universal: processed; by hkpgpgate101.nvidia.com on Thu, 28 Feb 2019 13:27:38 -0800 Received: from HKMAIL104.nvidia.com (10.18.16.13) by HKMAIL101.nvidia.com (10.18.16.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 28 Feb 2019 21:27:36 +0000 Received: from NAM04-BN3-obe.outbound.protection.outlook.com (104.47.46.50) by HKMAIL104.nvidia.com (10.18.16.13) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Thu, 28 Feb 2019 21:27:36 +0000 Received: from DM6PR12MB3324.namprd12.prod.outlook.com (20.178.31.154) by DM6PR12MB2601.namprd12.prod.outlook.com (20.176.116.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.21; Thu, 28 Feb 2019 21:27:33 +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.1643.022; Thu, 28 Feb 2019 21:27:33 +0000 From: Ashish Singhal To: "Cohen, Eugene" , "Wu, Hao A" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] MdeModulePkg/SdMmcPciHcDxe: Fix DMA on SDHC v3 64-bit systems Thread-Index: AdTOimUh6bq74L7bQyCZsF0hnADHfgAhuWlQABE+2EAAEKP68AABVU+wAANAbhA= Date: Thu, 28 Feb 2019 21:27:33 +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-02-28T21:27:31.9817310Z; 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: 02b65406-5318-4b6c-1da9-08d69dc38d5d x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:DM6PR12MB2601; x-ms-traffictypediagnostic: DM6PR12MB2601: x-ms-exchange-purlcount: 1 x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; DM6PR12MB2601; 23:FpAXyLqRQt6mXYWpPzzNVFTNxZr1t+twPXwvyGFX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4L15tgEACpX3VsLKEdXDRAQc2yO0fjLqToTaVlUgWTPhqnVGXNiVQ+?= =?us-ascii?Q?/5avoIbvjLmfNEcbcZKVGjUs3PSl8tOCMpjaYIhLt4aKyAOpIz04LNp+thWh?= =?us-ascii?Q?TbiRPyIz+5ZWUda/K5E/qmQ7n3sgqMeG7A3Zo9a/1GJjZDDQa35IXU4ViGEM?= =?us-ascii?Q?9LfWcik8FvsndvoIfqOmqzqAWCJtAVGItQpX4z/BNftAxoQzaT0g42IDHPAc?= =?us-ascii?Q?Md5yZM/Pocn5u31c7fxtSCgG7gUmgjlL4u0nj13HDev6+28WGs8HZaLAOR+e?= =?us-ascii?Q?k1sb5Qk1MxUCpteYFPaVd6beugQ2E9cQAxqHzOh734uV6tlJrLfjDJGQRdYb?= =?us-ascii?Q?ADa9NiZN8ajORVEkKGK3ZZ5PymCWpPKBhXxr+BrcPKisf8E8Z6E3lCzsxHQi?= =?us-ascii?Q?7yDYJ0RB9ExWR666acxq3SDhOe6jD+PlQRTA4EUdtZCDe9MJQnssKpeWxv23?= =?us-ascii?Q?1fVaV/yx5J2FQSodtYGWX0tbQ8=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0962D394D2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6029001)(346002)(136003)(366004)(39860400002)(376002)(396003)(13464003)(189003)(199004)(6246003)(236005)(74316002)(606006)(55016002)(316002)(93886005)(6306002)(105586002)(7736002)(8936002)(25786009)(53936002)(9686003)(106356001)(33656002)(52536013)(54896002)(71190400001)(81166006)(81156014)(97736004)(2501003)(5660300002)(110136005)(476003)(71200400001)(2906002)(14454004)(11346002)(486006)(99286004)(256004)(446003)(26005)(186003)(7696005)(478600001)(66066001)(3846002)(53546011)(790700001)(102836004)(14444005)(86362001)(76176011)(6436002)(68736007)(6506007)(229853002)(966005)(6116002)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB2601; H:DM6PR12MB3324.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: NazpCHm4dc4Dh0t9xNWnVqdnXVfF3Go/qYSLmDPFC4nrhZTf33sI0KHL58AJAZmDim5el/JeS+DrX1hKtKnlyUMuAcoh2eZmNXjjbwI4JrYL3GqNel+GZPeTF1sTY61Ct2rVVyl20evigtwV1sdSrj7+qgeqzv4LDGTtjIR10Q9/OCxkPPL/qdyDSnnaoSKA22CgjoPQ/oN0XTxBc05eauzlrxlkQnJkyCYuGFIL3zjRv/GfLRgpM8FfIppLYb7a4nA/PT4EW8kpL8kp05Gans3gKVCtH9kdksbEJsAXWQgHhNPPkzq+aHbXf6wqD8/prM538GH44ZbvGhqpKLgZDxdqXvIcSN6P3xZ2G+H5M5LeO8JXzIMYgAJGaj7Yfoshqeq0Op+o0uhd2vmZbtfAgknUPesOOQn8Fnjp+WTbIW0= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 02b65406-5318-4b6c-1da9-08d69dc38d5d X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 21:27:33.3455 (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: DM6PR12MB2601 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1551389258; bh=gAIaRdlCUjZtXApIruLEI+cVFufe0ymSYBTt80YiUdk=; 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=WnlxRKkqaBDqJo7omfoBxCn2fRa0bRQIqrowgrGLkKUGlZurl0vjNs/qIytHoYQT8 Wm6vtkD1s2FjfA+nWca+ZeW+DSQgHMqohD3Ehdbmhwk3nC1G76enfmG2Uc9aKF+T0y Gq9NSWbViEytm+qOyFKVl0BXznrFA5SJr+5GppgCtWTjuJ5FjqcBScXH6RGMeUxkKr VIufRGZClo8tA/6f8elpthGZ6I+8FttLpPAz//hpw9zQ4w4KwzUyAgZzar9zVBeatp 1PuidUrnVmqivLVfa8U7hAG5hRTJuFpu4kvK8cl2iDUdbcc2yjqjSfCqP+3f5zH8/i BgHxbn4Fq9OEQ== X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [PATCH] MdeModulePkg/SdMmcPciHcDxe: Fix DMA on SDHC v3 64-bit systems 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: Thu, 28 Feb 2019 21:27:41 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Eugene, We do not have support for V4 64b DMA right now but it can be added later i= f needed. I am trying to understand the reason behind changing the check fr= om AND to OR. Right now, we disable 64b DMA Support in PCI if the controlle= r cannot support 64b DMA in V3 as well as V4. If either of these support 64= b DMA, we do not disable it. In the code, we set Support64BitDma to TRUE by= default and change it to FALSE only if any of the controller does not supp= ort it in V3 as well as V4. If all controllers support it in V3 or V4 we ke= ep 64b DMA support enabled. // // Enable 64-bit DMA support in the PCI layer if this controller // supports it. // if (Support64BitDma) { Status =3D PciIo->Attributes ( PciIo, EfiPciIoAttributeOperationEnable, EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE, NULL ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_WARN, "SdMmcPciHcDriverBindingStart: failed to enable 6= 4-bit DMA (%r)\n", Status)); } } Thanks Ashish From: Cohen, Eugene Sent: Thursday, February 28, 2019 12:56 PM To: Ashish Singhal ; Wu, Hao A ; edk2-devel@lists.01.org Subject: RE: [PATCH] MdeModulePkg/SdMmcPciHcDxe: Fix DMA on SDHC v3 64-bit = systems Ashish, * With my change, if any of the controller did not support 64b DMA in V= 3 as well as V4 capability, we are not enabling it in PCI layer. The logic is: if (Private->Capability[Slot].SysBus64V3 =3D=3D 0 && Private->Capability[Slot].SysBus64V4 =3D=3D 0) { Support64BitDma =3D FALSE; } which means that for a SDHC v3 controller you have SysBus64V3=3D1 and SysBu= s64V4=3D0 the FALSE assignment is never done - this is not correct. Perhap= s you intended an OR instead of an AND? Either way changing this to an || = or using my patch is the same logical result because a V3 controller will u= se 32-bit DMA and V4 controller will use 64-bit DMA (a V4 controller should= have the V3 bit set). I really saw no reason to be checking the V3 bit si= nce the driver was unprepared to do V3 64-bit DMA operations anyways. Eugene From: Ashish Singhal > Sent: Thursday, February 28, 2019 12:15 PM To: Cohen, Eugene >; Wu, Hao A >; edk2-devel@lists.01.org Subject: RE: [PATCH] MdeModulePkg/SdMmcPciHcDxe: Fix DMA on SDHC v3 64-bit = systems Hello Eugene, My patch enabled support for SDHC 4.0 and above in general including suppor= t for 64b ADMA descriptor. The check for V3 capability for 64b DMA was alre= ady there and similar check was implemented for V4 capability for 64b DMA. = Earlier, if any of the V3 controller did not support 64b DMA, we were not e= nabling it in PCI layer. With my change, if any of the controller did not s= upport 64b DMA in V3 as well as V4 capability, we are not enabling it in PC= I layer. This check in my opinion is better because we only disable 64b DMA PCI supp= ort when both V3 and V4 have it disabled. Thanks Ashish -----Original Message----- From: Cohen, Eugene > Sent: Thursday, February 28, 2019 4:24 AM To: Wu, Hao A >; edk2-devel@l= ists.01.org Cc: Ashish Singhal = > Subject: RE: [PATCH] MdeModulePkg/SdMmcPciHcDxe: Fix DMA on SDHC v3 64-bit = systems Hao, > I remember the commit b5547b9ce97e80c3127682a2a5d4b9bd14af353e from > Ashish only handles the controllers with version greater or equal to 4.00= . Right - that commit added support for SDHC 4.0 and above. The original driv= er supported SDHC 3.0 albeit only with SDMA and 32-bit ADMA support. With that commit two descriptor types are supported the 32-bit ADMA descrip= tor (SD_MMC_HC_ADMA_32_DESC_LINE which is 64-bits in size) and the V4 64-bi= t ADMA descriptor (SD_MMC_HC_ADMA_64_DESC_LINE which is 128-bits in size). However the commit mistakenly added a check for the V3 capability for 64-bi= t DMA and used it to set the PCI DUAL_ADDRESS_CYCLE attributre which then d= oes not the 32-bit compatible bounce buffer mechanism. Later, when we attem= pt an ADMA data transfer we hit an ASSERT because the PCI DMA subsystem is = not using bounce buffers to provide 32-bit DMA compatible memory. So the pa= tch I submitted simply removes the unnecessary check of the V3 64-bit DMA c= apability check so the PCI DUAL_ADDRESS_CYCLE attribute is not set allowing= 32-bit DMA to succeed on these platforms. > And the ADMA2 (96-bit Descriptor) mode for V3 controllers is selected > by setting the 'DMA Select' filed in the Host Control 1 Register to > 11b. But the currently behavior of the driver is setting the field to > 10b, which I think will not switch to the ADMA2 (96-bit Descriptor) mode = for V3. Correct, right now for a V3 controller only 32-bit DMA is supported. An enh= ancement for V3 64-bit ADMA would improve performance on controllers that s= upport that mode by eliminating the bounce buffer and associated memory cop= ies. I think we should file a BZ for SD HCI V3 64-bit ADMA support - if you= agree I would be happy to do that. I should point out that we have done extensive testing of this change on ou= r host controller. Thanks, Eugene --- From: Wu, Hao A > Sent: Wednesday, February 27, 2019 8:25 PM To: Cohen, Eugene >; edk2-devel@lists.0= 1.org Cc: Ashish Singhal = > Subject: RE: [PATCH] MdeModulePkg/SdMmcPciHcDxe: Fix DMA on SDHC v3 64-bit = systems Loop Ashish in. Some comments below. > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Cohen, Eugene > Sent: Wednesday, February 27, 2019 6:59 PM > To: mailto:edk2-devel@lists.01.org; Wu, Hao A > Subject: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Fix DMA on SDHC > v3 64-bit systems > > The SdMmcPciHcDriverBindingStart function was checking two different > capability bits in determining whether 64-bit DMA modes were > supported, one mode is defined in the SDHC version > 3 specification (using 96-bit descriptors) and another is defined in > the SDHC version 4 specification (using 128-bit descriptors). Since > the currently implementation of 64-bit > ADMA2 only supports the SDHC version 4 implementation it is incorrect > to check the V3 64-bit capability bit since this will activate V4 > ADMA2 on V3 controllers. I remember the commit b5547b9ce97e80c3127682a2a5d4b9bd14af353e from Ashish = only handles the controllers with version greater or equal to 4.00. And the ADMA2 (96-bit Descriptor) mode for V3 controllers is selected by se= tting the 'DMA Select' filed in the Host Control 1 Register to 11b. But the= currently behavior of the driver is setting the field to 10b, which I thin= k will not switch to the ADMA2 (96-bit Descriptor) mode for V3. Maybe there is something I miss here. Could you help to provide some more d= etail on the issue you met? Thanks. Best Regards, Hao Wu > > Cc: Hao Wu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eugene Cohen > --- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > index b474f8d..5bc91c5 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > @@ -666,8 +666,7 @@ 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->Capability[Slot].SysBus64V4 =3D=3D 0) { > Support64BitDma =3D FALSE; > } > > -- > 2.7.4 > _______________________________________________ > edk2-devel mailing list > mailto: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 may= contain confidential information. Any unauthorized review, use, disclosure or distr= ibution is prohibited. If you are not the intended recipient, please contact the se= nder by reply email and destroy all copies of the original message. ---------------------------------------------------------------------------= --------