From nobody Thu Mar 28 20:37:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53217+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53217+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1579003555; cv=none; d=zohomail.com; s=zohoarc; b=EX2reej6XBOb81L8SD50K+giKHC8P2BUx2r2I0DgRVqdZ+4UUM2cyRGjw0QrSfO38PY7NWn/MCwmrjp36KWUrWDjqYZBFd9Qgr2r8dvnvR39CsGAJOOK+NzVGZk4JVriY6UqMjrEI6pAn4Bp4q6wEb/oBnl2S0akssGuiWj6T8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579003555; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=fXGDU+jXeOC/W9UHaPluaAyvISchXzrNixPB6p6iisk=; b=Zr64PXLVh/ijKIJ/dI+1DNp2vDSakPuJDilcuBiMbgEdak0+kpj0E/jJ5gJIVU0gfKP6Jv8Ddcn74Y3dnTtbNqKWtGsPZ0lcTPWo0mySK7PJBmJFM7IK/ztItaXfVK6CBgarU/wQNsC8DWPENyjHAME6lcc2HLiKn2HwgYd5WRI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53217+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 157900355501458.89070312598801; Tue, 14 Jan 2020 04:05:55 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id foxVYY1788612xU0Fh2bF2Pd; Tue, 14 Jan 2020 04:05:54 -0800 X-Received: from mga06.intel.com (mga06.intel.com []) by mx.groups.io with SMTP id smtpd.web12.10582.1579003552856918646 for ; Tue, 14 Jan 2020 04:05:54 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2020 04:05:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,432,1571727600"; d="scan'208";a="248028878" X-Received: from gklab-27-32.ger.corp.intel.com ([10.102.28.45]) by fmsmga004.fm.intel.com with ESMTP; 14 Jan 2020 04:05:51 -0800 From: "Albecki, Mateusz" To: devel@edk2.groups.io Cc: Mateusz Albecki , Hao A Wu , Marcin Wojtas , Zhichao Gao , Liming Gao Subject: [edk2-devel] [PATCHv2 1/4] MdeModulePkg/SdMmcPciHcDxe: Fix DAT lane SW reset Date: Tue, 14 Jan 2020 13:05:27 +0100 Message-Id: <20200114120530.1660-2-mateusz.albecki@intel.com> In-Reply-To: <20200114120530.1660-1-mateusz.albecki@intel.com> References: <20200114120530.1660-1-mateusz.albecki@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mateusz.albecki@intel.com X-Gm-Message-State: Ktb7jwqEXQcf3MmY7UYg8y0gx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1579003554; bh=jTRIsCKgl9smmfJXfV3ZacQa2oFDS8ZZo3eiRG0Do7U=; h=Cc:Date:From:Reply-To:Subject:To; b=fTSJxZZNwJxqq/DkOa+8Op2H8TzKatbStCIt4QyGkkSUQND3LTWVeAo83uiaLFRzZDJ yFt6YMUWar6vwxJDLRdzt2Xb+Tcac1FPt0FqAsYrQ80WmQUe8UW66FANK9p1QwBxqccbQ llOLmh/mIJJ6NmrdWTRwSi0EkFwwqYqmQ3E= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Driver used to reset the DAT lane on a current error which is not required according to SD specification(it's not going to help). This patch will reset the DAT lane only on DAT lane specific errors. Cc: Hao A Wu Cc: Marcin Wojtas Cc: Zhichao Gao Cc: Liming Gao Signed-off-by: Mateusz Albecki Reviewed-by: Hao A Wu --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c b/MdeModulePk= g/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c index e7f2fac69b..b1f316d444 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c @@ -7,7 +7,7 @@ It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use. =20 Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. - Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -2229,7 +2229,7 @@ SdMmcCheckTrbResult ( if ((IntStatus & 0x0F) !=3D 0) { SwReset |=3D BIT1; } - if ((IntStatus & 0xF0) !=3D 0) { + if ((IntStatus & 0x70) !=3D 0) { SwReset |=3D BIT2; } =20 --=20 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydz= ial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-31= 6 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata= i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wi= adomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiek= olwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the s= ole use of the intended recipient(s). If you are not the intended recipient= , please contact the sender and delete all copies; any review or distributi= on by others is strictly prohibited. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53217): https://edk2.groups.io/g/devel/message/53217 Mute This Topic: https://groups.io/mt/69691993/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu Mar 28 20:37:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53218+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53218+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1579003566; cv=none; d=zohomail.com; s=zohoarc; b=ARDZgwK/Y3sqfhfxQGE2E4+aJsiYwGGUHtvEdUSeEo6k4CejZI7Q+CGptnKi7pTEW9SKff+EIYqvlnrlY3zkQd0DLV3nV8f2HS9IxTp9YNvXWznkoVDGNRpGhj7SLjnRlnLNYccvQE1KAOhwQOkIMtyXXFS6aDkmPPlrq8SXta4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579003566; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=6jmYZq+VNCxI9+lxDANxykjmhaL6P5M0qbN+Bv29IgI=; b=i42RyPHwvKqNs3Kd9elaJDfaqLNQVX5vY7nAG+G7Dem0Fe3nBVp/8mbtZ7VNIU/Uxwq5py5DNufQE/q9ffAcnWduzmFPxPL7qNw21Y0BAU8fWeKCVFvnjkQmWmdtYybnMy3UpkUe9t7Wq61k/p2g8yjvuGuZmJ7FutAI4wqTrHM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53218+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1579003566410845.675289349058; Tue, 14 Jan 2020 04:06:06 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Whq6YY1788612xObNigj8iR8; Tue, 14 Jan 2020 04:06:05 -0800 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web12.10586.1579003565254711279 for ; Tue, 14 Jan 2020 04:06:05 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2020 04:06:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,432,1571727600"; d="scan'208";a="248028958" X-Received: from gklab-27-32.ger.corp.intel.com ([10.102.28.45]) by fmsmga004.fm.intel.com with ESMTP; 14 Jan 2020 04:06:02 -0800 From: "Albecki, Mateusz" To: devel@edk2.groups.io Cc: Mateusz Albecki , Hao A Wu , Marcin Wojtas , Zhichao Gao , Liming Gao Subject: [edk2-devel] [PATCHv2 2/4] MdeModulePkg/SdMmcPciHcDxe: Refactor command error detection Date: Tue, 14 Jan 2020 13:05:28 +0100 Message-Id: <20200114120530.1660-3-mateusz.albecki@intel.com> In-Reply-To: <20200114120530.1660-1-mateusz.albecki@intel.com> References: <20200114120530.1660-1-mateusz.albecki@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mateusz.albecki@intel.com X-Gm-Message-State: G27DMbZwnZnCDQNg88DZfj5xx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1579003565; bh=nl2AkG+ON4hy7jh3jot7eAhIB1wbJsJUU9beh1G39vY=; h=Cc:Date:From:Reply-To:Subject:To; b=B2YuJtMdGePHLNFUiF+jwI8KwFf+suRY3ZYS6gdhzBEPnD/R3P5t/GxJvYhNLW+fvxA vGvLPw7DT27XVSH22xJrSS8ltSChNShXosncunpeVgw3CzBNvgiSS2/n84JA06ct0pveB FN/yoC5GSIQCkDQ/veoi0law2jOsQM7/e5k= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1140 Error detection function will now check if the command failure has been caused by one of the errors that can appear randomly on link(CRC error + end bit error). If such an error has been a cause of failure, function will return EFI_CRC_ERROR instead of EFI_DEVICE_ERROR to indicate to the higher level that command has a chance of succeeding if resent. Cc: Hao A Wu Cc: Marcin Wojtas Cc: Zhichao Gao Cc: Liming Gao Signed-off-by: Mateusz Albecki Reviewed-by: Hao A Wu --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 215 +++++++++++++++----= ---- 1 file changed, 140 insertions(+), 75 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c b/MdeModulePk= g/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c index b1f316d444..637455b400 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c @@ -2137,6 +2137,137 @@ SdMmcExecTrb ( return Status; } =20 +/** + Performs SW reset based on passed error status mask. + + @param[in] Private Pointer to driver private data. + @param[in] Slot Index of the slot to reset. + @param[in] ErrIntStatus Error interrupt status mask. + + @retval EFI_SUCCESS Software reset performed successfully. + @retval Other Software reset failed. +**/ +EFI_STATUS +SdMmcSoftwareReset ( + IN SD_MMC_HC_PRIVATE_DATA *Private, + IN UINT8 Slot, + IN UINT16 ErrIntStatus + ) +{ + UINT8 SwReset; + EFI_STATUS Status; + + SwReset =3D 0; + if ((ErrIntStatus & 0x0F) !=3D 0) { + SwReset |=3D BIT1; + } + if ((ErrIntStatus & 0x70) !=3D 0) { + SwReset |=3D BIT2; + } + + Status =3D SdMmcHcRwMmio ( + Private->PciIo, + Slot, + SD_MMC_HC_SW_RST, + FALSE, + sizeof (SwReset), + &SwReset + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D SdMmcHcWaitMmioSet ( + Private->PciIo, + Slot, + SD_MMC_HC_SW_RST, + sizeof (SwReset), + 0xFF, + 0, + SD_MMC_HC_GENERIC_TIMEOUT + ); + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + +/** + Checks the error status in error status register + and issues appropriate software reset as described in + SD specification section 3.10. + + @param[in] Private Pointer to driver private data. + @param[in] Trb Pointer to currently executing TRB. + @param[in] IntStatus Normal interrupt status mask. + + @retval EFI_CRC_ERROR CRC error happened during CMD execution. + @retval EFI_SUCCESS No error reported. + @retval Others Some other error happened. + +**/ +EFI_STATUS +SdMmcCheckAndRecoverErrors ( + IN SD_MMC_HC_PRIVATE_DATA *Private, + IN UINT8 Slot, + IN UINT16 IntStatus + ) +{ + UINT16 ErrIntStatus; + EFI_STATUS Status; + EFI_STATUS ErrorStatus; + + if ((IntStatus & BIT15) =3D=3D 0) { + return EFI_SUCCESS; + } + + Status =3D SdMmcHcRwMmio ( + Private->PciIo, + Slot, + SD_MMC_HC_ERR_INT_STS, + TRUE, + sizeof (ErrIntStatus), + &ErrIntStatus + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // If the data timeout error is reported + // but data transfer is signaled as completed we + // have to ignore data timeout. We also assume that no + // other error is present on the link since data transfer + // completed successfully. Error interrupt status + // register is going to be reset when the next command + // is started. + // + if (((ErrIntStatus & BIT4) !=3D 0) && ((IntStatus & BIT1) !=3D 0)) { + return EFI_SUCCESS; + } + + // + // We treat both CMD and DAT CRC errors and + // end bits errors as EFI_CRC_ERROR. This will + // let higher layer know that the error possibly + // happened due to random bus condition and the + // command can be retried. + // + if ((ErrIntStatus & (BIT1 | BIT2 | BIT5 | BIT6)) !=3D 0) { + ErrorStatus =3D EFI_CRC_ERROR; + } else { + ErrorStatus =3D EFI_DEVICE_ERROR; + } + + Status =3D SdMmcSoftwareReset (Private, Slot, ErrIntStatus); + if (EFI_ERROR (Status)) { + return Status; + } + + return ErrorStatus; +} + /** Check the TRB execution result. =20 @@ -2160,10 +2291,8 @@ SdMmcCheckTrbResult ( UINT32 Response[4]; UINT64 SdmaAddr; UINT8 Index; - UINT8 SwReset; UINT32 PioLength; =20 - SwReset =3D 0; Packet =3D Trb->Packet; // // Check Trb execution result by reading Normal Interrupt Status registe= r. @@ -2179,87 +2308,23 @@ SdMmcCheckTrbResult ( if (EFI_ERROR (Status)) { goto Done; } + // - // Check Transfer Complete bit is set or not. + // Check if there are any errors reported by host controller + // and if neccessary recover the controller before next command is execu= ted. // - if ((IntStatus & BIT1) =3D=3D BIT1) { - if ((IntStatus & BIT15) =3D=3D BIT15) { - // - // Read Error Interrupt Status register to check if the error is - // Data Timeout Error. - // If yes, treat it as success as Transfer Complete has higher - // priority than Data Timeout Error. - // - Status =3D SdMmcHcRwMmio ( - Private->PciIo, - Trb->Slot, - SD_MMC_HC_ERR_INT_STS, - TRUE, - sizeof (IntStatus), - &IntStatus - ); - if (!EFI_ERROR (Status)) { - if ((IntStatus & BIT4) =3D=3D BIT4) { - Status =3D EFI_SUCCESS; - } else { - Status =3D EFI_DEVICE_ERROR; - } - } - } - + Status =3D SdMmcCheckAndRecoverErrors (Private, Trb->Slot, IntStatus); + if (EFI_ERROR (Status)) { goto Done; } + // - // Check if there is a error happened during cmd execution. - // If yes, then do error recovery procedure to follow SD Host Controller - // Simplified Spec 3.0 section 3.10.1. + // Check Transfer Complete bit is set or not. // - if ((IntStatus & BIT15) =3D=3D BIT15) { - Status =3D SdMmcHcRwMmio ( - Private->PciIo, - Trb->Slot, - SD_MMC_HC_ERR_INT_STS, - TRUE, - sizeof (IntStatus), - &IntStatus - ); - if (EFI_ERROR (Status)) { - goto Done; - } - if ((IntStatus & 0x0F) !=3D 0) { - SwReset |=3D BIT1; - } - if ((IntStatus & 0x70) !=3D 0) { - SwReset |=3D BIT2; - } - - Status =3D SdMmcHcRwMmio ( - Private->PciIo, - Trb->Slot, - SD_MMC_HC_SW_RST, - FALSE, - sizeof (SwReset), - &SwReset - ); - if (EFI_ERROR (Status)) { - goto Done; - } - Status =3D SdMmcHcWaitMmioSet ( - Private->PciIo, - Trb->Slot, - SD_MMC_HC_SW_RST, - sizeof (SwReset), - 0xFF, - 0, - SD_MMC_HC_GENERIC_TIMEOUT - ); - if (EFI_ERROR (Status)) { - goto Done; - } - - Status =3D EFI_DEVICE_ERROR; + if ((IntStatus & BIT1) =3D=3D BIT1) { goto Done; } + // // Check if DMA interrupt is signalled for the SDMA transfer. // --=20 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydz= ial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-31= 6 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata= i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wi= adomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiek= olwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the s= ole use of the intended recipient(s). If you are not the intended recipient= , please contact the sender and delete all copies; any review or distributi= on by others is strictly prohibited. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53218): https://edk2.groups.io/g/devel/message/53218 Mute This Topic: https://groups.io/mt/69691997/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu Mar 28 20:37:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53219+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53219+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1579003567; cv=none; d=zohomail.com; s=zohoarc; b=YoBOyzKOmxxhpaoWb9pbaauQyRMw/4UiVuM/kdK1O+MVPH6D+lKpxZeAQ74RrFzPU3KfLop/1wqNghZWE8LfqNtZDnnxS7eDVbzkLKz0+URLn2EMYXnlNcLuWddpZOvefkQ2n/UGr/amHqmTlyX90LNKbC6FzqInU+zN4vpgX2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579003567; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=i0OaP43z5DLhO7JERWZ0JgbAxFkSwvAs9x1Vq7QKyKo=; b=KPmTl+Xr+H6FLo22HIk0P4I0fXUt4zqVti3q5PnDYVBfx9stzIyNtK2I9CXHg6Jqq/oGyUyxsD4uWcPYQHzfAm9jRHyvAvxa6vXNNXoAQLM3+8zkUb+rHFyo+vT/KoaAs47vECbelGlqzbV1ZKbtUzp3pyfHfLl/kxbulsEhqP0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53219+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1579003567749804.8047596496693; Tue, 14 Jan 2020 04:06:07 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id NDULYY1788612xDJsrpHkwAI; Tue, 14 Jan 2020 04:06:07 -0800 X-Received: from mga02.intel.com (mga02.intel.com []) by mx.groups.io with SMTP id smtpd.web12.10586.1579003565254711279 for ; Tue, 14 Jan 2020 04:06:06 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2020 04:06:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,432,1571727600"; d="scan'208";a="248028979" X-Received: from gklab-27-32.ger.corp.intel.com ([10.102.28.45]) by fmsmga004.fm.intel.com with ESMTP; 14 Jan 2020 04:06:04 -0800 From: "Albecki, Mateusz" To: devel@edk2.groups.io Cc: Mateusz Albecki , Hao A Wu , Marcin Wojtas , Zhichao Gao , Liming Gao Subject: [edk2-devel] [PATCHv2 3/4] MdeModulePkg/SdMmcPciHcDxe: Add retries for sync commands Date: Tue, 14 Jan 2020 13:05:29 +0100 Message-Id: <20200114120530.1660-4-mateusz.albecki@intel.com> In-Reply-To: <20200114120530.1660-1-mateusz.albecki@intel.com> References: <20200114120530.1660-1-mateusz.albecki@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mateusz.albecki@intel.com X-Gm-Message-State: bofLn5OPBuYrgctVXdcVYmEPx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1579003567; bh=c8l/sLqki2vesadHjYM4wkmOuJEwCXhQrZ/mhj9NeQw=; h=Cc:Date:From:Reply-To:Subject:To; b=lTxCHNbOaAh/VacUYjAT2iIQgYmWaJlgkfh518Rta9Dfs5dyAdNJZeCQTBAUY/exZLI DtsHSu/NTMNYomw3TgTHuMY0ekcHsCk7e0XboyImrcx1iXgXVZttrF9El3Ow3+n3R684G 4L6uHK3oD9Z91fvDAOS8cF7WKFA0TfvCxmg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1140 To increase the resiliency driver will now attempt to retry the commands that failed due to the CRC error up to 5 times. This should address the problems with the commands that fail due to random condition on links. This should also help the boards on which CMD13 is particularly unstable after switching the link frequency. Cc: Hao A Wu Cc: Marcin Wojtas Cc: Zhichao Gao Cc: Liming Gao Signed-off-by: Mateusz Albecki Reviewed-by: Hao A Wu --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 83 ++++++++++++++----= ---- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h | 5 +- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 1 + 3 files changed, 59 insertions(+), 30 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c b/MdeModule= Pkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c index 373f1bed45..193b0f24e2 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c @@ -7,7 +7,7 @@ It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use. =20 Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. - Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -974,6 +974,58 @@ SdMmcPciHcDriverBindingStop ( return Status; } =20 +/** + Execute TRB synchronously. + + @param[in] Private Pointer to driver private data. + @param[in] Trb Pointer to TRB to execute. + + @retval EFI_SUCCESS TRB executed successfully. + @retval Other TRB failed. +**/ +EFI_STATUS +SdMmcPassThruExecSyncTrb ( + IN SD_MMC_HC_PRIVATE_DATA *Private, + IN SD_MMC_HC_TRB *Trb + ) +{ + EFI_STATUS Status; + EFI_TPL OldTpl; + + // + // Wait async I/O list is empty before execute sync I/O operation. + // + while (TRUE) { + OldTpl =3D gBS->RaiseTPL (TPL_NOTIFY); + if (IsListEmpty (&Private->Queue)) { + gBS->RestoreTPL (OldTpl); + break; + } + gBS->RestoreTPL (OldTpl); + } + + while (Trb->Retries) { + Status =3D SdMmcWaitTrbEnv (Private, Trb); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D SdMmcExecTrb (Private, Trb); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D SdMmcWaitTrbResult (Private, Trb); + if (Status =3D=3D EFI_CRC_ERROR) { + Trb->Retries--; + } else { + return Status; + } + } + + return Status; +} + /** Sends SD command to an SD card that is attached to the SD controller. =20 @@ -1023,7 +1075,6 @@ SdMmcPassThruPassThru ( EFI_STATUS Status; SD_MMC_HC_PRIVATE_DATA *Private; SD_MMC_HC_TRB *Trb; - EFI_TPL OldTpl; =20 if ((This =3D=3D NULL) || (Packet =3D=3D NULL)) { return EFI_INVALID_PARAMETER; @@ -1066,34 +1117,8 @@ SdMmcPassThruPassThru ( return EFI_SUCCESS; } =20 - // - // Wait async I/O list is empty before execute sync I/O operation. - // - while (TRUE) { - OldTpl =3D gBS->RaiseTPL (TPL_NOTIFY); - if (IsListEmpty (&Private->Queue)) { - gBS->RestoreTPL (OldTpl); - break; - } - gBS->RestoreTPL (OldTpl); - } - - Status =3D SdMmcWaitTrbEnv (Private, Trb); - if (EFI_ERROR (Status)) { - goto Done; - } - - Status =3D SdMmcExecTrb (Private, Trb); - if (EFI_ERROR (Status)) { - goto Done; - } + Status =3D SdMmcPassThruExecSyncTrb (Private, Trb); =20 - Status =3D SdMmcWaitTrbResult (Private, Trb); - if (EFI_ERROR (Status)) { - goto Done; - } - -Done: SdMmcFreeTrb (Trb); =20 return Status; diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h b/MdeModule= Pkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h index 0304960132..5bc3577ba2 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h @@ -3,7 +3,7 @@ Provides some data structure definitions used by the SD/MMC host control= ler driver. =20 Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. -Copyright (c) 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -130,6 +130,8 @@ typedef struct { =20 #define SD_MMC_HC_TRB_SIG SIGNATURE_32 ('T', 'R', 'B', 'T') =20 +#define SD_MMC_TRB_RETRIES 5 + // // TRB (Transfer Request Block) contains information for the cmd request. // @@ -152,6 +154,7 @@ typedef struct { EFI_EVENT Event; BOOLEAN Started; UINT64 Timeout; + UINT32 Retries; =20 SD_MMC_HC_ADMA_32_DESC_LINE *Adma32Desc; SD_MMC_HC_ADMA_64_V3_DESC_LINE *Adma64V3Desc; diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c b/MdeModulePk= g/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c index 637455b400..b0384a507a 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c @@ -1683,6 +1683,7 @@ SdMmcCreateTrb ( Trb->Event =3D Event; Trb->Started =3D FALSE; Trb->Timeout =3D Packet->Timeout; + Trb->Retries =3D SD_MMC_TRB_RETRIES; Trb->Private =3D Private; =20 if ((Packet->InTransferLength !=3D 0) && (Packet->InDataBuffer !=3D NULL= )) { --=20 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydz= ial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-31= 6 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata= i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wi= adomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiek= olwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the s= ole use of the intended recipient(s). If you are not the intended recipient= , please contact the sender and delete all copies; any review or distributi= on by others is strictly prohibited. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53219): https://edk2.groups.io/g/devel/message/53219 Mute This Topic: https://groups.io/mt/69691999/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu Mar 28 20:37:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53220+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53220+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1579003574; cv=none; d=zohomail.com; s=zohoarc; b=HyRdYAo3mwTKkUmHblbf8JQdvsa7F1W1xp1BETx5xOceIEzzHz2ztZH3uhOMdtH+pU3UbTWId4OJ73Cqk8I8bhuoje20F/VXSQ+WeRglLf03EyjdufNNA6rMYUX6+aOU2IvhgWY9L1GJgLrRTTDfeu+rj4TEUQfqnpzIM+uAsmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579003574; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=HRGxA4FJnnf3/FcMx7Y2hdVv6sscGvND0zWnN5ZzyAk=; b=bn3hcOwcS39xLAbQT0RrXKT51ZC2UBFa94eNz9XTnwyxXbQZHTVilAVGi9PydV0F5bMRopqE4D+gckC4bQZRNHByy4VV+rIu0PdeCfNWBFsqEJi3Qw6jfQBi4cp8zpnWAnyUvfdJmr4Xo0K8WFcix65cCH3uxQOVKIwO2C+sHwg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53220+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1579003574669245.42971429413092; Tue, 14 Jan 2020 04:06:14 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id MXG1YY1788612xvGfAlNzBYW; Tue, 14 Jan 2020 04:06:14 -0800 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web12.10589.1579003573737879878 for ; Tue, 14 Jan 2020 04:06:13 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2020 04:06:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,432,1571727600"; d="scan'208";a="248029022" X-Received: from gklab-27-32.ger.corp.intel.com ([10.102.28.45]) by fmsmga004.fm.intel.com with ESMTP; 14 Jan 2020 04:06:11 -0800 From: "Albecki, Mateusz" To: devel@edk2.groups.io Cc: Mateusz Albecki , Hao A Wu , Marcin Wojtas , Zhichao Gao , Liming Gao Subject: [edk2-devel] [PATCHv2 4/4] MdeModulePkg/SdMmcPciHcDxe: Add retries for async commands Date: Tue, 14 Jan 2020 13:05:30 +0100 Message-Id: <20200114120530.1660-5-mateusz.albecki@intel.com> In-Reply-To: <20200114120530.1660-1-mateusz.albecki@intel.com> References: <20200114120530.1660-1-mateusz.albecki@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mateusz.albecki@intel.com X-Gm-Message-State: yjuV5Lkhd6XpdmofBg8br8khx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1579003574; bh=yuGr7el6sInPh3hCDFN8UDmeWZbemrGfxJuBJnNhsBs=; h=Cc:Date:From:Reply-To:Subject:To; b=q5Igs5oVXw7yFKU3ggjdik2wYZHRFYPAIKXlXguP1QcyyaocvH3Cl7ChzUws6fYlr8P mlUwavBXkQBjfWcQzXNjFbqoEhi42yj5Xa+gs2VPWsDcIZG2uEaX3Vma2vRbmPMJ78hHh MNKuwRd5m7WN6IahJsEXDsWqiPT7ul8aUK8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch adds retries for async execution for commands that failed due to the CRC errors. Cc: Hao A Wu Cc: Marcin Wojtas Cc: Zhichao Gao Cc: Liming Gao Signed-off-by: Mateusz Albecki Reviewed-by: Hao A Wu --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c b/MdeModule= Pkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c index 193b0f24e2..b18ff3e972 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c @@ -211,8 +211,10 @@ Done: gBS->SignalEvent (TrbEvent); return; } - } - if ((Trb !=3D NULL) && (Status !=3D EFI_NOT_READY)) { + } else if ((Trb !=3D NULL) && (Status =3D=3D EFI_CRC_ERROR) && (Trb->Ret= ries > 0)) { + Trb->Retries--; + Trb->Started =3D FALSE; + } else if ((Trb !=3D NULL)) { RemoveEntryList (Link); Trb->Packet->TransactionStatus =3D Status; TrbEvent =3D Trb->Event; --=20 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydz= ial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-31= 6 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata= i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wi= adomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiek= olwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the s= ole use of the intended recipient(s). If you are not the intended recipient= , please contact the sender and delete all copies; any review or distributi= on by others is strictly prohibited. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53220): https://edk2.groups.io/g/devel/message/53220 Mute This Topic: https://groups.io/mt/69692003/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-